/* Shared app chrome (js/chrome.js builds it). Three parts:
   1. The Laboratory's header: the brand header, the "You" chip and a row of module tabs (a bottom bar on
      phones). Only pages with data-tab="lab" get it now. The Laboratory loads this file but not base.css,
      and defines only the Forest & Gold names, so every token here has the old name as its fallback
      (var(--leaf, var(--forest))) and the Lab keeps its own colours, type and sizes. Don't drop the fallbacks.
   2. The You panel, shared by both, so it carries the fallbacks too.
   3. The shell (SG-85), for every other page: a side rail from 600px, a five-tab bar on a phone, the
      reading width, and round mode. Its classes never reach the Laboratory, so it reads base.css directly. */

/* ---------- 1. The Laboratory's header and tabs ---------- */

.sg-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:18px; }
.sg-brand { display:flex; align-items:center; gap:12px; color:inherit; text-decoration:none; min-width:0; -webkit-tap-highlight-color:transparent; }
.sg-brand svg { flex:none; width:60px; height:60px; }   /* Remy: mark = title + tagline height */
.sg-word { display:block; font-family:var(--font-head, "Bitter", Georgia, serif); font-weight:700; font-size:34px; line-height:1.1; letter-spacing:-.01em; color:var(--ink); }
.sg-tag { display:block; font-size:13px; font-style:var(--tag-style, italic); color:var(--ink-2, var(--ink-soft)); margin-top:3px; }
.sg-brand:hover .sg-word { color:var(--leaf-text, var(--leaf, var(--forest))); }

/* The You chip: .sg-chip in this header, .sg-you in the shell (part 3 gives that one its size). */
.sg-chip, .sg-you { --me:var(--leaf, var(--forest)); flex:none; width:32px; height:32px; border-radius:50%; padding:0; cursor:pointer;
  border:2px solid var(--me); background:color-mix(in srgb, var(--me) 20%, var(--panel, var(--card))); color:var(--ink);
  font:700 13px var(--font-head, "Sora", sans-serif); display:flex; align-items:center; justify-content:center; }
.sg-chip:hover, .sg-you:hover { background:color-mix(in srgb, var(--me) 38%, var(--panel, var(--card))); }
.sg-chip:focus-visible { outline:none; box-shadow:0 0 0 3px var(--leaf-soft, var(--forest-soft)); }

/* ---------- 2. The You panel ---------- */
.sg-panel { position:absolute; z-index:60; width:300px; max-width:calc(100vw - 24px); max-height:calc(100vh - 24px); max-height:calc(100dvh - 24px - env(safe-area-inset-bottom, 0px)); overflow-y:auto;
  background:var(--panel, var(--card)); color:var(--ink); border:1px solid var(--edge, var(--line)); border-radius:var(--r-card, 14px);
  box-shadow:var(--shadow-lift); padding:16px; font-size:14.5px; line-height:1.4; }
.sg-panel:focus { outline:none; }
.sg-panel :focus-visible, .sg-top :focus-visible, .sg-nav :focus-visible { outline:2px solid var(--leaf-text, var(--forest)); outline-offset:2px; }
.sg-panel .sg-email { color:var(--ink-2, var(--ink-soft)); margin-bottom:14px; overflow-wrap:anywhere; }
.sg-panel .sg-email b { color:var(--ink); font-weight:600; }
.sg-panel .sg-lbl { display:block; color:var(--ink-2, var(--ink-soft)); font-size:13px; font-weight:600; margin:0 0 6px; }
.sg-panel input[type=text] { display:block; width:100%; min-height:44px; font:inherit; font-size:16px; padding:0 12px; border-radius:var(--r-ctl, 10px);
  border:1.5px solid var(--edge, var(--line)); background:var(--bg, var(--paper)); color:var(--ink); margin-bottom:14px; }
