/* shell.css — top bar, rail, content area, footer, drawer host, modal, toasts, palette, menus.
   Heights use --app-h (100vh minus --app-inset-bottom, tokens.css), so a docked strip never covers the composer/footer. */

.shell { height: var(--app-h); display: grid; grid-template-rows: var(--topbar-h) 1fr; }

/* ---------------- top bar ---------------- */
.topbar {
  height: var(--topbar-h); background: var(--header); color: var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px;
  position: relative; z-index: 30;
  box-shadow: 0 1px 0 var(--topbar-line), 0 3px 6px -2px rgba(38,30,20,.10);
}
.tb-brand { display: flex; align-items: center; min-width: 0; }
.lockup { display: flex; align-items: center; gap: 9px; color: var(--ink); }
.lockup img { width: 27px; height: 27px; }
.lockup .w { display: flex; flex-direction: column; line-height: 1; }
.lockup .w b { font-weight: 800; font-size: 13px; letter-spacing: .26em; }
.lockup .w small { font-family: var(--mono); font-size: 7.4px; letter-spacing: .42em; color: var(--mut2); margin-top: 3px; }
.wordmark { margin-left: 14px; padding-left: 15px; border-left: 1px solid rgba(0,0,0,.20); display: flex; align-items: center; height: 30px; }
.wordmark .twm { font-family: var(--script); font-size: 38px; line-height: 1; position: relative; top: 5px; letter-spacing: .01em; color: var(--ink); }
.tb-right { display: flex; align-items: center; gap: 16px; }
.viewas { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid rgba(0,0,0,.43); border-radius: var(--r-pill); padding: 6px 13px; font: 600 12.5px var(--sans); background: transparent; color: var(--ink); }
.viewas:hover, .viewas[aria-expanded="true"] { background: rgba(0,0,0,.06); }
.viewas svg { width: 14px; height: 14px; }
.tbicon { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--ink); padding: 6px 6px; border-radius: 9px; position: relative; }
.tbicon:hover, .tbicon[aria-expanded="true"] { background: rgba(0,0,0,.06); }
.tbicon svg { width: 17px; height: 17px; }
.tbicon .unread { position: absolute; top: 5px; left: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--bblue); box-shadow: 0 0 0 2px var(--header); }
.who { display: flex; align-items: center; gap: 9px; padding: 3px 6px 3px 3px; border-radius: 30px; text-align: left; }
.who:hover, .who[aria-expanded="true"] { background: rgba(0,0,0,.06); }
.who .av { width: 31px; height: 31px; font-size: 11px; }
.who .meta-txt { display: flex; flex-direction: column; }
.who .nm { font-size: 12.5px; font-weight: 600; line-height: 1.15; white-space: nowrap; }
.who .ti { font-size: 10.5px; color: var(--mut2); line-height: 1.2; white-space: nowrap; }

/* ---------------- body grid ---------------- */
.shell-body { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 0; transition: grid-template-columns .26s ease; }
.shell[data-rail="open"] .shell-body { grid-template-columns: var(--rail-w-open) 1fr; }

