/* Shared frame and components, used by both pages. Values come from theme.css only. */

/* ---------- frame ---------- */
.app { --pad-l:max(var(--pad), env(safe-area-inset-left)); --pad-r:max(var(--pad), env(safe-area-inset-right));
       position:fixed; inset:0; display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:calc(var(--topbar) + env(safe-area-inset-top)) minmax(0,1fr) auto;
       padding:0 var(--pad-r) 0 var(--pad-l); transition:padding var(--dur-slow) var(--ease); }
.stage { min-height:0; overflow:hidden; padding-top:var(--s-3); display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; }
.orb-space { flex:1 1 0; min-height:150px; max-height:min(46vh, 420px); width:min(100%, 520px); }
.dock-wrap { display:flex; flex-direction:column; align-items:center; gap:var(--s-4); padding:var(--s-4) 0 max(var(--s-5), env(safe-area-inset-bottom)); }
.dock { display:flex; align-items:center; justify-content:center; gap:var(--s-3); }

/* ---------- top bar: brand, current app, then connection + tools. A hairline separates it from the stage. ---------- */
.topbar { position:relative; display:flex; align-items:stretch; gap:var(--s-2); min-width:0; padding-top:env(safe-area-inset-top); }
.topbar::before { content:""; position:absolute; z-index:-1; top:0; bottom:0; left:calc(-1 * var(--pad-l)); right:calc(-1 * var(--pad-r)); background:linear-gradient(to bottom, color-mix(in srgb, var(--bg) 55%, transparent), transparent); pointer-events:none; }
.topbar::after { content:""; position:absolute; left:calc(-1 * var(--pad-l)); right:calc(-1 * var(--pad-r)); bottom:0; height:1px; background:linear-gradient(to right, transparent, var(--border) 12%, var(--border) 88%, transparent); }
.topbar-right { display:flex; align-items:center; gap:var(--s-2); min-width:0; margin-left:auto; }
.brand { display:flex; align-items:center; gap:var(--s-3); min-width:var(--tap); color:var(--text); text-decoration:none; font-weight:var(--fw-semibold); }
.brand .logo { display:block; height:32px; width:auto; }

.badge { position:absolute; top:var(--s-1); right:var(--s-1); min-width:16px; height:16px; padding:0 var(--s-1); border-radius:var(--r-sm); font-size:var(--fs-xs); font-weight:var(--fw-semibold); line-height:16px; text-align:center; color:var(--on-accent); background:var(--accent); }

/* ---------- button: primary / secondary / ghost / danger, plus the icon shape ---------- */
.btn { position:relative; display:inline-flex; align-items:center; justify-content:center; gap:var(--s-2); min-height:var(--control); padding:0 var(--s-5); border:1px solid transparent; border-radius:var(--r-md);
       font-size:var(--fs-md); font-weight:var(--fw-semibold); line-height:1; white-space:nowrap; text-decoration:none; color:var(--text); background:transparent;
       transition:background var(--dur), border-color var(--dur), color var(--dur), box-shadow var(--dur-slow) var(--ease-spring), transform var(--dur-slow) var(--ease-spring); }
.btn:active:not(:disabled) { transform:translateY(1px); transition-duration:60ms; }
.btn:disabled { cursor:default; opacity:.45; }
.btn-primary { color:var(--on-accent); background:var(--accent); box-shadow:inset 0 1px 0 var(--accent-hi), var(--shadow-accent); }
.btn-primary:hover:not(:disabled) { background:var(--accent-hover); box-shadow:inset 0 1px 0 var(--accent-hi), var(--shadow-accent-hover); transform:translateY(-1px); }
.btn-primary:active:not(:disabled) { background:var(--accent-press); box-shadow:inset 0 1px 0 var(--accent-hi), var(--shadow-accent-press); transform:translateY(1px); }
.btn-secondary { background:var(--surface-2); border-color:var(--border-strong); box-shadow:inset 0 1px 0 var(--hl); }
.btn-secondary:hover { background:var(--surface-3); }
.btn-ghost { color:var(--text-2); }
.btn-ghost:hover { background:var(--surface-2); color:var(--text); }
.btn-ghost[aria-expanded="true"] { background:var(--surface-2); color:var(--text); }
.btn-icon { flex:none; width:var(--tap); height:var(--tap); min-height:0; padding:0; }

