:root {
  color-scheme: light;
  --gold: #a97824;
  --gold-bright: #d3a64c;
  --ink: #172019;
  --paper: #f7f2e6;
  --surface: #fffdf7;
  --surface-2: #eee6d5;
  --line: #cfc3ab;
  --muted: #62695f;
  --good: #21684a;
  --warn: #925f16;
  --bad: #a43b34;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius: 18px;
  --shadow: 0 22px 60px rgba(46, 37, 19, .12);
  --ease: 220ms cubic-bezier(.2, .8, .2, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3ecd9;
  --paper: #0e1411;
  --surface: #151c18;
  --surface-2: #202921;
  --line: #3c493e;
  --muted: #b8c0b5;
  --good: #73c69a;
  --warn: #e3b866;
  --bad: #f08b84;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
*[hidden] { display: none !important; }
html { min-width: 320px; background: var(--paper); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); }
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
a { color: var(--good); }
:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
.skip { position: fixed; left: -999px; top: 10px; z-index: 100; padding: 12px 16px; border-radius: 8px; background: var(--ink); color: var(--paper); }
.skip:focus { left: 10px; }
.shell { width: min(1180px, 100%); margin: auto; padding-inline: 24px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0; color: var(--gold); font-size: .72rem; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
.muted { color: var(--muted); }
.number { font-variant-numeric: tabular-nums; }

.preview-bar { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(18px); }
.preview-inner { min-height: 60px; display: flex; align-items: center; gap: 12px; padding-block: 8px; }
.preview-label { margin-right: auto; font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.directions { display: flex; gap: 6px; }
.direction, .icon-button { min-height: 44px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); padding: 8px 14px; transition: background var(--ease), color var(--ease), transform var(--ease); }
.direction:hover, .icon-button:hover { transform: translateY(-1px); }
.direction[aria-pressed="true"] { border-color: var(--gold); background: var(--ink); color: var(--paper); }
.icon-button { min-width: 44px; padding-inline: 12px; }

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-inner { min-height: 78px; display: flex; align-items: center; gap: 14px; }
.roundel { width: 48px; height: 48px; flex: 0 0 auto; }
.brand { min-width: 0; margin-right: auto; }
.brand strong { display: block; font-family: var(--serif); font-size: 1.18rem; }
.brand span { display: block; overflow: hidden; color: var(--muted); font-size: .74rem; letter-spacing: .12em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .82rem; }
.status-chip::before { width: 8px; height: 8px; border-radius: 50%; background: var(--good); content: ""; }

.login { min-height: calc(100dvh - 60px); display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); }
.login-art { position: relative; min-height: 500px; display: flex; align-items: flex-end; overflow: hidden; padding: clamp(32px, 8vw, 104px); background: #101713; color: #f8f0dc; isolation: isolate; }
.login-art::before { position: absolute; inset: -16%; z-index: -2; background: radial-gradient(circle at 74% 18%, rgba(211,166,76,.35), transparent 27%), radial-gradient(circle at 28% 76%, rgba(91,134,91,.28), transparent 33%), linear-gradient(142deg, transparent 44%, rgba(255,255,255,.055) 44.2%, transparent 45%); content: ""; }
.login-art::after { position: absolute; right: -8%; bottom: -25%; z-index: -1; width: 72%; aspect-ratio: 1; border: 1px solid rgba(211,166,76,.28); border-radius: 50%; box-shadow: 0 0 0 44px rgba(211,166,76,.05), 0 0 0 88px rgba(211,166,76,.035); content: ""; }
.login-copy { max-width: 660px; }
.login-copy .roundel { width: 86px; height: 86px; margin-bottom: 34px; }
.login h1, .hero h1 { font-family: var(--serif); font-weight: 500; letter-spacing: -.045em; }
.login h1 { max-width: 11ch; margin: 12px 0 18px; font-size: clamp(3rem, 7vw, 6.8rem); line-height: .9; }
.login-art p:last-child { max-width: 50ch; color: #d8d2c1; }
.login-panel { display: grid; align-content: center; padding: clamp(30px, 6vw, 80px); background: var(--surface); }
.login-panel > div { width: min(440px, 100%); margin: auto; }
.login-panel h2 { margin: 10px 0 8px; font: 500 2rem/1.05 var(--serif); }

.field { display: grid; gap: 7px; margin: 18px 0; }
.field label, legend { font-weight: 750; }
.field small { color: var(--muted); }
input, select, textarea { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); padding: 12px 13px; }
textarea { min-height: 108px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); padding: 11px 17px; font-weight: 800; text-decoration: none; transition: background var(--ease), transform var(--ease), opacity var(--ease); }
.button:hover { transform: translateY(-1px); }
.button.primary { border-color: var(--gold); background: var(--ink); color: var(--paper); }
.button.gold { border-color: var(--gold); background: var(--gold); color: #111713; }
.button:disabled { cursor: wait; opacity: .5; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row .primary { flex: 1; }
.preview-entry { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }

main { min-height: calc(100dvh - 138px); padding-block: 34px 116px; }
.hero { min-height: 280px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr); align-items: end; gap: 30px; padding: 48px 0 34px; }
.hero h1 { max-width: 13ch; margin: 9px 0 16px; font-size: clamp(2.7rem, 6vw, 5.7rem); line-height: .94; }
.hero-copy { max-width: 58ch; color: var(--muted); }
.hero-proof { padding: 24px; border-left: 1px solid var(--line); }
.hero-proof strong { display: block; font: 500 3.7rem/1 var(--serif); }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card h2 { margin: 7px 0 8px; font: 500 1.75rem/1.1 var(--serif); }
.metric { min-height: 168px; display: flex; flex-direction: column; }
.metric-value { margin-top: auto; font: 500 3.2rem/1 var(--serif); }
.metric small { color: var(--muted); }
.feature-card { position: relative; overflow: hidden; background: var(--ink); color: var(--paper); }
.feature-card::after { position: absolute; right: -12%; bottom: -52%; width: 52%; aspect-ratio: 1; border: 1px solid color-mix(in srgb, var(--gold) 65%, transparent); border-radius: 50%; content: ""; }
.feature-card p { max-width: 42ch; color: color-mix(in srgb, var(--paper) 74%, transparent); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h1 { margin: 7px 0 0; font: 500 clamp(2.3rem, 5vw, 4.4rem)/.96 var(--serif); letter-spacing: -.035em; }
.list { display: grid; gap: 10px; }
.soul-row, .history-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 13px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 13px; }
.initials { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--gold); font-family: var(--serif); font-weight: 800; }
.soul-row p, .history-row p { margin: 0; }
.soul-row small, .history-row small { color: var(--muted); }
.pill { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .76rem; font-weight: 800; }
.pill.good { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); color: var(--good); }
.pill.warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); color: var(--warn); }
.empty { padding: 32px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); text-align: center; }
.notice { margin-bottom: 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.notice.warn { border-color: var(--warn); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { position: sticky; bottom: 84px; z-index: 10; display: flex; justify-content: flex-end; padding-top: 14px; }
.form-actions .button { min-width: 210px; box-shadow: var(--shadow); }

.bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 40; display: flex; justify-content: center; gap: 6px; padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(18px); }
.bottom-nav button { min-width: 116px; min-height: 52px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); padding: 8px 14px; font-weight: 750; }
.bottom-nav button[aria-current="page"] { background: var(--ink); color: var(--paper); }
#live:not(:empty) { position: fixed; right: 18px; bottom: 86px; z-index: 70; width: min(480px, calc(100% - 36px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow); }
#live.error { background: var(--bad); color: #fff; }
#live.success { background: var(--good); color: #fff; }
.offline { position: fixed; top: 70px; right: 14px; z-index: 45; padding: 9px 13px; border-radius: 999px; background: var(--warn); color: #16110a; font-weight: 800; }

/* Direction B: a nocturnal field journal with stronger depth and luminous gold. */
html[data-direction="watch"] { --gold: #d6ad52; --gold-bright: #f0d48e; --paper: #0c0d0c; --surface: #151613; --surface-2: #20231d; --ink: #f8f0dc; --line: #3a392f; --muted: #c2bba9; --good: #8ec7a0; color-scheme: dark; }
html[data-direction="watch"][data-theme="light"] { --paper: #eee8db; --surface: #faf5e9; --surface-2: #e3d9c6; --ink: #171814; --line: #c9bda7; --muted: #5f6359; --good: #376b4b; color-scheme: light; }
html[data-direction="watch"] body { background-image: radial-gradient(900px 520px at 88% 2%, color-mix(in srgb, var(--gold) 14%, transparent), transparent 65%); }
html[data-direction="watch"] .card { border-radius: 8px; }
html[data-direction="watch"] .feature-card { background: linear-gradient(145deg, #1b241e, #090b09); }

/* Direction C: an open, optimistic field map with curved forms and more air. */
html[data-direction="fields"] { --gold: #9f641e; --gold-bright: #d39a4c; --paper: #f5ead7; --surface: #fffaf1; --surface-2: #e6d4b8; --ink: #1d3028; --line: #cdbb9c; --muted: #5c6c63; --good: #2d7058; --radius: 30px; --shadow: 0 20px 50px rgba(77,54,24,.1); }
html[data-direction="fields"][data-theme="dark"] { --paper: #111b17; --surface: #19251f; --surface-2: #26372e; --ink: #f3ead7; --line: #465a4e; --muted: #b7c4bc; --good: #83cbaa; }
html[data-direction="fields"] body { background-image: radial-gradient(700px 360px at 10% 0%, color-mix(in srgb, var(--good) 12%, transparent), transparent 60%); }
html[data-direction="fields"] .hero { grid-template-columns: minmax(0, .9fr) minmax(280px, .55fr); }
html[data-direction="fields"] .hero h1 { max-width: 10ch; }
html[data-direction="fields"] .feature-card { background: var(--good); }
html[data-direction="fields"] .card { border-color: transparent; }

@media (max-width: 820px) {
  .shell { padding-inline: 18px; }
  .preview-inner { flex-wrap: wrap; }
  .preview-label { width: 100%; margin: 0; }
  .directions { flex: 1; overflow-x: auto; padding-bottom: 2px; }
  .direction { white-space: nowrap; }
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 390px; padding: 42px 24px; }
  .login h1 { font-size: clamp(3.2rem, 15vw, 5.8rem); }
  .login-panel { padding: 42px 20px 60px; }
  .topbar-inner { min-height: 68px; }
  .status-chip { display: none; }
  .hero, html[data-direction="fields"] .hero { min-height: 0; grid-template-columns: 1fr; padding: 34px 0 26px; }
  .hero-proof { border-top: 1px solid var(--line); border-left: 0; padding: 18px 0 0; }
  .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; }
  .two { grid-template-columns: 1fr; gap: 0; }
  .card { padding: 20px; }
}

@media (max-width: 480px) {
  .shell { padding-inline: 14px; }
  .preview-inner { position: relative; gap: 8px; }
  .preview-label { padding-right: 62px; }
  .directions { width: 100%; margin: 0; overflow: visible; }
  .direction { min-width: 0; flex: 1; padding-inline: 4px; font-size: 0; }
  .direction::after { content: attr(data-short); font-size: .72rem; }
  .icon-button { position: absolute; top: 8px; right: 14px; }
  .roundel { width: 42px; height: 42px; }
  .brand strong { font-size: 1rem; }
  .hero h1 { font-size: 2.75rem; }
  .section-head { align-items: start; flex-direction: column; }
  .soul-row, .history-row { grid-template-columns: 42px minmax(0,1fr); }
  .soul-row .pill, .history-row .pill { grid-column: 2; justify-self: start; }
  .bottom-nav { justify-content: space-around; }
  .bottom-nav button { min-width: 0; flex: 1; padding-inline: 4px; font-size: .78rem; }
  .form-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .preview-bar, .topbar, .bottom-nav, .form-actions, #live, .offline { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; }
}

/* Ancestry is read from the selected Embassy, never a second placement form. */
.placement-ancestry { margin-block: 22px; padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.placement-ancestry dl { display: grid; gap: 12px; margin: 14px 0 0; }
.placement-ancestry dl > div { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 12px; }
.placement-ancestry dt { color: var(--muted); }
.placement-ancestry dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; }

.not-seated { display: grid; align-content: center; min-height: calc(100dvh - 100px); padding: 28px; }
.not-seated > .card { width: min(620px, 100%); margin: auto; }
.not-seated h1 { font: 500 clamp(2rem, 5vw, 3.6rem)/1.05 var(--serif); }

/* Gold stays legible on paper; the fixed dark art uses its luminous pair. */
:root { --gold: #875814; }
html[data-theme="dark"] { --gold: #d3a64c; }
html[data-direction="watch"][data-theme="light"] { --gold: #7b4e12; }
html[data-direction="fields"][data-theme="light"] { --gold: #7b4e12; }
html[data-direction="fields"][data-theme="dark"] { --gold: #d39a4c; }
.button.gold { background: var(--gold-bright); }
.feature-card p:not(.eyebrow) { color: inherit; }
.login-art .eyebrow { color: var(--gold-bright); }
.feature-card .eyebrow { color: inherit; }
html[data-direction="watch"] .feature-card { color: #f8f0dc; }
html[data-direction="watch"] .feature-card p:not(.eyebrow) { color: #d8d2c1; }

.appearance-bar { border-bottom: 1px solid var(--line); background: var(--surface); }
.appearance-inner { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.appearance-inner .icon-button { position: static; }
