/* ============================================================
   LCARS theme — "NEPTUNE" design language
   Star Trek Technical Library
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Antonio:wght@300;400;500;600;700&display=swap');

:root {
    --salmon: #FF9966;
    --gold: #FFCC66;
    --lilac: #CC99CC;
    --ice: #99CCFF;
    --peri: #9999FF;
    --red: #CC6666;
    --brown: #5a3d1f;
    --brown-2: #3a2a14;
    --brown-3: #2a1d0f;
    --card: #0d0d0d;
    --card-2: #171717;
    --text: #FFCC99;
    --text-dim: #9a8c7c;
    --text-mute: #6f6256;
    --accent: var(--salmon);
    --font: 'Antonio', 'Oswald', sans-serif;
    --font-body: 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif;
    --gap: 6px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0; height: 100%;
    background: #000; color: var(--text);
    font-family: var(--font); -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
a { color: var(--ice); text-decoration: none; }
a:hover { color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: var(--brown); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--salmon); }

@keyframes blink { 0%,49% { opacity: 1 } 50%,100% { opacity: .2 } }
@keyframes redpulse { 0%,100% { box-shadow: inset 0 0 0 6px var(--red), inset 0 0 70px 12px rgba(204,80,80,.35) } 50% { box-shadow: inset 0 0 0 6px #6e2222, inset 0 0 40px 6px rgba(204,80,80,.12) } }

/* ---------------- accent per manual ---------------- */
.accent-orange { --accent: var(--salmon); }
.accent-violet { --accent: var(--lilac); }
.accent-blue   { --accent: var(--ice); }
.accent-gold   { --accent: var(--gold); }
.accent-peri   { --accent: var(--peri); }
.accent-red    { --accent: var(--red); }

/* ---------------- cockpit grid ---------------- */
.lcars {
    position: fixed; inset: 0;
    display: grid;
    grid-template-columns: 208px 1fr;
    grid-template-rows: 104px 1fr 60px;
    grid-template-areas: "rail topbar" "rail main" "rail botbar";
    gap: var(--gap); padding: var(--gap);
    background: #000;
}

/* ---------------- left rail (full height) ---------------- */
.rail {
    grid-area: rail;
    display: flex; flex-direction: column; gap: 4px; min-height: 0;
}
.rail-elbow-top {
    background: var(--accent); border-radius: 60px 0 0 0; min-height: 104px; flex: none;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end;
    padding: 0 16px 12px; color: #000;
}
.rail-elbow-top .le-sub { font-size: 11px; font-weight: 600; letter-spacing: 2px; opacity: .7; }
.rail-elbow-top .le-title { font-size: 27px; font-weight: 700; line-height: .82; letter-spacing: 1px; text-transform: uppercase; }
.rail-nav { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; }
.rail-fill { flex: none; height: 14px; background: var(--brown-3); }
.rail-tag {
    background: var(--lilac); color: #000; height: 24px; flex: none;
    display: flex; align-items: center; justify-content: flex-end; padding: 0 14px;
    font-size: 12px; font-weight: 600; letter-spacing: 1.5px;
}
.rail-elbow-bot {
    background: var(--accent); border-radius: 0 0 0 60px; height: 38px; flex: none;
    display: flex; align-items: flex-start; justify-content: flex-end; padding: 8px 16px 0;
    color: #000; font-size: 12px; font-weight: 700; letter-spacing: 1.5px;
}

