/* Weft — layout and components for the chat view
 *
 * Lifted verbatim from the integration bench prototype when the client
 * moved to ES modules. Kept as a separate file rather than inline so the CSP can be a
 * plain 'self' with no nonce, and so the browser can cache it across page loads.
 */

/* The `hidden` attribute, defended.
 *
 * The UA sheet says [hidden]{display:none}, but that is a *user-agent* rule and loses
 * to any author rule that sets display — which several below do. `.panel{display:flex}`
 * alone would mean panels.js hiding a stacked layer, and the model filter hiding a
 * filtered-out row, both silently do nothing: the element stays on screen with the
 * attribute correctly set, which is a miserable thing to debug. One line, once.
 */
[hidden]{display:none !important}
/* Read by a screen reader, never seen: who said a bubble, the announcer (views/chat.js). */
.sr-only{position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden;
  clip:rect(0 0 0 0); clip-path:inset(50%); white-space:nowrap; border:0}

/* ---- layer 0: canvas, the floor. Fixed, full viewport, never reacts to content. */
#cv-wrap{position:fixed;inset:0;z-index:0}
#cv{position:absolute;inset:0;width:100%;height:100%}
/* ELIZA's CRT, while she is the pick: fine scanlines that roll slowly downwards, and
   one brighter line sweeping top to bottom, after the BBS terminal they come from. The
   window stays Weft's (donut, bubbles, theme), only the floor changes: dark glass in
   either theme, with the lines in fern. Both move by transform alone, so the compositor
   runs them and no frame is repainted for it; the donut's frame budget is not touched.
   Calm and still motion (COMFORT, at the end of this file) stop both and hide the sweep.

   The roll moves in whole pixels (steps). Moved smoothly, every line sat between two
   pixel rows most of the time, and on a desktop screen one line (where the compositor's
   tiles meet) visibly pulsed brighter and dimmer as it crossed. */
:root{--floor:var(--bg)}
:root[data-eliza]{--floor:#12141a}  /* the dark theme's --bg, whatever the theme */
:root[data-eliza] #cv-wrap{background:var(--floor)}
#crt{position:absolute; inset:0; overflow:hidden; pointer-events:none; display:none}
:root[data-eliza] #crt{display:block}
#crt::before{
  content:''; position:absolute; left:0; right:0; top:-5px; bottom:0;
  background:repeating-linear-gradient(to bottom,
    color-mix(in srgb, var(--fern) 12%, transparent) 0 1px, transparent 1px 5px);
  animation:crt-roll 10s steps(5) infinite; will-change:transform;
}
#crt::after{
  content:''; position:absolute; left:0; right:0; top:0; height:3px;
  background:color-mix(in srgb, var(--fern) 18%, transparent);
  animation:crt-sweep 9s linear infinite; will-change:transform;
}
/* One line-pitch per loop, so the roll never jumps. */
@keyframes crt-roll{to{transform:translateY(5px)}}
@keyframes crt-sweep{from{transform:translateY(-3px)} to{transform:translateY(100dvh)}}

/* ---- layer 1: chat log, floats over the scene, transparent background.
   It lives BETWEEN the top bar and the input bar, not under them: the canvas is the
   only layer that runs edge to edge. --top-h and --bar-h are the bars' measured
   heights (chat.js keeps them current, so a growing input box or a wrapped top bar
   moves the log's edge with it). Spanning the whole viewport put the bottom of the
   scrollbar and the last bubble behind the input bar, and the top behind the menu.

   It takes pointer events. It used to pass them through to the canvas, which listens
   for none — and an element that takes no pointer events has a scrollbar nobody can
   drag, so the wheel was the only way back up the conversation. */
#log{
  position:fixed; left:0; right:0; z-index:1;
  top:var(--top-h, 56px); bottom:var(--bar-h, 62px);
  padding:16px;
  display:flex; flex-direction:column; gap:10px;
  overflow-y:auto; overscroll-behavior:contain;
}
/* A short conversation sits at the bottom, by the input, rather than under the menu.
   An auto margin rather than justify-content:flex-end, which makes the overflow
   unreachable once the log is long enough to scroll. */
#log > :first-child{margin-top:auto}
.row{display:flex;flex-direction:column;align-items:flex-start;gap:4px}
.row.user{align-items:flex-end}
.bubble{
  max-width:82%; padding:10px 14px; border-radius:16px;
  background:color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter:blur(6px);
  box-shadow:0 2px 6px rgba(0,0,0,.12);
  white-space:pre-wrap; overflow-wrap:break-word;
}
.row.user .bubble{border-bottom-right-radius:5px}
.row.ai .bubble{border-bottom-left-radius:5px}
/* identity tint: bubbles always wear the live palette. :root defines DEFAULT
   (fern/twilight); setPair() overrides the vars per identity, un-dressing =
   removing the overrides so theme defaults shine through. */
:root{
  --weft-a:var(--fern);
  --weft-b:var(--twilight);
}
.row.ai .bubble{
  border:3px solid var(--weft-a);
  background:color-mix(in srgb, var(--weft-a) 12%,
              color-mix(in srgb, var(--panel) var(--glass), transparent));
}
/* user bubbles: same frosted glass, neutral — identity tint keys off the SENDER
   (colour-B) once the bridge supplies it, not the picked weft */
.row .bubble{
  background:color-mix(in srgb, var(--panel) var(--glass), transparent);
}
/* How much of a bubble is its own panel and how much the floor through it. Half, but a
   light bubble over ELIZA's dark floor needs nearly all of its own, or dark words end
   up on muddy grey. */
:root{--glass:50%}
:root[data-eliza][data-theme=light]{--glass:92%}
@media (prefers-color-scheme: light){
  :root[data-eliza]:not([data-theme=dark]){--glass:92%}
}
.row.user .bubble{
  border:3px solid color-mix(in srgb, var(--weft-b) 55%, transparent);
}
/* Someone else's turn in a shared conversation: their name over it, and a quieter
   border than the user's own, so the eye can tell whose is whose. */
.row .speaker{font-size:.78rem; opacity:.75; padding:0 6px}
.row.user.other .bubble{border-style:dashed; border-color:color-mix(in srgb, var(--weft-b) 35%, transparent)}
:root[data-dressed] #dot{background:radial-gradient(circle at 30% 30%, var(--weft-a), var(--weft-b))}

/* ---- layer 2: chrome (input bar). Fixed, floats over bubbles. */
#bar{
  position:fixed; left:0; right:0; bottom:0; z-index:2;
  display:flex; gap:8px; align-items:flex-end;
  padding:10px 12px; padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));
  background:color-mix(in srgb, var(--panel) 85%, transparent);
  backdrop-filter:blur(8px);
  border-top:1px solid var(--edge);
}
#bar > *{flex-shrink:0}
#in{
  flex:1; min-width:0; resize:none; font:inherit;
  background:color-mix(in srgb, var(--in) 90%, transparent);
  border:1px solid var(--inedge); border-radius:20px; color:var(--text);
  padding:10px 16px; max-height:120px; line-height:1.4;
  transition:max-height .15s;
}
#in:focus{outline:none; border-color:var(--fern)}
button{background:var(--twilight); color:#fff; border:0; border-radius:20px; padding:10px 16px; font:inherit; cursor:pointer}

/* ---- the send shelf (js/shelf.js): hold or swipe up on send, petals wait above it.
   Opens and closes only by the user's own gesture, so the log makes room for it. */
#send-wrap{position:relative}
#send{
  position:relative; overflow:visible;
  user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
  -webkit-tap-highlight-color:transparent;
  touch-action:none;  /* the swipe is ours, not the page's scroll */
  transition:transform .12s ease;
}
#send.holding{transform:scale(.94)}
:root[data-shelf-open] #log, :root[data-tray] #log{padding-bottom:84px}  /* clear of the petals and the tray above the bar */

/* ---- the tray (js/tray.js): pictures waiting to go with the next message, in a row
   above the bar on the left. It stops short of the right edge, where the petals live. */
