/*
 * Direction: a dark navy app shell with gold accents around a warm parchment page, a painted
 * landscape hero, a serif display face, and clean scientific charts in blue/orange/purple.
 * No framework, no web fonts (CSP is 'self' only), no inline styles.
 */
:root {
  --navy-0: #070e18;
  --navy-1: #0b1626;
  --navy-2: #112238;
  --navy-line: #1d3550;
  --gold: #c19a4b;
  --gold-hi: #e3c374;
  --gold-lo: #8a6a2b;
  --paper: #eadfc4;
  --paper-hi: #f4ecd6;
  --paper-lo: #d8c79f;
  --ink: #1a1816;
  --ink-soft: #4d4538;
  --blue: #2f6fbd;
  --orange: #e08a2c;
  --purple: #7a56b8;
  --red: #a8322d;
  --teal: #2a8a8f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  background:
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(47, 111, 189, .16), transparent 70%),
    var(--navy-0);
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
p { margin: 0 0 1rem; }
h1, h2, h3, h4 { font-family: var(--serif); margin: 0 0 .5rem; }
.muted { color: var(--ink-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- shell ---- */
.shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: 64px 1fr;
  grid-template-areas: "top top" "side main";
  min-height: 100vh;
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 1.5rem; padding: 0 1.4rem;
  color: #e7dfca; background: linear-gradient(180deg, #0d1a2d, var(--navy-1));
  border-bottom: 1px solid var(--gold-lo);
  box-shadow: 0 1px 0 rgba(227, 195, 116, .18), 0 6px 20px rgba(0, 0, 0, .4);
}
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--gold-hi); font: 600 .92rem var(--serif); letter-spacing: .24em; text-transform: uppercase; }
.mark { width: 22px; height: 24px; background: linear-gradient(160deg, var(--gold-hi), var(--gold-lo)); clip-path: polygon(50% 0, 100% 24%, 100% 76%, 50% 100%, 0 76%, 0 24%); position: relative; }
.mark::after { content: ""; position: absolute; inset: 5px 6px; background: var(--navy-1); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.path { flex: 1; max-width: 26rem; margin: 0 auto; padding: .45rem 1rem; border: 1px solid var(--navy-line); border-radius: 999px; font: .8rem var(--mono); color: #7f93aa; background: rgba(5, 12, 22, .55); }
.path b { color: var(--gold-lo); font-weight: 400; }
.who-bar { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.who-bar form { margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: block; border: 1px solid var(--gold-lo); object-fit: cover; }
.avatar.big { width: 60px; height: 60px; }

.side { grid-area: side; display: flex; flex-direction: column; justify-content: space-between; padding: 1.4rem 0 1.6rem; background: linear-gradient(180deg, var(--navy-1), var(--navy-0)); border-right: 1px solid #0f1d30; }
.side nav { display: flex; flex-direction: column; gap: .15rem; }
.side nav > a, .side .soon { display: flex; align-items: center; gap: .9rem; padding: .78rem 1.5rem; color: #b9c4d2; text-decoration: none; font: .95rem var(--serif); border-left: 3px solid transparent; }
.side nav > a:hover { color: var(--gold-hi); background: rgba(193, 154, 75, .08); }
.side nav > a.active { color: var(--gold-hi); border-left-color: var(--gold); background: linear-gradient(90deg, rgba(193, 154, 75, .3), rgba(193, 154, 75, 0)); }
.side .soon { color: #5f7187; cursor: default; }
.side .soon small { margin-left: auto; font: .62rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #46586d; }
.ico { width: 20px; height: 20px; flex: none; }
.side-foot { padding: 0 1.5rem; text-align: center; color: #5c4a28; }
.crest { width: 62px; height: 78px; color: #6e5a2e; }
.side-foot p { margin: .8rem 0 0; font: .62rem var(--sans); letter-spacing: .3em; text-transform: uppercase; color: #4d5e74; }

.content {
  grid-area: main; min-width: 0; padding: 2.2rem 2.4rem 2rem; color: var(--ink);
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .33  0 0 0 0 .22  0 0 0 0 .09  0 0 0 .2 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    radial-gradient(ellipse 80% 60% at 70% 0%, rgba(255, 248, 225, .7), transparent 70%),
    radial-gradient(ellipse at 50% 120%, rgba(150, 105, 50, .28), transparent 60%),
    linear-gradient(180deg, var(--paper-hi), var(--paper) 45%, var(--paper-lo));
  box-shadow: inset 8px 0 18px -8px rgba(0, 0, 0, .45);
}
footer { margin-top: 2.6rem; text-align: center; font: .68rem var(--serif); letter-spacing: .32em; text-transform: uppercase; color: rgba(77, 69, 56, .7); }

/* ---- type ---- */
h1 { font-size: clamp(2.3rem, 5vw, 3.7rem); line-height: 1.07; font-weight: 700; letter-spacing: -.012em; color: var(--ink); }
.gold { background: linear-gradient(180deg, #cba352 10%, #8d6624); -webkit-background-clip: text; background-clip: text; color: transparent; }
.eyebrow { margin: 0 0 1rem; font: 500 .7rem var(--sans); letter-spacing: .34em; text-transform: uppercase; color: var(--ink-soft); }
.lede { max-width: 31rem; font: 1.12rem/1.55 var(--serif); color: #3a342a; }
h2 { font-size: .8rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-lo); }
.intro { margin-bottom: 1.4rem; }
.intro h1 { font-size: clamp(2rem, 4vw, 2.8rem); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.35rem; cursor: pointer; text-decoration: none; font: 600 .95rem var(--serif); border-radius: 4px; border: 1px solid transparent; }
.btn.small { padding: .38rem .95rem; font-size: .82rem; }
.btn.primary { color: #1c1406; background: linear-gradient(180deg, #d6b468, #a07a33); border-color: #8a6a2b; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 3px 8px rgba(40, 25, 5, .28); }
.btn.primary:hover { background: linear-gradient(180deg, #e2c27c, #ad853a); }
.btn.ghost { background: transparent; color: var(--ink); border-color: rgba(26, 24, 22, .4); }
.btn.ghost:hover { background: rgba(26, 24, 22, .07); }
.topbar .btn.ghost { color: var(--gold-hi); border-color: var(--gold-lo); }
.topbar .btn.ghost:hover { background: rgba(193, 154, 75, .14); }
.btn.danger { background: transparent; color: var(--red); border-color: rgba(168, 50, 45, .5); font-weight: 500; }
.btn.danger:hover { background: rgba(168, 50, 45, .09); }
.link { color: var(--ink); text-decoration: none; padding-bottom: 2px; border-bottom: 2px solid var(--gold); font: .98rem var(--serif); }
.link:hover { color: var(--gold-lo); }
.cta { display: flex; align-items: center; gap: 1.6rem; margin-top: 1.8rem; }

/* ---- hero ---- */
/* The art is 900x470 and fills the right 70%, so the hero must be at least that tall at any
   width or `slice` crops the top of the painting (and the tallest figure's head). */
.hero { position: relative; overflow: hidden; margin: -2.2rem -2.4rem 2rem; min-height: max(25rem, calc((100vw - 232px) * 0.39)); }
.hero-art { position: absolute; inset: 0 0 0 30%; -webkit-mask-image: linear-gradient(90deg, transparent, #000 26%); mask-image: linear-gradient(90deg, transparent, #000 26%); }
.hero-svg { display: block; width: 100%; height: 100%; }
.hero-svg .procession { color: #1d1a16; }
.hero-svg .procession path { stroke: #1d1a16; }
.hero-copy { position: relative; z-index: 1; padding: 3.2rem 2.4rem 3rem; max-width: 41rem; }
.hero-copy h1 { font-size: clamp(2.1rem, 4.2vw, 3.3rem); }

/* ---- panels, cards ---- */
.card, .panel.paper {
  padding: 1.2rem 1.4rem; margin-top: 1.4rem;
  background: rgba(255, 251, 240, .55); border: 1px solid rgba(110, 85, 40, .32); border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 8px 22px rgba(80, 55, 20, .12);
}
.panel.dark { padding: 1.2rem 1.4rem; color: #d3deeb; background: linear-gradient(180deg, #102139, #0a1524); border: 1px solid var(--navy-line); border-radius: 6px; box-shadow: 0 12px 30px rgba(5, 10, 20, .45); }
.panel.dark h3, .panel.dark h4 { color: #eee3c6; }
.panel-head { display: flex; align-items: center; gap: .65rem; padding-bottom: .75rem; margin-bottom: .9rem; border-bottom: 1px solid rgba(120, 95, 50, .3); }
.panel.dark .panel-head { border-bottom-color: var(--navy-line); }
.panel-head svg { width: 22px; height: 22px; color: var(--gold); }
.panel-head h3 { margin: 0; font-size: 1.08rem; font-weight: 600; }
.panel h4 { margin: 1.1rem 0 .4rem; font-size: .92rem; font-weight: 600; }
.lab { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.3fr); gap: 1.3rem; }
.lab .panel { margin-top: 0; }
.lab-slot > .muted { padding: 2rem 0; }
.equation { margin: .2rem 0 .5rem; font: italic 1.28rem var(--serif); color: #f1e2ba; }
.equation sup, .equation sub { font-size: .7em; }
.params { display: flex; gap: 1.3rem; font: .82rem var(--mono); color: #93a8be; }
.resid { display: block; width: 100%; height: auto; }
.rgrid { stroke: #23405c; stroke-width: .8; }
.rgrid.zero { stroke: #8fb0d0; stroke-dasharray: 4 4; }
.rtick, .rlabel { fill: #8ea4bb; font: 11px var(--sans); }
.dot { fill: #4aa3ff; opacity: .85; }

.analysis { display: grid; grid-template-columns: minmax(0, 1fr) 14.5rem; gap: 1.2rem; align-items: start; }
.chart { display: block; width: 100%; height: auto; }
.cgrid { stroke: rgba(80, 62, 34, .2); stroke-width: .8; }
.ctick, .clabel { fill: #5a4d38; font: 11px var(--sans); }
.numeral { fill: #6a5232; font: italic 13px var(--serif); }
.frame { fill: none; stroke: rgba(80, 62, 34, .45); }
.line { fill: none; stroke-width: 2.1; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.7s cubic-bezier(.3, .6, .3, 1) forwards; }
.end { opacity: 0; animation: pop .3s 1.5s forwards; }
.fit { fill: none; stroke: #1a1816; stroke-width: 1.2; stroke-dasharray: 4 4; opacity: .55; }
.stage { fill: #fff; stroke: var(--blue); stroke-width: 2.2; cursor: pointer; }
.stage:hover, .stage:focus-visible { stroke: var(--gold); stroke-width: 3.6; outline: none; }
.legend text { fill: #3a3024; font: 11px var(--sans); }
.datatip { pointer-events: none; }
.datatip rect { fill: #0b1626; stroke: var(--gold-lo); }
.datatip text { fill: #f0e1b8; font: 11px var(--sans); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { to { opacity: 1; } }
.insights { padding-left: 1.2rem; border-left: 1px solid rgba(120, 95, 50, .3); }
.insights h4 { margin-top: 0; font-size: .74rem; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-lo); }
.insights ul { list-style: none; margin: 0; padding: 0; }
.insights li { display: flex; gap: .7rem; margin-bottom: 1rem; }
.insights svg { width: 22px; height: 22px; flex: none; margin-top: .15rem; color: var(--gold-lo); }
.insights p { margin: 0; font-size: .9rem; line-height: 1.4; }
.insights strong { display: block; font: 600 .95rem var(--serif); }
.insights span { color: var(--ink-soft); font-size: .84rem; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; margin-top: .6rem; padding-top: .9rem; border-top: 1px solid rgba(120, 95, 50, .3); }
.controls label { font: .74rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.controls input[type=range] { width: 120px; accent-color: var(--gold-lo); }
.controls output { min-width: 3ch; font: .82rem var(--mono); }
.controls .btn { margin-left: auto; padding: .35rem 1rem; font-size: .85rem; }

.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; margin-top: 1.4rem; }
.features .card { margin-top: 0; }
.features h3 { font-size: 1.1rem; }
.features p { color: var(--ink-soft); font-size: .92rem; }
.features small { font: .66rem var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--gold-lo); }

/* ---- forms and lists (admin, account) ---- */
.alert { padding: .6rem .9rem; margin: 0 0 1rem; background: rgba(255, 251, 240, .7); border-left: 3px solid var(--gold); }
.alert.error { border-left-color: var(--red); color: #7e2420; }
.alert.ok { border-left-color: var(--teal); color: #1f6266; }
.row { display: flex; gap: .6rem; margin: 1rem 0; }
input[type=email] { flex: 1; min-width: 0; padding: .6rem .8rem; font: inherit; color: var(--ink); background: rgba(255, 255, 255, .7); border: 1px solid rgba(110, 85, 40, .45); border-radius: 4px; }
input[type=email]:focus { outline: none; border-color: var(--gold-lo); box-shadow: 0 0 0 2px rgba(193, 154, 75, .35); }
.users { list-style: none; margin: 0; padding: 0; }
.users li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-top: 1px solid rgba(110, 85, 40, .28); }
.users li form { margin: 0; }
.users .who { min-width: 0; overflow-wrap: anywhere; }
.users small { display: block; color: var(--ink-soft); }
.tag { white-space: nowrap; padding: .05rem .65rem; font: .66rem var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--gold-lo); border: 1px solid var(--gold-lo); border-radius: 999px; }
.profile { display: flex; align-items: center; gap: 1rem; }

@media (max-width: 62rem) {
  .lab, .analysis { grid-template-columns: 1fr; }
  .insights { padding-left: 0; border-left: 0; padding-top: .6rem; }
}
@media (max-width: 52rem) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "top" "side" "main"; }
  .topbar { height: 56px; padding: 0 1rem; }
  .path, .side-foot { display: none; }
  .side { padding: 0; }
  .side nav { flex-direction: row; overflow-x: auto; }
  .side nav > a, .side .soon { padding: .7rem 1rem; border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .side nav > a.active { border-bottom-color: var(--gold); background: none; }
  .content { padding: 1.4rem 1rem 1.6rem; box-shadow: none; }
  .hero { margin: -1.4rem -1rem 1.4rem; min-height: 22rem; }
  .hero-art { inset: 0; opacity: .5; }
  .hero-copy { padding: 2rem 1rem; }
  .features { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .line { animation: none; stroke-dashoffset: 0; }
  .end { animation: none; opacity: 1; }
  html { scroll-behavior: auto; }
}