/* ---------------- rail ---------------- */
.rail { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 14px 8px calc(var(--footer-h) + 12px); border-right: 1px solid rgba(0,0,0,.035); min-height: 0; overflow: visible; position: relative; z-index: 20; }
.shell[data-rail="open"] .rail { align-items: stretch; }
.rail .exp { width: 28px; height: 28px; border-radius: 7px; background: var(--surface); display: flex; align-items: center; justify-content: center; margin: 0 0 12px; box-shadow: var(--shadow); color: var(--ink); align-self: center; }
.shell[data-rail="open"] .rail .exp { align-self: flex-end; margin-right: 4px; }
.rail .exp svg { width: 15px; height: 15px; transition: transform .2s; }
.shell[data-rail="open"] .rail .exp svg { transform: rotate(180deg); }
.rail .nav { position: relative; height: 40px; min-width: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 11px; color: var(--mut); }
.shell[data-rail="open"] .rail .nav { justify-content: flex-start; padding: 0 10px; }
.rail .nav:hover { background: var(--surface); color: var(--ink); }
.rail .nav.on { background: var(--pink-t); color: var(--red); }
.rail .nav .lbl-t { display: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.shell[data-rail="open"] .rail .nav .lbl-t { display: inline; }
.rail .nav .tip { position: absolute; left: 48px; top: 50%; transform: translateY(-50%) scale(.96); background: var(--ink); color: #fff; font: 600 12px var(--sans); padding: 5px 10px; border-radius: 8px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--t-fast), transform var(--t-fast); z-index: 40; }
.rail .nav:hover .tip, .rail .nav:focus-visible .tip { opacity: 1; transform: translateY(-50%) scale(1); }
.shell[data-rail="open"] .rail .nav .tip { display: none; }
.rail .spacer { flex: 1; }

/* ---------------- main + view ---------------- */
/* clip (not hidden): the closed drawer sits off-canvas inside .main; `hidden` still allows programmatic scrolling
   (focus / scrollIntoView) that would shift the whole view sideways. */
.main { position: relative; min-width: 0; min-height: 0; overflow: hidden; overflow: clip; }
.view { height: calc(var(--app-h) - var(--topbar-h)); overflow-y: auto; overflow-x: hidden; padding-bottom: var(--footer-h); scroll-padding-top: 24px; }
.view.view-full { overflow: hidden; padding-bottom: 0; }
.page { max-width: var(--content-max); margin: 0 auto; padding: 28px 40px 70px; }
.page-narrow { max-width: 980px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 18px 0 18px; }
.page-head h1 { font-size: var(--fz-h); }
.page-sub { color: var(--mut); font-size: 15px; margin: 8px 0 0; max-width: 72ch; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--mut); }
.crumb:hover { color: var(--ink); }
.crumb svg { width: 14px; height: 14px; }

/* ---------------- footer ---------------- */
.foot { position: fixed; left: 0; right: 0; bottom: var(--app-inset-bottom); height: var(--footer-h); display: flex; justify-content: space-between; align-items: center; padding: 0 18px; font-size: 12px; color: var(--mut2); z-index: 25; pointer-events: none; background: linear-gradient(0deg, var(--bg) 55%, rgba(226,230,225,0)); }
.foot > * { pointer-events: auto; }
.foot .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-right: 8px; vertical-align: 1px; }
.foot .disc { font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; background: rgba(0,0,0,.06); border-radius: 20px; padding: 2px 9px; margin-left: 10px; }
.foot .links { display: flex; gap: 16px; }
.foot .links a, .foot .links button { color: var(--mut2); font-size: 12px; }
.foot .links a:hover, .foot .links button:hover { color: var(--ink); }

