    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
      --bg:       #0a0a0a;
      --surface:  #141414;
      --surface2: #1e1e1e;
      --border:   #2a2a2a;
      --text:     #eaeaea;
      --muted:    #888;
      --accent:   #ffffff;
      --green:    #4ade80;
      --red:      #f87171;
    }
    /* Color-blind safe palette (deuteranopia / protanopia friendly).
       Activated by adding `.cb-safe` to the body. Maps the standard
       red/green/amber feedback to blue/yellow/violet pairings that
       are distinguishable across the three most common forms of
       colour-vision deficiency without sacrificing dark-mode legibility. */
    body.cb-safe {
      --green: #38bdf8;   /* sky blue replaces lime green */
      --red:   #facc15;   /* amber-yellow replaces red */
    }
    html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

    /* ---- Base input reset ---- */
    input[type=date], input[type=time], input[type=datetime-local] { color-scheme: dark; }
    input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]) {
      background: var(--surface2); border: 1px solid var(--border); color: var(--text);
      border-radius: 6px; padding: 0.5rem 0.75rem; font-size: 0.875rem;
      font-family: inherit; box-sizing: border-box; outline: none; -webkit-appearance: none;
    }
    input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]):focus { border-color: #4a4a4a; }
    input::placeholder { color: var(--muted); }

    /* ---- Auth ---- */
    #auth-screen { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 2rem; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; }
    /* When the iPad carousel stage is active, the auth-box becomes a glassy
       floating card overlaying the carousel rather than a centred form on
       a flat background. The invite-screen uses its own .auth-box without
       this stage, so those styles only apply inside #auth-stage. */
    #auth-screen.has-stage { padding: 0; align-items: stretch; justify-content: stretch; }
    .auth-box { width: 100%; max-width: 360px; }
    .auth-logo { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; background: linear-gradient(135deg, #fff 0%, #666 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 0.5rem; }
    .auth-sub { color: var(--muted); margin-bottom: 2rem; }

    /* ---- iPad carousel marketing stage ----
       Full-viewport layer behind the auth card. Coverflow-style: active iPad
       sits centred and full size, neighbours translate + scale + fade.
       Auth card floats over the right side on desktop, bottom-centre on phone. */
    #auth-stage {
      --ipad-w: 720px;
      --ipad-h: 540px;
      --slide-gap: 240px;
      position: absolute; inset: 0;
      overflow: hidden;
      background:
        radial-gradient(ellipse at 30% 30%, rgba(74, 222, 128, 0.08), transparent 60%),
        radial-gradient(ellipse at 70% 70%, rgba(56, 132, 248, 0.06), transparent 55%),
        linear-gradient(180deg, #050505 0%, #0a0a0a 100%);
    }
    #auth-stage .stage-vignette {
      position: absolute; inset: 0; pointer-events: none;
      background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.45) 90%);
      z-index: 2;
    }
    .ipad-track {
      position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
      width: var(--ipad-w); height: var(--ipad-h);
      perspective: 1600px;
      z-index: 1;
    }
    .ipad-slide {
      position: absolute; inset: 0;
      transition: transform 0.7s cubic-bezier(0.25,0.46,0.45,0.94),
                  opacity 0.7s cubic-bezier(0.25,0.46,0.45,0.94),
                  filter 0.7s ease;
      will-change: transform, opacity;
    }
    .ipad-frame {
      width: 100%; height: 100%;
      background: #0c0c0c; border-radius: 28px; padding: 14px;
      position: relative;
      box-shadow:
        0 0 0 1px #2a2a2a inset,
        0 0 0 2px #161616,
        0 30px 80px rgba(0,0,0,0.55),
        0 12px 32px rgba(0,0,0,0.4);
    }
    .ipad-frame::before {
      /* Subtle camera dot on the long edge */
      content: ''; position: absolute; top: 50%; left: 6px; transform: translateY(-50%);
      width: 4px; height: 4px; border-radius: 50%;
      background: #1c1c1c; box-shadow: 0 0 0 1px #050505;
    }
    .ipad-screen {
      width: 100%; height: 100%;
      border-radius: 16px; overflow: hidden;
      background: #0a0a0a;
      position: relative;
    }
    .ipad-screen img {
      width: 100%; height: 100%;
      object-fit: cover; display: block;
      transform-origin: center center;
    }
    .ipad-slide.active .ipad-frame {
      box-shadow:
        0 0 0 1px #333 inset,
        0 0 0 2px #161616,
        0 0 100px rgba(74, 222, 128, 0.12),
        0 30px 80px rgba(0,0,0,0.55);
    }
    .ipad-slide.active .ipad-screen img {
      animation: kenBurns 8s ease-in-out infinite alternate;
    }
    @keyframes kenBurns {
      from { transform: scale(1) translate(0, 0); }
      to   { transform: scale(1.04) translate(-1.2%, 0.4%); }
    }
    /* Caption sits below the iPad, fades in only for active slide.
       Glassy pill backdrop so it stays readable against any tile colour. */
    .slide-caption {
      position: absolute; left: 50%; top: calc(50% + var(--ipad-h) / 2 + 32px);
      transform: translate(-50%, 0);
      font-size: 0.875rem; font-weight: 500;
      color: rgba(255,255,255,0.92);
      letter-spacing: 0.06em; text-transform: uppercase;
      opacity: 0; transition: opacity 0.4s ease 0.15s;
      pointer-events: none; z-index: 3;
      text-align: center; white-space: nowrap;
      padding: 0.45rem 1rem;
      background: rgba(8, 8, 8, 0.6);
      border: 1px solid rgba(255,255,255,0.05);
      border-radius: 999px;
      backdrop-filter: blur(10px) saturate(140%);
      -webkit-backdrop-filter: blur(10px) saturate(140%);
      text-shadow: 0 1px 2px rgba(0,0,0,0.6);
    }
    .slide-caption.visible { opacity: 1; }

    /* Dots */
    .ipad-dots {
      position: absolute; left: 50%; bottom: 4.5rem;
      transform: translateX(-50%);
      display: flex; gap: 8px;
      z-index: 4;
    }
    .ipad-dots .dot {
      width: 6px; height: 6px; border-radius: 50%;
      background: rgba(255,255,255,0.18); border: none; padding: 0;
      cursor: pointer; transition: all 0.4s ease;
    }
    .ipad-dots .dot.active { background: #4ade80; width: 22px; border-radius: 3px; }
    .ipad-dots .dot:focus-visible { outline: 2px solid #4ade80; outline-offset: 3px; }

    /* Glassy auth card overlay */
    #auth-screen.has-stage .auth-box {
      position: absolute; z-index: 10;
      right: 6vw; top: 50%; transform: translateY(-50%);
      width: min(92vw, 380px);
      padding: 2rem 1.75rem 1.5rem;
      background: rgba(10, 10, 10, 0.72);
      border: 1px solid rgba(255, 255, 255, 0.06);
      border-radius: 18px;
      backdrop-filter: blur(20px) saturate(140%);
      -webkit-backdrop-filter: blur(20px) saturate(140%);
      box-shadow:
        0 1px 0 0 rgba(255,255,255,0.04) inset,
        0 24px 60px rgba(0,0,0,0.55);
    }

    /* Phone: stage shrinks, auth card moves to bottom-centre full-width */
    @media (max-width: 720px) {
      #auth-stage { --ipad-w: 480px; --ipad-h: 360px; --slide-gap: 160px; }
      .ipad-track { top: 30%; }
      .slide-caption { display: none; }
      .ipad-dots { bottom: calc(2rem + 320px); }
      #auth-screen.has-stage .auth-box {
        right: 50%; top: auto; bottom: 1.5rem;
        transform: translate(50%, 0);
        width: calc(100vw - 2rem);
        max-width: 420px;
      }
    }

    /* First-visit interaction hint */
    .carousel-hint {
      position: absolute; left: 50%; bottom: 2rem;
      transform: translate(-50%, 8px);
      font-size: 0.75rem; font-weight: 500;
      color: rgba(255,255,255,0.7);
      letter-spacing: 0.08em; text-transform: uppercase;
      padding: 0.4rem 0.85rem;
      background: rgba(15,15,15,0.65);
      border: 1px solid rgba(255,255,255,0.06);
      border-radius: 999px;
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      opacity: 0; transition: opacity 0.5s ease, transform 0.5s ease;
      z-index: 5; pointer-events: none;
      white-space: nowrap;
    }
    .carousel-hint.visible {
      opacity: 1;
      transform: translate(-50%, 0);
    }

    /* Reduced motion: kill autoplay, Ken Burns, transitions. JS also bails. */
    @media (prefers-reduced-motion: reduce) {
      .ipad-slide { transition: none; }
      .ipad-slide.active .ipad-screen img { animation: none; }
      .slide-caption { transition: none; }
      .carousel-hint { transition: none; }
    }
    .field { margin-bottom: 1rem; }
    .field label { display: block; font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.375rem; }
    .field input { width: 100%; padding: 0.6875rem 0.875rem; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 7px; font-size: 0.9375rem; }
    .field input:focus { outline: none; border-color: #4a4a4a; }
    .btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.6875rem 1.125rem; border: none; border-radius: 7px; font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: background 0.14s, color 0.14s, border-color 0.14s, box-shadow 0.14s, transform 0.1s, opacity 0.12s; white-space: nowrap; }
    .btn:disabled { opacity: 0.4; cursor: not-allowed; }
    .btn:active:not(:disabled) { transform: translateY(0) !important; box-shadow: none !important; }
    .btn-primary { background: linear-gradient(175deg, #ffffff 0%, #d0d0d0 100%); color: #0a0a0a; width: 100%; margin-top: 0.25rem; }
    .btn-primary:hover:not(:disabled) { background: linear-gradient(175deg, #ffffff 0%, #bebebe 100%); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255,255,255,0.06); }
    .btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
    .btn-ghost:hover:not(:disabled) { border-color: #4a4a4a; color: var(--text); background: rgba(255,255,255,0.03); }
    .btn-danger { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
    .btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.25); transform: translateY(-1px); }
    .btn-green { background: rgba(74,222,128,0.12); color: var(--green); border: 1px solid rgba(74,222,128,0.25); width: 100%; margin-top: 0.5rem; }
    .btn-green:hover:not(:disabled) { background: rgba(74,222,128,0.22); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74,222,128,0.06); }
    .btn-copied { color: var(--green) !important; border-color: rgba(74,222,128,0.4) !important; }
    .auth-toggle { margin-top: 1rem; text-align: center; }
    .auth-toggle button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.8125rem; }
    .auth-toggle button:hover { color: var(--text); }
    .msg { padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 0.8125rem; margin-top: 0.625rem; display: none; }
    .msg.error { display: block; background: rgba(248,113,113,0.08); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }
    .msg.info  { display: block; background: rgba(74,222,128,0.08); color: var(--green); border: 1px solid rgba(74,222,128,0.2); }

    /* ---- App layout ---- */
    #app { display: none; height: 100vh; flex-direction: column; width: 100%; overflow: hidden; }
    header { display: flex; align-items: center; gap: 0.875rem; padding: 0 1rem; height: 50px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
    .logo { font-size: 0.9375rem; font-weight: 700; letter-spacing: -0.02em; margin-right: auto; }
    header select { padding: 0.375rem 1.75rem 0.375rem 0.625rem; background: var(--surface2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.5rem center; border: 1px solid var(--border); color: var(--text); border-radius: 6px; font-size: 0.8125rem; cursor: pointer; -webkit-appearance: none; appearance: none; transition: border-color 0.14s; }
    header select:hover { border-color: #4a4a4a; }
    header select:focus { outline: none; border-color: #4a4a4a; }
    .main { display: flex; flex: 1; overflow: hidden; }

    /* ---- Sidebar ---- */
    #sidebar { width: 360px; flex-shrink: 0; border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; display: flex; flex-direction: column; padding: 0.75rem; gap: 0.375rem; scrollbar-width: thin; scrollbar-color: #252525 transparent; }
    #sidebar::-webkit-scrollbar { width: 5px; }
    #sidebar::-webkit-scrollbar-track { background: transparent; }
    #sidebar::-webkit-scrollbar-thumb { background: #252525; border-radius: 3px; }
    #sidebar::-webkit-scrollbar-thumb:hover { background: #363636; }
    .hint { font-size: 0.8125rem; color: var(--muted); padding: 0.5rem 0.75rem; background: var(--surface2); border-radius: 6px; border: 1px solid var(--border); }
    .hint.placed { color: var(--green); background: rgba(74,222,128,0.06); border-color: rgba(74,222,128,0.25); }
    .field-label { font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.375rem; }
    textarea { width: 100%; padding: 0.625rem 0.75rem; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 7px; font-size: 0.875rem; resize: vertical; min-height: 88px; font-family: inherit; line-height: 1.5; }
    textarea:focus { outline: none; border-color: #4a4a4a; }
    textarea::placeholder { color: var(--muted); }

    /* ---- Result card ---- */
    @keyframes result-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
    .result-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.125rem; }
    #result-card { animation: result-in 0.2s ease both; }
    .result-card h3 { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.75rem; line-height: 1.35; }
    .path-preview { border-radius: 6px; overflow: hidden; margin-bottom: 0.75rem; display: none; }
    .path-preview svg { display: block; width: 100%; height: auto; }
    .meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.75rem; }
    .meta-item .k { font-size: 0.5625rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 0.1rem; }
    .meta-item .v { font-size: 1.075rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
    details { margin-bottom: 0; }
    details summary { font-size: 0.75rem; color: var(--muted); cursor: pointer; user-select: none; }
    details summary:hover { color: var(--text); }
    details pre { margin-top: 0.5rem; font-size: 0.6875rem; color: var(--muted); white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 0.5rem; border-radius: 4px; }

    /* ---- Map ---- */
    #map-wrap { flex: 1; position: relative; overflow: hidden; min-width: 0; }
    #map { width: 100%; height: 100%; }
    .map-style-toggle { position: absolute; bottom: 2rem; right: 1rem; z-index: 1000; background: rgba(20,20,20,0.85); backdrop-filter: blur(8px); border: 1px solid var(--border); color: var(--muted); padding: 0.4rem 0.75rem; border-radius: 6px; font-size: 0.75rem; cursor: pointer; }
    .map-style-toggle:hover { color: var(--text); border-color: #4a4a4a; }

    /* ---- Spinner ---- */
    .spin { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(0,0,0,0.15); border-top-color: rgba(0,0,0,0.6); border-radius: 50%; animation: spin 0.55s linear infinite; }
    .btn-primary .spin { border-color: rgba(0,0,0,0.15); border-top-color: #000; }
    @keyframes spin { to { transform: rotate(360deg); } }
    /* Loading state: hide text, show centered spinner via pseudo-element */
    .btn-loading { color: transparent !important; pointer-events: none; position: relative; }
    .btn-loading::after { content: ''; position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid rgba(0,0,0,0.18); border-top-color: #000; border-radius: 50%; animation: spin 0.55s linear infinite; }
    .btn-ghost.btn-loading::after { border-color: rgba(255,255,255,0.15); border-top-color: var(--muted); }

    /* ---- Usage bar ---- */
    .usage-bar { display: none; }
    .usage-bar-label { display: flex; justify-content: space-between; margin-bottom: 0.3rem; }
    .usage-bar-label span { font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
    .usage-track { height: 3px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
    .usage-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.4s, background 0.4s; }

    /* ---- History panel ---- */
    .history-header { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
    /* Grey shimmer placeholder rows shown while /api/missions is in-flight on
       first paint - prevents the history pane from appearing empty. */
    .history-skeleton-row {
      height: 56px;
      background: linear-gradient(90deg, var(--surface2) 0%, #2a2a2a 50%, var(--surface2) 100%);
      background-size: 200% 100%;
      animation: history-skel-shimmer 1.5s ease-in-out infinite;
      border-radius: 7px;
      margin-bottom: 0.375rem;
      border: 1px solid var(--border);
    }
    @keyframes history-skel-shimmer {
      0%   { background-position: 200% 0; }
      100% { background-position: -200% 0; }
    }
    @media (prefers-reduced-motion: reduce) {
      .history-skeleton-row { animation: none; background: var(--surface2); }
    }
    #history-section { border-top: none; padding-top: 0; }
    .history-list { display: flex; flex-direction: column; gap: 0.375rem; }
    .history-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.625rem 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; cursor: pointer; min-height: 44px; transition: border-color 0.14s; }
    .history-item:hover { border-color: #4a4a4a; }
    /* Template left-accent via inset box-shadow */
    .history-item--orbit    { box-shadow: inset 3px 0 0 #60a5fa; }
    .history-item--reveal   { box-shadow: inset 3px 0 0 #fb923c; }
    .history-item--crane    { box-shadow: inset 3px 0 0 #c084fc; }
    .history-item--helix    { box-shadow: inset 3px 0 0 #34d399; }
    .history-item--dronie   { box-shadow: inset 3px 0 0 #f472b6; }
    .history-item--traverse { box-shadow: inset 3px 0 0 #22d3ee; }
    .history-item--grid     { box-shadow: inset 3px 0 0 #a3e635; }
    .history-item--flyby    { box-shadow: inset 3px 0 0 #fb923c; }
    .history-item--terrain  { box-shadow: inset 3px 0 0 #f59e0b; }
    .history-item--patrol   { box-shadow: inset 3px 0 0 #818cf8; }
    .history-item.loaded { border-color: rgba(74,222,128,0.4); background: rgba(74,222,128,0.03); }
    .history-item .hi-name { flex: 1; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .history-item .hi-tag { font-size: 0.6875rem; padding: 0.175rem 0.45rem; border-radius: 4px; flex-shrink: 0; }
    .hi-tag.orbit  { color: #60a5fa; background: rgba(96,165,250,0.12); }
    .hi-tag.reveal { color: #fb923c; background: rgba(251,146,60,0.12); }
    .hi-tag.crane  { color: #c084fc; background: rgba(192,132,252,0.12); }
    .hi-tag.helix  { color: #34d399; background: rgba(52,211,153,0.12); }
    .hi-tag.dronie { color: #f472b6; background: rgba(244,114,182,0.12); }
    .hi-tag.draft  { color: var(--muted); background: var(--surface2); }
    .hi-tag.orbit::before    { content: '🔄 '; font-style: normal; }
    .hi-tag.reveal::before   { content: '📽 '; font-style: normal; }
    .hi-tag.crane::before    { content: '🏗 '; font-style: normal; }
    .hi-tag.helix::before    { content: '🌀 '; font-style: normal; }
    .hi-tag.dronie::before   { content: '🚁 '; font-style: normal; }
    .hi-tag.traverse::before { content: '↔ '; font-style: normal; }
    .hi-tag.grid::before     { content: '🔍 '; font-style: normal; }
    .hi-tag.flyby::before    { content: '✈ '; font-style: normal; }
    .hi-tag.terrain::before  { content: '✏ '; font-style: normal; }
    .hi-tag.patrol::before   { content: '⬡ '; font-style: normal; }
    .hi-del { background: none; border: none; color: #555; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0.125rem; flex-shrink: 0; }
    .hi-del:hover { color: var(--red); }
    .hi-user-tag { font-size: 0.5rem; padding: 0.05rem 0.3rem; border-radius: 8px; background: rgba(74,222,128,0.08); color: var(--green); border: 1px solid rgba(74,222,128,0.18); flex-shrink: 0; }
    .prompt-footer { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.375rem; }
    .char-count { font-size: 0.625rem; color: var(--muted); }

    /* ---- Sun info ---- */
    .sun-info { display: none; flex-wrap: wrap; gap: 0.3rem 0.6rem; font-size: 0.6875rem; color: var(--muted); padding: 0.3rem 0; border-top: 1px solid var(--border); margin-top: 0.35rem; }
    .sun-info span { white-space: nowrap; min-width: 0; }

    /* ---- Flight time ---- */
    .flight-est { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; }
    .flight-est strong { color: var(--text); font-weight: 600; }

    /* ---- Result actions ---- */
    .result-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.375rem; margin-top: 0.5rem; }
    .result-actions .btn { margin-top: 0; font-size: 0.75rem; min-width: 0; white-space: nowrap; padding-left: 0.4rem; padding-right: 0.4rem; overflow: hidden; text-overflow: ellipsis; }
    .result-actions .btn-green { width: auto; grid-column: span 2; }

    /* ---- Subject height ---- */
    .subject-height-row { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.35rem; }
    .subject-height-row label { font-size: 0.6875rem; color: var(--muted); white-space: nowrap; }
    .subject-height-row input { width: 72px; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 5px; padding: 0.3rem 0.5rem; font-size: 0.875rem; font-family: inherit; -moz-appearance: textfield; min-height: 34px; }
    .subject-height-row input::-webkit-inner-spin-button { opacity: 0.4; }
    .subject-height-row input:focus { outline: none; border-color: #4a4a4a; }
    .subject-height-row span { font-size: 0.8125rem; color: var(--muted); }

    /* ---- Prompt chips ---- */
    .prompt-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
    .chip { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); border-radius: 100px; padding: 0.3rem 0.7rem; font-size: 0.75rem; cursor: pointer; font-family: inherit; line-height: 1.5; min-height: 32px; display: inline-flex; align-items: center; transition: background 0.14s, border-color 0.14s, color 0.14s; }
    .chip.active { border-color: rgba(74,222,128,0.5); color: var(--green); background: rgba(74,222,128,0.08); }
    .chip:hover { border-color: #4a4a4a; color: var(--text); background: rgba(255,255,255,0.03); }

    /* ---- Mission rename ---- */
    .r-name { cursor: text; border-radius: 4px; padding: 0.1rem 0.25rem; margin: -0.1rem -0.25rem; outline: none; }
    .r-name:focus { background: var(--bg); box-shadow: 0 0 0 1px var(--border); }

    /* ---- Map search box ---- */
    #map-search-input { position: absolute; top: 10px; left: 10px; z-index: 600; width: 220px; padding: 0.5rem 0.75rem; background: rgba(14,14,14,0.92); backdrop-filter: blur(8px); border: 1px solid var(--border); color: var(--text); border-radius: 7px; font-size: 0.875rem; font-family: inherit; outline: none; }
    #map-search-input:focus { border-color: #4a4a4a; }
    #map-search-input::placeholder { color: var(--muted); }
    /* Google Places autocomplete dropdown dark theme */
    .pac-container { background: rgba(14,14,14,0.97) !important; border: 1px solid var(--border) !important; border-top: none !important; box-shadow: 0 8px 24px rgba(0,0,0,.5) !important; font-family: inherit !important; }
    .pac-item { color: var(--muted) !important; border-top: 1px solid var(--surface2) !important; padding: 0.35rem 0.75rem !important; font-size: 0.8125rem !important; cursor: pointer; }
    .pac-item:hover, .pac-item-selected { background: var(--surface2) !important; color: var(--text) !important; }
    .pac-item-query { color: var(--text) !important; font-size: 0.875rem !important; }
    .pac-matched { color: var(--green) !important; font-weight: 600 !important; }
    .pac-icon { display: none !important; }
    /* Hide Google Maps default logo / attribution overlap with our UI */
    .gm-style-cc { display: none !important; }
    /* AdvancedMarker default pin hidden */
    .gm-style img[src*="pin"] { display: none; }

    /* ---- Param editor ---- */
    .param-editor { border-top: 1px solid var(--border); padding-top: 0.6rem; margin-top: 0.5rem; }
    .param-editor-title { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.45rem; }
    .param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 0.5rem; margin-bottom: 0.55rem; }
    .param-field { display: flex; flex-direction: column; gap: 0.15rem; }
    .param-field label { font-size: 0.5625rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
    .param-field input[type=number], .param-field select { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 5px; padding: 0.3rem 0.5rem; font-size: 0.875rem; font-family: inherit; width: 100%; min-height: 36px; }
    .param-field input[type=number]::-webkit-inner-spin-button { opacity: 0.4; }
    .param-field input[type=number] { -moz-appearance: textfield; }
    .param-field input:focus, .param-field select:focus { outline: none; border-color: #4a4a4a; }
    .param-regen { width: 100%; }

    /* ---- Terrain safety ---- */
    #terrain-safety { font-size: 0.75rem; border-radius: 5px; padding: 0.375rem 0.625rem; margin-bottom: 0.75rem; display: none; background: var(--bg); border: 1px solid var(--border); }
    .ts-ok       { color: #4ade80; }
    .ts-warn     { color: #f59e0b; }
    .ts-critical { color: var(--red); }
    .ts-checking { color: var(--muted); }
    .ts-unknown  { color: #555; }

    /* ---- Altitude chart ---- */
    #r-alt-chart svg { display:block; width:100%; height:56px; border-radius:5px; overflow:hidden; }
    .alt-chart-label { font-size:0.5625rem; color:#555; margin-bottom:0.1rem; }

    /* ---- Camera panel ---- */
    #r-camera { display:none; margin-bottom:0.4rem; }
    .camera-toggle { background:none; border:none; color:#555; cursor:pointer; font-size:0.625rem; font-family:inherit; padding:0.1rem 0; width:100%; text-align:left; }
    .camera-toggle:hover { color:var(--muted); }
    #camera-body { font-size:0.6875rem; color:var(--muted); background:var(--surface2); border:1px solid var(--border); border-radius:6px; padding:0.4rem 0.6rem; margin-top:0.2rem; line-height:1.6; }
    .camera-row { display:flex; flex-wrap:wrap; gap:0.2rem 0.75rem; }
    .camera-row strong { color:var(--text); font-weight:600; }
    .camera-sub { font-size:0.625rem; color:#555; margin-top:0.15rem; }

    /* ---- Shot gallery ---- */
    .gallery-section { margin-top:0.75rem; }
    .gallery-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:0.35rem; }
    .gallery-header span { font-size:0.6875rem; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; }
    .gallery-toggle-btn { background:none; border:none; color:#555; cursor:pointer; font-size:0.7rem; font-family:inherit; padding:0; }
    .gallery-grid { display:none; grid-template-columns:1fr 1fr; gap:0.35rem; }
    .gallery-grid.open { display:grid; }
    .gallery-card { background:var(--surface2); border:1px solid var(--border); border-radius:7px; padding:0.45rem 0.5rem; cursor:pointer; transition:border-color 0.15s; }
    .gallery-card:hover { border-color:#4a4a4a; }
    .gallery-cat { font-size:0.5rem; text-transform:uppercase; letter-spacing:.08em; margin-bottom:0.2rem; }
    .gallery-cat.cinematic { color:#818cf8; }
    .gallery-cat.action    { color:#f87171; }
    .gallery-cat.landscape { color:#4ade80; }
    .gallery-cat.survey    { color:#f59e0b; }
    .gallery-name { font-size:0.75rem; font-weight:600; color:var(--text); line-height:1.25; }
    .gallery-desc { font-size:0.625rem; color:var(--muted); margin-top:0.15rem; line-height:1.4; }

    /* ---- Terrain / sequence / 3D additions ---- */
    .hi-tag.terrain  { color: #f59e0b; background: rgba(245,158,11,0.12); }
    .hi-tag.traverse { color: #22d3ee; background: rgba(34,211,238,0.12); }
    .hi-tag.grid     { color: #a3e635; background: rgba(163,230,53,0.12); }
    .hi-tag.flyby    { color: #fb923c; background: rgba(251,146,60,0.12); }
    .map-3d-toggle { position: absolute; bottom: 2rem; right: 7.5rem; z-index: 1000; background: rgba(20,20,20,0.85); backdrop-filter: blur(8px); border: 1px solid var(--border); color: var(--muted); padding: 0.4rem 0.75rem; border-radius: 6px; font-size: 0.75rem; cursor: pointer; display: block !important; }
    .map-3d-toggle:hover { color: var(--text); border-color: #4a4a4a; }
    .map-3d-toggle.active { color: var(--green); border-color: rgba(74,222,128,0.4); }
    .map-fullscreen-btn { position: absolute; bottom: 2rem; right: 14rem; z-index: 1000; background: rgba(20,20,20,0.85); backdrop-filter: blur(8px); border: 1px solid var(--border); color: var(--muted); padding: 0.4rem 0.75rem; border-radius: 6px; font-size: 0.75rem; cursor: pointer; }
    .map-fullscreen-btn:hover { color: var(--text); border-color: #4a4a4a; }
    #map-wrap.map-fullscreen { position: fixed !important; inset: 0 !important; z-index: 500; width: 100vw !important; height: 100vh !important; }
    #map-wrap.map-fullscreen .map-fullscreen-btn { right: 1rem; bottom: 2rem; }

    /* iPad landscape (1024-1180px): widen the sidebar and push map controls in. */
    @media (min-width: 901px) and (max-width: 1180px) {
      #sidebar { width: 420px; }
      .map-3d-toggle      { right: 8rem; }
      .map-style-toggle   { right: 1.5rem; }
      .map-fullscreen-btn { right: 14.5rem; }
    }

    /* iPad portrait / phone (<=900px): stack the bottom-right map controls vertically. */
    @media (max-width: 900px) {
      .map-3d-toggle,
      .map-style-toggle,
      .map-fullscreen-btn {
        right: 1rem;
      }
      .map-style-toggle   { bottom: 2rem; }
      .map-3d-toggle      { bottom: 5rem; }
      .map-fullscreen-btn { bottom: 8rem; }
    }
    .terrain-panel { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; }
    .terrain-panel-title { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .06em; color: #f59e0b; margin-bottom: 0.4rem; }
    .seq-panel { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; }
    .seq-item { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.5rem; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; }
    .seq-battery { font-size: 0.6rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 0.3rem; margin-top: 0.1rem; display: flex; flex-direction: column; gap: 0.2rem; }
    .seq-battery-row { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
    .seq-batt-icon { font-size: 0.65rem; }
    .seq-swap-tag { font-size: 0.55rem; background: rgba(245,158,11,0.13); color: #f59e0b; border-radius: 3px; padding: 0.1rem 0.35rem; border: 1px solid rgba(245,158,11,0.25); }
    .pf-item { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 6px; background: var(--surface2); border: 1px solid var(--border); cursor: pointer; user-select: none; transition: background 0.15s; }
    .pf-item.checked { background: rgba(74,222,128,0.06); border-color: rgba(74,222,128,0.25); }
    .pf-item.warn { background: rgba(245,158,11,0.07); border-color: rgba(245,158,11,0.3); }
    .pf-item.error { background: rgba(248,113,113,0.07); border-color: rgba(248,113,113,0.3); }
    .pf-cb { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--border); flex-shrink: 0; margin-top: 1px; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; }
    .pf-item.checked .pf-cb { background: #4ade80; border-color: #4ade80; color: #000; }
    .pf-label { font-size: 0.8125rem; line-height: 1.3; flex: 1; }
    .pf-sub { font-size: 0.675rem; color: var(--muted); display: block; margin-top: 0.1rem; }
    .seq-num { font-size: 0.625rem; color: var(--muted); width: 14px; text-align: center; flex-shrink: 0; }
    .seq-name { flex: 1; font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .handle-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.6); cursor: move; touch-action: none; }
    #terrain-mode-btn.active { color: #f59e0b; border-color: rgba(245,158,11,0.4); }
    #patrol-mode-btn.active  { color: #818cf8; border-color: rgba(129,140,248,0.4); }
    .hi-tag.patrol { color: #818cf8; background: rgba(129,140,248,0.12); }
    /* ---- Wind indicator ---- */
    .wind-info { font-size: 0.6875rem; color: var(--text); padding: 0.35rem 0.625rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
    .wind-warn { color: var(--red) !important; }
    .wind-advisory-high { font-size: 0.6875rem; padding: 0.25rem 0.5rem; border-radius: 5px; margin-bottom: 0.3rem; line-height: 1.4; background: rgba(248,113,113,0.08); color: var(--red); border: 1px solid rgba(248,113,113,0.18); }
    .wind-advisory-medium { font-size: 0.6875rem; padding: 0.25rem 0.5rem; border-radius: 5px; margin-bottom: 0.3rem; line-height: 1.4; background: rgba(245,158,11,0.07); color: #f59e0b; border: 1px solid rgba(245,158,11,0.18); }
    /* ---- Collapsible sections ---- */
    .sk-section { border: 1px solid var(--border); border-radius: 8px; flex-shrink: 0; }
    .sk-section-hdr { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0.575rem 0.875rem; background: var(--surface2); border: none; color: var(--text); cursor: pointer; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; font-family: inherit; text-align: left; gap: 0.5rem; }
    .sk-section-hdr:hover { background: #1a1a1a; }
    .sk-chevron { font-size: 0.5rem; color: var(--muted); transition: transform 0.2s; display: inline-block; }
    .sk-collapsed .sk-chevron { transform: rotate(-180deg); }
    .sk-section-body { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.625rem; }
    .sk-generate-area { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.25rem; }
    .sk-status-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.1rem 0; }
    #airspace-toggle-btn { display: none; background: none; border: none; color: #555; cursor: pointer; padding: 0.2rem 0; font-size: 0.6875rem; font-family: inherit; white-space: nowrap; }
    #airspace-toggle-btn:hover { color: var(--muted); }
    #airspace-toggle-btn.active { color: #818cf8; }
    /* ---- Airspace warning ---- */
    .airspace-advisory { font-size: 0.6875rem; padding: 0.25rem 0.5rem; border-radius: 5px; margin-bottom: 0.3rem; line-height: 1.4; background: rgba(99,102,241,0.07); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }
    /* ---- Forecast chips ---- */
    .forecast-chip { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 0.35rem 0.5rem; cursor: pointer; font-family: inherit; flex-shrink: 0; min-width: 40px; transition: border-color 0.14s, background 0.14s; }
    .forecast-chip:hover { border-color: #4a4a4a; background: rgba(255,255,255,0.03); }
    .forecast-chip.today { border-color: rgba(74,222,128,0.3); }
    .forecast-chip.active { border-color: rgba(74,222,128,0.5); background: rgba(74,222,128,0.08); }
    .fc-day { font-size: 0.5625rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
    .forecast-chip.today .fc-day { color: var(--green); }
    .fc-icon { font-size: 1rem; line-height: 1.2; }
    .fc-wind { font-size: 0.5rem; color: var(--muted); }
    .fc-wind.warn { color: var(--red); }
    .fc-temp { font-size: 0.5rem; color: #666; white-space: nowrap; }
    .forecast-row { position: relative; }
    .forecast-row::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 28px; background: linear-gradient(to right, transparent, var(--surface)); pointer-events: none; }
    /* ---- Inspire / AI Flight Advisor ---- */
    @keyframes inspire-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
    .inspire-panel { display: none; flex-direction: column; gap: 0.375rem; margin-top: 0.375rem; }
    .inspire-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.75rem 0.5rem; cursor: pointer; transition: border-color 0.15s, background 0.15s; animation: inspire-in 0.22s ease both; }
    .inspire-card:nth-child(2) { animation-delay: 0.07s; }
    .inspire-card:nth-child(3) { animation-delay: 0.14s; }
    .inspire-card:hover { border-color: #505050; background: #1f1f1f; }
    .inspire-card-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.2rem; }
    .inspire-card-tmpl { font-size: 0.6rem; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 3px; padding: 0.1rem 0.3rem; color: var(--muted); white-space: nowrap; }
    .inspire-card-title { font-size: 0.8125rem; font-weight: 600; flex: 1; }
    .inspire-card-text { font-size: 0.6875rem; color: var(--muted); line-height: 1.45; margin-bottom: 0.25rem; }
    .inspire-card-loc { font-size: 0.6rem; color: var(--indigo); margin-bottom: 0.2rem; }
    .inspire-card-cta { font-size: 0.6rem; color: #666; text-align: right; }
    .inspire-card:hover .inspire-card-cta { color: #777; }
    .inspire-card-active { border-color: var(--green) !important; background: rgba(74,222,128,0.06) !important; }
    .inspire-close-btn { position: absolute; top: 4px; right: 4px; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.75rem; line-height: 1; padding: 2px 4px; border-radius: 3px; }
    .inspire-close-btn:hover { color: var(--text); }
    .inspire-row { display: none; align-items: center; gap: 0.5rem; }
    #inspire-btn { font-size: 0.6875rem; background: none; border: none; color: #555; cursor: pointer; padding: 0.2rem 0; flex: 1; text-align: left; }
    #inspire-btn:hover { color: var(--text); }
    #inspire-refresh { background: none; border: none; color: #555; cursor: pointer; padding: 0.2rem; font-size: 0.875rem; line-height: 1; border-radius: 4px; display: none; }
    #inspire-refresh:hover { color: var(--muted); }
    /* ---- Pitch profile editor ---- */
    #pitch-profile-panel { border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.375rem; }
    #speed-profile-panel { border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.375rem; }
    /* ---- Share page ---- */
    #share-screen { display: none; min-height: 100vh; background: #080808; flex-direction: column; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; color: #eaeaea; }
    .share-header { height: 60px; display: flex; align-items: center; padding: 0 1.5rem; border-bottom: 1px solid #161616; gap: 1rem; flex-shrink: 0; }
    .share-logo { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.03em; background: linear-gradient(135deg,#fff 0%,#666 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
    .share-info-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.875rem; border-top: 1px solid #161616; padding-top: 1rem; }
    @media (max-width: 640px) {
      #share-screen > div:last-child { flex-direction: column-reverse; }
      #share-sidebar { width: 100% !important; border-left: none !important; border-top: 1px solid #1a1a1a; max-height: 55vh; }
      #share-map { flex: 1; min-height: 200px; }
    }
    @media (max-width: 480px) { .share-info-grid { grid-template-columns: repeat(2,1fr); } }

    /* ---- Lasso / shape draw ---- */
    #draw-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 200; pointer-events: none; touch-action: none; border-radius: 0; }
    #draw-canvas.active { pointer-events: auto; cursor: crosshair; }
    #lasso-btn.active, #rect-btn.active, #square-btn.active { color: #f59e0b !important; border-color: rgba(245,158,11,0.4) !important; }

    /* ---- Admin screen ---- */
    #admin-screen { display: none; min-height: 100vh; background: #080808; color: #eaeaea; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
    .admin-header { height: 60px; display: flex; align-items: center; padding: 0 1.5rem; border-bottom: 1px solid #161616; gap: 1rem; flex-shrink: 0; }
    .admin-logo { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.03em; background: linear-gradient(135deg,#fff 0%,#666 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
    .admin-body { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 2rem; }
    .admin-section { background: #0d0d0d; border: 1px solid #1a1a1a; border-radius: 10px; overflow: hidden; }
    .admin-section-header { padding: 0.875rem 1.25rem; border-bottom: 1px solid #1a1a1a; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; display: flex; align-items: center; gap: 0.75rem; }
    .admin-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
    .admin-table th { padding: 0.5rem 1.25rem; text-align: left; font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.08em; color: #777; border-bottom: 1px solid #1a1a1a; font-weight: 500; }
    .admin-table td { padding: 0.5rem 1.25rem; border-bottom: 1px solid #111; color: #bbb; vertical-align: middle; }
    .admin-table tr:last-child td { border-bottom: none; }
    .admin-table tr:hover td { background: #111; }
    .admin-empty { padding: 1.5rem 1.25rem; color: #666; font-size: 0.75rem; text-align: center; }
    .admin-tag { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 4px; font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
    .admin-tag.pro { background: rgba(74,222,128,0.12); color: #4ade80; }
    .admin-tag.free { background: rgba(255,255,255,0.05); color: #555; }
    .admin-tag.pending { background: rgba(250,204,21,0.10); color: #facc15; }
    .admin-tag.used { background: rgba(255,255,255,0.04); color: #666; }

    /* ---- Simulation controls overlay ---- */
    #sim-controls { position: absolute; bottom: 3.75rem; left: 50%; transform: translateX(-50%); z-index: 20; background: rgba(10,10,10,0.92); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem 0.875rem; min-width: 280px; max-width: 90vw; display: none; align-items: center; gap: 0.625rem; }
    .sim-prog-track { flex: 1; height: 3px; background: var(--surface2); border-radius: 2px; overflow: hidden; margin-bottom: 0.2rem; }
    .sim-prog-fill { height: 100%; background: #facc15; border-radius: 2px; width: 0%; }
    #sim-time { font-size: 0.625rem; color: var(--muted); white-space: nowrap; }
    #sim-marker-dot { width: 24px; height: 24px; pointer-events: none; }

    /* ---- Waypoint inline editor popup ---- */
    #wp-info-popup { position:absolute; z-index:600; background:rgba(10,10,10,0.93); backdrop-filter:blur(10px); border:1px solid var(--border); border-radius:10px; padding:0.5rem 0.75rem 0.6rem; min-width:230px; pointer-events:auto; box-shadow:0 4px 18px rgba(0,0,0,0.55); }
    #wp-info-popup .wpi-hdr { display:flex; align-items:center; justify-content:space-between; gap:0.5rem; margin-bottom:0.35rem; }
    #wp-info-popup .wpi-title { font-size:0.6875rem; font-weight:600; color:var(--text); white-space:nowrap; }
    #wp-info-popup .wpi-close { background:none; border:none; color:var(--muted); cursor:pointer; font-size:1rem; padding:0; line-height:1; flex-shrink:0; }
    #wp-info-popup .wpi-close:hover { color:var(--text); }
    #wp-info-popup .wpi-row { display:flex; align-items:center; gap:0.35rem; margin-bottom:0.2rem; }
    #wp-info-popup .wpi-lbl { font-size:0.625rem; color:var(--muted); width:42px; flex-shrink:0; }
    #wp-info-popup .wpi-val { font-size:0.6875rem; color:var(--text); font-weight:500; width:48px; text-align:right; flex-shrink:0; font-variant-numeric:tabular-nums; }
    #wp-info-popup input[type=range] { flex:1; cursor:pointer; height:14px; -webkit-appearance:none; appearance:none; background:transparent; }
    #wp-info-popup input[type=range]::-webkit-slider-runnable-track { height:3px; background:var(--border); border-radius:2px; }
    #wp-info-popup input[type=range]::-webkit-slider-thumb { -webkit-appearance:none; appearance:none; width:12px; height:12px; border-radius:50%; background:var(--green); margin-top:-4.5px; cursor:pointer; box-shadow:0 0 4px rgba(74,222,128,0.3); }
    #wp-info-popup input[type=range]::-moz-range-track { height:3px; background:var(--border); border-radius:2px; }
    #wp-info-popup input[type=range]::-moz-range-thumb { border:none; width:12px; height:12px; border-radius:50%; background:var(--green); cursor:pointer; }
    #wp-info-popup .wpi-all-row { display:flex; align-items:center; gap:0.35rem; margin-top:0.3rem; }
    #wp-info-popup .wpi-all-row label { font-size:0.6875rem; color:var(--muted); cursor:pointer; }
    #wp-info-popup input[type=checkbox] { width:auto; accent-color:#4ade80; cursor:pointer; }

    /* ---- Altitude profile editor ---- */
    #alt-profile-panel { border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.375rem; }
    .alt-profile-title { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 0.375rem; display: flex; justify-content: space-between; align-items: center; }
    .alt-profile-title button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.75rem; padding: 0; }
    .alt-profile-title button:hover { color: var(--text); }
    .alt-profile-actions { display: flex; gap: 0.375rem; margin-top: 0.375rem; }
    .alt-profile-actions .btn { flex: 1; margin-top: 0; font-size: 0.8125rem; }

    /* ---- Mobile (portrait + any narrow viewport) ---- */
    @media (max-width: 640px) {
      .main { flex-direction: column-reverse; overflow: hidden; }
      #sidebar { width: 100%; max-width: 100%; height: 55vh; min-height: 0; border-right: none; border-top: 1px solid var(--border); overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
      #map-wrap { flex: 1; min-height: 0; height: auto; }
      header { padding: 0 0.75rem; gap: 0.5rem; }
      textarea { resize: none; }
    }
    /* ---- Mobile landscape (iPhone rotated) ---- */
    /* ---- Toast notifications ---- */
    #toast-container { position: fixed; bottom: 5rem; right: 1.5rem; z-index: 99999; display: flex; flex-direction: column; gap: 0.4rem; pointer-events: none; max-width: 320px; }
    .toast { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 0.6rem 0.875rem; border-radius: 8px; font-size: 0.8125rem; line-height: 1.4; opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; pointer-events: auto; }
    .toast.show { opacity: 1; transform: translateY(0); }
    .toast.toast-success { border-color: rgba(74,222,128,0.35); color: var(--green); }
    .toast.toast-error { border-color: rgba(248,113,113,0.35); color: var(--red); }
    .toast.toast-info { border-color: rgba(148,163,184,0.25); color: #94a3b8; }
    .toast.toast-warning { border-color: rgba(250,204,21,0.4); color: #facc15; }
    .toast { cursor: pointer; }
    .toast:hover { transform: translateY(0) scale(1.02); }
    .toast-dismiss-all { background: rgba(15,15,15,0.85); border: 1px solid var(--border); color: var(--muted); padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.6875rem; cursor: pointer; align-self: flex-end; pointer-events: auto; opacity: 0.85; transition: opacity 0.15s; }
    .toast-dismiss-all:hover { opacity: 1; color: var(--text); }
    /* ---- Unified export popover ---- */
    /* The popover uses [hidden] for show/hide. We need display:flex when
       visible, but inline display:flex would override [hidden]'s display:none
       and leave the popover permanently visible (and intercepting clicks
       on adjacent buttons - regression caught by Playwright J11). */
    #export-popover:not([hidden]) { display: flex; }
    .export-row { display: flex; align-items: center; gap: 0.6rem; width: 100%; background: transparent; border: 1px solid transparent; color: var(--text); padding: 0.5rem 0.55rem; border-radius: 6px; cursor: pointer; text-align: left; font-size: 0.8125rem; transition: background 0.12s, border-color 0.12s; }
    .export-row:hover, .export-row:focus-visible { background: var(--surface2); border-color: var(--border); outline: none; }
    .export-row .ex-ico { font-size: 1.05rem; flex-shrink: 0; width: 1.2rem; text-align: center; }
    .export-row .ex-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
    .export-row .ex-label { font-weight: 500; line-height: 1.2; }
    .export-row .ex-sub { font-size: 0.6875rem; color: var(--muted); line-height: 1.3; }
    .export-row .ex-ext { font-size: 0.6875rem; color: var(--muted); flex-shrink: 0; font-family: monospace; }
    .export-row[data-export="kmz"] .ex-label { color: var(--green); }
    /* ---- Snapshot diff table ---- */
    .snap-diff-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
    .snap-diff-table thead th { background: var(--surface2); color: var(--muted); font-weight: 600; padding: 0.4rem 0.55rem; text-align: left; font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); }
    .snap-diff-table tbody td { padding: 0.35rem 0.55rem; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; line-height: 1.4; }
    .snap-diff-table tr.row-unchanged td { color: var(--muted); }
    .snap-diff-table tr.row-changed td.cell-alt-up { color: var(--green); }
    .snap-diff-table tr.row-changed td.cell-alt-down { color: var(--red); }
    .snap-diff-table tr.row-added td { background: rgba(74,222,128,0.08); }
    .snap-diff-table tr.row-removed td { background: rgba(248,113,113,0.08); color: var(--muted); text-decoration: line-through; }
    .snap-diff-table .delta-pill { display: inline-block; padding: 0.05rem 0.35rem; border-radius: 4px; font-size: 0.6875rem; font-weight: 600; }
    .snap-diff-table .delta-pill.up { background: rgba(74,222,128,0.18); color: var(--green); }
    .snap-diff-table .delta-pill.down { background: rgba(248,113,113,0.18); color: var(--red); }
    /* ---- Prompt autocomplete chips ---- */
    .pac-chip { background: rgba(74,222,128,0.08); border: 1px solid rgba(74,222,128,0.32); color: var(--green); padding: 0.18rem 0.5rem; border-radius: 999px; font-size: 0.6875rem; cursor: pointer; transition: background 0.12s, border-color 0.12s; line-height: 1.3; font-family: inherit; }
    .pac-chip:hover, .pac-chip:focus-visible { background: rgba(74,222,128,0.18); border-color: var(--green); outline: none; }
    .pac-chip kbd { background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; padding: 0 0.2rem; font-size: 0.5625rem; color: var(--muted); margin-left: 0.25rem; font-family: inherit; }
    /* ---- Templates gallery cards ---- */
    .tg-card { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.55rem 0.55rem 0.65rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; cursor: pointer; text-align: left; transition: transform 0.12s, border-color 0.12s, background 0.12s; }
    .tg-card:hover, .tg-card:focus-visible { transform: translateY(-2px); border-color: var(--green); background: rgba(74,222,128,0.04); outline: none; }
    .tg-card .tg-svg { width: 100%; height: 88px; background: rgba(15,15,15,0.5); border-radius: 5px; display: block; }
    .tg-card .tg-svg path { stroke: #4ade80; stroke-width: 2; fill: none; opacity: 0.78; stroke-linecap: round; stroke-linejoin: round; }
    .tg-card .tg-svg .tg-trace { stroke-dasharray: 6 4; animation: tg-trace 4s linear infinite; }
    @keyframes tg-trace { to { stroke-dashoffset: -100; } }
    .tg-card .tg-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
    .tg-card .tg-desc { font-size: 0.7rem; color: var(--muted); line-height: 1.4; }
    .tg-card .tg-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.15rem; font-size: 0.625rem; color: var(--muted); }
    .tg-card .tg-dur { background: rgba(74,222,128,0.1); border: 1px solid rgba(74,222,128,0.25); color: var(--green); padding: 0.05rem 0.35rem; border-radius: 4px; font-weight: 600; }
    @media (prefers-reduced-motion: reduce) { .tg-card .tg-svg .tg-trace { animation: none; stroke-dasharray: none; } }
    /* ---- Result card tabs ---- */
    .r-tabs { display: flex; gap: 0; margin: 0.4rem 0 0.5rem; padding: 0; border-bottom: 1px solid var(--border); }
    .r-tabs [role="tab"] { background: none; border: none; color: var(--muted); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; padding: 0.45rem 0.7rem; cursor: pointer; position: relative; transition: color 0.12s; font-family: inherit; }
    .r-tabs [role="tab"]:hover { color: var(--text); }
    .r-tabs [role="tab"][aria-selected="true"] { color: var(--green); }
    .r-tabs [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 0.5rem; right: 0.5rem; bottom: -1px; height: 2px; background: var(--green); border-radius: 2px; }
    .result-card.show-overview .r-tab-conditions,
    .result-card.show-overview .r-tab-tech,
    .result-card.show-conditions .r-tab-overview,
    .result-card.show-conditions .r-tab-tech,
    .result-card.show-tech .r-tab-overview,
    .result-card.show-tech .r-tab-conditions { display: none !important; }
    /* ---- Generate skeleton trail ---- */
    #gen-skeleton { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.5rem 0.6rem; margin: 0.4rem 0 0; background: rgba(15,15,15,0.55); border: 1px solid var(--border); border-radius: 8px; font-size: 0.75rem; }
    #gen-skeleton .sk-row { display: flex; align-items: center; gap: 0.5rem; opacity: 0.35; transition: opacity 0.25s, color 0.25s; color: var(--muted); }
    #gen-skeleton .sk-row.is-active { opacity: 1; color: var(--text); }
    #gen-skeleton .sk-row.is-done { opacity: 0.85; color: var(--green); }
    #gen-skeleton .sk-row.is-error { opacity: 1; color: var(--red); }
    #gen-skeleton .sk-bullet { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.18); flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
    #gen-skeleton .sk-row.is-active .sk-bullet { background: var(--green); box-shadow: 0 0 0 0 rgba(74,222,128,0.55); animation: sk-pulse 1.1s infinite; }
    #gen-skeleton .sk-row.is-done .sk-bullet { background: var(--green); box-shadow: none; }
    #gen-skeleton .sk-row.is-error .sk-bullet { background: var(--red); }
    #gen-skeleton .sk-row.is-done .sk-bullet::after { content: "✓"; color: #0c1b13; font-size: 0.55rem; line-height: 8px; display: block; text-align: center; margin-top: -0.1rem; }
    #gen-skeleton .sk-icon { font-size: 0.9rem; flex-shrink: 0; }
    #gen-skeleton .sk-text { line-height: 1.3; }
    @keyframes sk-pulse { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,0.55); } 70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
    @media (prefers-reduced-motion: reduce) { #gen-skeleton .sk-row.is-active .sk-bullet { animation: none; } }
    /* ---- Modal transitions ---- */
    .modal-overlay { opacity: 0; transition: opacity 0.15s; }
    .modal-overlay.is-open { opacity: 1; }
    .modal-overlay > div { transform: translateY(8px); transition: transform 0.15s; }
    .modal-overlay.is-open > div { transform: translateY(0); }

    /* ---- History empty state ---- */
    .history-empty { text-align: center; color: var(--muted); font-size: 0.8125rem; padding: 0.875rem 0 0.25rem; }
    .empty-illu { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; padding: 0.6rem 0.5rem 0.4rem; text-align: center; }
    .empty-illu img { width: 100%; max-width: 220px; height: auto; opacity: 0.95; border-radius: 6px; animation: ei-fade 0.4s ease-out; }
    .empty-illu .ei-title { font-size: 0.8125rem; color: var(--text); margin: 0.25rem 0 0; }
    .empty-illu .ei-sub { font-size: 0.6875rem; color: var(--muted); margin: 0; max-width: 240px; line-height: 1.45; }
    @keyframes ei-fade { 0% { opacity: 0; transform: translateY(4px); } 100% { opacity: 0.95; transform: translateY(0); } }
    @media (prefers-reduced-motion: reduce) { .empty-illu img { animation: none; } }
    /* ---- Share link panel ---- */
    #share-link-panel { display: none; background: var(--bg); border: 1px solid rgba(74,222,128,0.25); border-radius: 7px; padding: 0.5rem 0.75rem; margin-top: 0.375rem; }
    #share-link-url { font-size: 0.6875rem; color: var(--muted); word-break: break-all; margin-bottom: 0.3rem; }
    .share-link-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
    .share-copy-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 5px; padding: 0.15rem 0.5rem; font-size: 0.6875rem; cursor: pointer; white-space: nowrap; font-family: inherit; }
    .share-copy-btn:hover { color: var(--text); border-color: #4a4a4a; }
    /* ---- Plan-for time picker drum ---- */
    #plan-time-btn.tpc-open { border-color: rgba(74,222,128,0.5); }
    .tpc-wrap { position:absolute; top:calc(100% + 4px); left:0; z-index:8000; background:#111; border:1px solid #272727; border-radius:10px; box-shadow:0 10px 40px rgba(0,0,0,.9); width:172px; overflow:hidden; }
    .tpc-drums { display:flex; height:150px; position:relative; border-bottom:1px solid #1a1a1a; }
    .tpc-drums::before,.tpc-drums::after { content:''; position:absolute; left:0; right:0; height:56px; pointer-events:none; z-index:2; }
    .tpc-drums::before { top:0; background:linear-gradient(to bottom,#111 0%,transparent 100%); }
    .tpc-drums::after  { bottom:0; background:linear-gradient(to top,#111 0%,transparent 100%); }
    .tpc-reticle { position:absolute; left:0; right:0; top:60px; height:30px; background:rgba(74,222,128,0.05); border-top:1px solid rgba(74,222,128,0.18); border-bottom:1px solid rgba(74,222,128,0.18); z-index:1; pointer-events:none; }
    .tpc-col { flex:1; overflow-y:scroll; scroll-snap-type:y mandatory; scrollbar-width:none; -ms-overflow-style:none; }
    .tpc-col::-webkit-scrollbar { display:none; }
    .tpc-col-ap { flex:0; min-width:46px; }
    .tpc-item,.tpc-spacer { height:30px; line-height:30px; text-align:center; scroll-snap-align:start; font-size:0.8125rem; color:#333; cursor:pointer; user-select:none; transition:color 0.08s,font-size 0.08s; }
    .tpc-spacer { pointer-events:none; }
    .tpc-item.tpc-sel  { color:#eaeaea; font-size:1rem; font-weight:600; }
    .tpc-item.tpc-near { color:#525252; font-size:0.875rem; }
    .tpc-sep { display:flex; align-items:center; justify-content:center; width:12px; flex-shrink:0; font-size:0.875rem; color:#444; padding-bottom:2px; }
    .tpc-footer { padding:0.35rem 0.625rem; display:flex; justify-content:flex-end; }
    .tpc-set { background:none; border:none; color:var(--green); font-size:0.6875rem; font-family:inherit; cursor:pointer; font-weight:700; letter-spacing:0.06em; text-transform:uppercase; padding:0.1rem 0; }
    .tpc-set:hover { opacity:0.75; }
    /* ---- Mobile: result card scrollable ---- */
    @media (max-width: 640px) {
      #result-card { max-height: calc(55vh - 5rem); overflow-y: auto; }
    }

    @keyframes bw-shimmer {
      0%   { transform: translateX(-100%); }
      100% { transform: translateX(100%); }
    }

    @media (max-height: 500px) and (orientation: landscape) {
      .main { flex-direction: row; }
      #sidebar { width: 300px; height: 100%; border-right: 1px solid var(--border); border-top: none; overflow-y: auto; padding: 0.75rem; gap: 0.625rem; }
      #map-wrap { flex: 1; min-height: unset; height: 100%; }
      header { height: 42px; padding: 0 0.75rem; gap: 0.5rem; }
      header select, header .btn { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
      .hint { font-size: 0.75rem; }
      textarea { min-height: 56px; font-size: 0.8125rem; }
      .prompt-chips { gap: 0.2rem; }
      .chip { font-size: 0.625rem; padding: 0.125rem 0.375rem; }
      .result-card { padding: 0.625rem; }
    }

    /* ---- Voice / mic button ---- */
    .mic-btn {
      position: relative;
      width: 26px;
      height: 26px;
      border-radius: 50%;
      border: 1px solid var(--border);
      background: var(--bg);
      color: var(--muted);
      font-size: 0.75rem;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      padding: 0;
      transition: border-color 120ms ease, color 120ms ease, transform 80ms ease;
      user-select: none;
      -webkit-user-select: none;
      touch-action: manipulation;
    }
    .mic-btn:hover  { color: var(--text); border-color: #4a4a4a; }
    .mic-btn:focus-visible { outline: 2px solid var(--accent, #4ade80); outline-offset: 2px; }
    .mic-btn:active { transform: scale(0.94); }
    .mic-btn .mic-dot {
      position: absolute;
      top: 1px;
      right: 1px;
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: transparent;
      transition: background-color 120ms ease;
    }
    .mic-btn[data-state="requesting-permit"] {
      color: var(--accent, #4ade80);
      border-color: rgba(74,222,128,0.4);
    }
    .mic-btn[data-state="requesting-permit"] .mic-dot {
      background: #f59e0b;
      animation: mic-pulse 0.9s ease-in-out infinite;
    }
    .mic-btn[data-state="listening"] {
      color: var(--accent, #4ade80);
      border-color: rgba(74,222,128,0.6);
      background: rgba(74,222,128,0.06);
    }
    .mic-btn[data-state="listening"] .mic-dot {
      background: #ef4444;
      animation: mic-pulse 0.9s ease-in-out infinite;
    }
    .mic-btn[data-state="processing"] {
      color: var(--muted);
      border-color: var(--border);
      opacity: 0.7;
      cursor: default;
    }
    .mic-btn[data-state="error"] {
      color: #ef4444;
      border-color: rgba(239,68,68,0.5);
    }
    @keyframes mic-pulse {
      0%, 100% { opacity: 0.4; }
      50%      { opacity: 1; }
    }
    @media (prefers-reduced-motion: reduce) {
      .mic-btn .mic-dot { animation: none !important; }
      .mic-btn { transition: none; }
    }

    /* ---- Char count warning thresholds (T19c) ---- */
    /* Default .char-count is muted grey - see earlier in this file.
       At 500+ chars we nudge amber, at 600+ we push red so pilots know
       they're drifting toward an unwieldy prompt. The hard server-side
       cap is much higher; this is purely a "you can do better" signal. */
    .char-count.warn   { color: #d97706; }
    .char-count.danger { color: #dc2626; }

    /* ---- Mission rename save indicator (T19d) ---- */
    /* Tiny inline state next to the editable mission title. Fades in
       to "Saving…", flips green to "Saved" briefly, then fades out.
       On failure stays red + clickable to retry. */
    .save-state {
      font-size: 0.75rem;
      color: var(--muted);
      margin-left: 0.5rem;
      align-self: center;
      flex-shrink: 0;
      transition: opacity 0.3s ease, color 0.2s ease;
      opacity: 1;
      line-height: 1;
    }
    .save-state:empty { opacity: 0; }
    .save-state.is-saving { color: var(--muted); }
    .save-state.is-saved  { color: var(--green); }
    .save-state.is-failed { color: #ef4444; cursor: pointer; text-decoration: underline; }

    /* ---- Reduced-motion backstop (T19a) ---- */
    /* Single safety net over per-component reduced-motion rules already
       sprinkled above. Anything we forgot to wrap is reduced to a
       near-instant 0.01ms so the UI feels static for users who request
       it (vestibular reasons / OS accessibility setting). 0.01ms (not 0)
       so JS that listens for transitionend / animationend still fires. */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }
  </style>
