/* ============================================================
   Jellystructure — app shell (production)
   Builds on wf.css tokens. Full-viewport left-sidebar shell.
   ============================================================ */

.app-body { margin: 0; min-height: 100vh; }

/* minmax(0, 1fr), not bare 1fr (== minmax(auto, 1fr)): the main column is a plain block with no
   overflow/min-width of its own, so any unwrapped long string deep inside it (a series title, a raw
   filename) would otherwise become that column's automatic minimum size and blow the whole grid — and
   the viewport — wider than the sidebar + content should ever be.
   RESTORED 2026-07-31 after a design-tool sync silently reverted this a second time — see the
   reference memory note on diffing design/app/*.css after every sync before touching this again. */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

/* ---------- sidebar ---------- */
.app-side {
  position: sticky; top: 0; align-self: start; height: 100vh;
  background: var(--fill-2);
  border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 2px; overflow: auto;
}
[data-dir="aurora"] .app-side { background: linear-gradient(180deg, var(--fill-2), var(--bg)); }

.app-side .logo {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.18rem;
  padding: 4px 8px 18px; display: flex; align-items: center; gap: 11px; letter-spacing: -.01em;
}
.app-side .logo .brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  filter: drop-shadow(0 4px 14px rgba(123,110,240,.45));
}

.app-side a.nav {
  display: flex; align-items: center; gap: 11px; justify-content: space-between;
  padding: 9px 11px; border-radius: var(--radius-s);
  color: var(--ink-soft); text-decoration: none; font-size: .92rem; font-weight: 500;
  position: relative; transition: background .15s ease, color .15s ease;
}
.app-side a.nav .l { display: flex; align-items: center; gap: 11px; }
.app-side a.nav .ico { width: 19px; height: 19px; flex: none; display: inline-flex; align-items: center; justify-content: center; color: currentColor; opacity: .85; }
.app-side a.nav .ico svg { width: 100%; height: 100%; }
.app-side a.nav:hover { background: var(--fill-3); color: var(--ink); text-decoration: none; }
.app-side a.nav.active { color: var(--ink); background: var(--hi-soft); font-weight: 600; }
.app-side a.nav.active .ico { opacity: 1; color: var(--acc-ink); }
.app-side a.nav.active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--grad);
}
.app-side a.nav .count {
  font-size: .72rem; background: var(--bad); color: #fff; border-radius: 20px;
  padding: 1px 8px; font-weight: 600; min-width: 22px; text-align: center;
}

.app-side .group-label { padding-top: 16px; }

/* Phase 148 — collapsible nav groups. .group-label doubles as a <button> (group-toggle) now,
   so it needs its browser button chrome reset on top of the plain-label typography above.
   RE-ADDED 2026-07, RESTORED AGAIN 2026-07-31 after a second design-tool sync overwrote this
   file and silently dropped it — see the reference memory note on syncing before touching this
   block again. */
.app-side .nav-group { display: flex; flex-direction: column; }
.app-side .group-label.group-toggle {
  display: flex; align-items: center; width: 100%;
  background: transparent; border: 0; cursor: pointer;
  text-align: left; font-family: inherit; border-radius: var(--radius-s);
  transition: background .15s ease, color .15s ease;
}
.app-side .group-label.group-toggle:hover { background: var(--fill-3); color: var(--ink); }
.app-side .group-label .grp-chev { margin-left: auto; flex: none; opacity: .6; transition: transform .18s ease; }
.app-side .nav-group.collapsed .grp-chev { transform: rotate(-90deg); }
.app-side .nav-group-items { display: flex; flex-direction: column; overflow: hidden; }
.app-side .nav-group.collapsed .nav-group-items { display: none; }

.app-side .grow { flex: 1; min-height: 12px; }

.app-side .status {
  font-size: .8rem; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-s); background: var(--fill); display: flex; flex-direction: column; gap: 7px;
}
.app-side .status .row { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); }

/* three-way theme picker (Light / Dark / System) */
.theme-seg {
  margin-top: 12px; display: flex; gap: 3px; padding: 3px;
  border: 1px solid var(--line-2); border-radius: var(--radius-s); background: var(--fill-2);
}
.theme-seg button {
  flex: 1; height: 28px; border: none; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--ink-soft);
  font-family: 'Sora', sans-serif; font-size: .76rem; font-weight: 600;
  transition: color .18s ease, background .18s ease;
}
.theme-seg button:hover { color: var(--ink); }
.theme-seg button.on { background: var(--hi-soft); color: var(--acc-ink); box-shadow: inset 0 0 0 1px rgba(123,110,240,.3); }

/* ---------- main ---------- */
.app-main2 { padding: 32px 38px 140px; max-width: 1240px; }
.app-main2.wide { max-width: 1480px; }
/* full-height app page: no page scroll, inner panes scroll themselves */
.app-main2.app-flush { padding: 0; max-width: none; height: 100vh; overflow: hidden; }

