@layer reset, theme, structure, components, responsive, motion;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { color-scheme: dark; -webkit-text-size-adjust: 100%; height: 100%; }
  body { margin: 0; min-width: 320px; min-height: 100dvh; min-height: 100svh; }
  button, input, select { font: inherit; }
  button { color: inherit; }
  button, a, input { -webkit-tap-highlight-color: transparent; }
  button { border: 0; }
  svg { display: block; }
  [hidden] { display: none !important; }
}

@layer theme {
  :root {
    --ink: #eef1f8;
    --ink-soft: #a9b3c9;
    --ink-faint: #737f99;
    --canvas: #070c1a;
    --canvas-2: #0b1224;
    --surface: rgba(15, 24, 46, .92);
    --surface-solid: #0f182e;
    --surface-high: #17223f;
    --line: rgba(196, 208, 236, .12);
    --line-strong: rgba(196, 208, 236, .23);
    --accent: #d9b36a;
    --accent-bright: #f0d293;
    --gold: #ddb56d;
    --gold-soft: rgba(221, 181, 109, .16);
    --blue: #86a9de;
    --violet: #ad97d7;
    --rose: #d5938f;
    --danger: #ed988e;
    --shadow: 0 24px 80px rgba(0, 0, 0, .38);
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  html[data-theme="light"] {
    color-scheme: light;
    --ink: #141c33;
    --ink-soft: #4d5875;
    --ink-faint: #7a8299;
    --canvas: #f3eee2;
    --canvas-2: #f8f4ea;
    --surface: rgba(251, 248, 240, .94);
    --surface-solid: #faf6ec;
    --surface-high: #efe8d8;
    --line: rgba(20, 32, 64, .12);
    --line-strong: rgba(20, 32, 64, .23);
    --accent: #9a6b1f;
    --accent-bright: #7d5514;
    --gold: #9c6c22;
    --gold-soft: rgba(156, 108, 34, .12);
    --blue: #2f5b9a;
    --violet: #7358a5;
    --rose: #a95854;
    --shadow: 0 24px 70px rgba(20, 28, 52, .16);
  }

  body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    font-synthesis: none;
  }
}

@layer structure {
  .app-shell {
    display: grid;
    grid-template-rows: 72px minmax(0, 1fr) 30px;
    height: 100dvh;
    height: 100svh;
    overflow: hidden;
    background: var(--canvas);
  }

  .topbar {
    z-index: 20;
    display: grid;
    grid-template-columns: 290px minmax(400px, 1fr) 180px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
    backdrop-filter: blur(18px);
  }

  .workspace {
    position: relative;
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    min-height: 0;
  }

  .app-shell.is-sidebar-collapsed .workspace {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .app-shell.is-sidebar-collapsed .explore-panel {
    overflow: hidden;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
  }

  html.is-immersive .app-shell {
    height: 100dvh;
    height: 100svh;
    grid-template-rows: calc(56px + env(safe-area-inset-top, 0px)) minmax(0, 1fr) 0;
  }

  html.is-immersive .topbar { padding-top: env(safe-area-inset-top, 0px); }
  html.is-immersive .statusbar { display: none; }

  .explore-panel {
    z-index: 12;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 28px 22px 18px;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: var(--surface-solid);
    scrollbar-width: thin;
  }

  .stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    isolation: isolate;
    background:
      radial-gradient(circle at 50% 45%, rgba(70, 100, 170, .12), transparent 38%),
      linear-gradient(135deg, transparent 49.75%, rgba(255,255,255,.018) 50%, transparent 50.25%),
      var(--canvas);
    background-size: auto, 34px 34px, auto;
  }

  #atlasCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    outline: none;
    touch-action: none;
  }

  #atlasCanvas:active { cursor: grabbing; }
  #atlasCanvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

  .lens-view {
    min-width: 0;
    min-height: 0;
    padding: clamp(28px, 5vw, 64px);
    overflow: auto;
    background:
      radial-gradient(circle at 85% 0, var(--gold-soft), transparent 32%),
      var(--canvas-2);
  }

  .person-panel {
    position: absolute;
    z-index: 18;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, calc(100vw - 290px));
    overflow-y: auto;
    border-left: 1px solid var(--line-strong);
    background: var(--surface);
    box-shadow: -24px 0 70px rgba(0, 0, 0, .25);
    backdrop-filter: blur(26px);
  }

  .statusbar {
    z-index: 21;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-top: 1px solid var(--line);
    background: var(--surface-solid);
    color: var(--ink-faint);
    font-size: 11px;
    letter-spacing: .03em;
  }
}