#tray{
  position:absolute; left:12px; bottom:calc(100% + 10px);
  max-width:calc(100% - 150px);
  display:flex; gap:8px; overflow-x:auto; padding:6px 6px 0 0;
  scrollbar-width:none;
}
#tray::-webkit-scrollbar{display:none}
.tray-item{position:relative; flex-shrink:0; width:56px; height:56px}
.tray-item img{
  width:100%; height:100%; object-fit:cover; display:block;
  border-radius:10px; border:2px solid var(--inedge);
  box-shadow:0 4px 14px rgba(0,0,0,.3);
}
.tray-item.pending img{opacity:.5; animation:ledpulse 1s ease-in-out infinite}
.tray-item.failed img{border-color:#c62828; opacity:.6}
/* a file in the tray: its icon and name on a tile the size of a thumbnail */
.tray-file{
  width:100%; height:100%; box-sizing:border-box; padding:6px 4px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  border-radius:10px; border:2px solid var(--inedge); background:var(--panel); color:var(--text);
  box-shadow:0 4px 14px rgba(0,0,0,.3); font-size:10px; line-height:1.15; text-align:center;
}
.tray-file span{max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.tray-item.pending .tray-file{opacity:.5; animation:ledpulse 1s ease-in-out infinite}
.tray-item.failed .tray-file{border-color:#c62828; opacity:.6}
.tray-remove{
  position:absolute; top:-6px; right:-6px;
  width:22px; height:22px; padding:0; border-radius:50%;
  font-size:11px; line-height:22px; text-align:center;
  background:var(--panel); color:var(--text); border:1px solid var(--inedge);
  -webkit-tap-highlight-color:transparent;
}

/* ---- pictures in a bubble, and the full-size view a tap opens */
.bubble-pics{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:6px}
.bubble-pics:last-child{margin-bottom:0}
.bubble-pics.bubble-shown{margin:6px 0 0}
.bubble-pic{padding:0; background:none; border:0; border-radius:10px; cursor:zoom-in; line-height:0}
.bubble-pic img{
  display:block; max-width:min(240px, 60vw); max-height:240px; min-width:48px; min-height:48px;
  border-radius:10px; object-fit:cover; background:color-mix(in srgb, var(--panel) 60%, transparent);
}
.bubble-pic.gone{cursor:default}
.bubble-pic.gone img{width:96px; height:72px}

/* ---- a file on a message (js/files.js): a card in the bubble's own colours, with a
   tint to lift it off the bubble, an icon for its kind, and play and download */
.bubble-files{display:flex; flex-direction:column; gap:6px; margin-bottom:6px}
.bubble-files:last-child{margin-bottom:0}
.bubble-files.bubble-handed{margin:6px 0 0}
.file-card{
  min-width:min(240px, 100%); max-width:340px; box-sizing:border-box; padding:8px 10px;
  border-radius:12px; background:color-mix(in srgb, currentColor 9%, transparent);
  border:1px solid color-mix(in srgb, currentColor 18%, transparent);
}
.file-row{display:flex; align-items:center; gap:10px}
.file-icon .ic{width:22px; height:22px; opacity:.85}
.file-words{flex:1; min-width:0; display:flex; flex-direction:column}
.file-name{font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.file-detail{font-size:.8em; opacity:.7}
.file-actions{display:flex; gap:4px}
.file-action{
  width:34px; height:34px; padding:0; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  background:color-mix(in srgb, currentColor 12%, transparent); color:inherit; border:0; cursor:pointer;
}
.file-action:hover, .file-action:focus-visible{background:color-mix(in srgb, currentColor 22%, transparent)}
.file-action .ic{width:16px; height:16px}
.file-card.pending .file-row, .file-card.busy .file-row{opacity:.6; animation:ledpulse 1s ease-in-out infinite}
.file-card.gone{opacity:.6}
.file-player{display:block; width:100%; margin-top:8px}
video.file-player{max-height:50dvh; border-radius:8px; background:#000}
#lightbox{
  position:fixed; inset:0; z-index:8;
  display:flex; align-items:center; justify-content:center;
  padding:16px; background:rgba(0,0,0,.82); cursor:zoom-out;
}
#lightbox img{max-width:100%; max-height:100%; object-fit:contain; border-radius:8px}

/* the invitation: a small + on send that bobs now and then while the shelf is shut.
   transform and opacity only, so it costs the compositor and not a repaint. */
#send .hint{
  position:absolute; top:-6px; right:-2px;
  font-size:15px; line-height:1; color:var(--dim);
  animation:hintjump 2.4s ease-in-out infinite;
  pointer-events:none;
}
@keyframes hintjump{
  0%,72%,100%{transform:translateY(0); opacity:.55}
  78%{transform:translateY(-3px); opacity:.9}
  84%{transform:translateY(-4px); opacity:1}
  90%{transform:translateY(-1px); opacity:.7}
}
#send-wrap.open .hint, #send.holding .hint{animation:none; opacity:0; transition:opacity .15s}

/* the shelf: a row ending at send's right edge, so nothing runs off a phone screen */
#send-shelf{
  /* Inset from send's right edge: push to talk sits over the middle of the button,
     where the thumb already is, and clears the log's scrollbar. */
  position:absolute; right:10px; bottom:calc(100% + 10px);
  display:flex; gap:14px; padding-left:8px;
  pointer-events:none; touch-action:none;
}
#send-wrap.open #send-shelf{pointer-events:auto}
#send-shelf .petal .ic{width:20px; height:20px}
#send-shelf .petal{
  position:relative; width:46px; height:46px; padding:0;
  border-radius:50%; display:flex; align-items:center; justify-content:center;
  background:color-mix(in srgb, var(--panel) 92%, transparent);
  border:2px solid var(--inedge); color:var(--text); font-size:20px;
  box-shadow:0 4px 14px rgba(0,0,0,.35); backdrop-filter:blur(8px);
  user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
  -webkit-tap-highlight-color:transparent;
  opacity:0; transform:translateY(14px) scale(.5);
  transition:opacity .18s ease, transform .18s cubic-bezier(.34,1.56,.64,1),
             border-color .15s, color .15s;
}
#send-wrap.open .petal{opacity:1; transform:translateY(0) scale(1)}
/* the pop staggers outward from send, so the row seems to grow out of it */
#send-wrap.open .petal:nth-last-child(1){transition-delay:.04s}
#send-wrap.open .petal:nth-last-child(2){transition-delay:.09s}
/* :hover only where hovering is real; on a phone it sticks to the last thing tapped */
@media (hover:hover){
  #send-shelf .petal:hover{border-color:var(--fern); color:var(--fern)}
  #send-shelf .petal:hover em{opacity:1}
}
#send-shelf .petal:focus-visible, #send-shelf .petal.flash{
  border-color:var(--fern); color:var(--fern); outline:none;
}
/* the label floats ABOVE its petal, on a backing of its own so it reads over bubbles
   and backdrops alike. Shown on hover (desktop) or when a tap flashes it. */
#send-shelf .petal em{
  position:absolute; bottom:50px; left:50%; transform:translateX(-50%);
  font-style:normal; font-size:11px; line-height:1.3; white-space:nowrap;
  padding:3px 8px; border-radius:8px;
  background:color-mix(in srgb, var(--panel) 92%, transparent);
  border:1px solid var(--inedge); color:var(--text);
  box-shadow:0 2px 8px rgba(0,0,0,.25);
  opacity:0; transition:opacity .15s; pointer-events:none;
}
#send-shelf .petal:focus-visible em, #send-shelf .petal.flash em{opacity:1}
/* the label of the right-most petal would centre past the screen edge; anchor it */
#send-shelf .petal:last-child em{left:auto; right:-4px; transform:none}

/* ---- layer 3: top chrome + drawer pages, above everything */
#topbar{
  position:fixed; top:0; left:0; right:0; z-index:3;
  display:flex; align-items:center; gap:10px; padding:8px 14px;
  padding-top:calc(8px + env(safe-area-inset-top,0px));
  background:color-mix(in srgb, var(--panel) 60%, transparent);
  backdrop-filter:blur(8px);
  border-bottom:1px solid var(--edge);
}
/* aero rule: chrome ON the glass rail is solid; the rail itself floats */
#stat-led{
  width:14px; height:14px; border-radius:50%; flex-shrink:0;
  background:var(--dim); box-shadow:0 0 8px 1px currentColor;
  transition:background .4s;
}
#stat-led.red{background:#e05555; color:#e05555}
#stat-led.green{background:var(--fern); color:var(--fern)}
#stat-led.blue{background:#4da3ff; color:#4da3ff}
#stat-led.amber{background:#f0a832; color:#f0a832; animation:ledpulse 1s ease-in-out infinite}
@keyframes ledpulse{0%,100%{opacity:.45}50%{opacity:1}}

/* NOTIFICATIONS WAITING: the bell, on the LED alone.
 *
 * It takes the shape and keeps the health colour, because the colour still means what
 * it always did: a red bell is news the window cannot refresh. A pulse and a small
 * swing rather than a number: it reads at arm's length on an old phone. It is the one
 * bell, and the one to press: a weft with news wears a ring on its pea instead (below),
 * to be seen, not pressed. */
#stat-led.ringing{
  width:auto; height:auto; border-radius:6px; background:none; box-shadow:none;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
}
#stat-led.ringing .ic{width:20px; height:20px; fill:currentColor; stroke:currentColor;
  filter:drop-shadow(0 0 4px currentColor)}
#stat-led.ringing:focus-visible{outline:2px solid var(--text); outline-offset:2px}
#stat-led.green[role=button]:focus-visible{outline:2px solid var(--text); outline-offset:3px}
#stat-led.ringing .ic{transform-origin:50% 12%; animation:bell-ring 2.4s ease-in-out infinite}
@keyframes bell-ring{
  0%, 45%, 100%{transform:scale(1) rotate(0)}
  8%{transform:scale(1.14) rotate(-12deg)}
  16%{transform:scale(1.14) rotate(10deg)}
  24%{transform:scale(1.08) rotate(-6deg)}
  32%{transform:scale(1.04) rotate(3deg)}
}
/* Line icons (js/icons.js): one stroke style, drawn in the text colour. */
.ic{width:18px; height:18px; flex:0 0 auto; fill:none; stroke:currentColor;
  stroke-width:2; stroke-linecap:round; stroke-linejoin:round}

/* Pick: the thread crossing the warp, and the main thing on the top bar. A bar that
   spans the space between the LED and the hamburger (centred, and capped on a wide
   screen), dressed in the current weft's pair: name on the left, what it can do and
   its ⚙ on the right. Below it, a listbox of every weft.

   The name ellipsises rather than growing: letting a long name push the ⚙ or the
   hamburger off a phone screen would cost the user the menus that fix it.

   Centred on the whole bar whenever there is room. The middle track grows to 720px
   before the sides get anything; the sides then split what is left evenly, each never
   narrower than its contents. So a wide screen centres the Pick exactly, and a phone
   gives it every pixel the LED and the right group do not need, rather than reserving
   a dead column on the left just to mirror the mute and the hamburger. */
#topbar{display:grid; gap:12px;
  grid-template-columns:minmax(max-content,1fr) minmax(0,720px) minmax(max-content,1fr)}
#topbar-right{display:flex; justify-content:flex-end; align-items:center; gap:10px}
#pick{position:relative; min-width:0; display:flex; justify-content:center}

/* The gradient border is two backgrounds: the tinted fill clipped to the padding box,
   the pair's gradient to the border box, showing through a transparent border. */
.pick-bar{
  flex:1; min-width:0; max-width:720px;
  display:flex; align-items:center;
  border:2px solid transparent; border-radius:999px;
  background:
    linear-gradient(color-mix(in srgb, var(--weft-a) 12%, var(--in)),
                    color-mix(in srgb, var(--weft-a) 12%, var(--in))) padding-box,
    linear-gradient(90deg, var(--weft-a), var(--weft-b)) border-box;
  box-shadow:0 0 14px -4px var(--weft-a);
}

/* the name half: opens the menu */
#pick-button{
  flex:1; min-width:0;
  display:flex; align-items:center; gap:10px;
  padding:7px 8px 7px 12px; border:0; border-radius:999px 0 0 999px;
  background:none; color:var(--dim);
  font:inherit; font-size:15px; font-weight:600; cursor:pointer;
}
#pick-button.chosen{color:var(--text)}
#pick-button:focus-visible{outline:2px solid var(--text); outline-offset:-2px}
#pick-button .led{
  width:14px; height:14px; flex:0 0 auto; border-radius:50%;
  background:radial-gradient(circle at 30% 30%, var(--weft-a), var(--weft-b));
  box-shadow:0 0 8px 1px var(--weft-a);
}
#pick-button .pick-name{min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
#pick-button .chev{color:var(--dim); font-size:11px; transition:transform .2s ease}
#pick-button[aria-expanded=true] .chev{transform:rotate(180deg)}

/* what a weft can do: quiet marks, not buttons */
.pick-caps{display:flex; align-items:center; gap:4px; color:var(--dim); padding:0 4px}
.pick-caps:empty{display:none}
.pick-caps .ic{width:16px; height:16px}