/* rail buttons */
.rail-btn, .nav-link {
    appearance: none; border: none; cursor: pointer; width: 100%;
    background: var(--gold); color: #000; min-height: 46px; flex: none;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end;
    padding: 5px 14px 7px; text-align: right;
    font-family: var(--font); transition: filter .12s;
}
.rail-btn:hover, .nav-link:hover { filter: brightness(1.16); color: #000; }
.rail-btn .rb-code, .nav-link .rb-code { font-size: 10px; font-weight: 600; letter-spacing: 1.5px; opacity: .6; }
.rail-btn .rb-label, .nav-link .rb-label { font-size: 19px; font-weight: 700; line-height: .85; text-transform: uppercase; letter-spacing: .5px; }
.rail-btn.orange { background: var(--salmon); } .rail-btn.gold { background: var(--gold); }
.rail-btn.lilac { background: var(--lilac); } .rail-btn.blue { background: var(--ice); }
.rail-btn.peri { background: var(--peri); }
.rail-btn.red { background: var(--red); }
.rail-btn.dim { opacity: .5; } .rail-btn.dim:hover { opacity: 1; }
.rail-btn.active, .nav-link.active { box-shadow: inset 0 0 0 3px #000; opacity: 1; }

.rail-divider { color: var(--text-mute); font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; padding: 8px 4px 2px; flex: none; }

/* chapter tree in rail */
.nav-chapter { flex: none; }
.nav-chapter > summary {
    list-style: none; cursor: pointer; background: var(--lilac); color: #000;
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 12px 6px 14px; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
}
.nav-chapter > summary::-webkit-details-marker { display: none; }
.nav-chapter > summary:hover { filter: brightness(1.12); }
.nav-chapter > summary .cnum { background: #000; color: var(--lilac); border-radius: 9px; padding: 0 7px; font-size: 12px; }
.nav-sections { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px; }
.nav-sections a {
    display: flex; gap: 7px; align-items: baseline; background: var(--card);
    color: var(--text); padding: 4px 10px; border-left: 3px solid var(--brown); font-size: 13px;
}
.nav-sections a .sid { color: var(--accent); font-weight: 600; min-width: 30px; }
.nav-sections a:hover { background: var(--card-2); color: #fff; }
.nav-sections a.active { background: var(--accent); color: #000; }
.nav-sections a.active .sid { color: #000; }

.rail .search-box { flex: none; display: flex; gap: 4px; }
.rail .search-box input {
    flex: 1; min-width: 0; background: var(--card); border: 2px solid var(--brown-2);
    color: var(--text); padding: 7px 12px; font-family: var(--font-body); font-size: 13px; border-radius: 0;
}
.rail .search-box input:focus { outline: none; border-color: var(--accent); }
.rail .search-box button { background: var(--accent); color: #000; border: none; font-family: var(--font); font-weight: 700; padding: 0 12px; cursor: pointer; }

/* ---------------- top bar ---------------- */
.topbar { grid-area: topbar; display: flex; gap: var(--gap); align-items: stretch; min-width: 0; }
.tb-title {
    background: var(--gold); color: #000; min-width: 160px; max-width: 42%;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
    padding: 10px 22px 12px; overflow: hidden;
}
.tb-title .tb-sub { font-size: 12px; font-weight: 600; letter-spacing: 2px; opacity: .7; }
.tb-title .tb-main { font-size: 27px; font-weight: 700; line-height: .84; letter-spacing: .5px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tb-status { flex: 1; min-width: 0; background: var(--brown-2); display: flex; flex-direction: column; justify-content: space-between; padding: 10px 20px 12px; }
.tb-status .tb-stat { display: flex; align-items: center; gap: 10px; color: var(--peri); font-size: 14px; font-weight: 600; letter-spacing: 2px; }
.tb-status .tb-stat .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--peri); animation: blink 1.4s steps(1) infinite; }
.tb-status .tb-node { color: #8f7a55; font-size: 13px; font-weight: 500; letter-spacing: 1.5px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-clock { background: var(--ice); color: #000; min-width: 190px; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; padding: 0 24px; border-radius: 0 26px 0 0; }
.tb-clock .tb-sd { font-size: 12px; font-weight: 600; letter-spacing: 1.5px; opacity: .7; }
.tb-clock .tb-time { font-size: 34px; font-weight: 700; line-height: .9; letter-spacing: 2px; font-variant-numeric: tabular-nums; }

/* ---------------- main ---------------- */
.main { grid-area: main; background: #000; overflow: auto; padding: 6px 10px 40px 4px; min-height: 0; }

/* ---------------- bottom bar ---------------- */
.botbar { grid-area: botbar; display: flex; gap: var(--gap); align-items: stretch; }
.botbar .bb-label { background: var(--lilac); color: #000; display: flex; align-items: center; padding: 0 22px; font-size: 17px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; }
.botbar .bb-mid { flex: 1; min-width: 0; background: #2a1d2a; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.botbar .bb-mid span:first-child { color: #9a7a9a; font-size: 13px; font-weight: 600; letter-spacing: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.botbar .bb-link { display: flex; align-items: center; gap: 9px; color: var(--lilac); font-size: 13px; font-weight: 600; letter-spacing: 2px; white-space: nowrap; }
.botbar .bb-link .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lilac); animation: blink 1.1s steps(1) infinite; }
.botbar .bb-rev { background: var(--ice); color: #000; display: flex; align-items: center; padding: 0 24px; font-size: 16px; font-weight: 700; letter-spacing: 1px; border-radius: 0 0 26px 0; white-space: nowrap; }

/* ---------------- typography / headings ---------------- */
h1, h2, h3, .lcars-head { font-family: var(--font); text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.main h1 { font-size: 2.2rem; margin: 4px 0 6px; line-height: .95; }
.main h2 { font-size: 1.5rem; color: var(--gold); }
.section-eyebrow { color: var(--lilac); font-size: .82rem; letter-spacing: 3px; text-transform: uppercase; }
.section-id-badge { color: #000; background: var(--accent); border-radius: 14px; padding: 2px 14px; font-weight: 700; }

/* section header: pill + extending bar */
.lcars-head { display: flex; align-items: flex-end; gap: 10px; }
.lcars-head::after { content: ""; flex: 1; height: 12px; background: var(--gold); border-radius: 6px; opacity: .4; }

/* ---------------- prose ---------------- */
.prose { font-family: var(--font-body); font-size: 1rem; line-height: 1.62; color: var(--text); max-width: 72ch; }
.prose p { margin: 0 0 1.05em; }
.prose h3 { font-size: 1.1rem; color: var(--gold); margin: 1.5em 0 .5em; }
.prose ul { margin: 0 0 1.1em; padding-left: 1.2em; }
.prose li { margin: .3em 0; }
.prose .xref { color: var(--ice); border-bottom: 1px dotted var(--ice); font-weight: 600; }
.prose .xref:hover { color: #fff; background: rgba(153,204,255,.18); }
.prose aside, .prose .sidebar, .prose .authors-note {
    display: block; background: #14110c; border-left: 4px solid var(--lilac);
    border-radius: 0 10px 10px 0; padding: 10px 16px; margin: 1.2em 0;
    color: var(--text-dim); font-size: .92rem; font-style: italic;
}

/* glossary inline tooltip */
.lcars-term { color: var(--gold); border-bottom: 1px dashed var(--brown); cursor: help; position: relative; }
.lcars-term:hover { color: #fff; }
.lcars-term::after {
    content: attr(data-def); position: absolute; left: 0; bottom: 130%;
    width: max-content; max-width: 320px; background: #14110c; color: var(--text);
    border: 2px solid var(--accent); border-radius: 12px; padding: 10px 14px;
    font-size: .82rem; line-height: 1.4; font-family: var(--font-body); font-weight: 400;
    text-transform: none; letter-spacing: 0; box-shadow: 0 8px 30px rgba(0,0,0,.7);
    opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .15s, transform .15s;
    z-index: 50; pointer-events: none;
}
.lcars-term:hover::after { opacity: 1; visibility: visible; transform: translateY(0); }

/* ---------------- buttons ---------------- */
.pillbtn {
    display: inline-flex; align-items: center; gap: 8px; background: var(--gold); color: #000; border: none;
    border-radius: 18px; font-family: var(--font); font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    padding: 9px 20px; cursor: pointer; font-size: .9rem;
}
.pillbtn.accentbtn { background: var(--accent); }
.pillbtn.lilac { background: var(--lilac); } .pillbtn.blue { background: var(--ice); } .pillbtn.gold { background: var(--gold); }
.pillbtn:hover { filter: brightness(1.12); color: #000; }

/* ---------------- library manual cards ---------------- */
.manual-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 16px; margin: 16px 0; }
.manual-card { display: grid; grid-template-columns: 150px 1fr; background: var(--card); overflow: hidden; border-left: 8px solid var(--accent); transition: transform .15s, background .15s; }
.manual-card:hover { transform: translateY(-3px); background: #141414; }
.manual-card img { width: 150px; height: 100%; object-fit: cover; object-position: center top; background: #fff; }
.mc-body { padding: 14px 18px; }
.mc-series { color: var(--accent); font-size: .76rem; letter-spacing: 2px; text-transform: uppercase; }
.mc-body h3 { margin: 2px 0; font-size: 1.3rem; color: var(--text); }
.mc-subject { color: var(--text-dim); font-size: .82rem; margin-bottom: 7px; }
.mc-body p { color: var(--text-dim); font-family: var(--font-body); font-size: .86rem; line-height: 1.45; margin: 0 0 9px; }
.mc-stats { display: flex; flex-wrap: wrap; gap: 7px; }
.mc-stats span { background: #1a1a1a; color: var(--text); border-radius: 6px; padding: 2px 9px; font-size: .7rem; text-transform: uppercase; }

/* hero */
.hero { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; margin-bottom: 20px; }
.hero .cover { width: 100%; border: 3px solid var(--accent); display: block; }
.hero h1 { font-size: 2.4rem; margin: .1em 0; }
.hero .kicker { color: var(--lilac); letter-spacing: 3px; text-transform: uppercase; }
.hero .lead p { font-family: var(--font-body); line-height: 1.55; color: var(--text); }

/* generic cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lcars-card { background: var(--card); padding: 14px 16px; border-left: 6px solid var(--accent); transition: transform .15s, background .15s; }
.lcars-card:hover { transform: translateY(-3px); background: var(--card-2); }
.lcars-card.lilac { border-left-color: var(--lilac); } .lcars-card.blue { border-left-color: var(--ice); } .lcars-card.gold { border-left-color: var(--gold); }
.lcars-card.red { border-left-color: var(--red); } .lcars-card.peri { border-left-color: var(--peri); }

/* spec/datasheet tables inside cleaned prose */
.prose table { border-collapse: collapse; margin: 16px 0; width: 100%; max-width: 760px; font-family: var(--font-body); }
.prose caption { text-align: left; color: var(--accent); font-family: var(--font); font-size: 1.05rem; font-weight: 700; letter-spacing: .5px; padding-bottom: 6px; text-transform: uppercase; }
.prose th, .prose td { border: 1px solid var(--brown); padding: 6px 13px; text-align: left; font-size: .92rem; vertical-align: top; }
.prose thead th, .prose th[scope="col"] { background: var(--brown-3); color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.prose tbody td:first-child, .prose th[scope="row"] { color: var(--text-dim); white-space: nowrap; font-weight: 600; }
.lcars-card h3 { margin: 0 0 6px; font-size: 1.1rem; }
.lcars-card p { margin: 0; color: var(--text-dim); font-family: var(--font-body); font-size: .88rem; }
.lcars-card .loc { color: var(--ice); font-size: .72rem; text-transform: uppercase; }

/* figures */
.fig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; }
.fig-card { background: var(--card); border: 2px solid var(--brown); overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; }
.fig-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.fig-card img { width: 100%; display: block; background: #fff; aspect-ratio: 3/4; object-fit: cover; object-position: top center; }
.fig-card .cap { padding: 8px 12px; font-size: .8rem; color: var(--text); font-family: var(--font-body); }
.fig-card .cap b { color: var(--accent); font-family: var(--font); }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.93); z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; }
.lightbox .lb-cap { color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.lightbox img { max-width: 92vw; max-height: 82vh; background: #fff; border: 3px solid var(--accent); }
.lightbox .lb-close { position: absolute; top: 20px; right: 26px; background: var(--red); color: #000; border: none; border-radius: 18px; font-family: var(--font); font-weight: 700; padding: 8px 18px; cursor: pointer; text-transform: uppercase; }

/* related / cross-ref */
.related-box { margin: 28px 0 0; background: #0a0a0a; border-radius: 0 0 0 0; padding: 14px 18px; border-left: 6px solid var(--ice); }
.related-box h3 { margin: 0 0 10px; color: var(--ice); }
.related-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.related-item { display: flex; flex-direction: column; gap: 2px; background: var(--card); padding: 10px 12px; border-left: 4px solid var(--accent); }
.related-item:hover { background: var(--card-2); }
.ri-manual { color: var(--accent); font-size: .7rem; letter-spacing: 1px; text-transform: uppercase; }
.ri-title { color: var(--text); font-size: .9rem; }
.ri-reason { color: var(--text-dim); font-family: var(--font-body); font-size: .78rem; }

/* explorer */
.ship-svg-wrap { background: #06060a; border: 2px solid var(--brown); padding: 10px; margin: 14px 0; }
.deck-layout { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.deck-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow-y: auto; }
.deck-row { display: flex; align-items: center; gap: 10px; cursor: pointer; background: var(--card); padding: 6px 12px; border-left: 5px solid var(--ice); }
.deck-row:hover, .deck-row.active { background: var(--card-2); border-left-color: var(--accent); }
.deck-row .dn { font-weight: 700; color: var(--accent); min-width: 58px; }
.deck-row .dname { color: var(--text); font-size: .9rem; }
.deck-row .dsec { margin-left: auto; font-size: .7rem; color: var(--text-mute); text-transform: uppercase; }
.deck-detail { background: var(--card); padding: 18px; border-left: 6px solid var(--accent); position: sticky; top: 0; }
.deck-detail .loc { color: var(--ice); font-size: .72rem; text-transform: uppercase; }
.system-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 10px; }
.system-cell { background: var(--card); padding: 12px 14px; border-left: 5px solid var(--lilac); cursor: pointer; }
.system-cell:hover { background: var(--card-2); }
.system-cell h4 { margin: 0 0 4px; font-family: var(--font); color: var(--gold); text-transform: uppercase; font-size: .95rem; }
.system-cell p { margin: 0; font-family: var(--font-body); font-size: .8rem; color: var(--text-dim); }
.system-cell .loc { color: var(--ice); font-size: .72rem; text-transform: uppercase; }

/* glossary */
.gloss-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.gloss-item { background: var(--card); padding: 14px 16px; border-left: 5px solid var(--accent); }
.gloss-item h4 { margin: 0 0 4px; color: var(--accent); text-transform: uppercase; }
.gloss-item .ab { color: #000; background: var(--accent); border-radius: 7px; padding: 0 7px; font-size: .72rem; margin-left: 6px; }
.gloss-item p { margin: 0; color: var(--text-dim); font-family: var(--font-body); font-size: .88rem; line-height: 1.45; }
.gloss-item a { font-size: .78rem; text-transform: uppercase; }
.alpha-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.alpha-bar a { background: var(--lilac); color: #000; border-radius: 8px; padding: 3px 10px; font-weight: 700; }

/* search */
.search-box { display: flex; gap: 6px; }
.search-result { background: var(--card); padding: 12px 16px; margin-bottom: 9px; border-left: 5px solid var(--accent); display: block; }
.search-result:hover { background: var(--card-2); }
.search-result .sr-badge { background: var(--accent); color: #000; border-radius: 7px; padding: 1px 8px; font-size: .7rem; text-transform: uppercase; }
.search-result .sr-id { color: var(--accent); font-weight: 700; }
.search-result .sr-title { color: var(--text); text-transform: uppercase; }
.search-result .sr-snip { color: var(--text-dim); font-family: var(--font-body); font-size: .88rem; margin-top: 4px; }
.search-result mark { background: var(--accent); color: #000; padding: 0 2px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* misc */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; border-top: 2px solid var(--brown); padding-top: 16px; }
.pager a { flex: 1; background: var(--card); padding: 12px 16px; border-right: 5px solid var(--accent); }
.pager a.next { text-align: right; border-right: none; border-left: 5px solid var(--accent); }
.pager a .lbl { display: block; color: var(--lilac); font-size: .75rem; letter-spacing: 2px; text-transform: uppercase; }
.pager a .ttl { color: var(--text); }
.muted { color: var(--text-dim); font-family: var(--font-body); }
.tagrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tag { background: #1a1a1a; color: var(--text); border-radius: 8px; padding: 3px 10px; font-size: .78rem; text-transform: uppercase; cursor: pointer; }
.tag.on { background: var(--accent); color: #000; }

#blazor-error-ui { position: fixed; bottom: 0; left: 0; width: 100%; background: var(--red); color: #000; padding: 10px 20px; z-index: 2000; display: none; font-family: var(--font); }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ---------------- responsive: drop the fixed cockpit on small screens ---------------- */
@media (max-width: 920px) {
    html, body { overflow: auto; }
    .lcars { position: static; display: block; padding: 6px; height: auto; }
    .rail { flex-direction: column; }
    .rail-elbow-top { border-radius: 30px 0 0 0; min-height: 70px; }
    .topbar, .botbar { margin-top: 6px; }
    .main { overflow: visible; }
    .hero, .manual-grid, .deck-layout { grid-template-columns: 1fr; }
}