/* ---------- mobile top bar + nav drawer (injected by app-shell.js) ---------- */
.app-topbar { display: none; }
.nav-backdrop { display: none; }
.app-topbar .burger {
  width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--fill-3); color: var(--ink); cursor: pointer;
}
.app-topbar .burger svg { width: 20px; height: 20px; }
.app-topbar .burger:active { background: var(--hi-soft); border-color: var(--hi); }
.app-topbar .tb-logo { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: 9px; }
.app-topbar .tb-logo .brand-mark { width: 24px; height: 24px; flex: none; border-radius: 7px; filter: drop-shadow(0 3px 10px rgba(123,110,240,.42)); }

.pagebar { display: flex; align-items: center; gap: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.pagebar h1 { font-size: 2rem; margin: 0; }
.pagebar .spacer { flex: 1; }
.crumb { font-size: .85rem; color: var(--ink-soft); }
.crumb a { color: var(--ink-soft); }
.page-sub { color: var(--ink-soft); max-width: 78ch; margin: 2px 0 26px; font-size: .98rem; line-height: 1.6; }
.backrow { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

/* ---------- floating dock stack (bottom-right) ---------- */
/* Both the scan dock and the needs-attention dock live in this flex column so
   they always stack with a consistent gap, regardless of collapsed/expanded
   or hidden state (no hardcoded offsets to drift). */
#dock-stack {
  position: fixed; right: 24px; bottom: 24px; z-index: 80;
  display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 14px;
  pointer-events: none;
}
#dock-stack > .dock { position: static; right: auto; bottom: auto; pointer-events: auto; }

/* ---------- ambient scan dock ---------- */
.dock {
  position: fixed; right: 24px; bottom: 24px; width: 340px; z-index: 80;
  background: var(--card-bg); -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
  color: var(--ink); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.dock::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--grad); opacity: var(--ambient);
}
.dock .dock-head { display: flex; align-items: center; gap: 9px; padding: 13px 15px; cursor: pointer; }
.dock .dock-head b { font-family: 'Space Grotesk', sans-serif; white-space: nowrap; font-size: .95rem; }
.dock .dock-head .kbd { background: transparent; }
.dock .dock-body { padding: 0 15px 15px; }
.dock .mono { color: var(--ink-soft); }
.dock.collapsed .dock-body { display: none; }
.dock.dock-hidden { display: none; }
.dock .dock-head .dock-close { background: transparent; cursor: pointer; opacity: .65; transition: opacity .15s, color .15s; }
.dock .dock-head .dock-close:hover { opacity: 1; color: var(--bad); }
.dock a { color: var(--acc-ink); }

.dock-log { position: fixed; right: 24px; bottom: 160px; width: 360px; z-index: 79; display: none; }
.dock-log.open { display: block; }

/* ---------- floating triage (needs-attention) dock ---------- */
.triage-dock::before { background: var(--bad); opacity: 1; }
.triage-dock .ico-attn { width: 20px; height: 20px; flex: none; display: inline-flex; color: var(--bad); }
.triage-dock .ico-attn svg { width: 100%; height: 100%; }
.triage-dock .td-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.02rem; }
.triage-dock .td-item { padding: 2px 0 0; }
.triage-dock .btn.sm { padding: 6px 10px; }

/* ---------- dashboard stats ---------- */
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat {
  background: var(--card-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: var(--card-bd); border-radius: var(--radius); box-shadow: var(--shadow-s);
  padding: 18px 20px; position: relative; overflow: hidden; transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); font-weight: 600; }
.stat .v { font-family: 'Space Grotesk', sans-serif; font-size: 2.3rem; font-weight: 600; line-height: 1.1; margin-top: 4px; letter-spacing: -.02em; }
.stat.alert { border-color: rgba(255,111,97,.45); }
.stat.alert::after {
  content: ''; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, var(--bad-soft), transparent 70%);
}
.stat.alert .v { color: var(--bad); }
[data-theme="light"] .stat.alert .v { color: #c23b2d; }
.stat.alert:hover { box-shadow: 0 10px 30px rgba(255,111,97,.18); }

/* ---------- library poster grid ---------- */
.poster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px; }
.poster { cursor: pointer; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 8px; }
.poster .imgslot { height: 224px; transition: transform .2s ease, box-shadow .25s ease, outline-color .2s ease;
  outline: 2px solid transparent; outline-offset: 2px; }