/* the ⚙: its own button, a sibling of the name half, behind a hairline */
.pick-bar-gear{
  flex:0 0 auto; display:flex; align-items:center;
  padding:7px 12px 7px 10px; margin-left:4px;
  background:none; border:0; border-left:1px solid color-mix(in srgb, var(--dim) 35%, transparent);
  border-radius:0 999px 999px 0; color:var(--dim); cursor:pointer;
}
.pick-bar-gear:hover{color:var(--text)}
.pick-bar-gear:focus-visible{outline:2px solid var(--text); outline-offset:-2px}

/* the menu drops from the bar, at the bar's width */
#pick-menu{
  position:absolute; top:calc(100% + 6px); left:50%; transform:translateX(-50%); z-index:4;
  width:100%; max-height:60dvh; overflow-y:auto;
  list-style:none; margin:0; padding:6px;
  background:var(--panel); border:1px solid var(--edge); border-radius:16px;
  box-shadow:0 10px 28px rgba(0,0,0,.32);
}
/* On a phone the bar sits left of centre, pushed over by the mute, and is too narrow
   for a long name, its marks and its ⚙. So the menu stops following the bar: with
   #pick no longer positioned, it anchors to the fixed #topbar instead, and drops
   centred on the screen at nearly its full width. */
@media (max-width:600px){
  #pick{position:static}
  #pick-menu{left:8px; right:8px; width:auto; transform:none}
}
.pick-item{display:flex; align-items:stretch; gap:2px}
.pick-item button{
  width:100%; display:flex; align-items:center; gap:8px;
  padding:10px 12px; border-radius:8px;
  background:none; border:0; color:var(--text); font:inherit; font-size:14px;
  text-align:left; cursor:pointer;
}
.pick-item button:hover, .pick-item button:focus-visible{background:var(--in); outline:none}
/* THE PEA.
 *
 * This was an oval, and the cause was two rules away from it: `#topbar span` used to
 * carry `flex:1`, and the pick menu lives inside #pick, which lives inside #topbar. So
 * the catch-all reached every span in the menu — including this one. `flex:1` is
 * shorthand for `flex-grow:1; flex-shrink:1; flex-basis:0%`, and that basis beats the
 * `width` below in a flex row, so the dot collapsed to nothing and then grew to fill the
 * row. Height held at 8px. A pea stepped upon.
 *
 * `flex-shrink:0` was already here and could not save it, because `#topbar span` is an
 * id plus an element and outranks two classes. The fix is to delete the over-broad
 * selector rather than to out-specify it — the spans it was dressing are all inside the
 * pick menu, where `.pick-item button` already sets the font size, and every one of them
 * has its own rule for anything else it needs.
 *
 * `flex:0 0 auto` rather than `flex-shrink:0` alone: it pins all three flex properties,
 * so the next well-meant layout rule that reaches in here finds nothing left to set.
 *
 * THE DOT IS COLOUR, NEVER STATUS. Grey already means "connected" on #stat-led a few
 * lines up, so a grey pea would read as a broken weft rather than an undressed one.
 * It wears the identity pair — the same radial recipe as #dot, colour A lit from the
 * top-left melting into colour B. Each row sets its own pick's pair on itself
 * (colours.js), so every pea shows its own weft rather than the current one; a pick
 * nobody has dressed wears fern/twilight. Static gradient: painted once, composited on
 * the GPU, nothing per frame. It must never be animated. A weft with notifications
 * waiting wears a ring around it instead, and the ring is what moves. */
.pick-item .led,
.colour-preview .led{
  width:10px; height:10px; flex:0 0 auto; align-self:center;
  border-radius:50%;
  background:radial-gradient(circle at 30% 30%, var(--weft-a), var(--weft-b));
}
/* The picked one glows rather than changing colour, because its colour is its identity
   and the identity did not change by being selected. */
.pick-item.on .led{box-shadow:0 0 6px 1px var(--weft-a)}
.pick-item.on > button[role=option]{background:color-mix(in srgb, var(--weft-a) 14%, transparent)}
.pick-item .led{width:12px; height:12px}
.pick-item .pick-caps{padding:0}
.pick-item .pick-caps .ic{width:14px; height:14px}
.pick-item .pick-name{flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
/* A weft with nothing to answer it stays on the menu, quieter. */
.pick-item.unbound .pick-name{color:var(--dim)}
/* The ⚙: its own tap target beside the option, never inside it. Sized for a thumb. */
.pick-item button.pick-gear{
  width:auto; flex:0 0 auto; align-items:center; justify-content:center;
  padding:8px 10px; color:color-mix(in srgb, var(--dim) 70%, transparent); line-height:1;
}
.pick-item button.pick-gear:hover, .pick-item button.pick-gear:focus-visible{color:var(--text)}
.pick-empty button{color:var(--dim); font-style:italic}
/* A weft with news: a ring in its own colour around the pea, on the bar and the menu
   alike. Nothing to press: the row still picks, and the LED's bell opens the letters.
   The ring breathes the way the donut does, so the pea becomes a tiny donut in the
   weft's own colour: keep it breathing, not blinking. Calm and still keep it, steady. */
#pick-button .led.waiting, .pick-item.waiting .led{
  outline:2px solid var(--weft-a); outline-offset:2px;
  animation:pea-ring 2.4s ease-in-out infinite;
}
@keyframes pea-ring{
  0%, 100%{outline-color:var(--weft-a); outline-offset:2px}
  50%{outline-color:color-mix(in srgb, var(--weft-a) 30%, transparent); outline-offset:3px}
}
/* the mute: one tap and nothing on this device speaks, wherever the drawer is.
   The same switch as "speak replies aloud", so the two always agree. */
#mute-btn{flex:0 0 auto; width:36px; height:36px; padding:0;
  display:flex; align-items:center; justify-content:center;
  border:1px solid var(--edge); border-radius:999px;
  background:color-mix(in srgb, var(--panel) 85%, transparent);
  color:var(--dim); cursor:pointer; backdrop-filter:blur(10px)}
