  :root {
    --bg:        #131316;
    --surface:   #1c1c1f;
    --card:      #212125;
    --card-2:    #26262b;
    --border:    rgba(255,255,255,0.07);
    --border-md: rgba(255,255,255,0.11);

    --text:      #e8e4de;
    --text-2:    #a09a91;
    --text-3:    #625e58;

    --c1: #8ecfb0; --c2: #e8a4a4; --c3: #e8c48a; --c4: #b4a8d8;
    --c5: #a8c8d8; --c6: #d8b4a8; --c7: #b8d4a0;
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { height: 100%; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    font-weight: 300;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
  }

  a { color: inherit; }
  button { font-family: inherit; cursor: pointer; }
  :focus-visible { outline: 2px solid var(--c5); outline-offset: 2px; border-radius: 4px; }

  /* ---------- HEADER ---------- */
  .topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; pointer-events: none; }
  .topbar-in {
    position: relative;
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    padding: 16px 26px;
    pointer-events: auto;
  }
  .wordmark {
    font-family: 'Lora', serif; font-size: 14.5px; font-weight: 500;
    letter-spacing: 0.01em; white-space: nowrap; text-decoration: none;
    background: none; border: none; color: var(--text);
    text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  }
  .wordmark em { font-style: italic; color: var(--text-2); }
  .nav { display: flex; gap: 8px; }
  .nav button {
    background: rgba(28,28,31,0.6); border: 1px solid var(--border-md);
    color: var(--text-2); border-radius: 100px;
    padding: 7px 18px; font-size: 12px; font-weight: 400;
    white-space: nowrap; backdrop-filter: blur(6px);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
  }
  .nav button:hover { color: var(--text); border-color: rgba(255,255,255,0.28); background: var(--card); }
  .nav-burger {
    display: none;
    flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 34px; padding: 0 10px;
    background: rgba(28,28,31,0.6); border: 1px solid var(--border-md);
    border-radius: 10px; backdrop-filter: blur(6px);
  }
  .nav-burger span { display: block; height: 1.5px; background: var(--text-2); border-radius: 2px; transition: background 0.2s; }
  .nav-burger:hover span { background: var(--text); }

  /* ---------- SKY ---------- */
  .landing {
    position: relative;
    height: 100svh;
    min-height: 480px;
    overflow: hidden;
    touch-action: none;
    background: radial-gradient(ellipse at 50% 38%, #17171c 0%, #131316 55%, #101013 100%);
  }
  .svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
  #sky, #sky-ca { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
  /* the CA'd copy of the scene, revealed only toward the edges (crisp centre) */
  #sky-ca {
    z-index: 1; pointer-events: none;
    filter: url(#crt-ca);
    -webkit-mask-image: radial-gradient(125% 125% at 50% 50%, transparent 34%, #000 100%);
    mask-image: radial-gradient(125% 125% at 50% 50%, transparent 34%, #000 100%);
  }
  /* faint static scanlines; the moving tracking bars are drawn on the canvas */
  .crt-overlay {
    position: absolute; inset: 0; z-index: 2; pointer-events: none;
    background: repeating-linear-gradient(to bottom,
      rgba(255,255,255,0.016) 0px, rgba(255,255,255,0.016) 1px, transparent 1px, transparent 3px);
    mix-blend-mode: soft-light;
  }
  .landing::after {
    content: "";
    position: absolute; inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 45%, transparent 58%, rgba(10,10,13,0.5) 100%);
  }

  .sky-label-layer {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
  }
  .sky-label {
    position: absolute;
    left: 0;
    top: 0;
    width: 220px;
    opacity: 0;
    text-align: center;
    text-shadow: 0 2px 7px rgba(0,0,0,0.9);
    transform: translate(-50%, 0);
    transform-origin: center top;
    will-change: transform, opacity, left, top;
  }
  .sky-label-sit {
    color: #d8d2c8;
    font-family: 'Lora', serif;
    font-style: italic;
    font-weight: 500;
  }
  .sky-label-tech {
    font-family: 'Lora', serif;
  }
  .sky-label-tech-name {
    color: var(--sky-label-color, var(--c3));
    font-size: var(--sky-label-name-size, 16px);
    font-weight: 500;
    line-height: var(--sky-label-name-line, 1.2);
  }
  .sky-label-tech-kq {
    color: #bdb7ad;
    font-size: var(--sky-label-kq-size, 14px);
    font-style: italic;
    font-weight: 400;
    line-height: var(--sky-label-kq-line, 1.25);
    margin-top: 2px;
  }
  .sky-label-tech-meta {
    color: #8f897f;
    font-family: 'Inter', sans-serif;
    font-size: var(--sky-label-meta-size, 12px);
    font-weight: 300;
    line-height: 1.35;
    margin-top: 6px;
    opacity: var(--sky-label-meta-opacity, 0);
    transition: opacity 0.16s ease;
  }

  .sky-center {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    text-align: center;
    pointer-events: none;
    width: min(700px, calc(100vw - 28px));
    padding: 0 14px;
    transition: opacity 0.45s ease, transform 0.45s ease;
  }
  .sky-center.hide { opacity: 0; transform: translate(-50%, -54%); }
  .sky-title {
    font-family: 'Lora', serif;
    font-size: clamp(21px, 5vw, 42px);
    font-weight: 500; line-height: 1.25; letter-spacing: -0.01em;
    text-shadow: 0 3px 22px rgba(0,0,0,0.95);
    opacity: 0; animation: rise 1s cubic-bezier(.22,.68,0,1.1) 0.25s forwards;
  }
  .sky-title em { font-style: italic; color: var(--c3); }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
  .sky-center.hide .sky-title { animation: none; opacity: 1; }

  .sky-hint {
    position: absolute; z-index: 4;
    left: 50%; bottom: 22px;
    transform: translateX(-50%);
    font-size: 11.5px; color: var(--text-3);
    letter-spacing: 0.06em;
    text-shadow: 0 2px 8px rgba(0,0,0,0.9);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
    white-space: nowrap;
  }
  .landing.focused .sky-hint { opacity: 1; }

  /* ---------- PANELS & MODAL (shared overlay) ---------- */
  .overlay {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(8,8,11,0.74);
    backdrop-filter: blur(6px);
    display: none; align-items: flex-start; justify-content: center;
    overflow-y: auto; padding: 6vh 20px 60px;
  }
  .overlay.open { display: flex; animation: fadeIn 0.25s ease both; }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

  .modal {
    width: min(820px, 100%);
    background: var(--surface);
    border: 1px solid var(--border-md);
    border-top-width: 3px;
    border-radius: 14px;
    animation: rise 0.3s ease both;
    position: relative;
  }
  .panel { border-top-color: var(--c3); }
  .panel-body { padding: 34px 40px 36px; }
  .panel-title { font-family: 'Lora', serif; font-size: 26px; font-weight: 500; margin-bottom: 18px; }
  .panel-title em { font-style: italic; color: var(--c3); }
  .panel-body p { color: var(--text-2); font-size: 13.5px; margin-bottom: 13px; max-width: 640px; }
  .panel-body p strong { color: var(--text); font-weight: 500; }
  .panel-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
  .p-stat {
    flex: 1; min-width: 160px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 18px;
  }
  .p-stat-num { font-family: 'Lora', serif; font-size: 24px; font-weight: 500; line-height: 1.2; }
  .p-stat-label { color: var(--text-2); font-size: 11.5px; line-height: 1.5; }
  .flow-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 22px; }
  .flow-pill {
    font-size: 11px; padding: 5px 14px; border-radius: 100px;
    border: 1px solid var(--border-md); color: var(--text-2);
    background: var(--card); white-space: nowrap;
  }
  .flow-arrow { color: var(--text-3); font-size: 13px; }

  .modal-close {
    position: absolute; top: 22px; right: 22px;
    background: transparent; border: 1px solid var(--border-md); color: var(--text-2);
    width: 32px; height: 32px; border-radius: 50%;
    font-size: 15px; line-height: 1; z-index: 2;
    transition: color 0.2s, border-color 0.2s;
  }
  .modal-close:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }

  /* index panel */
  .idx-group { margin-bottom: 26px; }
  .idx-head { font-family: 'Lora', serif; font-size: 15px; font-weight: 500; margin-bottom: 10px; }
  .idx-head .idx-sub { font-family: 'Inter', sans-serif; font-weight: 300; font-size: 11px; color: var(--text-3); margin-left: 10px; letter-spacing: 0.04em; }
  .idx-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .idx-item {
    text-align: left;
    background: var(--card); border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: 8px; padding: 10px 14px;
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
  }
  .idx-item:hover { background: var(--card-2); border-color: var(--border-md); }
  .idx-name { font-family: 'Lora', serif; font-size: 13px; font-weight: 500; }
  .idx-kq { font-family: 'Lora', serif; font-style: italic; font-size: 11.5px; color: var(--text-2); line-height: 1.45; }

  /* technique modal */
  .modal-head { padding: 30px 36px 22px; border-bottom: 1px solid var(--border); position: relative; }
  .modal-group { font-size: 10.5px; letter-spacing: 0.15em; text-transform: uppercase; margin-bottom: 10px; }
  .modal-title { font-family: 'Lora', serif; font-size: 28px; font-weight: 500; letter-spacing: -0.01em; margin-bottom: 8px; }
  .modal-kq { font-family: 'Lora', serif; font-style: italic; font-size: 15px; color: var(--text-2); line-height: 1.6; }

  .modal-body { padding: 8px 36px 30px; }
  .m-section { padding-top: 26px; }
  .m-label {
    font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--text-3); margin-bottom: 12px;
  }
  .m-section p { color: var(--text-2); font-size: 13.5px; margin-bottom: 12px; }
  .m-section p:last-child { margin-bottom: 0; }
  .m-section p strong { color: var(--text); font-weight: 500; }
  .m-section p em { font-style: italic; }

  /* collapsible sections (Limits / When / Examples) — description stays open above */
  .m-acc { border-top: 1px solid var(--border); }
  .m-acc-sum {
    list-style: none; cursor: pointer; -webkit-user-select: none; user-select: none;
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 16px 0 14px;
    font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-2);
    transition: color 0.18s;
  }
  .m-acc-sum::-webkit-details-marker { display: none; }
  .m-acc-sum:hover { color: var(--text); }
  .m-acc.warn .m-acc-sum { color: var(--accent, var(--c3)); }
  .m-acc-ico { position: relative; width: 11px; height: 11px; flex: none; opacity: 0.75; }
  .m-acc-ico::before, .m-acc-ico::after { content: ""; position: absolute; background: currentColor; border-radius: 2px; }
  .m-acc-ico::before { left: 0; right: 0; top: 4.75px; height: 1.5px; }
  .m-acc-ico::after { top: 0; bottom: 0; left: 4.75px; width: 1.5px; transition: transform 0.2s ease; }
  .m-acc[open] .m-acc-ico::after { transform: scaleY(0); }
  .m-acc-body { padding-bottom: 22px; }
  .m-acc-body p { color: var(--text-2); font-size: 13.5px; margin-bottom: 12px; }
  .m-acc-body p:last-child { margin-bottom: 0; }
  .m-acc-body p strong { color: var(--text); font-weight: 500; }
  .m-acc-body p em { font-style: italic; }
  .m-acc.warn .m-acc-body { border-left: 2px solid var(--accent, var(--c3)); padding-left: 15px; }

  .m-when li {
    list-style: none; position: relative;
    padding-left: 20px; color: var(--text-2); font-size: 13.5px; margin-bottom: 8px;
  }
  .m-when li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent, var(--text-3)); }
  .m-when li em { font-style: italic; }

  .pair { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
  .pair-default { padding: 14px 20px; background: var(--card); }
  .pair-method { padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--border); }
  .pair-tag { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); margin-bottom: 5px; }
  .pair-method .pair-tag { color: var(--accent, var(--text-2)); }
  .pair-q { font-family: 'Lora', serif; font-style: italic; font-size: 13.5px; line-height: 1.65; color: var(--text-2); }
  .pair-method .pair-q { color: var(--text); }
  .pair-single { padding: 14px 20px; background: var(--surface); }

  .modal-nav {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 18px 36px 26px; border-top: 1px solid var(--border);
  }
  .modal-nav button {
    background: transparent; border: 1px solid var(--border-md); color: var(--text-2);
    border-radius: 100px; padding: 8px 18px; font-size: 12px;
    max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
  }
  .modal-nav button:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }

  @media (max-width: 640px) {
    .topbar-in { padding: 10px 12px; gap: 8px; }
    .wordmark { font-size: 13px; }
    .nav-burger { display: flex; }
    .nav {
      position: absolute; top: calc(100% + 8px); right: 12px;
      flex-direction: column; align-items: stretch; gap: 6px;
      background: rgba(20,20,23,0.94); backdrop-filter: blur(12px);
      border: 1px solid var(--border-md); border-radius: 12px;
      padding: 8px; display: none;
      box-shadow: 0 14px 34px rgba(0,0,0,0.55);
    }
    .nav.open { display: flex; }
    .nav button { font-size: 12px; padding: 9px 14px; text-align: left; }
    .idx-grid { grid-template-columns: 1fr; }
    .overlay { padding: 0; }
    .modal { border-radius: 0; min-height: 100vh; border-left: none; border-right: none; }
    .modal-head, .modal-body, .modal-nav, .panel-body { padding-left: 20px; padding-right: 20px; }
    .panel-title, .modal-title { max-width: calc(100% - 58px); }
    .sky-focused .topbar { opacity: 0; pointer-events: none; }
    .sky-focused .landing.focused .sky-hint { opacity: 0; }
  }

  /* Portrait phones: the title moves up out of the star ring's way. */
  @media (max-width: 560px), (max-aspect-ratio: 13/16) {
    .sky-center { top: 13.5%; }
    .sky-center.hide { transform: translate(-50%, -56%); }
  }