.poster:hover { text-decoration: none; }
.poster:hover .imgslot { transform: translateY(-4px); box-shadow: 0 14px 32px rgba(0,0,0,.45); outline-color: var(--hi); }
.poster .ttl { font-size: .92rem; font-weight: 600; line-height: 1.2; }
.poster .yr { font-size: .78rem; color: var(--ink-soft); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.poster .flags { display: flex; gap: 5px; flex-wrap: wrap; }
/* varied poster hues so the grid reads as artwork, not repeats */
.poster:nth-child(8n+1) .imgslot::before { filter: hue-rotate(0deg); }
.poster:nth-child(8n+2) .imgslot::before { filter: hue-rotate(40deg); }
.poster:nth-child(8n+3) .imgslot::before { filter: hue-rotate(85deg); }
.poster:nth-child(8n+4) .imgslot::before { filter: hue-rotate(130deg); }
.poster:nth-child(8n+5) .imgslot::before { filter: hue-rotate(175deg); }
.poster:nth-child(8n+6) .imgslot::before { filter: hue-rotate(220deg); }
.poster:nth-child(8n+7) .imgslot::before { filter: hue-rotate(270deg); }
.poster:nth-child(8n+8) .imgslot::before { filter: hue-rotate(310deg); }

/* ---------- in-page tab strip ---------- */
.tabs2 { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tabs2 a, .tabs2 span {
  cursor: pointer; font-size: .9rem; font-weight: 600; text-decoration: none; color: var(--ink-soft);
  padding: 9px 4px; margin-bottom: -1px; border-bottom: 2px solid transparent; transition: color .2s ease, border-color .2s ease;
}
.tabs2 a:hover, .tabs2 span:hover { color: var(--ink); text-decoration: none; }
.tabs2 .on { color: var(--ink); border-bottom-color: var(--hi); }

/* override card */
.override {
  border: 1px solid rgba(63,182,245,.4); background: var(--info-soft);
  border-radius: var(--radius); padding: 16px 18px;
}

.kicker2 { font-family: 'Space Grotesk', sans-serif; font-size: .9rem; color: var(--acc-ink); font-weight: 600; }

/* ---------- command palette (⌘K) ---------- */
.cmdk-pill {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 8px; cursor: pointer;
  padding: 8px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-s);
  background: var(--fill-2); color: var(--ink-soft); font-family: 'Sora', sans-serif; font-size: .85rem;
}
.cmdk-pill:hover { border-color: var(--hi); color: var(--ink); }
.cmdk-pill .kbd { margin-left: auto; }
#cmd-palette { position: fixed; inset: 0; z-index: 130; display: none; justify-content: center; align-items: flex-start;
  background: rgba(8,10,16,.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); padding-top: 12vh; }
#cmd-palette.open { display: flex; }
#cmd-palette .cmdp-box { width: 560px; max-width: 92vw; background: var(--fill); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
#cmdp-input { width: 100%; border: none; background: transparent; color: var(--ink); font-family: 'Sora',sans-serif;
  font-size: 1.05rem; padding: 16px 18px; border-bottom: 1px solid var(--line); outline: none; box-sizing: border-box; }
#cmdp-list { max-height: 52vh; overflow: auto; padding: 6px; }
.cmdp-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-s); cursor: pointer; }
.cmdp-item.sel, .cmdp-item:hover { background: var(--hi-soft); }
.cmdp-ico { width: 17px; height: 17px; color: var(--ink-soft); flex: none; display: inline-flex; }
.cmdp-ico svg { width: 100%; height: 100%; }
.cmdp-label { flex: 1; font-size: .92rem; }
.cmdp-sub { color: var(--ink-soft); font-size: .8rem; }
.cmdp-kind { font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); flex: none; }
.cmdp-empty { padding: 16px; text-align: center; color: var(--ink-soft); font-size: .9rem; }

@media (max-width: 980px) {
  /* show the mobile chrome */
  .app-topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 70; height: 54px; padding: 0 12px;
    background: linear-gradient(180deg, var(--fill-2), var(--bg));
    border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }

  .shell { grid-template-columns: minmax(0, 1fr); }

  /* sidebar becomes an off-canvas drawer */
  .app-side {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; height: 100dvh;
    width: 274px; max-width: 84vw; z-index: 95;
    transform: translateX(-100%); transition: transform .26s cubic-bezier(.4,0,.2,1);
  }
  body.nav-open .app-side { transform: none; box-shadow: 16px 0 50px rgba(0,0,0,.55); }

  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 90;
    background: rgba(8,10,16,.62); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .26s ease;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  /* Phase 138 (FR-DB1) — "Recently processed" + "Quick actions" are desktop-only on the Dashboard.
     Guarded repo-side by scripts/check-mobile-css.sh — keep this exact rule. */
  .dash-sidecol { display: none; }

  .app-main2 { padding: 22px 18px 120px; }
  .app-main2.app-flush { height: calc(100vh - 54px); height: calc(100dvh - 54px); }
  .statgrid { grid-template-columns: repeat(2,1fr); }
  .pagebar h1 { font-size: 1.5rem; }
}