.sg-panel input[type=text]:focus { outline:none; border-color:var(--leaf, var(--forest)); box-shadow:0 0 0 3px var(--leaf-soft, var(--forest-soft)); }
/* 36px swatches on a 44px pitch: the gap is part of the target. The edge ring keeps a pale color visible; the pick gets a second, outer ring. */
.sg-swatches { display:flex; gap:8px; margin-bottom:14px; }
.sg-swatch { position:relative; flex:none; width:36px; height:36px; border-radius:50%; border:0; padding:0; cursor:pointer; background:var(--c);
  box-shadow:inset 0 0 0 1.5px var(--edge, var(--line)); }
.sg-swatch::after { content:""; position:absolute; inset:-4px; }
.sg-swatch.on { box-shadow:0 0 0 2px var(--panel, var(--card)), 0 0 0 4px var(--ink); }
.sg-panel .sg-swatch:focus-visible { outline-offset:5px; }
/* Light / Dark / Auto: the pick is a lighter tile with an outline, not tone alone. */
.sg-seg { display:grid; grid-template-columns:repeat(3, 1fr); padding:3px; border-radius:var(--r-ctl, 10px); background:var(--panel-2, var(--line)); margin-bottom:14px; }
.sg-seg button { min-height:44px; border:0; border-radius:9px; background:transparent; color:var(--ink-2, var(--ink-soft)); font:inherit; font-weight:600; cursor:pointer; }
.sg-seg button[aria-pressed="true"] { background:var(--bg, var(--paper)); color:var(--ink); box-shadow:inset 0 0 0 1.5px var(--edge, var(--ink-soft)); }
.sg-row { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; border-top:1px solid var(--line); padding-top:12px; }
.sg-row b { display:block; font-weight:600; }
.sg-row span span { display:block; font-size:13px; color:var(--ink-2, var(--ink-soft)); }
.sg-switch { position:relative; flex:none; width:52px; height:32px; border-radius:999px; border:0; padding:0; cursor:pointer;
  background:var(--panel-2, transparent); box-shadow:inset 0 0 0 1.5px var(--edge, var(--ink-soft)); }
.sg-switch::before { content:""; position:absolute; inset:-6px; }
.sg-switch::after { content:""; position:absolute; top:4px; left:4px; width:24px; height:24px; border-radius:50%; background:var(--edge, var(--ink-soft)); transition:transform .15s; }
.sg-switch[aria-checked="true"] { background:var(--leaf, var(--forest)); box-shadow:none; }
.sg-switch[aria-checked="true"]::after { transform:translateX(20px); background:var(--on-leaf, var(--on-forest)); }
/* The panel's ways out: Submit Feedback (a button) and Admin (a link), drawn alike. */
.sg-act { display:flex; align-items:center; gap:8px; width:100%; min-height:44px; margin-top:12px; padding:0 12px; border:0; border-radius:var(--r-ctl, 10px);
  background:var(--panel-2, var(--line)); color:var(--ink); font:inherit; font-weight:600; text-align:left; text-decoration:none; cursor:pointer; }
