/* Hi-fi · Earth
   Grounded and natural: sand, linen, moss, olive, clay and charcoal on a light paper
   grain. Editorial serif headings, plain sans body, tight corners, ruled lines.
   Layout base comes from ../style.css; hifi.js adds the rail and icons. */
:root {
  --ink: #24231f;
  --muted: #6b665c;
  --line: #d8cfbf;
  --line-strong: #24231f;
  --fill: #efe9de;
  --surface: #f7f3ec;
  --bg: #f7f3ec;
  --page: #ebe4d6;
  --moss: #46573a;
  --moss-dark: #36452c;
  --olive: #7a8551;
  --clay: #9a5636;
  --accent: #46573a;
  --accent-soft: #e2e5d6;
  --sim: #8a5a1c;
  --sim-bg: transparent;
  --ok: #46573a;
  --radius: 4px;
  --sans: "Work Sans", "Helvetica Neue", Arial, sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
}

body {
  background-color: var(--page);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 .22 0 0 0 0 .16 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  font-family: var(--sans); color: var(--ink);
}
.mono { font-family: var(--sans); font-weight: 600; letter-spacing: .14em; font-size: 10.5px; }

/* ---------- Header ---------- */
.topbar { max-width: none; padding: 0 max(40px, calc((100% - 1200px) / 2 + 40px)); height: 64px; border-bottom: 1px solid var(--line); background: rgba(247,243,236,.7); }
.topbar .brand { order: -1; gap: 16px; }
.app-name {
  font-family: var(--serif); font-weight: 500; font-size: 20px; letter-spacing: -0.01em; text-transform: none;
  display: inline-flex; align-items: center; gap: 10px; font-variation-settings: "opsz" 72;
}
.app-name::before {
  content: ""; width: 20px; height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2346573a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 19C5 10 11 5 20 4c-1 9-6 15-15 15z'/%3E%3Cpath d='M5 19l8-8'/%3E%3C/svg%3E") center / contain no-repeat;
}
.sim-badge { order: 2; color: var(--sim); border: 1px solid rgba(138,90,28,.45); border-radius: 2px; padding: 3px 8px; font-size: 10px; }
.step-label { color: var(--muted); }
.progress { display: none; }

/* ---------- Shell + rail ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 64px; max-width: 1200px; width: 100%; margin: 0 auto; padding: 56px 40px 24px; flex: 1; }
.content { min-width: 0; }
main { padding: 0; max-width: none; }
.rail { position: sticky; top: 32px; align-self: start; }
.rail-title { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--ink); margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-list li { display: flex; align-items: baseline; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); color: #9b9486; font-size: 14px; }
.rail-num { font-family: var(--serif); font-style: italic; font-size: 15px; width: 22px; flex-shrink: 0; display: inline-flex; align-items: center; }
.rail-num .n::before { content: "0"; }
.rail-check { width: 15px; height: 15px; display: none; stroke-width: 2.2; transform: translateY(2px); }
.rail-list li.current { color: var(--ink); font-weight: 600; }
.rail-list li.current .rail-num { color: var(--clay); }
.rail-list li.done { color: var(--ink); }
.rail-list li.done .rail-num { color: var(--olive); }
.rail-list li.done .n { display: none; }
.rail-list li.done .rail-check { display: block; }
.rail-note { font-size: 12px; color: var(--muted); margin: 20px 0 0; line-height: 1.55; }

/* ---------- Type ---------- */
h1 { font-family: var(--serif); font-weight: 500; font-size: 50px; line-height: 1.08; letter-spacing: -0.005em; word-spacing: .04em; margin: 0 0 14px; font-variation-settings: "opsz" 96, "SOFT" 0; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 22px; letter-spacing: -0.01em; margin-bottom: 18px; }
.sub { color: var(--muted); font-size: 18px; }
.step-head { margin-bottom: 40px; }
.link-btn { color: var(--clay); font-weight: 500; text-underline-offset: 4px; font-size: 15px; margin-top: 14px; }
.link-btn::after { content: " →"; }