#mute-btn:hover{color:var(--text); border-color:var(--inedge)}
#mute-btn[aria-pressed=true]{color:#ff9d8f;
  background:color-mix(in srgb, #c62828 12%, var(--panel));
  border-color:color-mix(in srgb, #c62828 40%, transparent)}
#mute-btn:focus-visible{outline:2px solid var(--fern); outline-offset:1px}
/* a bubble's speaker tapped while muted: the mute says why nothing played */
#mute-btn.nudge{animation:mute-nudge .5s ease 2}
@keyframes mute-nudge{
  0%,100%{transform:scale(1)}
  40%{transform:scale(1.18); box-shadow:0 0 0 4px color-mix(in srgb, #c62828 30%, transparent)}
}
/* voice off: nothing to replay */
:root[data-voice-off] .speaker{display:none}
#burger{background:none; border:0; cursor:pointer; padding:6px; border-radius:8px; display:flex; flex-direction:column; gap:4px}
#burger div{width:20px; height:2px; background:var(--dim); border-radius:2px}
#burger:hover div{background:var(--text)}
#scrim{position:fixed; inset:0; z-index:4; background:rgba(0,0,0,.35); display:none}
#scrim.show{display:block}
#drawer{
  position:fixed; top:0; right:0; height:100%; width:calc(100vw - 36px); max-width:520px; z-index:5;
  background:color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter:blur(14px);
  border-left:1px solid var(--edge);
  transform:translateX(100%); transition:transform .28s ease;
  padding:0; display:flex; flex-direction:column;
  overflow-y:auto;
}
/* the shadow only while open: a closed drawer's shadow is a faint strip down the
   right edge of the window */
#drawer.open{box-shadow:-8px 0 24px rgba(0,0,0,.25)}
/* the weft footer: fixed at the drawer's bottom, wordmark + links */
#drawer-foot{
  margin-top:auto; padding:14px 18px; padding-bottom:calc(14px + env(safe-area-inset-bottom,0px));
  border-top:1px solid var(--edge); flex-shrink:0;
  display:flex; align-items:center; gap:14px;
}
#drawer-foot .wordmark{font-size:15px; font-weight:700; letter-spacing:.04em; color:var(--text);
  background:none; border:0; border-radius:6px; padding:0}
#drawer-foot .wordmark:focus-visible{outline:2px solid var(--fern); outline-offset:3px}
/* One tap meets ELIZA (js/eliza.js). The pointer is the only tell. */
#drawer-foot .wordmark{cursor:pointer}
#drawer-foot .wordmark em{font-style:normal; color:var(--fern)}
#drawer-foot .wordmark .as-eliza{display:none}
/* Her name slipping through a burst, two in five (js/views/chat.js, onGlitchBurst):
   torn in, held still long enough to be read, torn out again. */
#drawer-foot .wordmark.slip .as-weft{display:none}
#drawer-foot .wordmark.slip .as-eliza{display:inline-block; animation:eliza-slip .7s steps(1, end) 1}
@keyframes eliza-slip{
  0%{transform:translate(-2px, 0); text-shadow:2px 0 #ff3b6b, -2px 0 #3bd8ff; clip-path:inset(8% 0 52% 0)}
  6%{transform:translate(3px, 0) skewX(-10deg); text-shadow:-3px 0 #ff3b6b, 3px 0 #3bd8ff; clip-path:inset(0 0 66% 0)}
  12%{transform:translate(-3px, 0); text-shadow:3px 0 #ff3b6b, -3px 0 #3bd8ff; clip-path:inset(70% 0 0 0)}
  18%{transform:translate(2px, -1px); text-shadow:-2px 0 #ff3b6b, 2px 0 #3bd8ff; clip-path:inset(28% 0 30% 0)}
  24%{transform:translate(1px, 0); text-shadow:-1px 0 #ff3b6b, 1px 0 #3bd8ff; clip-path:none}
  30%{transform:none; text-shadow:none; clip-path:none}
  82%{transform:translate(2px, 0); text-shadow:-2px 0 #ff3b6b, 2px 0 #3bd8ff; clip-path:inset(58% 0 4% 0)}
  88%{transform:translate(-3px, 0) skewX(10deg); text-shadow:3px 0 #ff3b6b, -3px 0 #3bd8ff; clip-path:inset(0 0 60% 0)}
  94%, 100%{transform:none; text-shadow:none; clip-path:none}
}
/* Something shifted (js/eliza.js, elizaBeckons). For as long as the drawer is open
   and she is unfound: every 2.4s a .6s burst, small, torn into slices and split into
   two colours, then back as if nothing happened. It waits for the drawer's slide. */
#drawer-foot .wordmark.glitch{animation:wordmark-glitch 2.4s steps(1, end) .38s infinite}
@keyframes wordmark-glitch{
  0%{transform:translate(-2px, 0); text-shadow:2px 0 #ff3b6b, -2px 0 #3bd8ff; clip-path:inset(8% 0 52% 0)}
  3%{transform:translate(2px, -1px); text-shadow:-2px 0 #ff3b6b, 2px 0 #3bd8ff; clip-path:inset(58% 0 4% 0)}
  6%{transform:translate(-1px, 1px); text-shadow:1px 0 #ff3b6b, -1px 0 #3bd8ff; clip-path:inset(28% 0 30% 0)}
  9%{transform:none; text-shadow:none; clip-path:none}
  14.5%{transform:translate(3px, 0) skewX(-10deg); text-shadow:-3px 0 #ff3b6b, 3px 0 #3bd8ff; clip-path:inset(0 0 66% 0)}
  17%{transform:translate(-3px, 0); text-shadow:3px 0 #ff3b6b, -3px 0 #3bd8ff; clip-path:inset(70% 0 0 0)}
  20%{transform:translate(1px, 0); text-shadow:-1px 0 #ff3b6b, 1px 0 #3bd8ff; clip-path:none}
  25%, 100%{transform:none; text-shadow:none; clip-path:none}
}
#drawer-foot .links{margin-left:auto; display:flex; gap:12px}
#drawer-foot a{color:var(--dim); font-size:13px; text-decoration:none; padding:4px 6px; border-radius:6px}
#drawer-foot a:hover{color:var(--text); background:var(--in)}
#drawer-foot .slogan{font-size:11px; color:var(--dim); margin-top:2px}
#drawer.open{transform:translateX(0)}
/* drawer anatomy: fixed header (title + close) / scrollable body / fixed footer */
#drawer-head{
  position:sticky; top:0; z-index:1; flex-shrink:0;
  padding:16px 18px;
  padding-top:calc(16px + env(safe-area-inset-top,0px));
  display:flex; align-items:center; gap:12px;
  background:var(--panel); backdrop-filter:blur(14px);
  border-bottom:1px solid var(--edge);
}
#drawer-head h2{font-size:16px; font-weight:700; margin:0; flex:1}
#drawer-close{background:none; border:0; cursor:pointer; color:var(--dim);
  line-height:1; padding:8px; border-radius:8px; display:flex}
#drawer-close .ic{width:20px; height:20px}
#drawer-close:hover{color:var(--text); background:var(--in)}
#drawer-body{flex:1; display:flex; flex-direction:column; gap:14px; min-height:0;
  padding:14px 18px; overflow-y:auto}
#drawer h3{font-size:14px; color:var(--dim); font-weight:600; letter-spacing:.05em}
#drawer label{display:flex; gap:8px; align-items:center; padding:8px 10px; border-radius:8px; cursor:pointer; font-size:14px}
#drawer label:hover{background:var(--in)}

/* ============================================================================
   Views added when the client moved to ES modules: the login card, the forced
   password change, and the boot-error card. Same glass-and-fern language as the
   chat window, so signing in does not feel like a different application.
   ============================================================================ */

/* The shell is empty until main.js mounts a view; give it the full stage. */
#app{min-height:100dvh}

/* Centred single-card layouts (login, password change, boot error). */
.centre{
  min-height:100dvh;
  display:flex; align-items:center; justify-content:center;
  padding:24px 16px;
}

.card{
  width:100%; max-width:380px;
  display:flex; flex-direction:column; gap:10px;
  padding:28px 24px;
  border-radius:18px;
  background:color-mix(in srgb, var(--panel) 50%, transparent);
  border:1px solid var(--edge);
  box-shadow:0 8px 28px rgba(0,0,0,.18);
  backdrop-filter:blur(6px);
}

.card h1{font-size:1.15rem; font-weight:600; margin-bottom:2px}

.card label{
  font-size:.78rem; letter-spacing:.04em; text-transform:uppercase;
  color:var(--dim); margin-top:8px;
}

.card input[type=text],
.card input[type=password]{
  width:100%; padding:11px 13px;
  font:inherit; color:var(--text);
  background:var(--in); border:1px solid var(--inedge); border-radius:11px;
  /* 16px minimum, or iOS Safari zooms the viewport on focus and never zooms back. */
  font-size:16px;
}
.card input:focus-visible{
  outline:2px solid var(--fern); outline-offset:1px; border-color:var(--fern);
}

.card button[type=submit]{
  margin-top:14px; padding:12px 16px;
  font:inherit; font-weight:600; color:#12141a;
  background:var(--fern); border:0; border-radius:11px; cursor:pointer;
}
.card button[type=submit]:hover{filter:brightness(1.06)}
.card button[type=submit]:disabled{opacity:.6; cursor:default; filter:none}

/* Secondary actions: "sign out instead". A button, because it acts — not a link. */
.linkish{
  align-self:flex-start;
  margin-top:4px; padding:4px 0;
  font:inherit; font-size:.85rem;
  color:var(--dim); background:none; border:0; cursor:pointer;
  text-decoration:underline; text-underline-offset:3px;
}
.linkish:hover{color:var(--text)}

.form-error{
  margin-top:8px; padding:9px 12px;
  font-size:.88rem; color:#ffb4a8;
  background:color-mix(in srgb, #c62828 22%, transparent);
  border:1px solid color-mix(in srgb, #c62828 45%, transparent);
  border-radius:9px;
}

.hint{font-size:.8rem; color:var(--dim); margin-top:-2px}

/* The wordmark, login-sized. The e is the weft: the one letter that travels. */
.wordmark-lg{
  font-size:2.1rem; font-weight:700; letter-spacing:-.02em; line-height:1;
}
.wordmark-lg em{font-style:normal; color:var(--fern)}

.card .slogan{font-size:.85rem; color:var(--dim); margin-bottom:6px}

/* The drawer's slide already lives above (#drawer / #drawer.open) — do not restate it
   here, or the later rule silently wins and the timing changes for no reason.

   The scrim DOES need correcting. The bench toggled it with display:none/.show, which
   cannot animate and — more to the point — `display:none` beats any opacity rule, so
   the scrim would never appear at all and clicking outside would not close the drawer.
   Give it a real box and fade it instead. */
#scrim{
  display:block; opacity:0; pointer-events:none;
  transition:opacity .22s ease;
}
#scrim.open{opacity:1; pointer-events:auto}

#drawer-body label{display:block; padding:6px 0; cursor:pointer}
#drawer-body h3{
  margin-top:16px; margin-bottom:4px;
  font-size:.72rem; letter-spacing:.1em; color:var(--dim);
}
#drawer-body .linkish{margin-bottom:4px}

/* ---- the drawer as a control panel: the theme in its head, the account on a card,
   each screen a chunk that says what it is for, the voice on a switch. The account
   card and chunks are shared with the Account screen. */
#drawer-head{gap:10px}
.seg{display:flex; background:var(--in); border:1px solid var(--inedge);
  border-radius:10px; padding:3px; gap:2px}
.seg-btn{background:none; border:0; color:var(--dim); font:inherit; font-size:.78rem;
  padding:6px 12px; border-radius:8px; cursor:pointer}
.seg-btn:hover{color:var(--text)}
.seg-btn[aria-pressed=true]{background:var(--panel); color:var(--text); box-shadow:0 1px 3px rgba(0,0,0,.35)}
.seg-btn:focus-visible{outline:2px solid var(--fern); outline-offset:-2px}

.acct{display:flex; gap:12px; align-items:center; padding:12px;
  border:1px solid var(--edge); border-radius:12px;
  background:color-mix(in srgb, var(--in) 60%, transparent)}
.acct-avatar{width:36px; height:36px; flex:0 0 auto; border-radius:50%;
  background:var(--fern); color:#12141a; font-weight:700; font-size:.95rem;
  display:flex; align-items:center; justify-content:center}
.acct-id{flex:1; min-width:0}
.acct-name{font-weight:700; font-size:.95rem; overflow-wrap:anywhere}
.acct-badge{font-size:.62rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
  color:var(--fern); border:1px solid color-mix(in srgb, var(--fern) 55%, transparent);
  padding:1px 6px; border-radius:99px; margin-left:4px; vertical-align:1px}
.acct-sub{font-size:.8rem; color:var(--dim); display:flex; align-items:center; gap:6px}
.dot-ok{width:7px; height:7px; border-radius:50%; background:var(--fern); flex:0 0 auto}
.signout-mini{padding:7px 14px; flex:0 0 auto;
  background:none; border:1px solid var(--edge); border-radius:8px; cursor:pointer;
  font:inherit; font-size:.8rem; color:var(--dim)}
.signout-mini:hover{color:#ff9d8f; background:color-mix(in srgb, #c62828 12%, transparent)}

.chunk{width:100%; display:flex; align-items:center; justify-content:space-between;
  padding:12px 14px; border-radius:12px; border:1px solid var(--edge);
  background:var(--in); color:var(--text); font:inherit; font-size:.92rem; cursor:pointer;
  text-align:left}
.chunk:hover{border-color:var(--inedge); background:color-mix(in srgb, var(--in) 70%, var(--panel))}
.chunk:focus-visible{outline:2px solid var(--fern); outline-offset:1px}
.chunk:disabled{opacity:.6; cursor:default}
.chunk.danger{color:#ff9d8f}
.chunk.danger:hover{background:color-mix(in srgb, #c62828 16%, var(--in));
  border-color:color-mix(in srgb, #c62828 45%, transparent)}
.chunk.big{position:relative; padding:16px 36px 16px 14px;
  flex-direction:column; align-items:flex-start; gap:3px}
.chunk.big span{font-size:1rem; font-weight:700}
.chunk.big em{font-style:normal; font-size:.78rem; color:var(--dim)}
.chunk.big::after{content:'\203A'; position:absolute; right:14px; top:50%;
  transform:translateY(-50%); color:var(--dim); font-size:1.2em}

.drawer-rule{height:1px; background:var(--edge); margin:4px 0}

/* a switch: the checkbox stays in the label for the keyboard and the screen reader,
   and the pill beside it is what the eye reads */
#drawer-body label.toggle-row, .tip-extras label.toggle-row, .notify label.toggle-row{display:flex; align-items:center; gap:10px; padding:12px 14px;
  border:1px solid var(--edge); background:var(--in); border-radius:12px;
  cursor:pointer; font-size:.92rem; position:relative}
.toggle-row input{position:absolute; opacity:0; pointer-events:none}
.switch{display:inline-block; width:36px; height:20px; flex:0 0 auto; margin-left:auto;
  border-radius:99px; background:var(--edge); position:relative; overflow:hidden;
  transition:background .18s ease}
.switch::after{content:''; position:absolute; top:2px; left:2px; width:16px; height:16px;
  border-radius:50%; background:var(--dim); transition:left .18s ease, background .18s ease}
.toggle-row input:checked ~ .switch{background:color-mix(in srgb, var(--fern) 45%, var(--in))}
.toggle-row input:checked ~ .switch::after{left:18px; background:var(--fern)}
.toggle-row input:focus-visible ~ .switch{outline:2px solid var(--fern); outline-offset:2px}

/* the Account screen */
.panel-body h3{font-size:.72rem; letter-spacing:.1em; color:var(--dim); margin-top:14px}
.panel-body .acct{margin-bottom:4px}
.panel-body .row-confirm{justify-content:flex-start}
/* a signed-in device: this one wears the fern edge, the rest the plain one */
.panel .row.device.current{border-color:color-mix(in srgb, var(--fern) 55%, transparent)}
.panel .row.device .acct-badge{white-space:nowrap}

/* the About screen: a preamble in two registers, then the finds */
.about-preamble{display:flex; flex-direction:column; gap:10px; padding:8px 2px 4px}
.about-preamble h2{font-size:1.3rem; font-weight:700; letter-spacing:.01em}
.about-preamble blockquote{margin:0; padding:2px 0 2px 14px; font-style:italic; line-height:1.55;
  color:color-mix(in srgb, var(--text) 82%, var(--dim));
  border-left:3px solid; border-image:linear-gradient(var(--fern), var(--twilight)) 1}
.about-preamble p{line-height:1.55}
.about-preamble .about-coda{color:var(--dim); font-size:.9rem}
.about-head{display:flex; align-items:center; gap:8px}
.about-tally{margin-left:auto; font-variant-numeric:tabular-nums; letter-spacing:.04em}
.panel button.row.find{width:100%; text-align:left; font:inherit; color:var(--text); cursor:pointer}
.panel button.row.find:hover{border-color:var(--fern)}
.panel button.row.find:focus-visible{outline:2px solid var(--fern); outline-offset:1px}
.panel .row.find.locked{border-style:dashed; background:transparent}
.panel .row.find.locked .row-name{color:var(--dim); letter-spacing:.2em}
.about-forget{display:flex; justify-content:flex-start}

/* the guide: a list of pages, and a page's short version with the way to the whole one */
.panel button.row.guide-row{width:100%; text-align:left; font:inherit; color:var(--text); cursor:pointer}
.panel button.row.guide-row:hover{border-color:var(--fern)}
.panel button.row.guide-row:focus-visible{outline:2px solid var(--fern); outline-offset:1px}
.guide-chev{color:var(--dim); font-size:1.3rem; line-height:1}
.panel-body.guide{display:flex; flex-direction:column; gap:14px}
/* the tip card's text (.tip-body, below), at reading size: a page is read, not glanced at */
.tip-body.guide-text{font-size:1rem; line-height:1.6; gap:12px}
.panel-body.guide-page{display:flex; flex-direction:column; gap:18px}
.guide-whole{align-self:flex-start; color:var(--fern); font-weight:600; text-decoration:none}
.guide-whole:hover, .guide-whole:focus-visible{text-decoration:underline}

/* notifications: letters, each in its own weft's colour, on a neutral page */
.notes-head{display:flex; justify-content:flex-end}
.notes-head:has(> [hidden]:only-child){display:none}
.notify{display:flex; flex-direction:column; gap:6px; margin-top:12px}
.panel .rows > .row.note{align-items:flex-start; border-left:3px solid var(--weft-a)}
.note-body{margin:8px 0 0; white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.5}
.note .bubble-pics{margin:8px 0 0}
.note .bubble-files{margin:8px 0 0}

/* ---- the gallery (js/views/gallery.js): a grid of tiles, pictures as themselves and
   files as their icon and name; a tile from a weft carries that weft's pea */
.gallery-head{display:flex; align-items:center; gap:10px}
.gallery-status{flex:1; margin:0; color:var(--dim); font-size:.85rem}
.gallery-add{display:inline-flex; align-items:center; gap:6px}
.gallery-add .ic{width:15px; height:15px}
.gallery-chips{display:flex; flex-wrap:wrap; gap:6px; margin:12px 0 4px}
.gallery-chip{
  padding:5px 12px; border-radius:999px; font-size:.85rem;
  background:var(--in); color:var(--dim); border:1px solid var(--inedge);
}
.gallery-chip:hover{color:var(--text)}
.gallery-chip[aria-checked=true]{
  color:var(--text); border-color:var(--fern);
  background:color-mix(in srgb, var(--fern) 18%, var(--in));
}
.gallery-grid{
  display:grid; grid-template-columns:repeat(auto-fill, minmax(104px, 1fr)); gap:10px;
  margin-top:12px;
}
.gallery-tile{
  position:relative; aspect-ratio:1; padding:0; overflow:hidden;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  border-radius:14px; border:1px solid var(--inedge); background:var(--in); color:var(--text);
  box-shadow:0 2px 8px rgba(0,0,0,.14); cursor:pointer;
  transition:transform .15s ease, border-color .15s ease;
}
.gallery-tile:hover{transform:translateY(-2px); border-color:var(--weft-a, var(--fern))}
.gallery-tile:focus-visible{outline:2px solid var(--fern); outline-offset:2px}
.gallery-tile.picture img{position:absolute; inset:0; width:100%; height:100%; object-fit:cover}
.gallery-tile.file{
  gap:6px; padding:10px 8px;
  background:linear-gradient(160deg,
    color-mix(in srgb, var(--weft-a, var(--fern)) 16%, var(--in)),
    color-mix(in srgb, var(--weft-b, var(--twilight)) 12%, var(--in)));
}
.gallery-tile.gone{opacity:.5}
.gallery-glyph .ic{width:30px; height:30px; opacity:.85}
.gallery-glyph.big{display:flex; justify-content:center; padding:18px 0}
.gallery-glyph.big .ic{width:64px; height:64px; opacity:.7}
.gallery-caption{display:flex; flex-direction:column; align-items:center; max-width:100%; line-height:1.2}
.gallery-caption:has(> :empty:first-child){display:none}
.gallery-name{
  max-width:100%; font-size:.78rem; font-weight:600; text-align:center;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  overflow-wrap:anywhere;
}
.gallery-type{font-size:.68rem; color:var(--dim)}
.gallery-pea{
  position:absolute; top:7px; right:7px; width:10px; height:10px; border-radius:50%;
  background:linear-gradient(135deg, var(--weft-a), var(--weft-b));
  box-shadow:0 0 0 2px color-mix(in srgb, #000 30%, transparent);
}
.gallery-empty{grid-column:1 / -1}
.gallery-foot{margin-top:18px}

.gallery-preview{
  display:flex; justify-content:center; margin-bottom:12px;
  border-radius:14px; background:var(--in); border:1px solid var(--inedge); overflow:hidden;
}
.gallery-preview.picture{background:#000}
.gallery-preview:has(.file-player){flex-direction:column; padding:12px}
.gallery-preview .file-player{margin-top:0}
.gallery-zoom{padding:0; background:none; border:0; border-radius:0; cursor:zoom-in; line-height:0}
.gallery-zoom img{max-width:100%; max-height:min(60dvh, 520px); object-fit:contain}
.gallery-text{
  margin:0; padding:12px 14px; width:100%; max-height:50dvh; overflow:auto;
  font-size:.82rem; line-height:1.45; white-space:pre-wrap; overflow-wrap:anywhere;
}
.gallery-from{color:var(--dim); font-size:.85rem; margin:0}
.gallery-wefts{display:flex; flex-wrap:wrap; gap:6px; margin:6px 0 4px}
.gallery-weft{
  display:inline-flex; align-items:center; gap:6px; padding:5px 12px 5px 9px;
  border-radius:999px; font-size:.85rem; color:var(--text);
  background:color-mix(in srgb, var(--weft-a) 16%, var(--in));
  border:1px solid color-mix(in srgb, var(--weft-a) 45%, transparent);
}
button.gallery-weft:hover{border-color:var(--weft-a)}
.gallery-weft .led{width:8px; height:8px; border-radius:50%;
  background:linear-gradient(135deg, var(--weft-a), var(--weft-b))}
.gallery-actions{display:flex; flex-wrap:wrap; gap:8px; margin-top:16px}
.gallery-send{margin-top:16px}
.gallery-send .hint{margin:0 0 4px}
/* who it is from: the pea, the name (to that weft's chat), when */
.note-from{display:flex; align-items:center; gap:8px; margin-bottom:4px; min-width:0}
.note-from .led{width:10px; height:10px; flex:0 0 auto; border-radius:50%;
  background:radial-gradient(circle at 30% 30%, var(--weft-a), var(--weft-b))}
.note-weft{font:inherit; font-size:.85rem; font-weight:700; color:var(--weft-a);
  background:none; border:0; padding:0; min-width:0;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
button.note-weft{cursor:pointer}
button.note-weft:hover{text-decoration:underline}
button.note-weft:focus-visible{outline:2px solid var(--weft-a); outline-offset:2px; border-radius:4px}
.note-from .row-sub{margin:0; white-space:nowrap}
/* the drawer entry's count: only there when something waits */
.chunk.big span .count{display:inline-block; margin-left:8px; padding:1px 7px; border-radius:999px;
  background:var(--fern); color:#12141a; font-size:.72rem; font-weight:700;
  vertical-align:2px; line-height:1.4}
.about-colophon{margin-top:18px; padding-top:14px; border-top:1px solid var(--edge);
  display:flex; align-items:baseline; gap:10px; font-size:.78rem; color:var(--dim)}
.about-colophon .wordmark{font-size:15px; font-weight:700; letter-spacing:.04em; color:var(--text)}
.about-colophon .wordmark em{font-style:normal; color:var(--fern)}

#drawer, .panel-body, #log{scrollbar-width:thin; scrollbar-color:var(--edge) transparent}


/* The login page's quiet tenants — one grey donut breathing at a time,
 * quarter-scale children of the chat donut, behind the card's glass.
 * Grey only, by the colour law: colour is reserved for heartbeat and speech. */
canvas.breathers{
  position:fixed; inset:0; z-index:0; pointer-events:none;
  /* A canvas with no CSS size displays at its ATTRIBUTE size — the backing
   * store — which here is the viewport times devicePixelRatio. Without these
   * lines the element is dpr× too big on screen (huge dotted lines) and, worse,
   * resize() reads its own inflated clientWidth, doubling the backing store on
   * every pass until the browser frowns. Explicit 100% breaks that loop: the
   * CSS box is always the viewport, the attribute is always the box times dpr,
   * and the two never feed back into each other. */
  width:100%; height:100%;
}
.centre{ position:relative; z-index:1; }

/* ============================================================================
   Full-screen panels: Providers, the Add/Edit form, Models.

   Above the drawer (z-index 5) rather than inside it. The drawer is a menu — a thing
   you glance at and dismiss — and these are places you stay and work, sometimes for
   as long as it takes to scan four hundred model ids. Cramming that into a 520px
   slide-over would make the list the width of a receipt.
   ============================================================================ */

#panel-host{position:fixed; inset:0; z-index:6}

.panel{
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  background:var(--bg);
}

.panel-inner{display:flex; flex-direction:column; height:100%; min-height:0}

/* Two lines and two ways out, like the drawer's head: back up one layer on the left,
   the name and what it is for in the middle, ✕ to the chat on the right. */
.panel-head{
  flex-shrink:0; display:flex; align-items:center; gap:10px;
  padding:14px 12px;
  padding-top:calc(14px + env(safe-area-inset-top,0px));
  background:var(--panel); border-bottom:1px solid var(--edge);
}
.panel-titles{flex:1; min-width:0; display:flex; flex-direction:column; gap:2px}
.panel-title{font-size:1.05rem; font-weight:700; margin:0;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.panel-subtitle{font-size:.78rem; color:var(--dim); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.panel-subtitle:empty{display:none}
.panel-back, .panel-close{
  flex:0 0 auto; background:none; border:0; color:var(--dim); cursor:pointer;
  width:40px; height:40px; border-radius:10px; line-height:1;
  display:flex; align-items:center; justify-content:center;
}
.panel-back .ic{width:26px; height:26px}
.panel-close .ic{width:20px; height:20px}
.panel-back:hover, .panel-close:hover{color:var(--text); background:var(--in)}
.panel-back:focus-visible, .panel-close:focus-visible{outline:2px solid var(--fern); outline-offset:-2px}

.panel-body{
  flex:1; min-height:0; overflow-y:auto;
  padding:14px 16px;
  padding-bottom:calc(24px + env(safe-area-inset-bottom,0px));
  display:flex; flex-direction:column; gap:12px;
  /* The lists are the content; a phone-width column on a desktop monitor would be
     perverse for a table of models, but an unbounded one is unreadable. The column is
     760px wide, but it is made by the side padding, not a max-width: the scroller
     stays the full width of the screen, so its scrollbar sits on the window's edge
     rather than floating beside the column. 100% here is the panel's width. */
  padding-inline:max(16px, calc((100% - 760px) / 2 + 16px));
}

.rows{display:flex; flex-direction:column; gap:8px}

/* Scoped to .panel deliberately. `.row` is already the chat log's bubble wrapper, and
   an unscoped rule here would win by source order — giving every chat bubble a panel
   border and padding, in a file where the cause is two hundred lines from the effect. */
.panel .row{
  display:flex; align-items:center; gap:12px;
  padding:12px 14px; border-radius:12px;
  background:var(--panel); border:1px solid var(--edge);
}
/* A list row lays out across: name on the left, its buttons on the right. Without this
   a provider's row took the chat log's column and stacked everything, centred. */
.panel .rows > .row{flex-direction:row}
.row-main{flex:1; min-width:0}
.row-name{font-weight:600; overflow-wrap:anywhere}
.row-sub{font-size:.78rem; color:var(--dim); overflow-wrap:anywhere}
.row-actions{display:flex; gap:6px; flex-shrink:0; flex-wrap:wrap; justify-content:flex-end}
.row-confirm{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end;
  font-size:.82rem; color:var(--dim);
}

button.small{
  background:var(--in); color:var(--text); border:1px solid var(--inedge);
  border-radius:9px; padding:6px 12px; font:inherit; font-size:.82rem; cursor:pointer;
}
button.small:hover{border-color:var(--fern)}
button.small.danger{color:#ffb4a8}
button.small.danger:hover{border-color:#c62828}

.empty{color:var(--dim); font-size:.9rem; padding:18px 2px; line-height:1.5}

/* The Add/Edit form reuses the login card's field language without the card. */
.panel-form{display:flex; flex-direction:column; gap:2px}
/* Sections in a panel that holds more than one decision. The rule is a separator
   rather than a box: a box would make each setting look like its own screen. */
.panel-section + .panel-section{
  margin-top:20px; padding-top:16px; border-top:1px solid var(--edge);
}
.section-title{font-size:.95rem; font-weight:700; margin-bottom:6px}
.panel-form label{
  font-size:.78rem; letter-spacing:.04em; text-transform:uppercase;
  color:var(--dim); margin-top:14px;
}
.panel-form input[type=text],
.panel-form input[type=number],
.panel-form input[type=password]{
  width:100%; padding:11px 13px; margin-top:4px;
  font:inherit; color:var(--text);
  background:var(--in); border:1px solid var(--inedge); border-radius:11px;
  /* 16px minimum, or iOS Safari zooms the viewport on focus and never zooms back. */
  font-size:16px;
}
.panel-form input:focus-visible{
  outline:2px solid var(--fern); outline-offset:1px; border-color:var(--fern);
}
.panel-form input:disabled{opacity:.5}
.panel-form .checkline{
  display:flex; align-items:center; gap:8px; margin-top:14px;
  font-size:.85rem; color:var(--dim); text-transform:none; letter-spacing:normal;
  cursor:pointer;
}
.panel-form .checkline input{accent-color:var(--fern)}
.panel-form button[type=submit]{
  margin-top:20px; padding:12px 16px;
  font:inherit; font-weight:600; color:#12141a;
  background:var(--fern); border:0; border-radius:11px; cursor:pointer;
}
.panel-form button[type=submit]:disabled{opacity:.6; cursor:default}

/* A dial is narrower than a field. At full width a box holding "20" reads as an
   invitation to write a sentence in it. */
.panel-form input[type=number]{width:7rem}

/* THE DOOR: an invite or a guide to copy. Monospace, because both hold
   an address or a key that has to be copied exactly. */
.door-shown:not(:empty){display:flex; flex-direction:column; gap:8px; margin-top:12px}
.door-text{
  width:100%; padding:10px 12px; resize:vertical;
  font:12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color:var(--text);
  background:var(--in); border:1px solid var(--inedge); border-radius:11px;
}

/* COLOURS — the preview is built from the window's own .row/.bubble classes, dressed
   with the pair on itself, so it cannot drift from what the window paints. It sits on
   the page background rather than the panel's, because that is what bubbles float over. */
.colour-preview{
  display:flex; flex-direction:column; gap:8px; margin:2px 0 4px; padding:12px;
  background:var(--bg); border:1px solid var(--edge); border-radius:14px;
}
.colour-preview .bubble{max-width:90%; font-size:.9rem}
.colour-preview .row.ai .bubble{display:flex; align-items:center; gap:8px}
.colour-pickers{display:flex; flex-wrap:wrap; gap:4px 20px}
.panel-form label.colour-pick{
  display:flex; align-items:center; gap:10px;
  font-size:.85rem; color:var(--text); text-transform:none; letter-spacing:normal;
  cursor:pointer;
}
.colour-pick input[type=color]{
  width:44px; height:32px; padding:0; flex:0 0 auto; cursor:pointer;
  background:none; border:1px solid var(--inedge); border-radius:8px;
}
.colour-pick input[type=color]::-webkit-color-swatch-wrapper{padding:3px}
.colour-pick input[type=color]::-webkit-color-swatch{border:0; border-radius:5px}
.colour-pick input[type=color]::-moz-color-swatch{border:0; border-radius:5px}
.panel-form > button.small{align-self:flex-start; margin-top:12px}

/* BACKGROUND — the picture on a wide screen and a phone, side by side.
 *
 * Same height, real aspect ratios, and the same crop the window does: cover, centred.
 * The ring is drawn where the donut will be, sized from the frame's LONGER side exactly
 * as donut.js sizes it (0.42 of the longer side as a radius, so 84% as a diameter) —
 * which is why it overflows the wide frame top and bottom and the phone at its sides. */
.bg-frames{display:flex; align-items:flex-end; gap:14px; margin:2px 0 4px}
.bg-frame{margin:0; display:flex; flex-direction:column; gap:4px}
.bg-frame figcaption{font-size:.75rem; color:var(--dim); text-align:center}
.bg-frame-stage{
  position:relative; overflow:hidden; height:120px;
  background:var(--bg); border:1px solid var(--edge); border-radius:10px;
}
.bg-frame.wide .bg-frame-stage{aspect-ratio:16/10}
.bg-frame.tall .bg-frame-stage{aspect-ratio:9/19.5}
.bg-frame-img{
  position:absolute; inset:0; width:100%; height:100%;
  object-fit:cover; object-position:center;
}
.bg-frame-ring{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  aspect-ratio:1; border-radius:50%;
  border:2px solid var(--weft-a); opacity:.85;
  box-shadow:0 0 8px color-mix(in srgb, var(--weft-a) 60%, transparent);
  pointer-events:none;
}
.bg-frame.wide .bg-frame-ring{width:84%}
.bg-frame.tall .bg-frame-ring{height:84%}
.bg-buttons{display:flex; flex-wrap:wrap; gap:8px 12px; margin-top:12px}

/* ADVANCED — a drawer, not a screen.
 *
 * <details> rather than a button and a hidden div, because the disclosure it already
 * implements is the one being asked for: keyboard operable, announced as expanded or
 * collapsed, and findable by a browser's own in-page search even while shut. The
 * styling below only replaces the default triangle with a marker that matches the
 * panel; none of the behaviour is re-implemented.
 *
 * What is in here is the boring half of a decision whose friendly half is already
 * visible above it. Nothing lives ONLY in this drawer — every dial in it has a sentence
 * outside that says what it is currently set to. */
.panel-form .advanced{margin-top:18px}
.panel-form .advanced > summary{
  display:flex; align-items:center; gap:8px;
  width:fit-content; padding:6px 12px;
  font-size:.82rem; color:var(--dim);
  background:var(--in); border:1px solid var(--inedge); border-radius:999px;
  cursor:pointer; list-style:none; user-select:none;
}
.panel-form .advanced > summary::-webkit-details-marker{display:none}
.panel-form .advanced > summary::before{
  content:"›"; display:inline-block; font-size:1.1em; line-height:1;
  transition:transform .15s ease;
}
.panel-form .advanced[open] > summary::before{transform:rotate(90deg)}
.panel-form .advanced > summary:hover{border-color:var(--fern); color:var(--text)}
.panel-form .advanced > summary:focus-visible{
  outline:2px solid var(--fern); outline-offset:1px;
}
/* The drawer's own contents keep the form's column layout, which they do not inherit
   through <details>. */
.panel-form .advanced[open]{display:flex; flex-direction:column}

/* Request headers: a name and a value side by side, and a way to drop the row. The
   name column is the narrower one; values like session keys run long. */
.header-rows{display:flex; flex-direction:column; gap:8px; margin-top:8px}
.header-row{display:grid; grid-template-columns:minmax(0,2fr) minmax(0,3fr) auto;
  gap:8px; align-items:center}
.panel-form .header-row input[type=text]{margin-top:0}
.header-buttons{display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center}

/* The valve sits apart from the settings above it: everything else on this panel saves
   the instant it changes, and this one cannot be undone. */
.panel-form .row-confirm{margin-top:22px}
/* Account: this device is somewhere else; a quiet offer under the clock, not a question */
.panel-form .row-confirm.zone-offer{margin-top:8px}
/* Account: region, then place, side by side where there is room for both */
.zone-selects{display:grid; grid-template-columns:minmax(0,2fr) minmax(0,3fr); gap:8px}
@media (max-width:360px){ .zone-selects{grid-template-columns:1fr} }
.zone-pick .hint{margin-top:8px}

/* The model filter. Only rendered once a provider returns enough models to get lost
   in — a real one answered with 445 the first time this screen met a live endpoint. */
.panel-body .filter{
  width:100%; padding:10px 13px;
  font:inherit; font-size:16px; color:var(--text);
  background:var(--in); border:1px solid var(--inedge); border-radius:11px;
}
.panel-body .filter:focus-visible{
  outline:2px solid var(--fern); outline-offset:1px; border-color:var(--fern);
}

/* A failure that arrived inside a reply, rendered inside the bubble it interrupted —
   so a user does not have to correlate two things that landed a second apart. */
.stream-error{
  margin-top:8px; padding:7px 10px;
  font-size:.82rem; color:#ffb4a8;
  background:color-mix(in srgb, #c62828 22%, transparent);
  border:1px solid color-mix(in srgb, #c62828 45%, transparent);
  border-radius:8px;
  white-space:normal;
}
#in:disabled, #bar button:disabled, #send[aria-disabled=true]{opacity:.55; cursor:default}

/* A voice that did not arrive. Dimmer than .stream-error on purpose: the reply is
   there and readable, and not hearing it is a disappointment rather than a failure. */
.voice-note{
  margin-top:8px; padding:6px 9px;
  font-size:.78rem; color:var(--dim);
  background:color-mix(in srgb, var(--in) 60%, transparent);
  border:1px solid var(--inedge); border-radius:8px;
  white-space:normal;
}

/* The replay control on a spoken bubble. Small and quiet — it is punctuation, not a
   button you are meant to notice before you have read the words. */
.speaker{
  display:flex; margin-top:8px; margin-left:auto;
  padding:4px 7px; font-size:.8rem; line-height:1;
  background:none; border:1px solid var(--inedge); border-radius:8px;
  color:var(--dim); cursor:pointer;
}
.speaker:hover{border-color:var(--fern); color:var(--text)}
.speaker .ic{width:15px; height:15px}

/* Providers screen: the divider before the speech section. */
.section-head{
  display:flex; align-items:center; gap:10px;
  margin-top:18px; padding-top:14px; border-top:1px solid var(--edge);
}
.section-head:first-child{margin-top:0; padding-top:0; border-top:0}
.section-head h2{font-size:.78rem; letter-spacing:.1em; color:var(--dim); flex:1; text-transform:uppercase}

/* Choosing which speech provider speaks a pick: a row that is itself the button. */
button.row.pick-speaker{
  width:100%; text-align:left; cursor:pointer;
  background:var(--panel); color:var(--text);
}
button.row.pick-speaker:hover{border-color:var(--fern)}
/* the provider this weft already speaks through */
button.row.pick-speaker.current{border-color:color-mix(in srgb, var(--fern) 55%, transparent)}

.panel-form select{
  width:100%; padding:11px 13px; margin-top:4px;
  font:inherit; font-size:16px; color:var(--text);
  background:var(--in); border:1px solid var(--inedge); border-radius:11px;
}
.panel-form select:focus-visible{
  outline:2px solid var(--fern); outline-offset:1px; border-color:var(--fern);
}

/* What a weft can do, beside its name, in the Pick's icons. Quiet marks, not badges —
   the useful glance is "which of these speak", and anything louder would compete with
   the name. */
.weft-row .row-name{display:flex; align-items:center; gap:8px}
.weft-row .row-name .pick-caps{padding:0; gap:6px}
.weft-row .row-name .pick-caps .ic{width:14px; height:14px}

/* The Wefts screen: a name field and its button on one line, then the list. */
.add-weft{display:flex; gap:8px}
.add-weft input{
  flex:1; min-width:0; padding:11px 13px;
  font:inherit; font-size:16px; color:var(--text);
  background:var(--in); border:1px solid var(--inedge); border-radius:11px;
}
.add-weft input:focus-visible{outline:2px solid var(--fern); outline-offset:1px}
.add-weft button{
  background:var(--fern); color:#12141a; border:0; border-radius:11px;
  padding:0 18px; font:inherit; font-weight:600; cursor:pointer;
}
/* flex-direction spelled out: the chat log's own `.row` is a column, and `.panel .row`
   does not say otherwise. */
.panel .row.weft-row, .panel .row.engine-model{flex-direction:row; cursor:pointer}
.panel .row.weft-row:hover, .panel .row.engine-model:hover,
.panel .row.weft-row:focus-visible, .panel .row.engine-model:focus-visible{
  border-color:var(--fern); outline:none;
}
.weft-row .led{
  width:12px; height:12px; flex:0 0 auto; border-radius:50%;
  background:radial-gradient(circle at 30% 30%, var(--weft-a), var(--weft-b));
}
.weft-row.unbound .row-sub{font-style:italic}
.weft-row .row-go{color:var(--dim); font-size:20px; line-height:1}

/* The engine's model chooser: shut, it is a field showing the bound model, dressed
   like the provider dropdown above it; open, a filter and a list that scrolls on its
   own, so four hundred models do not push the rest of the page out of reach. */
.model-button{
  width:100%; display:flex; align-items:center; gap:10px; margin-top:4px;
  padding:11px 13px; text-align:left; cursor:pointer;
  font:inherit; font-size:16px; color:var(--dim);
  background:var(--in); border:1px solid var(--inedge); border-radius:11px;
}
.model-button.chosen{color:var(--text)}
.model-button:hover{border-color:var(--fern)}
.model-button:focus-visible{outline:2px solid var(--fern); outline-offset:1px; border-color:var(--fern)}
.model-button[aria-expanded=true]{border-color:var(--fern)}
.model-picked{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.model-button .chev{color:var(--dim); font-size:11px; transition:transform .2s ease}
.model-button[aria-expanded=true] .chev{transform:rotate(180deg)}
.model-field{display:flex; flex-direction:column}
.model-drop{
  margin-top:6px; padding:10px; display:flex; flex-direction:column; gap:8px;
  background:color-mix(in srgb, var(--in) 45%, transparent);
  border:1px solid var(--edge); border-radius:12px;
}
.model-drop .hint{margin:0}
.engine-models{position:relative; max-height:min(50dvh, 420px); overflow-y:auto;
  scrollbar-width:thin; scrollbar-color:var(--edge) transparent}
.engine-models:empty{display:none}
.panel .row.engine-model.on{border-color:var(--fern); box-shadow:inset 3px 0 0 var(--fern)}

/* The words inside a bubble, kept apart from its furniture (speaker button, notices)
   so a streaming update cannot delete them. */
.bubble-text{white-space:pre-wrap; overflow-wrap:break-word}
.bubble-text:empty{display:none}
/* an address in a message (js/links.js): the bubble's own colour, underlined, so it reads
   on every weft's pair; a long one may break anywhere rather than widen the bubble */
.bubble-text a, .note-body a{color:inherit; text-decoration:underline;
  text-underline-offset:2px; overflow-wrap:anywhere}
.bubble-pics:has(+ .bubble-text:empty){margin-bottom:0}
/* several pictures on one message share the row as a grid of smaller ones */
.bubble-pics:has(> :nth-child(2)) .bubble-pic img{width:112px; height:112px; max-width:none}

/* ---- push to talk (js/ptt.js): the 🎤 petal while it listens, and while it thinks */
#send-shelf .petal.recording{
  border-color:#e05555; color:#e05555;
  background:color-mix(in srgb, #e05555 22%, var(--panel));
  animation:ptt-listen 1.1s ease-in-out infinite;
}
@keyframes ptt-listen{
  0%,100%{box-shadow:0 0 0 0 color-mix(in srgb, #e05555 55%, transparent)}
  50%{box-shadow:0 0 0 10px color-mix(in srgb, #e05555 0%, transparent)}
}
#send-shelf .petal.transcribing{border-color:var(--fern); animation:ledpulse 1s ease-in-out infinite}
/* the petal is held for seconds at a time; no long-press menu, no text selection */
#send-shelf .petal[data-act=ptt]{touch-action:none}

/* a message that was spoken wears a small mic on its corner */
.bubble.spoken{position:relative}
.spoken-mark{
  position:absolute; top:-9px; left:-9px; display:flex; padding:3px;
  color:var(--dim); background:var(--panel); border:1px solid var(--inedge); border-radius:50%;
}
.spoken-mark .ic{width:11px; height:11px}

/* ---- tips: the card, its ring, the (?) marks.
   The card is not modal: no scrim, so what it points at stays tappable. It docks low,
   above the input bar on the chat (--tip-lift is set by tutor.js), and above every
   other layer so it can speak about the drawer and the panels too. */
#tip{
  position:fixed; z-index:20; left:50%; transform:translateX(-50%);
  bottom:calc(var(--tip-lift, 16px) + env(safe-area-inset-bottom,0px));
  width:min(440px, calc(100vw - 24px)); max-height:min(60dvh, 520px); overflow-y:auto;
  background:var(--panel); color:var(--text);
  border:1px solid var(--inedge); border-radius:16px;
  box-shadow:0 14px 40px rgba(0,0,0,.45);
  padding:16px 18px 14px;
  animation:tip-in .22s ease-out;
}
/* the edge wears the current weft's pair, fern and twilight before there is one */
#tip::before{
  content:''; position:absolute; left:0; top:14px; bottom:14px; width:3px;
  border-radius:0 3px 3px 0; background:linear-gradient(var(--weft-a), var(--weft-b));
}
@keyframes tip-in{
  from{opacity:0; transform:translate(-50%, 12px)}
  to{opacity:1; transform:translate(-50%, 0)}
}
.tip-eyebrow{display:flex; align-items:center; gap:8px;
  font-size:.68rem; letter-spacing:.1em; text-transform:uppercase; color:var(--dim)}
.tip-dots{display:flex; gap:4px; margin-left:auto}
.tip-dots i{width:6px; height:6px; border-radius:50%; background:var(--edge)}
.tip-dots i.on{background:var(--fern)}
#tip h3{font-size:1.05rem; margin:6px 0; text-wrap:balance}
.tip-body{font-size:.92rem; line-height:1.5; display:flex; flex-direction:column; gap:8px}
.tip-body p, .tip-body ul, .tip-body ol{margin:0}
.tip-body ul, .tip-body ol{padding-left:20px; display:flex; flex-direction:column; gap:3px}
.tip-body code{font-size:.85em; background:var(--in); border:1px solid var(--inedge);
  border-radius:5px; padding:0 4px}
.tip-body a{color:var(--fern)}
/* A link to a hidden tip is not a link to look at: the words, underlined, and no more. */
.tip-body a[data-tip]{color:inherit; text-decoration:underline; text-decoration-thickness:1px;
  text-underline-offset:3px}
.tip-quiet{align-self:flex-start; background:none; border:0; padding:0; color:inherit; font:inherit;
  font-size:.88rem; cursor:pointer; text-decoration:underline; text-decoration-thickness:1px;
  text-underline-offset:3px}
.tip-or{font-size:.78rem; color:var(--dim); margin:10px 0 0}
/* a tip's way on to its guide page (`guide:`) */
.tip-more{margin:10px 0 0; font-size:.9rem}
.tip-more a{color:var(--fern); text-decoration:none}
.tip-more a:hover, .tip-more a:focus-visible{text-decoration:underline}
/* the controls a few tips carry under their words (ELIZA's card) */
.tip-extras{display:flex; flex-direction:column; gap:8px; margin-top:12px}
.tip-actions{display:flex; align-items:center; gap:12px; margin-top:12px}
.tip-got{margin-left:auto; background:var(--fern); color:#12141a; border:0; border-radius:10px;
  padding:8px 18px; font:inherit; font-weight:600; cursor:pointer}
.tip-off{background:none; border:0; padding:4px 0; color:var(--dim); font:inherit; font-size:.8rem;
  cursor:pointer; text-decoration:underline; text-underline-offset:3px}
.tip-off:hover{color:var(--text)}
#tip button:focus-visible{outline:2px solid var(--text); outline-offset:2px}

#tip-ring{
  position:fixed; z-index:19; pointer-events:none; border-radius:14px;
  border:2px solid var(--fern);
  animation:tip-ring 1.6s ease-in-out infinite;
}
@keyframes tip-ring{
  0%,100%{box-shadow:0 0 0 3px color-mix(in srgb, var(--fern) 30%, transparent)}
  50%{box-shadow:0 0 0 9px color-mix(in srgb, var(--fern) 0%, transparent)}
}

.qmark{
  width:22px; height:22px; margin-left:8px; padding:0; vertical-align:middle;
  display:inline-flex; align-items:center; justify-content:center;
  background:none; border:1px solid var(--inedge); border-radius:50%;
  color:var(--dim); font:inherit; font-size:.72rem; font-weight:700; letter-spacing:0;
  cursor:pointer;
}
.qmark:hover, .qmark:focus-visible{border-color:var(--fern); color:var(--fern); outline:none}
/* Lights out (tips.js, `mark()`): lit until its tip is opened, then a quiet fern ring.
   A guide page's mark, and every mark with tips off, stays plain. Still, on purpose:
   solid against ring reads without motion. */
.qmark.unread, .qmark.unread:hover{background:var(--fern); border-color:var(--fern); color:var(--bg)}
.qmark.unread:focus-visible{outline:2px solid var(--text); outline-offset:2px}
.qmark.read{border-color:color-mix(in srgb, var(--fern) 70%, var(--inedge)); color:var(--fern)}

.tips-line{display:flex; align-items:center; gap:10px}
.tips-line .hint{flex:1; margin:0}


/* ---- the audio debug log (js/audiodebug.js): ?audiodebug only.
   Under the top bar rather than over the composer, so a reply can still be sent and
   heard with the log open. Above everything, scrims included. */
.audiodebug{
  position:fixed; left:8px; right:8px; z-index:20;
  top:calc(60px + env(safe-area-inset-top,0px));
  background:rgba(10,12,16,.88); color:#d8f5c8; border:1px solid var(--edge); border-radius:10px;
  font:11px/1.35 ui-monospace,SFMono-Regular,Menlo,monospace;
}
.audiodebug-bar{display:flex; gap:6px; padding:6px}
.audiodebug-bar button{
  background:var(--in); color:var(--text); border:1px solid var(--inedge); border-radius:7px;
  font:inherit; padding:4px 10px;
}
.audiodebug-lines{max-height:38vh; overflow-y:auto; padding:0 8px 8px; white-space:pre-wrap; word-break:break-all;
  -webkit-user-select:text; user-select:text}
.audiodebug.collapsed{left:auto; background:none; border:0}
.audiodebug.collapsed .audiodebug-lines,
.audiodebug.collapsed .audiodebug-bar button:not(:first-child){display:none}

/* ==== COMFORT (js/comfort.js): motion, glass and hand, per device ====
   The device is a ceiling: comfort.js has already folded prefers-reduced-motion,
   prefers-reduced-transparency, prefers-contrast and forced-colors into these three
   attributes, so this is the only place in the stylesheet that needs to know.

   tests/client/comfort-css.test.mjs holds the inventory: every surface with a backdrop
   blur must be in the solid list below, and nothing may animate outside what the
   motion rules stop. Adding one means adding it here too. */

/* ---- motion: calm. Nothing large or looping moves. Every keyframe animation stops,
   so pulses hold their colour and ELIZA's lines hold still. Short transitions of
   colour and opacity stay; the drawer fades rather than sliding across the screen. */
:root:is([data-motion=calm], [data-motion=still]) :is(*, *::before, *::after){
  animation:none !important;
}
:root:is([data-motion=calm], [data-motion=still]) #crt::after{display:none}
:root:is([data-motion=calm], [data-motion=still]) #drawer{
  transform:none; opacity:0; visibility:hidden;
  transition:opacity .18s ease, visibility 0s linear .18s;
}
:root:is([data-motion=calm], [data-motion=still]) #drawer.open{
  opacity:1; visibility:visible; transition:opacity .18s ease;
}
/* the shelf's petals fade in where they stand, without the spring */
:root:is([data-motion=calm], [data-motion=still]) #send-shelf .petal{transform:none}
/* the wordmark's glitch: nothing moves or loops. The wordmark simply reads ELIZA while
   she beckons, her E in the e's colour (js/views/chat.js). */
:root:is([data-motion=calm], [data-motion=still]) #drawer-foot .wordmark.glitch .as-weft{display:none}
:root:is([data-motion=calm], [data-motion=still]) #drawer-foot .wordmark.glitch .as-eliza{display:inline}
/* the send hint stops bobbing, at the colour it rests at */
:root:is([data-motion=calm], [data-motion=still]) #send .hint{opacity:.55}

/* ---- motion: still. Nothing moves at all: no transitions either. */
:root[data-motion=still] :is(*, *::before, *::after){
  transition:none !important;
  scroll-behavior:auto !important;
}

/* ---- glass: less. Mostly opaque, a light blur: what Reduce Transparency does. */
:root[data-glass=less]{--glass:88%}
:root[data-glass=less] :is(.bubble, #bar, #send-shelf .petal, #topbar, #mute-btn,
                           #drawer, #drawer-head, .card){
  backdrop-filter:blur(3px);
}
:root[data-glass=less] :is(#bar, #topbar, #mute-btn, #drawer, .card){
  background:color-mix(in srgb, var(--panel) 94%, transparent);
}

/* ---- glass: solid. Opaque surfaces and no backdrop blur anywhere. */
:root[data-glass=solid]{--glass:100% !important}
:root[data-glass=solid] :is(*, *::before, *::after){backdrop-filter:none !important}
:root[data-glass=solid] :is(.bubble, #bar, #send-shelf .petal, #topbar, #mute-btn,
                            #drawer, #drawer-head, .card){
  background:var(--panel);
}
/* a weft's own bubble keeps its tint, on an opaque panel */
:root[data-glass=solid] .row.ai .bubble{
  background:color-mix(in srgb, var(--weft-a) 12%, var(--panel));
}
:root[data-glass=solid] #in{background:var(--in)}

/* ---- the Comfort screen (views/comfort.js) */
.comfort-row{display:flex; flex-direction:column; gap:8px; margin-top:6px}
.comfort-row h3{margin-top:14px}
.comfort-seg{align-self:flex-start}
.comfort-seg .seg-btn{padding:8px 16px; font-size:.88rem}
/* a choice the device has ruled out: plainly off, and the line below says why */
.comfort-seg .seg-btn:disabled{opacity:.4; cursor:not-allowed; text-decoration:line-through}
.comfort-says{margin:0}
.comfort-why{margin:0; font-size:.82rem; color:var(--text);
  border-left:3px solid var(--fern); padding:2px 0 2px 8px}

/* ---- hand: left. Send, and the shelf that opens from it, on the left; the text box
   and the tray of pictures move over to make room. Push to talk stays the petal
   nearest send, where the thumb already is. */
:root[data-hand=left] #bar{flex-direction:row-reverse}
:root[data-hand=left] #tray{left:auto; right:12px; padding:6px 0 0 6px}
:root[data-hand=left] #send-shelf{
  right:auto; left:10px; padding-left:0; padding-right:8px; flex-direction:row-reverse;
}
:root[data-hand=left] #send-shelf .petal:last-child em{right:auto; left:-4px}
:root[data-hand=left] #send .hint{right:auto; left:-2px}