.sg-act + .sg-act { margin-top:8px; }
/* Unread feedback beside Admin (SG-127): an owner's count, shown only above zero. */
.sg-count { margin-left:auto; min-width:24px; padding:2px 8px; border-radius:999px; background:var(--leaf, var(--forest)); color:var(--on-leaf, var(--on-forest)); font-size:13px; font-weight:700; line-height:1.4; text-align:center; font-variant-numeric:tabular-nums; }
.sg-hint { color:var(--ink-2, var(--ink-soft)); font-size:13px; margin:-8px 0 14px; }
.sg-seg button:disabled { cursor:default; }
.sg-seg.two { grid-template-columns:repeat(2, 1fr); }
.sg-seg.four { grid-template-columns:repeat(4, 1fr); }
/* The one-time Grade question (SG-263, js/chrome.js askGrade): a modal on whatever page she opens next. */
dialog.sg-ask { width:min(380px, calc(100vw - 32px)); padding:22px; border:0; border-radius:var(--r-card, 16px); background:var(--panel, var(--card)); color:var(--ink); font-family:var(--font-body, inherit); font-size:15px; }
dialog.sg-ask::backdrop { background:rgba(10,18,13,.55); }
dialog.sg-ask h2 { margin:0 0 8px; font:700 22px/1.15 var(--font-head, inherit); letter-spacing:-.02em; }
dialog.sg-ask p { margin:0 0 18px; line-height:1.45; color:var(--ink-2, var(--ink-soft)); }
dialog.sg-ask .sg-lbl { display:block; color:var(--ink-2, var(--ink-soft)); font-size:13px; font-weight:600; margin:0 0 6px; }
dialog.sg-ask .sg-seg { background:var(--panel-2, var(--line)); }
dialog.sg-ask p.sg-note { margin:0 0 12px; color:var(--miss); }
dialog.sg-ask :focus-visible { outline:2px solid var(--leaf-text, var(--forest)); outline-offset:2px; }
.sg-ask-acts { display:grid; grid-template-columns:1fr auto; gap:8px; margin-top:6px; }
.sg-ask-acts button { min-height:48px; padding:0 18px; border-radius:var(--r-ctl, 12px); font:inherit; font-weight:600; cursor:pointer; }
.sg-ask-go { border:0; background:var(--leaf, var(--forest)); color:var(--on-leaf, #fff); }
.sg-ask-go:disabled { opacity:.45; cursor:default; }
.sg-ask-no { border:1px solid var(--edge, var(--ink-soft)); background:transparent; color:var(--ink); }
@media (prefers-reduced-motion: no-preference) { dialog.sg-ask[open] { animation:sg-up .25s ease-out; } }
.sg-note { color:var(--miss); font-size:13px; margin:-8px 0 12px; }
@media (prefers-reduced-motion: reduce) { .sg-switch::after { transition:none; } }

.sg-tabs { display:flex; gap:2px; border-bottom:1px solid var(--line); margin:0 0 22px; overflow-x:auto; scrollbar-width:none; }
.sg-tabs::-webkit-scrollbar { display:none; }
.sg-tab { display:flex; align-items:center; gap:6px; text-decoration:none; font-size:14.5px; font-weight:600; color:var(--ink-2, var(--ink-soft));
  padding:10px 7px; border-bottom:2px solid transparent; margin-bottom:-1px; white-space:nowrap; flex:none; -webkit-tap-highlight-color:transparent; }
.sg-tab:hover { color:var(--ink); }
.sg-tab.on { color:var(--ink); border-bottom-color:var(--leaf, var(--forest)); }
.sg-tab.on svg { color:var(--leaf-text, var(--leaf, var(--forest))); }

@media (max-width:600px) {
  .sg-brand { gap:10px; }
  .sg-brand svg { width:48px; height:48px; }
  .sg-word { font-size:26px; }
  .sg-tag { font-size:var(--fs-min, 11.5px); white-space:nowrap; }
  .sg-tabs { position:fixed; left:0; right:0; bottom:0; z-index:40; margin:0; gap:0; overflow:visible; border-bottom:none; border-top:1px solid var(--line);
    background:color-mix(in srgb, var(--bg, var(--paper)) 92%, transparent); -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px);
    padding:4px max(4px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)); }
  .sg-tab { flex:1 1 auto; min-width:0; flex-direction:column; justify-content:center; gap:3px; min-height:52px; padding:6px 2px; font-size:var(--fs-min, 11px); border-bottom:none; margin:0; }
  .sg-tab span { max-width:100%; overflow:hidden; text-overflow:ellipsis; }   /* one line always; the narrowest phones get "In Other Wo…" rather than a taller bar */
  .sg-tab svg { width:22px; height:22px; }
  .sg-tab.on { color:var(--leaf-text, var(--leaf, var(--forest))); }
  body.sg-tabbed .wrap { padding-bottom:calc(90px + env(safe-area-inset-bottom)); }
}
@media (max-width:370px) { .sg-tag { white-space:normal; } }   /* narrowest phones: let the tagline wrap rather than hit the chip */
@media print { .sg-tabs, .sg-chip { display:none !important; } }