/* ---------- Surfaces ---------- */
.grid-3, .grid-2 { gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; transition: border-color .2s, box-shadow .2s; }
.grid-3 .card, .grid-2 .card { min-height: 380px; }
.card.has-content { border-color: var(--moss); box-shadow: inset 0 3px 0 var(--moss); }
.card-label { color: var(--muted); }
.ico-tile { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--moss); color: var(--moss); display: flex; align-items: center; justify-content: center; margin-bottom: 22px; transition: background .2s, color .2s; }
.ico-tile .ico { width: 21px; height: 21px; }
.card.has-content .ico-tile { background: var(--moss); color: var(--surface); }

label, .field-label { font-size: 13.5px; font-weight: 500; color: var(--ink); margin-top: 18px; }
input[type="text"], textarea { background: #fbf9f4; border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; font-family: var(--sans); font-size: 16px; }
input::placeholder, textarea::placeholder { color: #a39b8c; }
input[type="text"]:hover, textarea:hover { border-color: #bfb39e; }
input:focus, textarea:focus { border-color: var(--moss); outline: 3px solid rgba(70,87,58,.15); outline-offset: 0; }
:focus-visible { outline: 2px solid var(--moss); outline-offset: 3px; }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius); border: 1px solid var(--ink); background: transparent; font-weight: 500; padding: 13px 24px; letter-spacing: .01em; transition: background .15s, color .15s; }
.btn:hover { background: var(--ink); color: var(--surface); }
.btn-primary { background: var(--moss); border-color: var(--moss); color: #f7f3ec; }
.btn-primary:hover { background: var(--moss-dark); border-color: var(--moss-dark); }
.btn-primary::after { content: "  →"; white-space: pre; }
.btn-primary[aria-disabled="true"] { background: #b9b4a6; border-color: #b9b4a6; color: #f7f3ec; opacity: 1; }
.btn-primary[aria-disabled="true"]:hover { background: #b9b4a6; }
.done-actions .btn-primary::after, .compare-card .btn-primary::after { content: ""; }
.btn-small { padding: 8px 14px; font-size: 13px; }

/* Chat */
.bubble { border-radius: 4px; padding: 10px 13px; }
.bubble.ai { background: var(--accent-soft); border: 0; border-left: 2px solid var(--olive); }
.bubble.me { background: var(--ink); color: var(--surface); }
.bubble .who { font-family: var(--sans); font-weight: 600; }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 8px; border-radius: var(--radius); border: 1px solid var(--line); background: #fbf9f4; font-weight: 500; transition: all .15s; }
.chip:hover { border-color: var(--moss); }
.chip-ico { width: 18px; height: 18px; color: var(--olive); }
.chip[aria-pressed="true"] { background: var(--moss); border-color: var(--moss); color: var(--surface); font-weight: 500; }
.chip[aria-pressed="true"] .chip-ico { color: #dfe4c9; }

/* Toggle as editorial tabs */
.toggle { border: 0; border-bottom: 1px solid var(--line); background: transparent; border-radius: 0; gap: 24px; margin-bottom: 28px; }
.toggle-btn { background: transparent; padding: 10px 0; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 0; }
.toggle-btn[aria-pressed="true"] { background: transparent; color: var(--ink); border-bottom-color: var(--clay); }
.mode-panel.selected { border-color: var(--moss); box-shadow: inset 0 3px 0 var(--moss); }
.mode-panel:not(.selected) { opacity: .55; }

/* ---------- Understanding ---------- */
.ai-note { color: var(--sim); margin: -24px 0 26px; }
.sim-dot { background: var(--sim); border-radius: 0; transform: rotate(45deg); width: 6px; height: 6px; }
.rows { gap: 12px; }
.u-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; grid-template-columns: 170px 1fr auto; gap: 24px; }
.u-row .mono { font-family: var(--serif); font-style: italic; font-size: 18px; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 400; }
.u-row.edited { box-shadow: inset 3px 0 0 var(--moss); }
.u-value { background: transparent; border: 0; border-left: 1px solid var(--line); padding: 2px 0 2px 20px; font-size: 16.5px; line-height: 1.5; }
.edited-tag { font-family: var(--sans); font-weight: 600; color: var(--moss); margin: 8px 0 0 20px; }
.text-btn { color: var(--clay); font-weight: 500; text-underline-offset: 4px; }
.loading { font-family: var(--serif); font-style: italic; font-size: 18px; letter-spacing: 0; }

/* ---------- Versions ---------- */
.versions-layout { grid-template-columns: 300px 1fr; gap: 28px; }
.v-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.v-item:hover { border-color: #bfb39e; }
.v-item[aria-current="true"] { background: #fbf9f4; border-color: var(--moss); box-shadow: inset 4px 0 0 var(--moss); }
.v-item .mono { color: var(--muted); }
.v-preview { background: transparent; border: 0; padding: 0; font-size: 14px; line-height: 1.5; }
.v-item[aria-current="true"] .v-preview { background: transparent; }
.rec-tag { background: transparent; color: var(--clay); border: 1px solid var(--clay); border-radius: 2px; padding: 2px 7px; font-family: var(--sans); font-weight: 600; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
#moreVersions { border-style: dashed; border-color: #b3a891; }
.editor > .card-label { color: var(--ink); font-family: var(--serif); font-style: italic; font-size: 18px; letter-spacing: 0; text-transform: none; padding-bottom: 12px; border-bottom: 1px solid var(--ink); margin-bottom: 0; }
.part { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 20px 0; margin: 0; }
.part-head label { font-family: var(--sans); font-weight: 600; font-size: 10.5px; letter-spacing: .14em; color: var(--muted); }
.part textarea { background: #fbf9f4; border-style: solid; }
@keyframes flash { from { background: var(--accent-soft); } to { background: #fbf9f4; } }
.compare-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.compare-card.current { border-color: var(--moss); box-shadow: inset 0 3px 0 var(--moss); }
.compare-card pre { font-family: var(--sans); font-size: 15px; line-height: 1.5; }

/* ---------- Done ---------- */
.step[data-step="6"] .step-head::before {
  content: ""; display: block; width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--moss); margin-bottom: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2346573a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 24px no-repeat;
}
.final { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; max-width: 680px; }
.final-text { font-family: var(--sans); font-size: 17px; line-height: 1.6; }
.copy-ok { color: var(--moss); }

.footer-nav { max-width: none; padding: 40px 0 0; }
.footnote, .ver-switch { max-width: 1200px; color: var(--muted); }

/* ---------- Tablet / phone ---------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; gap: 0; padding-top: 0; }
  .rail { display: none; }
  .progress { display: block; width: 100%; max-width: none; height: 3px; background: var(--line); margin: 0; }
  .progress span { background: var(--moss); }
  main { padding-top: 40px; }
}
@media (max-width: 860px) {
  .versions-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; row-gap: 4px; }
  .shell { padding: 0 16px 16px; }
  main { padding-top: 28px; }
  h1 { font-size: 34px; }
  .sub { font-size: 16.5px; }
  .card { padding: 22px; }
  .grid-3 .card, .grid-2 .card { min-height: 0; }
  .u-row { grid-template-columns: 1fr; gap: 8px; padding: 18px; }
  .u-value { border-left: 0; padding-left: 0; }
  .edited-tag { margin-left: 0; }
  .toggle { display: flex; }
  .toggle-btn { flex: 0 0 auto; }
  .footer-nav { width: auto; position: sticky; bottom: 0; background: rgba(235,228,214,.96); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); margin: 0 -16px; }
}