/* ---------- the call bar: three ROUND buttons like a phone call. Mic and speaker are neutral; "off" is the INVERTED fill with a slashed icon (never red).
   END is the only solid-red control, larger, with the ONLY danger colour on the screen. Start / stop are pills of the same height family. ---------- */
.dock .btn-primary, #go, #stop { min-height:var(--call); padding:0 var(--s-6); border-radius:999px; }
.dock .btn-primary .ico, #go .ico, #stop .ico { width:22px; height:22px; }
.ctl { display:flex; flex-direction:column; align-items:center; gap:var(--s-2); animation:rise var(--dur-state) var(--ease) both; }
.ctl:nth-child(3) { animation-delay:50ms; } .ctl:nth-child(4) { animation-delay:100ms; }
.ctl:has(> button[hidden]) { display:none; }
.ctl-label { font-size:var(--fs-xs); font-weight:var(--fw-medium); line-height:1; color:var(--text-2); white-space:nowrap; }
.dock:has(.ctl) { gap:var(--s-6); align-items:flex-start; }
.btn-round { width:var(--call); height:var(--call); min-height:0; padding:0; border-radius:50%; color:var(--text); background:var(--ctl); border-color:var(--border-strong);
             box-shadow:inset 0 1px 0 var(--hl), var(--shadow-ctl); transition:background var(--dur), color var(--dur), border-color var(--dur), box-shadow var(--dur-slow) var(--ease-spring), transform var(--dur-slow) var(--ease-spring); }
.btn-round .ico { width:26px; height:26px; stroke-width:1.9; }
.btn-round:hover { background:var(--ctl-hover); box-shadow:inset 0 1px 0 var(--hl), var(--shadow-ctl-hover); transform:translateY(-2px); }
.btn-round:active:not(:disabled) { background:var(--ctl-press); transform:scale(.94); transition-duration:60ms; }
.btn-round[aria-pressed="true"] { color:var(--ctl-on-ink); background:var(--ctl-on); border-color:var(--ctl-on); }
.btn-round[aria-pressed="true"]:hover { background:var(--text-2); border-color:var(--text-2); }
.btn-round:focus-visible, .btn-end-pill:focus-visible, .dock .btn-primary:focus-visible { outline-offset:3px; border-radius:50%; }
.dock .btn-primary:focus-visible, .btn-end-pill:focus-visible, #go:focus-visible { border-radius:999px; }
.btn-end, .btn-end-pill { color:var(--on-danger); background:var(--danger-solid); border-color:transparent; box-shadow:inset 0 1px 0 var(--hl-strong), var(--shadow-danger); }
.btn-end { width:var(--call-end); height:var(--call-end); }
.btn-end .ico { width:30px; height:30px; }
.btn-end:hover, .btn-end-pill:hover { background:var(--danger-solid-hover); transform:translateY(-1px); }
.btn-end:active:not(:disabled), .btn-end-pill:active:not(:disabled) { background:var(--danger-solid-press); transform:translateY(1px); }
.btn-end:hover { transform:translateY(-2px); }
.btn-end:active:not(:disabled) { transform:scale(.94); }
.btn-end-pill { gap:var(--s-2); font-weight:var(--fw-semibold); }
.ctl:not(.ctl-end) > .btn-round { margin-block:calc((var(--call-end) - var(--call)) / 2); }   /* all three share one centre line and one label line although END is larger */
@keyframes rise { from { opacity:0; transform:translateY(10px) scale(.94); } }