/* ---------- 3. The shell ---------- */
/* --sg-foot is the room left under the page: the phone's tab bar, or just air. A page that runs something to the
   very bottom (the Notes sheet on a phone) reads it. */
body.sg-shell { --sg-rail:0px; --sg-gut:16px; --sg-foot:calc(96px + env(safe-area-inset-bottom)); }
/* The reading width: 760 of text, whatever the gutter. A page that needs more (the God View) sets --sg-read. */
body.sg-shell .wrap { max-width:calc(var(--sg-read, 760px) + 2 * var(--sg-gut)); margin:0 auto; padding:16px max(var(--sg-gut), env(safe-area-inset-right)) var(--sg-foot) max(var(--sg-gut), env(safe-area-inset-left)); }   /* a notch on either side (sideways) is not the page's to use */
.sg-top, .sg-nav { -webkit-tap-highlight-color:transparent; }

.sg-top { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; margin-bottom:14px; }
.sg-mark { display:flex; align-items:center; gap:7px; min-height:44px; color:var(--ink); text-decoration:none;
  font:800 19px/1 var(--font-head); letter-spacing:-.035em; }   /* Soren: Sora 800, set tight (SG-156) */
.sg-mark svg { flex:none; width:24px; height:24px; }
.sg-you { position:relative; width:36px; height:36px; }
.sg-you::after { content:""; position:absolute; inset:-6px; }   /* a 44px target */

/* Phone: a five-tab bar. The active tab is a solid green pill with a tinted-in icon, and every tab has its label. */
.sg-nav { position:fixed; left:0; right:0; bottom:0; z-index:8; display:flex; padding:6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  border-top:1px solid var(--line); background:color-mix(in srgb, var(--bg) 80%, transparent); -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px); }
.sg-nav .sg-mark, .sg-nav .sg-you, .sg-item.sg-rail-only, .sg-more { display:none; }
.sg-item { flex:1 1 0; min-width:0; min-height:48px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  font-size:12px; font-weight:500; line-height:1.2; color:var(--ink-2); text-decoration:none; }
.sg-i { display:grid; place-items:center; }
.sg-item:hover { color:var(--ink); }
.sg-item.on { color:var(--ink); font-weight:600; }
.sg-item.on svg { fill:color-mix(in srgb, currentColor 22%, transparent); }
@media (max-width:599px) {
  .sg-item[data-tab="study"] { order:1; }   /* Notes is last on the bar and second in the rail */
  .sg-i { width:46px; height:28px; border-radius:var(--r-pill); }
  .sg-item.on .sg-i { background:var(--leaf); color:var(--on-leaf); }
}

/* Tablet: the rail, icons over small labels. The active item is tinted and carries a bar on its left edge. */
@media (min-width:600px) {
  body.sg-shell { --sg-rail:calc(76px + env(safe-area-inset-left)); --sg-gut:20px; --sg-foot:64px; padding-left:var(--sg-rail); }
  body.sg-shell .wrap { padding-top:24px; }
  body.sg-shell:not(.sg-round) .wrap { padding-left:var(--sg-gut); }   /* the rail already clears the left inset */
  .sg-top { display:none; }
  .sg-nav { top:0; right:auto; width:var(--sg-rail); flex-direction:column; align-items:center; gap:4px; padding:max(16px, env(safe-area-inset-top)) 8px max(16px, env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); overflow-y:auto;
    border-top:0; background:color-mix(in srgb, var(--panel) 45%, var(--bg)); -webkit-backdrop-filter:none; backdrop-filter:none; }
  .sg-nav .sg-mark { display:flex; margin-bottom:10px; }
  .sg-nav .sg-mark span { display:none; }
  .sg-nav .sg-you { display:flex; margin-top:auto; }
  .sg-item, .sg-item.sg-rail-only { display:flex; flex:none; width:60px; min-height:52px; gap:2px; padding:6px 2px; border-radius:var(--r-sm); }
  .sg-item.on { background:var(--leaf-soft); color:var(--leaf-text); box-shadow:inset 3px 0 0 var(--leaf); }
}
/* A phone held sideways (SG-379): the rail is shorter than its items, so the mark goes and the items tighten until every one
   and the You chip are on screen with no scrolling. */
