/* ═════════ APP SHELL ═════════
   A spine of views + one open stage + a details panel that only exists when there is something to show.
   The palette (⌘K) is the scalable entry point, so the rail never has to hold everything. */
.app {
  position: fixed; inset: 0; z-index: 10; display: grid; background: var(--bg);
  grid-template-columns: var(--rail-w) minmax(0, 1fr) 0;
  grid-template-rows: 60px minmax(0, 1fr);
  grid-template-areas: 'rail strip strip' 'rail stage dossier';
  clip-path: circle(0 at 50% 50%);
  transition: clip-path 1.1s var(--ease-io), grid-template-columns .6s var(--ease-io);
}
.app.has-dossier { grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--dossier-w); }
.app.is-open { clip-path: circle(150vmax at 50% 50%); }
.app.is-closing { clip-path: circle(0 at 50% 50%); transition-duration: .7s, .6s; }
.app.is-open, .app.is-closing { z-index: 25; }   /* above the intro (20) so its circle reveal is seen, below the lock (30) */

/* entrance — three beats only: chrome, content, detail */
.app.is-open .rail, .app.is-open .strip { animation: fade .8s var(--ease-out) both .3s; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ── Rail ── */
.rail { grid-area: rail; display: flex; flex-direction: column; border-right: 1.5px solid var(--line-strong); min-height: 0; }
.rail__brand { display: grid; place-items: center; height: 60px; flex: none; border-bottom: 1.5px solid var(--line-strong); }
.rail__brand svg { width: 28px; height: 28px; transition: transform .4s var(--ease-out); } .rail__brand:hover svg { transform: rotate(-8deg) scale(1.1); }
.rail__k { flex: none; height: 44px; border-bottom: 1.5px solid var(--line-strong); color: var(--ink-3); transition: color .2s, background .2s; }
.rail__k kbd { border: 1.5px solid var(--line-strong); padding: 3px 7px; letter-spacing: .06em; } .rail__k:hover { color: var(--ink); background: var(--bg-3); }
.rail__views { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; }
.mode { flex: 1 1 auto; min-height: auto; text-decoration: none; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; align-items: center; gap: 8px; padding: 12px 0;
  border-bottom: 1.5px solid var(--line-strong); color: var(--ink-2); position: relative; transition: color .2s, background .2s; }
.mode em { font: 500 11px var(--font-mono); font-style: normal; letter-spacing: .1em; color: var(--ink-3); }
.mode span { writing-mode: vertical-rl; transform: rotate(180deg); font: 800 12px/1 var(--font-display); letter-spacing: .04em; text-transform: uppercase; }
.mode b { min-width: 26px; padding: 3px 0; text-align: center; font: 700 11px var(--font-mono); border: 1.5px solid currentColor; }

.mode:hover { color: var(--ink); background: var(--bg-3); } .mode:active { background: var(--bg-3); transform: scale(.985); }
.mode.is-on { background: var(--hit); color: var(--on-hit); } .mode.is-on em { color: var(--on-hit); }
.rail__foot { flex: none; display: grid; justify-items: center; gap: 12px; padding: 14px 0 16px; border-top: 1.5px solid var(--line-strong); }
.theme-switch--v { flex-direction: column; } .theme-switch--v button { width: 38px; padding: 10px 0; text-align: center; }
.rail__lock { color: var(--ink-3); padding: 4px 6px; } .rail__lock:hover { color: var(--alert); }

.l-short { display: none; font-style: normal; } .l-full { font-style: normal; }
/* Eight tiles never fit at full names below ~1100px of height (Dashboards/Setup would sit under a hidden scrollbar): short names, tiles share the column. */
@media (max-height: 1100px) and (min-width: 761px) { .l-full { display: none; } .l-short { display: inline; } .mode { padding: 6px 0; } .mode em { display: none; } .rail__views { scrollbar-width: thin; } }
@media (max-height: 880px) and (min-width: 761px) { .mode em { display: none; } .mode { padding: 7px 0; gap: 3px; } .mode span { font-size: 10px; letter-spacing: .02em; } .mode b { padding: 2px 0; min-width: 22px; } .rail__foot { padding: 6px 0; gap: 4px; } .theme-switch--v button { padding: 7px 0; } .rail__brand { height: 48px; } .rail__k { height: 32px; } }
@media (max-height: 700px) and (min-width: 761px) { .mode { padding: 3px 0; gap: 2px; } .mode span { font-size: 9px; letter-spacing: 0; } .mode b { padding: 1px 0; min-width: 20px; font-size: 10px; } .rail__brand { height: 40px; } .rail__k { height: 26px; } .rail__foot { padding: 4px 0; gap: 3px; } .theme-switch--v button { padding: 5px 0; } }
/* ── Strip ── */
.strip { grid-area: strip; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 28px; border-bottom: 1.5px solid var(--line-strong); min-width: 0; }
.strip__crumb { display: flex; align-items: baseline; gap: 12px; min-width: 0; white-space: nowrap; }
.strip__word { font: 900 18px/1 var(--font-display); letter-spacing: -.02em; } .strip__word i { font-style: normal; color: transparent; -webkit-text-stroke: 1.5px var(--ink); }
.strip__sep { color: var(--ink-3); } #crumb { color: var(--ink); font-weight: 700; }
.strip__r { display: flex; gap: 22px; color: var(--ink-2); white-space: nowrap; }
.strip__r .on { display: flex; align-items: center; gap: 8px; color: var(--ink); } .strip__r .on i { width: 7px; height: 7px; background: var(--ok); animation: blink 1.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.strip__tools { display: none; align-items: center; gap: 10px; } .strip__lock { color: var(--ink-3); padding: 6px; }

/* ── Stage / views ── */
.stage { grid-area: stage; position: relative; overflow: hidden; min-width: 0; }
.view { position: absolute; inset: 0; opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity .35s, transform .5s var(--ease-out), visibility 0s .35s; }
.view.is-on { opacity: 1; visibility: visible; transform: none; transition: opacity .45s .1s, transform .6s var(--ease-out) .1s, visibility 0s; }

/* ── Details panel — occupies space only when it has something to say ── */
.dossier { grid-area: dossier; position: relative; min-width: 0; overflow: hidden; }
.dossier__card { --edge: var(--line-strong); --fill: var(--bg-2); position: absolute; top: 18px; bottom: 18px; right: 18px; width: calc(var(--dossier-w) - 36px); transform: translateX(20px); opacity: 0; transition: transform .6s var(--ease-out), opacity .4s; }
.app.has-dossier .dossier__card { transform: none; opacity: 1; transition-delay: .15s; }
.dossier__x { position: absolute; z-index: 3; top: 10px; right: 12px; padding: 6px 8px; color: var(--ink-3); } .dossier__x:hover { color: var(--ink); }
.dossier__in { height: 100%; overflow-y: auto; padding: 26px 24px 28px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.dossier__in.swap > * { animation: rise .5s var(--ease-out) both; }
.dossier__in.swap > *:nth-child(2) { animation-delay: .04s; } .dossier__in.swap > *:nth-child(3) { animation-delay: .08s; } .dossier__in.swap > *:nth-child(4) { animation-delay: .12s; } .dossier__in.swap > *:nth-child(n+5) { animation-delay: .16s; }
.d-top { display: flex; justify-content: space-between; align-items: center; padding-right: 74px; } .d-id { color: var(--ink-2); }
.tag { padding: 5px 9px; font: 700 10px var(--font-mono); letter-spacing: .16em; text-transform: uppercase; background: var(--c, var(--ink)); color: var(--bg); }
.tag[data-sev='crit'] { --c: var(--alert); color: var(--bg); } .tag[data-sev='high'] { --c: var(--hit); color: var(--on-hit); } .tag[data-sev='med'] { --c: var(--blue); color: var(--bg); } .tag[data-sev='low'] { --c: var(--ink-3); color: var(--bg); } .tag[data-sev='ok'] { --c: var(--ok); color: var(--bg); }
[data-theme='light'] .tag[data-sev='crit'], [data-theme='light'] .tag[data-sev='med'] { color: #fff; } [data-theme='light'] .tag[data-sev='low'] { color: #fff; } [data-theme='light'] .tag[data-sev='ok'] { color: #fff; }
.d-title { font: 700 clamp(19px, 1.7vw, 23px)/1.2 var(--font-display); letter-spacing: -.03em; margin: 16px 0 18px; text-wrap: balance; }
.d-meta { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--line-strong); }
.d-meta div { padding: 9px 11px; border-right: 1.5px solid var(--line-strong); } .d-meta div:last-child { border: 0; }
.d-meta span { display: block; color: var(--ink-3); font-size: 10px; } .d-meta b { font: 600 14px var(--font-body); }
.d-h { color: var(--ink-3); margin: 22px 0 8px; } .d-p { font-size: 15px; line-height: 1.55; }
.d-ev { list-style: none; padding: 0; display: grid; gap: 6px; font: 400 12.5px/1.45 var(--font-mono); color: var(--ink-2); }
.d-ev li { padding-left: 18px; position: relative; } .d-ev li::before { content: '>'; position: absolute; left: 0; color: var(--blue-hot); font-weight: 700; } [data-theme='light'] .d-ev li::before { color: var(--blue); }
.d-conf { display: flex; align-items: center; gap: 12px; } .d-conf .snr__bar { height: 10px; } .d-conf b { font: 700 13px var(--font-mono); }
.note { margin-top: 22px; display: grid; grid-template-columns: 32px 1fr; gap: 14px; align-items: start; padding: 15px; background: var(--bg-3); border-left: 4px solid var(--hit); } [data-theme='light'] .note { border-left-color: var(--blue); }
.note svg { width: 32px; height: 32px; } .note p { font-size: 14.5px; line-height: 1.5; min-height: 3em; }
.note p::after { content: '▍'; margin-left: 2px; color: var(--hit); animation: blink 1s steps(2) infinite; } [data-theme='light'] .note p::after { color: var(--blue); }
.d-act { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ── Palette ── */
.palette { position: fixed; inset: 0; z-index: 50; display: grid; justify-items: center; align-items: start; padding: 14vh 16px 0; background: color-mix(in srgb, var(--bg) 72%, transparent); animation: fade .2s both; }
.palette__box { --edge: var(--ink); --fill: var(--bg-2); width: min(560px, 100%); animation: rise .35s var(--ease-out) both; }
.palette__in { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1.5px solid var(--line-strong); } .palette__in .mono { color: var(--hit); font-size: 16px; } [data-theme='light'] .palette__in .mono { color: var(--blue); }
.palette__in input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; font: 500 17px var(--font-body); } .palette__in kbd { border: 1.5px solid var(--line-strong); padding: 2px 7px; color: var(--ink-3); }
#palette-list { list-style: none; padding: 6px; max-height: 44vh; overflow-y: auto; }
#palette-list li { display: flex; justify-content: space-between; gap: 16px; padding: 11px 12px; cursor: pointer; font-size: 15px; }
#palette-list li small { font: 500 11px var(--font-mono); color: var(--ink-3); letter-spacing: .1em; white-space: nowrap; }
#palette-list li[aria-selected='true'] { background: var(--hit); color: var(--on-hit); } #palette-list li[aria-selected='true'] small { color: var(--on-hit); }

/* ── Toast ── */
.toast { position: fixed; z-index: 60; left: 50%; bottom: 28px; translate: -50% 30px; opacity: 0; padding: 12px 18px; background: var(--ink); color: var(--bg); pointer-events: none; transition: .45s var(--ease-out); max-width: calc(100vw - 32px); }
.toast.is-on { translate: -50% 0; opacity: 1; }

/* ═════ Responsive ═════ */
/* Tablet & small laptop: the details panel floats over the stage instead of squeezing it */
@media (max-width: 1100px) {
  .app, .app.has-dossier { grid-template-columns: var(--rail-w) minmax(0, 1fr); grid-template-areas: 'rail strip' 'rail stage'; }
  .dossier { position: fixed; z-index: 15; top: 60px; right: 0; bottom: 0; width: min(420px, 94vw); overflow: visible; pointer-events: none; }
  .dossier__card { top: 12px; bottom: auto; max-height: calc(100vh - 84px); right: 12px; width: auto; left: 0; pointer-events: none; display: flex; }
  .dossier__in { height: auto; flex: 1; min-height: 0; }
  .app.has-dossier .dossier__card { pointer-events: auto; }
}
/* Phone: the spine becomes a bottom tab bar; details become a bottom sheet */
@media (max-width: 760px) {
  :root { --cut: 10px; }
  .app, .app.has-dossier { grid-template-columns: minmax(0, 1fr); grid-template-rows: 52px minmax(0, 1fr) calc(60px + env(safe-area-inset-bottom)); grid-template-areas: 'strip' 'stage' 'rail'; }
  .rail { flex-direction: row; border-right: 0; border-top: 1.5px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom); background: var(--bg); position: relative; z-index: 20; }
  .rail__brand, .rail__foot { display: none; }
  .rail__views { flex-direction: row; overflow: visible; flex: 1; }
  .mode { flex: 1; height: auto; min-height: 60px; grid-template-rows: none; grid-auto-flow: row; gap: 3px; padding: 8px 0; border-bottom: 0; border-right: 1.5px solid var(--line-strong); align-content: center; }
  .mode span { writing-mode: horizontal-tb; transform: none; font-size: 9px; letter-spacing: -.01em; } .l-full { display: none; } .l-short { display: inline; } .mode em { display: none; }
  .mode b { position: absolute; top: 6px; right: 8px; min-width: 0; padding: 1px 5px; font-size: 10px; border-width: 1px; } .mode:not(:has(b))::after { display: none; }
  .rail__k { display: none; } .mode b.dotwrap { border: 0; top: 8px; right: 12px; }
  /* eight destinations do not fit a phone width without crushing the names: the bar scrolls sideways, the next tab peeks in, the active one is kept in view */
  .rail__views { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-snap-type: x proximity; overscroll-behavior-x: contain; } .rail__views::-webkit-scrollbar { display: none; }
  .mode { flex: 1 0 auto; min-width: 66px; padding-inline: 4px; scroll-snap-align: center; } .rail.has-more-r::after, .rail.has-more-l::before { content: ''; position: absolute; top: 0; bottom: 0; width: 22px; pointer-events: none; z-index: 2; } .rail.has-more-r::after { right: 0; background: linear-gradient(90deg, transparent, var(--bg)); } .rail.has-more-l::before { left: 0; background: linear-gradient(270deg, transparent, var(--bg)); }
  .strip { padding: 0 12px; gap: 8px; } .strip__sep, #crumb, .strip__conf, .pill__t { display: none; } .strip__crumb { flex: none; } .strip__link { flex: none; margin-left: auto; } .strip__r { display: none; } .strip__tools { display: flex; } .strip__word { font-size: 15px; } .strip__tools .theme-switch button { padding: 8px 12px; }
  .dossier { top: auto; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); width: auto; height: min(68vh, 560px); }
  .dossier__card { left: 8px; right: 8px; top: 0; bottom: 8px; max-height: none; transform: translateY(24px); }
  .dossier__in { height: 100%; }
  .app.has-dossier .dossier__card { transform: none; }
  .dossier__in { padding: 22px 18px 24px; }
  .toast { bottom: 84px; }
}
@media (prefers-reduced-motion: reduce) { .app, .app *, .palette, .palette * { animation-duration: .01s !important; transition-duration: .01s !important; } }