/* ---------- chip: the status indicator. State is carried by the SHAPE of the mark and by the label; colour only reinforces.
   idle = hollow ring, listening = ring with dot, thinking / connecting = half-filled and turning, speaking = diamond, connected = solid dot.
   The colour (--dot) comes from the nearest data-s; a voice sets --voice so its label matches its orb. Green means "connected" and nothing else. ---------- */
[data-s="live"] { --dot:var(--ok); }
[data-s="wait"] { --dot:var(--warn); }
[data-s="listening"], [data-s="thinking"], [data-s="speaking"] { --dot:var(--voice, var(--text-2)); }
.chip { display:inline-flex; align-items:center; gap:var(--s-2); min-width:0; font-size:var(--fs-sm); color:var(--text-2); white-space:nowrap; }
.chip::before { content:""; flex:none; box-sizing:border-box; width:10px; height:10px; border-radius:50%; background:var(--dot, var(--text-2)); transition:background var(--dur-state), border-color var(--dur-state); }
:is([data-s="live"] .chip, .chip[data-s="live"])::before { box-shadow:0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
:is([data-s="idle"] .chip, .chip[data-s="idle"])::before { background:transparent; border:2px solid var(--text-3); }
:is([data-s="listening"] .chip)::before { background:radial-gradient(circle, var(--dot) 38%, transparent 42%); border:2px solid var(--dot); }
:is([data-s="thinking"] .chip, .chip[data-s="wait"])::before { background:conic-gradient(var(--dot) 0 50%, transparent 0); border:2px solid var(--dot); animation:spin 1.2s linear infinite; }
:is([data-s="speaking"] .chip)::before { width:9px; height:9px; margin:0 .5px; border-radius:2px; transform:rotate(45deg); }
.chip > span { overflow:hidden; text-overflow:ellipsis; }
.chip time { color:var(--text); }
#conn[data-s="idle"] { display:none; }   /* the headline already says "ready"; the chip appears only when it adds connection or timer */
@keyframes spin { to { transform:rotate(360deg); } }
@keyframes pulse { 50% { opacity:.35; } }

/* ---------- input (also wraps a labelled field) ---------- */
.input { min-height:var(--control); padding:0 var(--s-4); background:var(--surface-2); border:1px solid var(--border-strong); border-radius:var(--r-md); outline:0; box-shadow:inset 0 1px 2px rgba(0,0,0,.18); transition:border-color var(--dur), box-shadow var(--dur-slow) var(--ease-spring), background var(--dur); }
.input:hover:not(:focus):not(:focus-within) { border-color:color-mix(in srgb, var(--border-strong) 60%, var(--text-2)); }
.input:focus, .input:focus-within { border-color:var(--accent); background:var(--surface); box-shadow:inset 0 1px 2px rgba(0,0,0,.18), var(--ring); }
.input:focus-visible, .input:focus-within { outline:0; }
.input::placeholder, .input input::placeholder { color:var(--text-3); }
.field { display:flex; align-items:center; gap:var(--s-3); font-size:var(--fs-sm); color:var(--text-2); }
.field input { flex:1; min-width:0; font-size:var(--fs-md); color:var(--text); text-overflow:ellipsis; background:transparent; border:0; outline:0; }

/* ---------- card ---------- */
.card { display:flex; flex-direction:column; align-items:flex-start; gap:var(--s-1); padding:var(--s-3) var(--s-4); text-align:left; color:var(--text); background:var(--surface); border:1px solid var(--border); border-radius:var(--r-md); box-shadow:inset 0 1px 0 var(--hl); }
button.card { cursor:pointer; transition:border-color var(--dur), background var(--dur), box-shadow var(--dur-slow) var(--ease-spring), transform var(--dur-slow) var(--ease-spring); }
button.card:hover { background:var(--surface-2); border-color:var(--border-strong); box-shadow:inset 0 1px 0 var(--hl), var(--shadow-card); transform:translateY(-1px); }
button.card[aria-pressed="true"] { background:var(--accent-soft); border-color:color-mix(in srgb, var(--accent) 70%, transparent); box-shadow:inset 0 1px 0 color-mix(in srgb, var(--accent) 25%, transparent), 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }

/* ---------- alert: warning by default, .fatal for errors ---------- */
.alert { display:flex; align-items:flex-start; gap:var(--s-3); width:min(560px, 100%); padding:var(--s-3) var(--s-4); margin-top:var(--s-2); text-align:left; font-size:var(--fs-sm); line-height:var(--lh-base); color:var(--text);
         background:var(--warn-soft); border:1px solid var(--warn); border-radius:var(--r-md); animation:enter var(--dur-slow) var(--ease); }
.alert::before { content:""; flex:none; width:8px; height:8px; margin-top:.5em; border-radius:50%; background:var(--warn); }
.alert.fatal { background:var(--danger-soft); border-color:var(--danger); }
.alert.fatal::before { background:var(--danger); }
@keyframes enter { from { opacity:0; transform:translateY(6px); } }

/* ---------- progress ---------- */
.progress { height:4px; border-radius:2px; background:var(--surface-3); overflow:hidden; box-shadow:inset 0 1px 1px rgba(0,0,0,.25); }
.progress i { display:block; height:100%; width:0; border-radius:2px; background:linear-gradient(to right, var(--accent-press), var(--accent) 70%, var(--accent-hi)); box-shadow:0 0 8px color-mix(in srgb, var(--accent) 55%, transparent); transition:width var(--dur-slow) var(--ease); }

/* ---------- dialog ---------- */
.dialog-scrim { position:fixed; inset:0; z-index:60; display:grid; place-items:center; padding:var(--s-4); background:var(--scrim); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); animation:enter var(--dur); }
.dialog { width:min(440px, 100%); padding:var(--s-5); text-align:left; background:var(--surface); border:1px solid var(--border); border-radius:var(--r-lg); box-shadow:var(--shadow); animation:lift var(--dur-state) var(--ease-spring); }
.dialog h2 { margin-bottom:var(--s-4); font-size:var(--fs-md); font-weight:var(--fw-semibold); }
.dialog dl { display:grid; grid-template-columns:auto 1fr; gap:var(--s-3) var(--s-4); align-items:center; font-size:var(--fs-sm); color:var(--text-2); }
.dialog .actions { display:flex; justify-content:flex-end; margin-top:var(--s-4); }
kbd { display:inline-block; min-width:28px; padding:var(--s-1) var(--s-2); text-align:center; font:var(--fw-semibold) var(--fs-xs)/var(--lh-base) var(--font); color:var(--text); background:var(--surface-2); border:1px solid var(--border-strong); border-radius:var(--r-sm); box-shadow:inset 0 1px 0 var(--hl), 0 1px 0 var(--border-strong); }
@keyframes lift { from { opacity:0; transform:translateY(8px) scale(.98); } }

