:root {
  color: #211c24;
  background: #f6f4f2;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --accent: #470b59;
  --ink: #211c24;
  --muted: #6c6470;
  --line: #d8d3cf;
  --soft: #ece9e6;
  --paper: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #eaf7ef;
  --warn: #8a5b08;
  --warn-bg: #fff5d8;
  --bad: #a13535;
  --bad-bg: #fdecec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 64px;
  padding: 14px clamp(18px, 4vw, 48px);
}

.wordmark {
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0;
  text-decoration: none;
}

.lang-switch {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  padding: 3px;
}

.lang-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  min-height: 30px;
  min-width: 42px;
}

.lang-button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--accent);
  box-shadow: 0 1px 2px rgb(33 28 36 / 8%);
}

.shell {
  margin: 0 auto;
  max-width: 1180px;
  min-width: 0;
  padding: clamp(24px, 4vw, 48px) clamp(18px, 4vw, 48px) 56px;
}

.intro {
  max-width: 780px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 10px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 64px;
  letter-spacing: 0;
  line-height: 0.96;
  max-width: 100%;
  overflow-wrap: break-word;
}

.lede {
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
  margin-top: 18px;
  max-width: 680px;
}

.workspace {
  align-items: start;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1.1fr) minmax(330px, 0.9fr);
  margin-top: 36px;
  min-width: 0;
}

.tool-panel,
.result-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgb(33 28 36 / 6%);
  min-width: 0;
}

.tool-panel {
  display: grid;
  gap: 0;
}

.field-group {
  border-bottom: 1px solid var(--line);
  padding: clamp(18px, 3vw, 26px);
}

.field-group:last-child {
  border-bottom: 0;
}

.field-head {
  align-items: flex-start;
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  min-width: 0;
}

.field-head > div {
  min-width: 0;
}

.step {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.field-head h2 {
  color: var(--ink);
  font-size: 18px;
  letter-spacing: 0;
  line-height: 1.2;
}

.field-head p,
.note,
#target-text,
#result-body {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-top: 5px;
}