@layer components {
  .brand {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 100%;
    padding: 0 20px;
    background: transparent;
    cursor: pointer;
    text-align: left;
  }

  .brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 13px;
    background: linear-gradient(145deg, var(--surface-high), transparent);
    color: var(--gold);
  }

  .brand-mark svg { width: 28px; }
  .brand-mark path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  .brand strong { display: block; font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1; }
  .brand small { display: block; margin-top: 4px; color: var(--ink-faint); font-size: 9px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }

  .view-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }

  .view-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 15px;
    border-radius: 12px;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
  }

  .view-tab:hover { background: var(--surface-high); color: var(--ink); }
  .view-tab.is-active { background: var(--gold-soft); color: var(--gold); }
  .tab-icon { font-size: 15px; }

  .top-actions { display: flex; justify-content: flex-end; gap: 6px; padding-right: 18px; }
  .icon-button {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    font-weight: 750;
  }
  .icon-button:hover { border-color: var(--line); background: var(--surface-high); color: var(--ink); }
  .icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .icon-button.is-active { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }

  .sidebar-open {
    position: absolute;
    z-index: 16;
    top: 12px;
    left: 12px;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--gold);
    box-shadow: var(--shadow);
    cursor: pointer;
  }
  .sidebar-open svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

  .panel-heading { margin: 2px 0 24px; }
  .eyebrow {
    margin: 0 0 8px;
    color: var(--gold);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .22em;
    text-transform: uppercase;
  }
  .panel-heading h1 {
    max-width: 230px;
    margin: 0;
    font-family: var(--serif);
    font-size: 27px;
    font-weight: 500;
    line-height: 1.04;
    letter-spacing: -.025em;
  }

  .search-box {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--canvas-2);
    transition: border-color .2s, box-shadow .2s;
  }
  .search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
  .search-box svg { flex: 0 0 auto; width: 19px; margin-left: 14px; fill: none; stroke: var(--ink-faint); stroke-width: 1.7; }
  .search-box input { min-width: 0; flex: 1; height: 46px; border: 0; outline: 0; background: transparent; color: var(--ink); padding: 0 8px 0 10px; }
  .search-box input::placeholder { color: var(--ink-faint); }
  kbd { display: inline-grid; min-width: 20px; height: 20px; place-items: center; padding: 0 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-high); color: var(--ink-faint); font-family: var(--sans); font-size: 10px; }
  .search-box kbd { margin-right: 10px; }

  .search-results {
    position: absolute;
    z-index: 40;
    top: 132px;
    left: 16px;
    width: 258px;
    max-height: min(420px, 58vh);
    padding: 7px;
    overflow-y: auto;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
  }
  .search-result {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    width: 100%;
    padding: 9px;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    text-align: left;
  }
  .search-result:hover, .search-result[aria-selected="true"] { background: var(--surface-high); }
  .search-result .mini-avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font-size: 10px; font-weight: 800; }
  .search-result strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .search-result small { display: block; margin-top: 2px; overflow: hidden; color: var(--ink-faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .search-result > small { margin: 0; }

  .filter-section { padding: 23px 0 20px; border-bottom: 1px solid var(--line); }
  .filter-section h2, .section-title h2 { margin: 0 0 13px; color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
  .section-title { display: flex; align-items: start; justify-content: space-between; }
  .text-button { padding: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 10px; font-weight: 700; }
  .generation-filter { display: flex; flex-wrap: wrap; gap: 6px; }
  .generation-chip { min-width: 30px; height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas-2); color: var(--ink-soft); cursor: pointer; font-size: 11px; font-weight: 750; }
  .generation-chip:hover { border-color: var(--line-strong); color: var(--ink); }
  .generation-chip.is-active { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }

  .switch-row { display: flex; min-height: 34px; align-items: center; justify-content: space-between; color: var(--ink-soft); font-size: 12px; cursor: pointer; }
  .switch-row span { display: flex; align-items: center; gap: 9px; }
  .switch-row input { appearance: none; position: relative; width: 34px; height: 19px; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--canvas); cursor: pointer; transition: background .2s; }
  .switch-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--ink-faint); transition: transform .2s, background .2s; }
  .switch-row input:checked { background: color-mix(in srgb, var(--accent) 35%, var(--canvas)); }
  .switch-row input:checked::after { transform: translateX(15px); background: var(--accent-bright); }
  .edge-swatch { width: 17px; height: 2px; border-radius: 5px; background: var(--accent); }
  .edge-swatch.adoption { background: repeating-linear-gradient(90deg, var(--violet) 0 4px, transparent 4px 7px); }
  .edge-swatch.partner { background: var(--gold); }

  .atlas-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 22px 0; }
  .atlas-summary div { padding: 11px 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--canvas-2); text-align: center; }
  .atlas-summary strong { display: block; font-family: var(--serif); font-size: 18px; font-weight: 500; }
  .atlas-summary span { display: block; margin-top: 2px; color: var(--ink-faint); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }

  .founder-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; margin-top: auto; padding: 10px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(130deg, var(--gold-soft), transparent); cursor: pointer; text-align: left; }
  .founder-card:hover { border-color: var(--gold); }
  .avatar { display: grid; place-items: center; border-radius: 50%; background: var(--surface-high); color: var(--ink); font-weight: 800; }
  .avatar.founder { width: 38px; height: 38px; background: var(--gold); color: #1b170f; font-size: 10px; }
  .founder-card small { display: block; color: var(--ink-faint); font-size: 9px; }
  .founder-card strong { display: block; margin-top: 2px; font-family: var(--serif); font-size: 13px; font-weight: 600; }
  .founder-card > span:last-child { color: var(--gold); }

  .stage-vignette { position: absolute; z-index: -1; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(0, 0, 0, .28); }
  .stage-hud { position: absolute; top: 18px; left: 20px; display: flex; align-items: center; gap: 8px; min-height: 33px; padding: 0 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink-soft); font-size: 10px; letter-spacing: .04em; backdrop-filter: blur(14px); pointer-events: none; }
  .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent); }
  .hud-divider { width: 1px; height: 13px; background: var(--line-strong); }
  .flight-readout { position: absolute; top: 60px; left: 20px; display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 11px; border: 1px solid color-mix(in srgb, var(--gold) 50%, var(--line)); border-radius: 18px; background: color-mix(in srgb, var(--surface) 85%, var(--gold-soft)); color: var(--gold); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); font-size: 10px; font-weight: 750; letter-spacing: .04em; pointer-events: none; }
  .flight-readout > span:first-child { font-size: 12px; }

  .add-child-button {
    position: absolute;
    z-index: 5;
    left: 0;
    top: 0;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 50%;
    background: var(--gold);
    color: #1c180f;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .32);
    cursor: pointer;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
  }
  .add-child-button:hover { filter: brightness(1.08); }
  .stage.is-globe .add-child-button { display: none; }

  .zoom-controls { position: absolute; right: 18px; bottom: 160px; display: grid; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.16); backdrop-filter: blur(14px); }
  .zoom-controls button { display: grid; width: 39px; height: 39px; place-items: center; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 18px; }
  .zoom-controls button:last-child { border-bottom: 0; }
  .zoom-controls button:hover { background: var(--surface-high); color: var(--ink); }
  .zoom-controls svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }

  .minimap-wrap { position: absolute; right: 18px; bottom: 25px; width: 182px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface); box-shadow: 0 12px 36px rgba(0,0,0,.18); backdrop-filter: blur(14px); }
  .minimap-wrap canvas { display: block; width: 180px; height: 102px; opacity: .85; }
  .minimap-wrap span { display: block; padding: 6px 9px; border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 8px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }

  .person-hint {
    position: absolute;
    z-index: 9;
    top: 0;
    left: 0;
    width: min(286px, calc(100% - 24px));
    padding: 14px 16px 13px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
    color: var(--ink);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    backdrop-filter: blur(18px);
    transition: opacity .16s ease, visibility .16s ease;
  }
  .person-hint.is-visible { opacity: 1; visibility: visible; }

  .stage-hud, .flight-readout, .zoom-controls { z-index: 4; }
  .globe-canvas { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; touch-action: none; }
  .globe-canvas.is-active { pointer-events: auto; cursor: grab; }
  .globe-canvas.is-active:active { cursor: grabbing; }
  .stage.is-globe .minimap-wrap, .stage.is-globe .gesture-hint { opacity: 0; visibility: hidden; }
  .minimap-wrap { transition: opacity .3s ease, visibility .3s ease; }
  .globe-hint { position: absolute; z-index: 9; top: 0; left: 0; width: min(260px, calc(100% - 24px)); padding: 12px 15px; border: 1px solid color-mix(in srgb, var(--gold) 42%, var(--line-strong)); border-radius: 15px; background: color-mix(in srgb, var(--surface-solid) 90%, transparent); color: var(--ink); opacity: 0; pointer-events: none; visibility: hidden; backdrop-filter: blur(18px); transition: opacity .16s ease, visibility .16s ease; }
  .globe-hint.is-visible { opacity: 1; visibility: visible; }
  .globe-hint h3, .globe-card h3 { margin: 4px 0 0; font-family: var(--serif); font-size: 19px; font-weight: 500; line-height: 1.15; letter-spacing: -.02em; }
  .globe-card { position: absolute; z-index: 10; top: 70px; left: 20px; display: flex; flex-direction: column; width: min(320px, calc(100% - 40px)); max-height: calc(100% - 110px); padding: 18px 18px 14px; border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line-strong)); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
  .globe-card .panel-close { top: 10px; right: 10px; width: 30px; height: 30px; font-size: 18px; }
  .globe-card h3 { padding-right: 32px; }
  .globe-person-list { display: grid; gap: 4px; min-height: 0; margin: 12px 0 10px; padding-right: 4px; overflow-y: auto; scrollbar-width: thin; }
  .globe-person { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas-2); color: var(--ink); cursor: pointer; font-size: 11px; text-align: left; }
  .globe-person:hover, .globe-person:focus-visible { border-color: var(--gold); outline: none; }
  .globe-person small { flex: none; color: var(--gold); font-size: 8px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
  .globe-person.is-estimated { color: var(--ink-soft); }
  .globe-person.is-estimated small { color: var(--ink-faint); }
  .globe-note { margin: 0; color: var(--ink-faint); font-size: 9px; line-height: 1.45; }
  .globe-legend { position: absolute; z-index: 3; right: 18px; bottom: 25px; display: grid; gap: 7px; padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface); color: var(--ink-soft); font-size: 9px; font-weight: 650; letter-spacing: .04em; opacity: 0; pointer-events: none; visibility: hidden; backdrop-filter: blur(14px); transition: opacity .3s ease, visibility .3s ease; }
  .stage.is-globe .globe-legend { opacity: 1; visibility: visible; }
  .globe-legend span { display: flex; align-items: center; gap: 8px; }
  .globe-legend i { display: block; flex: none; width: 9px; height: 9px; border-radius: 50%; }
  .globe-legend .is-recorded { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
  .globe-legend .is-estimated { width: 4px; height: 4px; margin: 0 2.5px; border-radius: 1px; background: var(--ink-soft); }
  .globe-legend .is-route { width: 14px; height: 2px; border-radius: 2px; background: var(--gold); }
  .globe-legend .is-journey { width: 14px; height: 0; border-top: 1.5px dashed var(--blue); border-radius: 0; }
  .hint-kicker { margin: 0; color: var(--gold); font-size: 8px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
  .person-hint h3 { margin: 4px 0 0; font-family: var(--serif); font-size: 20px; font-weight: 500; line-height: 1.15; letter-spacing: -.02em; }
  .hint-role { margin: 5px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.4; }
  .person-hint dl { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 6px 10px; margin: 12px 0 0; }
  .person-hint dt { color: var(--ink-faint); font-size: 8px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
  .person-hint dd { margin: 0; overflow-wrap: anywhere; font-size: 12px; line-height: 1.35; }
  .gesture-hint { position: absolute; bottom: 18px; left: 50%; display: flex; align-items: center; gap: 9px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink-faint); font-size: 9px; transform: translateX(-50%); pointer-events: none; }
  .gesture-hint i { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-faint); }

  .panel-close { position: absolute; z-index: 2; top: 15px; right: 15px; display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-high); color: var(--ink-soft); cursor: pointer; font-size: 21px; line-height: 1; }
  .panel-close:hover { border-color: var(--line-strong); color: var(--ink); }
  .person-hero { padding: 52px 30px 26px; border-bottom: 1px solid var(--line); background: radial-gradient(circle at 78% 12%, var(--gold-soft), transparent 39%); }
  .person-hero .large-avatar { display: grid; width: 68px; height: 68px; place-items: center; margin-bottom: 20px; border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent); border-radius: 22px; background: var(--gold-soft); color: var(--gold); font-family: var(--serif); font-size: 23px; }
  .person-hero h2 { margin: 0; font-family: var(--serif); font-size: clamp(28px, 3vw, 38px); font-weight: 500; line-height: 1.03; letter-spacing: -.035em; }
  .person-hero p { margin: 10px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
  .person-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
  .meta-chip { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--canvas-2); color: var(--ink-soft); font-size: 9px; font-weight: 700; letter-spacing: .04em; }
  .person-body { padding: 24px 30px 60px; }
  .detail-section { padding: 0 0 24px; }
  .detail-section + .detail-section { padding-top: 22px; border-top: 1px solid var(--line); }
  .detail-section h3 { margin: 0 0 13px; color: var(--ink-faint); font-size: 9px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
  .portrait-card { display: grid; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(135deg, var(--gold-soft), transparent 68%), var(--canvas-2); }
  .portrait-preview { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 13px; align-items: center; color: var(--ink); text-decoration: none; }
  .portrait-preview img, .portrait-empty > span { display: block; width: 104px; height: 104px; border: 1px solid color-mix(in srgb, var(--gold) 48%, var(--line)); border-radius: 11px; background: var(--surface-high); object-fit: cover; }
  .portrait-preview span { color: var(--gold); font-family: var(--serif); font-size: 19px; line-height: 1.1; }
  .portrait-preview:hover img { border-color: var(--gold); box-shadow: 0 8px 24px var(--gold-soft); }
  .portrait-empty { display: flex; align-items: center; gap: 13px; min-height: 104px; }
  .portrait-empty > span { display: grid; place-items: center; color: var(--gold); font-family: var(--serif); font-size: 26px; }
  .portrait-empty p { margin: 0; color: var(--ink-faint); font-size: 11px; }
  .photo-upload-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .secondary-button { display: inline-grid; min-height: 36px; place-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-high); color: var(--ink-soft); cursor: pointer; font-size: 10px; font-weight: 750; text-decoration: none; }
  .secondary-button:hover { border-color: var(--accent); color: var(--ink); }
  .photo-upload-form .secondary-button { position: relative; overflow: hidden; }
  .photo-upload-form input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
  .photo-upload-form .primary-button { min-height: 36px; padding-inline: 12px; }
  .photo-upload-form .primary-button:disabled { cursor: wait; opacity: .68; }
  .photo-upload-form p { flex: 1 0 100%; margin: 0; color: var(--ink-faint); font-size: 9px; }
  .relation-list { display: flex; flex-wrap: wrap; gap: 7px; }
  .person-link { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas-2); color: var(--ink-soft); cursor: pointer; font-size: 11px; }
  .person-link:hover { border-color: var(--accent); color: var(--ink); }
  .event-list { display: grid; gap: 0; }
  .event-row { position: relative; display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 0 0 18px; }
  .event-row::before { content: ""; position: absolute; top: 9px; bottom: -2px; left: 4px; width: 1px; background: var(--line); }
  .event-row:last-child::before { display: none; }
  .event-dot { position: relative; z-index: 1; width: 9px; height: 9px; margin-top: 3px; border: 2px solid var(--surface-solid); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .event-row strong { display: block; font-size: 11px; font-weight: 750; text-transform: capitalize; }
  .event-row p { margin: 3px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
  .event-row small { color: var(--gold); font-size: 9px; }
  .contact-card { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--gold-soft); }
  .contact-card a, .contact-card span { overflow-wrap: anywhere; color: var(--ink); font-size: 11px; }
  .source-list { display: grid; gap: 8px; }
  .source-link { display: block; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas-2); color: var(--ink-soft); text-decoration: none; }
  .source-link:hover { border-color: var(--accent); }
  .source-link strong { display: block; color: var(--ink); font-size: 11px; }
  .source-link small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .raw-details { border: 1px solid var(--line); border-radius: 10px; background: var(--canvas-2); }
  .raw-details summary { padding: 11px; color: var(--ink-soft); cursor: pointer; font-size: 11px; }
  .raw-details pre { max-height: 260px; margin: 0; padding: 0 11px 12px; overflow: auto; color: var(--ink-faint); font-family: var(--sans); font-size: 10px; line-height: 1.6; white-space: pre-wrap; }
  .warning-card { padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--ink-soft); font-size: 10px; line-height: 1.5; }

  .lens-header { display: flex; align-items: end; justify-content: space-between; gap: 30px; max-width: 1100px; margin: 0 auto 34px; }
  .lens-header h2 { margin: 0; font-family: var(--serif); font-size: clamp(36px, 5vw, 62px); font-weight: 500; letter-spacing: -.045em; }
  .lens-header > p { max-width: 370px; margin: 0 0 7px; color: var(--ink-soft); line-height: 1.6; }
  .timeline-controls { display: flex; gap: 10px; align-items: end; max-width: 1100px; margin: 0 auto 30px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-solid); }
  .timeline-controls label { display: grid; gap: 5px; color: var(--ink-faint); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
  .timeline-controls input, .relationship-fields input { min-height: 40px; border: 1px solid var(--line); border-radius: 9px; outline: 0; background: var(--canvas); color: var(--ink); padding: 0 10px; }
  .primary-button { min-height: 40px; padding: 0 17px; border-radius: 10px; background: var(--gold); color: #1c180f; cursor: pointer; font-size: 11px; font-weight: 800; }
  .primary-button:hover { filter: brightness(1.08); }
  .timeline-list { position: relative; display: grid; max-width: 980px; margin: 0 auto; padding-left: 88px; }
  .timeline-list::before { content: ""; position: absolute; top: 0; bottom: 0; left: 57px; width: 1px; background: linear-gradient(var(--gold), var(--line)); }
  .timeline-year { position: sticky; top: -1px; z-index: 2; align-self: start; width: 54px; margin: 0 0 -27px -88px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-solid); color: var(--gold); font-family: var(--serif); text-align: center; }
  .timeline-entry { position: relative; display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 18px; align-items: start; margin-bottom: 9px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-solid); }
  .timeline-entry::before { content: ""; position: absolute; top: 22px; left: -35px; width: 9px; height: 9px; border: 2px solid var(--canvas-2); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .timeline-entry button { padding: 0; background: transparent; color: var(--ink); cursor: pointer; text-align: left; font-size: 12px; font-weight: 750; }
  .timeline-entry p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
  .timeline-entry small { color: var(--ink-faint); font-size: 9px; text-transform: capitalize; }

  .place-grid, .source-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; max-width: 1100px; margin: 0 auto; }
  .place-card, .source-card { position: relative; min-height: 150px; padding: 21px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-solid); }
  .place-card::after { content: "⌖"; position: absolute; right: 11px; bottom: -20px; color: var(--gold-soft); font-family: var(--serif); font-size: 92px; }
  .place-card .count, .source-card .count { color: var(--gold); font-family: var(--serif); font-size: 32px; }
  .place-card h3, .source-card h3 { max-width: 90%; margin: 15px 0 6px; font-family: var(--serif); font-size: 19px; font-weight: 500; }
  .place-card p, .source-card p { margin: 0; color: var(--ink-faint); font-size: 10px; }
  .source-card { min-height: 170px; }
  .source-card .source-id { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink-faint); font-size: 10px; }
  .quality-card { max-width: 1100px; margin: 18px auto 0; padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-solid); }
  .quality-card h3 { margin: 0 0 10px; font-family: var(--serif); font-size: 21px; font-weight: 500; }
  .quality-card p { margin: 0; color: var(--ink-soft); line-height: 1.6; }

  dialog { max-width: calc(100vw - 28px); border: 1px solid var(--line-strong); border-radius: 22px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); backdrop-filter: blur(26px); }
  dialog::backdrop { background: rgba(3, 6, 15, .72); backdrop-filter: blur(7px); }
  .member-dialog { width: min(460px, calc(100vw - 28px)); }
  .member-fields { display: grid; gap: 12px; margin-top: 8px; }
  .member-fields label { display: grid; gap: 6px; color: var(--ink-faint); font-size: 9px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
  .member-fields input, .member-fields select { min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--canvas-2); color: var(--ink); font-size: 14px; letter-spacing: 0; text-transform: none; }
  .member-note { margin: 0; color: var(--ink-soft); font-size: 12px; letter-spacing: 0; text-transform: none; font-weight: 500; }
  .place-suggestions { display: grid; gap: 4px; max-height: 180px; overflow: auto; }
  .place-suggestions button { display: flex; justify-content: space-between; gap: 10px; min-height: 36px; padding: 7px 10px; border-radius: 8px; background: var(--canvas-2); color: var(--ink); cursor: pointer; font-size: 13px; letter-spacing: 0; text-align: left; text-transform: none; }
  .place-suggestions button:hover, .place-suggestions button.is-active { background: var(--gold-soft); color: var(--gold); }
  .place-suggestions small { color: var(--ink-faint); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
  .globe-source { opacity: .75; }
  .member-dialog .primary-button { width: 100%; margin-top: 16px; }
  .edit-record-button { margin-top: 14px; }
  .relationship-dialog { width: min(650px, calc(100vw - 28px)); }
  .help-dialog { width: min(520px, calc(100vw - 28px)); }
  .photo-dialog { width: min(960px, calc(100vw - 28px)); max-height: min(92dvh, 1000px); background: color-mix(in srgb, var(--canvas) 96%, var(--surface)); }
  .photo-dialog-shell { position: relative; padding: 18px; }
  .photo-dialog figure { display: grid; gap: 12px; margin: 0; }
  .photo-dialog img { display: block; width: auto; max-width: 100%; max-height: calc(84dvh - 90px); margin: 0 auto; border-radius: 12px; background: var(--canvas-2); object-fit: contain; }
  .photo-dialog figcaption { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 42px 0 4px; color: var(--ink); font-family: var(--serif); font-size: 18px; }
  .photo-dialog .panel-close { top: 9px; right: 9px; }
  .dialog-shell { position: relative; padding: 28px; }
  .dialog-shell header { position: relative; padding-right: 42px; }
  .dialog-shell header h2 { margin: 0; font-family: var(--serif); font-size: 31px; font-weight: 500; }
  .dialog-shell .panel-close { top: -4px; right: -4px; }
  .dialog-intro { max-width: 520px; margin: 10px 0 25px; color: var(--ink-soft); line-height: 1.6; }
  .relationship-fields { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end; }
  .relationship-fields label { display: grid; gap: 7px; color: var(--ink-faint); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
  .relationship-fields > span { padding-bottom: 12px; color: var(--gold); }
  .relationship-dialog .primary-button { width: 100%; margin-top: 16px; }
  .relationship-result { margin-top: 18px; }
  .path-summary { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--gold-soft); }
  .path-summary strong { display: block; font-family: var(--serif); font-size: 20px; font-weight: 500; }
  .path-summary ol { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0 0; padding: 0; list-style: none; }
  .path-summary li { color: var(--ink-soft); font-size: 10px; }
  .path-summary li:not(:last-child)::after { content: "→"; margin-left: 6px; color: var(--gold); }
  .shortcut-grid { display: grid; gap: 9px; margin-top: 22px; }
  .shortcut-grid span { display: grid; grid-template-columns: 90px 1fr; align-items: center; min-height: 38px; padding: 0 10px; border-radius: 9px; background: var(--canvas-2); }
  .shortcut-grid b { font-size: 11px; font-weight: 600; }

  .statusbar i { display: inline-block; width: 5px; height: 5px; margin-right: 6px; border-radius: 50%; background: var(--accent); }
  .status-shortcuts { display: flex; align-items: center; gap: 5px; }
  .status-shortcuts kbd { min-width: 16px; height: 16px; font-size: 8px; }

  .loading-screen { position: fixed; z-index: 100; inset: 0; display: grid; place-content: center; justify-items: center; background: var(--canvas); }
  .loading-screen p { margin: 23px 0 4px; font-family: var(--serif); font-size: 22px; }
  .loading-screen span { color: var(--ink-faint); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
  .loading-mark { position: relative; width: 74px; height: 74px; }
  .loading-mark::before { content: ""; position: absolute; top: 35px; left: 35px; width: 2px; height: 35px; background: var(--gold); }
  .loading-mark i { position: absolute; width: 13px; height: 13px; border: 2px solid var(--accent); border-radius: 50%; background: var(--canvas); }
  .loading-mark i:nth-child(1) { top: 2px; left: 29px; }
  .loading-mark i:nth-child(2) { top: 24px; left: 2px; }
  .loading-mark i:nth-child(3) { top: 24px; right: 2px; }
  .loading-mark i:nth-child(4) { top: 41px; left: 29px; }

  .toast { position: fixed; z-index: 200; bottom: 48px; left: 50%; max-width: min(420px, calc(100vw - 30px)); padding: 11px 15px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-size: 11px; opacity: 0; transform: translate(-50%, 15px); pointer-events: none; transition: opacity .2s, transform .2s; }
  .toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

  .login-page { display: grid; min-height: 100dvh; place-items: center; background: radial-gradient(circle at 50% 30%, var(--gold-soft), transparent 36%), var(--canvas); }
  .login-card { width: min(380px, calc(100vw - 32px)); padding: 28px 26px 24px; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
  .login-card h1 { margin: 8px 0 0; font-family: var(--serif); font-size: 32px; font-weight: 500; letter-spacing: -.03em; }
  .login-card > p { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
  .login-card form { display: grid; gap: 12px; margin-top: 18px; }
  .login-card label { display: grid; gap: 6px; color: var(--ink-faint); font-size: 9px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
  .login-card input { min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--canvas-2); color: var(--ink); font-size: 14px; letter-spacing: 0; text-transform: none; }
  .login-card .primary-button { min-height: 42px; }
  .login-error { margin-top: 14px !important; color: var(--danger) !important; }
  .error-page { display: grid; min-height: 100dvh; place-items: center; background: radial-gradient(circle, var(--surface-high), var(--canvas) 60%); }
  .error-page main { max-width: 560px; padding: 30px; text-align: center; }
  .error-page main > span { color: var(--gold); font-family: var(--serif); font-size: 80px; }
  .error-page h1 { margin: 10px 0; font-family: var(--serif); font-size: 38px; font-weight: 500; }
  .error-page p { color: var(--ink-soft); }
  .error-page a { display: inline-block; margin-top: 15px; padding: 11px 17px; border-radius: 10px; background: var(--gold); color: #19150d; font-weight: 800; text-decoration: none; }

  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
}

@layer responsive {
  @media (max-width: 980px) {
    .topbar { grid-template-columns: 220px 1fr 132px; }
    .workspace { grid-template-columns: 240px minmax(0, 1fr); }
    .app-shell.is-sidebar-collapsed .workspace { grid-template-columns: 0 minmax(0, 1fr); }
    .explore-panel { padding-inline: 16px; }
    .view-tab { padding-inline: 10px; }
    .view-tab .tab-icon { display: none; }
    .person-panel { width: min(400px, calc(100vw - 240px)); }
    .search-results { left: 8px; width: 224px; }
  }

  @media (max-width: 760px) {
    .app-shell { grid-template-rows: 60px minmax(0, 1fr); }
    .topbar { grid-template-columns: 1fr auto; backdrop-filter: none; }
    .brand { padding-left: 12px; }
    .brand-mark { width: 37px; height: 37px; }
    .view-tabs { position: fixed; z-index: 30; right: 10px; bottom: 10px; left: 10px; justify-content: space-around; height: 56px; border: 1px solid var(--line-strong); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
    .view-tab { flex: 1; justify-content: center; padding: 0 4px; font-size: 10px; }
    .view-tab .tab-icon { display: inline; }
    .top-actions { padding-right: 10px; }
    #themeButton { display: none; }
    .workspace { display: block; }
    .app-shell.is-sidebar-collapsed .explore-panel { display: none; }
    html.is-immersive .view-tabs { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .explore-panel { position: absolute; z-index: 15; top: 12px; left: 12px; width: min(310px, calc(100vw - 70px)); max-height: calc(100% - 90px); padding: 12px; border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow); }
    .panel-heading, .filter-section, .atlas-summary, .founder-card { display: none; }
    .search-results { top: 70px; left: 12px; width: calc(100% - 24px); }
    .stage, .lens-view { width: 100%; height: 100%; padding-bottom: 80px; }
    .person-panel { position: absolute; top: auto; left: 0; width: 100%; max-height: 78%; border-top: 1px solid var(--line-strong); border-left: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -24px 70px rgba(0,0,0,.35); }
    .person-hero { padding: 40px 20px 20px; }
    .person-body { padding: 20px 20px 80px; }
    .statusbar { display: none; }
    .minimap-wrap { display: none; }
    .zoom-controls { right: 12px; bottom: 84px; }
    .gesture-hint { bottom: 82px; }
    .lens-view { padding: 30px 18px 90px; }
    .lens-header { display: block; }
    .lens-header > p { margin-top: 12px; }
    .timeline-controls { flex-wrap: wrap; }
    .timeline-list { padding-left: 48px; }
    .timeline-list::before { left: 25px; }
    .timeline-year { margin-left: -48px; }
    .timeline-entry { grid-template-columns: 1fr; gap: 6px; }
    .timeline-entry::before { left: -28px; }
    .relationship-fields { grid-template-columns: 1fr; }
    .relationship-fields > span { display: none; }
  }

  @media (max-width: 430px) {
    .brand strong { font-size: 17px; }
    .brand small { display: none; }
    #relationshipButton { display: none; }
    .explore-panel { width: calc(100vw - 68px); }
    .stage-hud { top: 72px; left: 12px; }
    .flight-readout { top: 113px; left: 12px; }
    .gesture-hint { display: none; }
    .dialog-shell { padding: 22px 18px; }
    .shortcut-grid span { grid-template-columns: 76px 1fr; }
  }
}

@layer motion {
  .person-panel:not([hidden]) { animation: panel-in .3s cubic-bezier(.2,.8,.2,1); }
  dialog[open] { animation: dialog-in .24s cubic-bezier(.2,.8,.2,1); }
  dialog[open]::backdrop { animation: fade-in .2s; }
  .loading-mark { animation: breathe 1.8s ease-in-out infinite; }
  .loading-mark i { animation: node-pulse 1.8s ease-in-out infinite; }
  .loading-mark i:nth-child(2) { animation-delay: .15s; }
  .loading-mark i:nth-child(3) { animation-delay: .3s; }
  .loading-mark i:nth-child(4) { animation-delay: .45s; }
  @keyframes panel-in { from { opacity: 0; transform: translateX(24px); } }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
  @keyframes fade-in { from { opacity: 0; } }
  @keyframes breathe { 50% { transform: scale(1.05); } }
  @keyframes node-pulse { 50% { border-color: var(--gold); } }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  }
}