/* ---------- headline block of the assistant page ---------- */
.readout { width:min(680px, 100%); }
.readout { margin-top:var(--s-4); }
.readout h1 { font-family:var(--font-display); font-size:var(--fs-2xl); font-weight:var(--fw-semibold); line-height:var(--lh-tight); letter-spacing:-.015em; }
.readout .hint { max-width:44ch; margin:var(--s-2) auto 0; min-height:1.5em; color:var(--text-3); }
.caption { max-width:min(620px, 92%); min-height:calc(2 * var(--fs-lg) * var(--lh-base)); margin:var(--s-5) auto 0; font-size:var(--fs-lg); color:var(--text); display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; transition:opacity var(--dur-state); }
.caption.fade { opacity:0; }
.caption .who { margin-right:var(--s-2); font-size:var(--fs-sm); font-weight:var(--fw-semibold); color:var(--text-2); }
.swap { animation:enter var(--dur-state) var(--ease); }

/* ---------- sheet: the drawer content becomes a bottom sheet below 900px (chat panel, podcast transcript) ---------- */
@media (max-width: 899px) {
  .sheet { position:fixed; z-index:40; left:0; right:0; bottom:0; top:auto; width:auto; max-width:none; height:var(--sheet-h); margin:0; padding-bottom:env(safe-area-inset-bottom);
           background:var(--surface); border:1px solid var(--border-strong); border-bottom:0; border-radius:var(--r-lg) var(--r-lg) 0 0; box-shadow:var(--shadow); transform:translateY(100%); }
  .sheet::before { content:""; position:absolute; top:var(--s-2); left:50%; width:40px; height:4px; margin-left:-20px; border-radius:2px; background:var(--border-strong); }
  .sheet.open, .stage.log-on .sheet { transform:none; }
}