/* ---------------- drawer host (inside .main so the scrim never covers the rail; bug M12) ---------------- */
.drawer-scrim { position: absolute; inset: 0; background: rgba(20,18,17,.28); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.drawer-scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: absolute; top: 0; right: 0; height: calc(var(--app-h) - var(--topbar-h)); width: min(var(--drawer-w, 560px), 92%); background: var(--surface); z-index: 41; display: flex; flex-direction: column; transform: translateX(101%); visibility: hidden; transition: transform var(--t-mid) var(--ease), visibility 0s linear var(--t-mid); }
.drawer.on { transform: none; visibility: visible; box-shadow: var(--shadow-drawer); transition: transform var(--t-mid) var(--ease), visibility 0s; } /* no shadow while hidden (reference bug 17) */
.drawer-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer-hd h2 { font-size: 17px; font-weight: 800; }
.drawer-hd .sub { font-size: 13px; color: var(--mut); margin-top: 3px; }
.drawer-bd { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
.drawer-ft { border-top: 1px solid var(--line); padding: 12px 22px calc(12px + var(--footer-h)); display: flex; gap: 10px; align-items: center; justify-content: flex-end; font-size: 12px; color: var(--mut); }

/* ---------------- modal ---------------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(20,18,17,.38); z-index: 80; display: grid; place-items: center; padding: 24px; animation: fade .18s ease both; }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); border-top: 3px solid var(--brand); animation: rise .22s var(--ease) both; }
.modal-hd { padding: 20px 22px 6px; }
.modal-hd h2 { font-size: 18px; }
.modal-bd { padding: 8px 22px 6px; color: var(--mut); font-size: 14px; }
.modal-ft { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; }

/* ---------------- toasts ---------------- */
/* top-right under the top bar: clear of the composer, the footer and any bottom inset. z 65: above drawers (41), below
   top-bar menus (70), modals (80), the console (81), ⌘K (85) and the guide layer, so a toast never covers a control the
   user or the coach is pointing at. Newest at the bottom of the stack (max 3, toasts.js). */
.toasts { position: fixed; top: calc(var(--topbar-h) + 12px); right: 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 65; pointer-events: none; max-width: min(460px, calc(100vw - 40px)); }
.toast { background: #1B1A19; color: #fff; padding: 11px 18px; border-radius: var(--r-lg); font: 600 13.5px var(--sans); box-shadow: var(--shadow-lg); max-width: 100%; animation: toastIn .3s var(--ease) both; pointer-events: auto; display: flex; align-items: center; gap: 10px; }
.toast .tag { margin-left: 2px; }
.toast.out { animation: toastOut .25s ease both; }
.toast-error { background: var(--red-d); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }

/* ---------------- popover menus (view as, bell, avatar) ---------------- */
.menu { position: fixed; z-index: 70; min-width: 240px; max-width: 360px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-pop); border: 1px solid var(--line); padding: 6px; animation: rise .16s var(--ease) both; }
.menu-hd { padding: 8px 10px 6px; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; text-align: left; font-size: 13px; color: var(--ink); }
.menu-item:hover, .menu-item:focus-visible { background: var(--nested); }
.menu-item.on { background: var(--pink-t); }
.menu-item .meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.menu-item .meta small { color: var(--mut2); font-size: 11.5px; }
.menu-item .chk { margin-left: auto; color: var(--red); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-note { font-size: 11.5px; color: var(--mut2); padding: 6px 10px 4px; }
.notif { display: grid; grid-template-columns: 8px 1fr; gap: 10px; padding: 9px 10px; border-radius: 9px; text-align: left; width: 100%; }
.notif:hover { background: var(--nested); }
.notif .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bblue); margin-top: 6px; }
.notif.sev-high .dot { background: var(--red); }
.notif b { display: block; font-size: 13px; line-height: 1.3; }
.notif small { color: var(--mut2); font-size: 11.5px; }
.notif.ack b { font-weight: 500; color: var(--mut); }
.notif.ack .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line2); }

/* ---------------- command palette ---------------- */
.palette-scrim { position: fixed; inset: 0; background: rgba(20,18,17,.30); z-index: 85; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; animation: fade .14s ease both; }
.palette { width: min(640px, 92vw); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop); overflow: hidden; animation: rise .16s var(--ease) both; }
.palette-in { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.palette-in input { flex: 1; border: 0; outline: 0; font-size: 16px; background: transparent; }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-group { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--mut2); padding: 10px 10px 4px; }
.palette-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; text-align: left; font-size: 14px; }
.palette-item .hint { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--mut2); white-space: nowrap; }
.palette-item.on { background: var(--pink-t); }
.palette-item.on .hint { color: var(--red-d); }
.palette-empty { padding: 18px; color: var(--mut); text-align: center; }
.palette-ft { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--mut2); }

/* ---------------- boot / error screens ---------------- */
.boot { height: var(--app-h); display: grid; place-items: center; color: var(--mut); font-size: 14px; }
.boot .card { max-width: 520px; }

@media (max-width: 900px) {
  .page { padding: 20px 20px 60px; }
  .who .meta-txt, .foot .links a:nth-child(n+3) { display: none; }
}
