:root {
  color-scheme: dark;
  --bg: #0a1e18;
  --ink: #f5ebd7;
  --muted: #bec9bb;
  --gold: #e4c589;
  --edge: #6a6249;
  --panel: #132d24;
  --serif: Georgia, 'Times New Roman', serif;
  font: 16px/1.55 system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(ellipse at 18% 0%, #204333 0%, transparent 58%), var(--bg); }
.masthead { padding: 1.2rem clamp(1rem, 5vw, 5rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid #77654970; }
.brand { color: var(--gold); text-decoration: none; font-family: var(--serif); letter-spacing: .22em; white-space: nowrap; }
.brand span { font-size: 1.75rem; vertical-align: middle; margin-right: .25rem; }
.nav { display: flex; gap: clamp(.1rem, 2vw, 1.4rem); }
.nav button { border: 0; border-radius: 0; padding: .55rem .65rem; font-size: .9rem; color: var(--muted); background: transparent; }
.nav button[aria-current] { color: var(--gold); box-shadow: inset 0 -1px var(--gold); }
main { width: min(1120px, calc(100% - 2.5rem)); margin: auto; }
.welcome { display: grid; grid-template-columns: 1.07fr 1fr; gap: clamp(2rem, 6vw, 6rem); align-items: center; min-height: 73vh; padding: 3rem 0; }
.intro { text-align: center; }
.emblem { width: 140px; aspect-ratio: 1; margin: 0 auto 1.8rem; border: 1px solid #aa905e90; border-radius: 50%; display: grid; place-items: center; color: var(--gold); box-shadow: 0 0 52px #cba86822, inset 0 0 35px #cba86815; position: relative; }
.emblem::before,.emblem::after { content: ''; position: absolute; inset: 20%; border: 1px solid #aa905e80; transform: rotate(45deg); }
.emblem::after { inset: 10px; border-radius: 50%; }
.emblem span { font-size: 4.7rem; line-height: 1; }
.eyebrow { font-size: .72rem; color: var(--gold); text-transform: uppercase; letter-spacing: .25em; font-weight: 650; margin: 0 0 .65rem; }
h1,h2,h3 { font-family: var(--serif); font-weight: 400; line-height: 1.06; overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(3rem, 8vw, 6.7rem); letter-spacing: -.06em; }
h1 em { color: var(--gold); font-weight: 400; }
h2 { font-size: clamp(1.55rem, 3vw, 2.15rem); margin: 0 0 1.1rem; }
h3 { font-size: 1.35rem; margin-bottom: .35rem; }
.lede { color: var(--muted); font-size: 1.13rem; }
.panel { background: linear-gradient(145deg,#19362b,var(--panel)); border: 1px solid var(--edge); border-radius: 18px; padding: clamp(1rem, 3vw, 2rem); box-shadow: 0 22px 50px #06120d50; min-width: 0; }
.form-grid,.city-row,.reading-layout,.graph-layout { display: grid; gap: .75rem; }
.form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.city-row { grid-template-columns: minmax(0,1fr) auto; align-items: stretch; }
label { display: block; font-size: .86rem; font-weight: 550; margin: .8rem 0 .32rem; }
input,select,button,textarea { font: inherit; color: var(--ink); border: 1px solid var(--edge); background: #0c241b; border-radius: 8px; padding: .65rem .78rem; min-width: 0; }
input,select,textarea { width: 100%; }
button { cursor: pointer; }
button:disabled { opacity: .7; cursor: wait; }
:focus-visible { outline: 2px solid #ffdc8d; outline-offset: 3px; }
.primary { background: #e0c185; color: #17241b; font-weight: 680; border-color: #e0c185; }
.primary:hover { background: #f4d79b; }
.secondary { background: transparent; color: var(--gold); }
.secondary:hover,.nav button:hover { background: #cbb47b19; }
#compute { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.note,.empty,footer { color: var(--muted); font-size: .88rem; }
footer { text-align: center; padding: 1.5rem 1rem 2rem; }
#status { color: var(--gold); min-height: 1.5em; overflow-wrap: anywhere; }
.section-heading,.profile-heading { margin: 3rem 0 2rem; }
.profile-heading { text-align: center; }
.profile-heading h1 { font-size: clamp(2.7rem, 7vw, 5.2rem); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.profile-heading .actions { justify-content: center; }
.stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .85rem; }
.stats dt { color: var(--gold); font-size: .78rem; }
.stats dd { margin: .3rem 0 0; font: 1.55rem/1.15 var(--serif); overflow-wrap: anywhere; }
.stats p { margin-bottom: 0; }
.graph-layout { grid-template-columns: minmax(0, 1.38fr) minmax(0,1fr); align-items: start; gap: 1rem; }
.graph-panel { background: radial-gradient(ellipse at center,#254a38,#11291f); padding: .7rem; }
#graph svg { display: block; width: min(100%, 500px); margin: auto; overflow: visible; }
.silhouette { fill: #0e251c; stroke: #8e784d; stroke-width: 1; }
.track,.segment,.channel-hit { fill: none; stroke-width: 5; }
.track { stroke: #58675a; }
.segment.personality { stroke: #e4c589; }
.segment.design { stroke: #ee9b8e; }
.segment.both { stroke: #e5acf4; }
.segment.active { stroke: #9bdcc7; }
.channel-hit { stroke: transparent; stroke-width: 12; }
.center-shape { fill: #203d31; stroke: #ac9b74; stroke-width: 1.4; }
.center-shape.defined { fill: #8d7544; stroke: #f1cf89; }
.graph-target { cursor: pointer; }
.graph-target:hover .track,.graph-target:focus-visible .track,.graph-target:hover .center-shape,.graph-target:hover .gate { stroke: white; }
.gate { fill: #0c221a; stroke: #abb9a3; stroke-width: .8; }
.gate.personality { fill: #75591e; stroke: #e4c589; }
.gate.design { fill: #874238; stroke: #ee9b8e; }
.gate.both { fill: #70417b; stroke: #e5acf4; }
.gate.active { fill: #25604e; stroke: #9bdcc7; }
.gate-label { fill: white; font: 11px system-ui; font-weight: 700; text-anchor: middle; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 1rem; row-gap: .3rem; padding: 0; list-style: none; font-size: .79rem; }
.legend li::before { content: '●'; margin-right: .35rem; }
.legend .personality::before { color: #e4c589; }
.legend .design::before { color: #ee9b8e; }
.legend .both::before { color: #e5acf4; }
.legend .active::before { color: #9bdcc7; }
.catalog { margin-top: 1rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.check input { width: auto; }
#catalog { display: grid; gap: .4rem; max-height: 23rem; overflow: auto; padding: .25rem; }
#catalog button { text-align: left; }
.reading-layout { grid-template-columns: minmax(0,1.3fr) minmax(0,1fr); align-items: start; }
.reading:not(:empty) { border-top: 1px solid var(--edge); margin-top: 1.5rem; padding-top: .5rem; }
.reading p { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 65ch; }
.saved-item { display: flex; justify-content: space-between; gap: .65rem; align-items: center; padding: .65rem 0; }
.saved-item + .saved-item { border-top: 1px solid var(--edge); }
.saved-item button { overflow-wrap: anywhere; }
textarea { min-height: 8rem; margin-top: 1rem; }
@media (max-width: 760px) {
  .welcome,.reading-layout,.graph-layout { grid-template-columns: minmax(0,1fr); }
  .welcome { padding-top: 2rem; }
  .emblem { width: 104px; margin-bottom: 1.2rem; }
  .emblem span { font-size: 3.5rem; }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 490px) {
  .masthead { flex-direction: column; padding: .65rem .25rem; gap: .25rem; }
  .nav { gap: .3rem; }
  main { width: calc(100% - 1.5rem); }
  .city-row { grid-template-columns: minmax(0,1fr); }
  .panel { border-radius: 12px; }
}
@media print {
  :root { color-scheme: light; --ink: #17251d; --gold: #634c20; --muted: #27382f; }
  body,.panel { background: white; box-shadow: none; }
  .masthead,.actions,button,footer,#status { display: none !important; }
  .panel { break-inside: avoid; }
}

#graph-sheet {
  width: min(100% - 1rem, 34rem);
  max-width: none;
  margin: auto auto max(.5rem, env(safe-area-inset-bottom));
  padding: 1rem 1.15rem 1.25rem;
  color: var(--ink);
  background: #19362b;
  border: 1px solid var(--edge);
  border-radius: 20px;
}
#graph-sheet::backdrop { background: #06120dba; }
.sheet-actions { display: flex; justify-content: flex-end; margin-bottom: .85rem; }
#graph-sheet-content p:last-child { margin-bottom: 0; }

@media screen and (max-width: 760px) {
  .masthead {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #0e261eef;
    backdrop-filter: blur(12px);
  }
  .nav button, .actions button, .sheet-actions button { min-height: 44px; }
  main > section { scroll-margin-top: 7rem; }
  .section-heading, .profile-heading { margin: 1.55rem 0 1.2rem; }
  .graph-panel { padding: .3rem; }
  .graph-panel .legend { padding: .35rem; margin: .2rem 0 .45rem; }
  .stats dd { font-size: 1.35rem; }
  #catalog button { min-height: 44px; }
}
@media screen and (max-width: 490px) {
  .masthead { gap: .05rem; padding: .25rem .25rem 0; }
  .brand { font-size: .82rem; }
  .brand span { font-size: 1.35rem; }
  .nav { width: 100%; max-width: 29rem; justify-content: space-evenly; gap: 0; }
  .nav button { padding-inline: .5rem; }
  .welcome { align-content: start; gap: 1.3rem; padding: 1.25rem 0 1.75rem; min-height: auto; }
  .intro .emblem { width: 48px; margin-bottom: .7rem; }
  .intro .emblem span { font-size: 1.7rem; }
  .intro .emblem::after { inset: 4px; }
  .intro h1 { font-size: clamp(2.5rem, 11vw, 3.35rem); }
  .intro h1 br { display: none; }
  .intro h1 em::before { content: ' '; }
  .intro .lede { max-width: 28ch; margin: .55rem auto 0; font-size: .95rem; }
  #birth h2 { margin-bottom: .65rem; }
  .profile-heading h1 { font-size: clamp(2.25rem, 10vw, 3.1rem); }
  .profile-heading .actions, .reading-layout .actions { display: grid; }
  .stats { gap: .55rem; }
  .stats .panel { padding: .75rem; }
}