/* ---------- desktop and tablet only (chat panel, transcript, keyboard help): absent on a phone, not merely hidden from view.
   Same query as PHONE in shared.js and the media attribute of mobile.css. ---------- */
@media (max-width: 640px), (max-height: 480px) { .wide-only { display:none !important; } }

/* ---------- responsive frame ---------- */
@media (max-width: 899px) { :root { --pad:var(--s-4); } }
@media (max-width: 420px) { .brand .name { display:none; } }

/* Side panel (the conversation on "/", the episode's transcript on /podcast): docked on the right on wide screens, a bottom sheet below 900px (.sheet). The page makes room for it. */
.chat { display:flex; flex-direction:column; overflow:hidden; visibility:hidden; transition:transform var(--dur-slow) var(--ease), visibility 0s var(--dur-slow); }
.chat.open { visibility:visible; transition:transform var(--dur-slow) var(--ease), visibility 0s; }
@media (min-width: 900px) {
  .chat { position:fixed; z-index:40; top:0; bottom:0; right:0; width:var(--drawer-w); background:var(--glass); backdrop-filter:blur(18px); -webkit-backdrop-filter:blur(18px); border-left:1px solid var(--border); box-shadow:-16px 0 48px -24px rgba(0,0,0,.6); transform:translateX(100%); }
  .chat.open { transform:none; }
  body.chat-open .app { --pad-r:calc(var(--drawer-w) + var(--gutter)); }
}

.chat-head { display:flex; align-items:center; gap:var(--s-2); flex:none; padding:var(--s-3) var(--s-2) var(--s-3) var(--s-4); border-bottom:1px solid var(--border); }
.chat-head .titles { min-width:0; flex:1; }
.chat-head h2 { font-size:var(--fs-md); font-weight:var(--fw-semibold); line-height:var(--lh-tight); }
.chat-head .chip { font-size:var(--fs-sm); color:var(--text-2); }

.chat-log { flex:1; min-height:0; overflow-y:auto; display:flex; flex-direction:column; gap:var(--s-4); padding:var(--s-4); overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent; }
.chat-empty { margin:auto; max-width:260px; text-align:center; font-size:var(--fs-sm); color:var(--text-2); }
.chat-empty svg { display:block; width:22px; height:22px; margin:0 auto var(--s-4); padding:var(--s-3); box-sizing:content-box; color:var(--text-2); background:var(--surface-2); border:1px solid var(--border); border-radius:var(--r-md); box-shadow:inset 0 1px 0 var(--hl); }
.divider { display:flex; align-items:center; gap:var(--s-3); font-size:var(--fs-xs); color:var(--text-3); }
.divider::before, .divider::after { content:""; flex:1; height:1px; background:var(--border); }

/* the product name is "Digimate Live": "Live" is set lighter, in the logo's orange, so the wordmark reads as one name */
.brand .live { margin-left:.28em; color:var(--accent-hi); font-weight:var(--fw-medium); }

/* Compact app header leaves room for connection status. */
@media (max-width:640px) {
  .topbar .brand .name { display:none; }
  .topbar { gap:4px; }
  .topbar-right { gap:4px; }
  .topbar-right .chip { flex:none; white-space:nowrap; }
  /* Keep the full status accessible; phones show the mark and chat timer. */
  .topbar-right #connText { 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; }
  .topbar-right .chip time { flex:none; }
}