.segmented {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented.compact {
  max-width: 440px;
}

.segment {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  min-height: 82px;
  padding: 14px;
  text-align: left;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.compact .segment {
  min-height: 52px;
  text-align: center;
}

.segment:hover {
  border-color: #bdb5c2;
}

.segment[aria-checked="true"] {
  background: #fbf7fd;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.segment span {
  display: block;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.segment small {
  color: var(--muted);
  display: block;
  font-size: 13px;
  line-height: 1.35;
  margin-top: 6px;
}

.measurement-visual {
  background: #f8f7f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  overflow: hidden;
  place-items: center;
  padding: clamp(16px, 3vw, 24px);
}

.measurement-layout {
  align-items: center;
  display: grid;
  gap: 18px 20px;
  grid-template-areas:
    "paper side"
    "below .";
  grid-template-columns: minmax(220px, 280px) minmax(170px, 210px);
  justify-items: center;
  max-width: 560px;
  --guide-x-field-offset: 0px;
  --guide-x-end: 100%;
  --guide-x-start: 0%;
  --guide-x-y: 50%;
  --guide-y-end: 100%;
  --guide-y-start: 0%;
  --guide-y-x: 50%;
  width: 100%;
}

.paper-column {
  display: grid;
  gap: 12px;
  grid-area: paper;
  justify-items: center;
  min-width: 0;
  width: 100%;
}

.paper-preview {
  background: #fff;
  border: 1px solid #cfc9c5;
  box-shadow: 0 6px 16px rgb(33 28 36 / 8%);
  display: block;
  margin: 0;
  max-width: 280px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.paper-preview img {
  display: block;
  height: auto;
  width: 100%;
}

.measurement-axis {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgb(255 255 255 / 78%);
  opacity: 0.92;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.measurement-axis::before,
.measurement-axis::after {
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 3px;
  content: "";
  position: absolute;
}

.measurement-axis-x {
  height: 2px;
  left: var(--guide-x-start);
  top: var(--guide-x-y);
  transform: translateY(-50%);
  width: calc(var(--guide-x-end) - var(--guide-x-start));
}

.measurement-axis-x::before {
  height: 16px;
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
}

.measurement-axis-x::after {
  height: 16px;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
  width: 4px;
}

.measurement-axis-y {
  height: calc(var(--guide-y-end) - var(--guide-y-start));
  left: var(--guide-y-x);
  top: var(--guide-y-start);
  transform: translateX(-50%);
  width: 2px;
}

.measurement-axis-y::before {
  left: 50%;
  height: 4px;
  top: 0;
  transform: translate(-50%, -50%);
  width: 16px;
}

.measurement-axis-y::after {
  bottom: 0;
  height: 4px;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 16px;
}

.dimension-field {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgb(33 28 36 / 5%);
  display: block;
  min-width: 0;
  padding: 12px 12px 10px;
  position: relative;
  width: 100%;
}

.dimension-field::before {
  background: var(--accent);
  content: "";
  pointer-events: none;
  position: absolute;
}

.width-field {
  align-self: center;
  grid-area: side;
  transform: translateY(var(--guide-x-field-offset));
}

.width-field::before {
  height: 2px;
  left: -21px;
  top: 50%;
  transform: translateY(-50%);
  width: 21px;
}

.height-field {
  grid-area: below;
  max-width: 280px;
}

.height-field::before {
  height: 18px;
  left: var(--guide-y-x);
  top: -19px;
  transform: translateX(-50%);
  width: 2px;
}

.dimension-field span {
  color: var(--ink);
  display: block;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 8px;
}

.dimension-field input {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 24px;
  min-height: 52px;
  padding: 10px 12px;
  width: 100%;
}

.dimension-field small {
  color: var(--accent);
  display: block;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 8px;
}

.dimension-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(71 11 89 / 14%);
  outline: 0;
}

.result-panel {
  padding: clamp(18px, 3vw, 26px);
  position: sticky;
  top: 18px;
}

.kicker {
  color: var(--accent);
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.target-block h2 {
  font-size: 22px;
  letter-spacing: 0;
  line-height: 1.2;
}

.result-box {
  background: #f8f7f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 20px;
  padding: 16px;
}

.result-box[data-tone="ok"] {
  background: var(--ok-bg);
  border-color: rgb(31 122 77 / 30%);
}

.result-box[data-tone="warn"] {
  background: var(--warn-bg);
  border-color: rgb(138 91 8 / 30%);
}

.result-box[data-tone="bad"] {
  background: var(--bad-bg);
  border-color: rgb(161 53 53 / 30%);
}

.status-pill {
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 9px;
}

.result-box[data-tone="ok"] .status-pill {
  color: var(--ok);
}

.result-box[data-tone="warn"] .status-pill {
  color: var(--warn);
}

.result-box[data-tone="bad"] .status-pill {
  color: var(--bad);
}

.result-box h3 {
  font-size: 21px;
  letter-spacing: 0;
  line-height: 1.25;
  margin-top: 12px;
}

.scale-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 18px 0 0;
  overflow: hidden;
}

.scale-list div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 14px;
}

.scale-list div:last-child {
  border-bottom: 0;
}

.scale-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.scale-list dd {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  margin: 0;
}

.actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.primary-action,
.secondary-action {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-size: 15px;
  font-weight: 800;
  justify-content: center;
  min-height: 48px;
  padding: 12px 14px;
  text-decoration: none;
  width: 100%;
}

.primary-action {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}

.primary-action:disabled {
  background: #b7aebc;
  border-color: #b7aebc;
  cursor: not-allowed;
}

.secondary-action {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.secondary-action:disabled {
  color: #aaa2aa;
  cursor: not-allowed;
}

.note {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 14px;
}

@media (max-width: 840px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 58px;
  }

  .shell {
    padding-left: 14px;
    padding-right: 14px;
    width: 100%;
  }

  .intro {
    max-width: 100%;
  }

  .tool-panel,
  .result-panel {
    max-width: calc(100vw - 28px);
    width: 100%;
  }

  .field-group,
  .result-panel {
    padding: 18px;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .segment {
    min-height: auto;
  }

  .measurement-visual {
    min-height: 0;
    padding: 14px;
  }

  .measurement-layout {
    grid-template-areas:
      "paper"
      "side"
      "below";
    grid-template-columns: 1fr;
    max-width: 320px;
  }

  .paper-preview {
    max-width: 230px;
  }

  .height-field,
  .width-field {
    max-width: none;
  }

  .dimension-field::before {
    display: none;
  }

  .width-field {
    transform: none;
  }

  h1 {
    font-size: 30px;
    line-height: 1.04;
  }

  .lede {
    font-size: 17px;
  }
}