@media (min-width:600px) and (max-height:520px) {
  .sg-nav { gap:2px; padding-top:max(8px, env(safe-area-inset-top)); padding-bottom:max(8px, env(safe-area-inset-bottom)); }
  .sg-nav .sg-mark { display:none; }
  .sg-item, .sg-item.sg-rail-only { min-height:40px; padding:3px 2px; }
}
/* Laptop: the full rail. */
@media (min-width:1024px) {
  body.sg-shell { --sg-rail:calc(172px + env(safe-area-inset-left)); --sg-gut:28px; }
  .sg-nav { align-items:stretch; padding:max(18px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
  .sg-nav .sg-mark { margin:0 6px 12px; }
  .sg-nav .sg-mark span, .sg-more { display:inline; }
  .sg-nav .sg-you { align-self:flex-start; margin-left:6px; }
  .sg-item, .sg-item.sg-rail-only { flex-direction:row; justify-content:flex-start; width:auto; min-height:40px; gap:10px; padding:8px 10px; font-size:14.5px; }
  .sg-item svg { width:18px; height:18px; }
}

/* A round: no rail, no header, no tab bar. The page's own way out is the only one. */
body.sg-round { padding-left:0; --sg-foot:64px; }
body.sg-round .sg-top, body.sg-round .sg-nav { display:none; }
@media print { .sg-top, .sg-nav { display:none !important; } body.sg-shell { padding-left:0; } }

/* The owl that can move (SG-160; js/chrome.js owlMoving). The lid rests as the brow; each state moves only the lid and the pupils.
   Blink drops the lid about every 4.4 s, asleep keeps it down, wide lifts it. Under Reduce Motion the owl is there and still, eyes open. */
.owl-m { display:block; flex:none; overflow:visible; }
.owl-m .o-lid, .owl-m .o-pup { transition:transform .35s cubic-bezier(.2, .9, .3, 1.15); }
.owl-m .o-pup { transform-box:fill-box; transform-origin:center; }
.owl-m.asleep .o-lid { transform:translateY(21px); }
.owl-m.wide .o-lid { transform:translateY(-9px); }
.owl-m.wide .o-pup { transform:scale(1.16); }
@keyframes owl-blink { 0%, 90%, 100% { transform:none; } 95% { transform:translateY(21px); } }
@media (prefers-reduced-motion: no-preference) {
  .owl-m.blink .o-lid { animation:owl-blink 4.4s ease-in-out infinite; }
}

/* The AI line (SG-215, js/ai-note.js): one small, quiet line on every screen that shows model output. On the Play field it centres under
   the content; elsewhere it sits left. It is text in the second ink and never a banner, so Notes and Writing stay calm. */
.ai-note { margin:14px 0 0; font-size:13px; line-height:1.4; color:var(--ink-2); }
.play .ai-note { text-align:center; }
.review .ai-note { margin:16px 0 0; }

/* SG-243: the rotating line under a screen's name (js/taglines.js). Quieter than the name, louder than the .tagline below it;
   two lines are reserved on a phone so a long pick doesn't push the page down once it is swapped in. */
.subtag { color:var(--ink-2); font-family:var(--font-head); font-weight:600; font-size:16px; line-height:1.35; letter-spacing:-.01em; margin:6px 0 10px; }
@media (max-width:560px) { .subtag { min-height:2.7em; } }
