/* ============================================================================
   TricorderAgent — public web build
   ----------------------------------------------------------------------------
   One file, no build step, no framework, no webfont. This is the browser-only
   sibling of the desktop app: same visual language, none of the machine access.

   The look descends from LCARS — amber signal colour, upper-case micro-labels,
   monospace for anything the machine said — but it is not a replica. What
   carries the identity: a near-black blue-shifted ground, translucent surfaces
   that layer instead of stack, hairline borders, and amber used sparingly
   enough that it still means something when it appears.

   Colour discipline: amber is the agent and the system. Blue is the operator.
   Purple is reasoning. Green, red and teal are state. Nothing is decorative.

   Sections: TOKENS · RESET · SHELL · TOPBAR · TRANSCRIPT · MESSAGES ·
             MARKDOWN · THINKING · TOOLS · APPROVALS · COMPOSER · PANEL ·
             SETTINGS · DIAGNOSTICS · UTILITIES · RESPONSIVE · MOTION
   ============================================================================ */

/* ── TOKENS ──────────────────────────────────────────────────────────────── */
:root {
    /* Signal */
    --amber:        #ffa724;
    --amber-bright: #ffd6a0;
    --amber-dim:    #8a6234;
    --amber-glow:   rgba(255, 167, 36, .16);

    /* Roles */
    --blue:   #82a9ff;   /* the operator */
    --purple: #b98cff;   /* reasoning */
    --teal:   #4fd6e8;   /* scanning, live data */
    --green:  #3ee08f;   /* ok */
    --red:    #ff6b7a;   /* fail */

    /* Ground — blue-shifted black, not neutral grey */
    --bg:        #06070b;
    --bg-raised: #0b0d14;
    --bg-card:   #10131d;
    --bg-input:  #141826;
    --bg-sunk:   #05060a;

    --line:      #232838;
    --line-soft: #191d29;
    --line-lit:  rgba(255, 214, 160, .16);

    --text:     #e8e6e1;
    --text-mid: #b3aea6;
    --text-dim: #8b867f;

    --radius-sm: 9px;
    --radius:    13px;
    --radius-lg: 20px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI",
            Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Code", Menlo,
            Consolas, "Liberation Mono", monospace;

    --ease: cubic-bezier(.2, .8, .2, 1);
    --fast: .13s var(--ease);
    --med:  .22s var(--ease);

    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    --topbar-h: 54px;
    --measure:  860px;
}

/* ── RESET ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; height: 100%; -webkit-text-size-adjust: 100%; color-scheme: dark; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100%;
    line-height: 1.55;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* A single wide amber wash at the top of the ground — cheap depth, no element. */
body::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(120% 60% at 50% -10%, rgba(255, 167, 36, .07), transparent 60%),
        radial-gradient(80% 50% at 85% 100%, rgba(79, 214, 232, .04), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #333a4e; background-clip: padding-box; }

.skip-link {
    position: absolute; left: 8px; top: -60px; z-index: 100;
    background: var(--amber); color: #1a1206; padding: 8px 14px;
    border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: calc(8px + var(--safe-top)); }

/* ── SHELL ───────────────────────────────────────────────────────────────── */
.app {
    position: relative; z-index: 1;
    display: grid;
    /* minmax(0, 1fr), not the implicit auto track: an auto column is sized to
       its content's max-content width, so a topbar that does not quite fit a
       narrow phone would widen the whole page instead of letting its own
       children shrink. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr auto auto;
    height: 100dvh;
}

/* ── TOPBAR ──────────────────────────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; gap: 10px;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) 12px 0;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(6, 7, 11, .82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { color: var(--amber); font-size: 1.05rem; line-height: 1; }
.brand-name {
    font-weight: 700; font-size: .82rem; letter-spacing: .14em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { color: var(--amber); margin-left: 2px; }

.brand-home {
    color: var(--text-dim); font-size: .68rem; letter-spacing: .1em;
    text-transform: uppercase; padding: 4px 8px; border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft); white-space: nowrap;
    transition: color var(--fast), border-color var(--fast);
}
.brand-home:hover { color: var(--amber); border-color: var(--line-lit); text-decoration: none; }

.topbar-spacer { flex: 1; }

.icon-btn {
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    color: var(--text-mid); font-size: 1.05rem;
    border: 1px solid transparent;
    transition: background var(--fast), color var(--fast), border-color var(--fast);
}
.icon-btn:hover { background: var(--bg-card); color: var(--text); border-color: var(--line-soft); }

.status-pill {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 11px; border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-card);
    font-size: .7rem; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-mid); white-space: nowrap;
    max-width: 44vw; overflow: hidden; text-overflow: ellipsis;
    transition: border-color var(--fast), color var(--fast);
}
.status-pill:hover { border-color: var(--line-lit); color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); flex: none; }
.dot.is-ok   { background: var(--green); box-shadow: 0 0 0 3px rgba(62, 224, 143, .16); }
.dot.is-warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-glow); }
.dot.is-bad  { background: var(--red);   box-shadow: 0 0 0 3px rgba(255, 107, 122, .16); }
.dot.is-busy { background: var(--teal);  animation: pulse 1.1s var(--ease) infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ── TRANSCRIPT ──────────────────────────────────────────────────────────── */
.transcript {
    overflow-y: auto; overscroll-behavior: contain;
    padding: 22px 16px 8px;
    scroll-padding-bottom: 40px;
}
.transcript-inner { max-width: var(--measure); margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* ── WELCOME ─────────────────────────────────────────────────────────────── */
.welcome { text-align: center; padding: 26px 4px 8px; }
.welcome-mark {
    font-size: 2.1rem; color: var(--amber); line-height: 1;
    margin-bottom: 14px; text-shadow: 0 0 26px var(--amber-glow);
}
.welcome h2 { font-size: 1.42rem; font-weight: 650; letter-spacing: -.015em; margin-bottom: 8px; }
.welcome p { color: var(--text-mid); max-width: 54ch; margin: 0 auto; font-size: .93rem; }

.welcome-note {
    margin: 18px auto 0; max-width: 62ch;
    border: 1px solid var(--line); border-left: 2px solid var(--amber);
    background: var(--bg-card); border-radius: var(--radius);
    padding: 12px 14px; text-align: left;
    font-size: .82rem; color: var(--text-mid);
}
.welcome-note strong { color: var(--text); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.chip {
    padding: 7px 13px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--bg-card);
    color: var(--text-mid); font-size: .81rem;
    transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.chip:hover { border-color: var(--line-lit); color: var(--text); background: var(--bg-input); }

/* ── MESSAGES ────────────────────────────────────────────────────────────── */
.msg { display: flex; flex-direction: column; gap: 6px; }
.msg-role {
    font-size: .64rem; letter-spacing: .14em; text-transform: uppercase;
    color: var(--text-dim); display: flex; align-items: center; gap: 7px;
}
.msg-role::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.msg--user   .msg-role { color: var(--blue); }
.msg--agent  .msg-role { color: var(--amber); }
.msg--system .msg-role { color: var(--text-dim); }

.msg-body { font-size: .95rem; overflow-wrap: anywhere; }

.msg--user .msg-body {
    background: rgba(130, 169, 255, .07);
    border: 1px solid rgba(130, 169, 255, .18);
    border-radius: var(--radius);
    padding: 10px 14px;
    white-space: pre-wrap;
}

.msg--system .msg-body {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--bg-raised); padding: 10px 14px;
    color: var(--text-mid); font-size: .86rem;
}
.msg--system.is-error .msg-body { border-color: rgba(255, 107, 122, .35); color: #ffb3bb; }

.caret {
    display: inline-block; width: 7px; height: 1.05em;
    background: var(--amber); vertical-align: text-bottom;
    margin-left: 2px; animation: blink .95s steps(2, start) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* ── MARKDOWN ────────────────────────────────────────────────────────────── */
.md > * + * { margin-top: .7em; }
.md h1, .md h2, .md h3, .md h4 { font-weight: 650; letter-spacing: -.01em; line-height: 1.3; margin-top: 1.2em; }
.md h1 { font-size: 1.24rem; } .md h2 { font-size: 1.12rem; }
.md h3 { font-size: 1rem; }    .md h4 { font-size: .93rem; color: var(--text-mid); }
.md ul, .md ol { padding-left: 1.35em; }
.md li + li { margin-top: .25em; }
.md blockquote {
    border-left: 2px solid var(--amber-dim); padding-left: 12px; color: var(--text-mid);
}
.md code {
    font-family: var(--mono); font-size: .86em;
    background: var(--bg-sunk); border: 1px solid var(--line-soft);
    border-radius: 5px; padding: .1em .38em;
}
.md pre {
    background: var(--bg-sunk); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 12px 14px;
    overflow-x: auto; position: relative;
}
.md pre code { background: none; border: none; padding: 0; font-size: .84rem; line-height: 1.6; }
.md table { border-collapse: collapse; width: 100%; font-size: .87rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md th { background: var(--bg-raised); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md img { max-width: 100%; border-radius: var(--radius-sm); }

.code-copy {
    position: absolute; top: 7px; right: 7px;
    font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
    color: var(--text-dim); border: 1px solid var(--line);
    background: var(--bg-card); border-radius: 6px; padding: 3px 8px;
    opacity: 0; transition: opacity var(--fast), color var(--fast);
}
.md pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--amber); }

/* ── THINKING ────────────────────────────────────────────────────────────── */
.think {
    border: 1px solid rgba(185, 140, 255, .22);
    border-radius: var(--radius); background: rgba(185, 140, 255, .05);
    overflow: hidden;
}
.think > summary {
    cursor: pointer; list-style: none;
    padding: 7px 12px; font-size: .68rem; letter-spacing: .12em;
    text-transform: uppercase; color: var(--purple);
    display: flex; align-items: center; gap: 7px;
}
.think > summary::-webkit-details-marker { display: none; }
.think > summary::after { content: '▾'; margin-left: auto; font-size: .8rem; }
.think[open] > summary::after { content: '▴'; }
.think-body {
    padding: 0 12px 11px; font-size: .84rem; color: var(--text-mid);
    white-space: pre-wrap; font-family: var(--mono); line-height: 1.6;
    max-height: 340px; overflow-y: auto;
}

/* ── TOOLS ───────────────────────────────────────────────────────────────── */
.tool {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--bg-card); overflow: hidden;
}
.tool + .tool { margin-top: 8px; }
.tool-head {
    width: 100%; display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; text-align: left;
}
.tool-icon { color: var(--amber); font-size: .8rem; flex: none; }
.tool-name { font-family: var(--mono); font-size: .82rem; color: var(--text); }
.tool-args {
    font-family: var(--mono); font-size: .74rem; color: var(--text-dim);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1;
}
.tool-state {
    font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
    padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); flex: none;
    color: var(--text-dim);
}
.tool.is-running .tool-state { color: var(--teal); border-color: rgba(79, 214, 232, .35); }
.tool.is-running .tool-icon { animation: pulse 1.1s var(--ease) infinite; }
.tool.is-ok    .tool-state { color: var(--green); border-color: rgba(62, 224, 143, .3); }
.tool.is-fail  .tool-state { color: var(--red);   border-color: rgba(255, 107, 122, .3); }
.tool.is-fail  { border-color: rgba(255, 107, 122, .28); }
.tool-body {
    border-top: 1px solid var(--line-soft); background: var(--bg-sunk);
    padding: 10px 12px; font-family: var(--mono); font-size: .76rem;
    color: var(--text-mid); white-space: pre-wrap; overflow-x: auto;
    max-height: 300px; overflow-y: auto; line-height: 1.55;
}
.tool-body dt {
    font-size: .6rem; letter-spacing: .12em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: 3px;
}
.tool-body dd + dt { margin-top: 10px; }

/* ── APPROVALS ───────────────────────────────────────────────────────────── */
.approvals { padding: 0 16px; }
.approvals:empty { display: none; }
.approval {
    max-width: var(--measure); margin: 0 auto 10px;
    border: 1px solid var(--amber-dim); border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255, 167, 36, .09), rgba(255, 167, 36, .03));
    padding: 12px 14px;
}
.approval-title {
    font-size: .66rem; letter-spacing: .13em; text-transform: uppercase;
    color: var(--amber); margin-bottom: 7px;
}
.approval-what { font-family: var(--mono); font-size: .82rem; margin-bottom: 4px; }
.approval-detail {
    font-family: var(--mono); font-size: .74rem; color: var(--text-mid);
    background: var(--bg-sunk); border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm); padding: 8px 10px; margin: 8px 0;
    max-height: 180px; overflow: auto; white-space: pre-wrap;
}
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
    padding: 8px 15px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--bg-card);
    color: var(--text); font-size: .84rem; font-weight: 500;
    transition: background var(--fast), border-color var(--fast), color var(--fast), opacity var(--fast);
}
.btn:hover { border-color: var(--line-lit); background: var(--bg-input); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #1a1206; font-weight: 600; }
.btn-primary:hover { background: var(--amber-bright); border-color: var(--amber-bright); }
.btn-ghost { background: transparent; color: var(--text-mid); }
.btn-ghost:hover { color: var(--text); }
.btn-ghost.danger { color: var(--red); border-color: rgba(255, 107, 122, .28); }
.btn-sm { padding: 5px 11px; font-size: .77rem; }

/* ── COMPOSER ────────────────────────────────────────────────────────────── */
.composer {
    border-top: 1px solid var(--line-soft);
    background: rgba(6, 7, 11, .86);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    padding: 9px 16px calc(9px + var(--safe-bottom));
}
.composer-inner { max-width: var(--measure); margin: 0 auto; }

.composer-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; flex-wrap: wrap; }
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--bg-card);
    font-size: .64rem; letter-spacing: .09em; text-transform: uppercase;
    color: var(--text-dim);
    transition: border-color var(--fast), color var(--fast);
}
.pill:hover { border-color: var(--line-lit); color: var(--text-mid); }
.pill-val { color: var(--amber); font-weight: 600; }
.pill.is-off .pill-val { color: var(--text-dim); }
.composer-spacer { flex: 1; }
.stat { font-family: var(--mono); font-size: .68rem; color: var(--text-dim); }

.composer-row {
    display: flex; align-items: flex-end; gap: 8px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--bg-input); padding: 6px 6px 6px 12px;
    transition: border-color var(--fast);
}
.composer-row:focus-within { border-color: var(--amber-dim); }
#input {
    flex: 1; background: none; border: none; resize: none;
    font-size: .95rem; line-height: 1.5; max-height: 190px;
    padding: 6px 0; outline: none;
}
#input::placeholder { color: var(--text-dim); }
.send-btn {
    width: 36px; height: 36px; flex: none; border-radius: var(--radius-sm);
    background: var(--amber); color: #1a1206; display: grid; place-items: center;
    font-size: .95rem; transition: background var(--fast), opacity var(--fast);
}
.send-btn:hover { background: var(--amber-bright); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn.stop { background: var(--red); color: #240a0e; }

/* ── PANEL ───────────────────────────────────────────────────────────────── */
.scrim {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(3, 4, 7, .62);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    animation: fade var(--med);
}
@keyframes fade { from { opacity: 0; } }

.panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
    width: min(430px, 100vw);
    display: flex; flex-direction: column;
    background: var(--bg-raised);
    border-left: 1px solid var(--line);
    animation: slide var(--med);
    padding-top: var(--safe-top); padding-bottom: var(--safe-bottom);
}
@keyframes slide { from { transform: translateX(100%); } }

.panel-head {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px 8px 14px;
    border-bottom: 1px solid var(--line-soft);
}
.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.tab {
    padding: 6px 11px; border-radius: var(--radius-sm);
    font-size: .76rem; color: var(--text-dim); white-space: nowrap;
    transition: background var(--fast), color var(--fast);
}
.tab:hover { color: var(--text-mid); }
.tab.is-active { background: var(--bg-card); color: var(--amber); }

.panel-body { flex: 1; overflow-y: auto; padding: 16px 14px 30px; }

.field { display: block; margin-bottom: 17px; }
.field > .label {
    display: block; font-size: .64rem; letter-spacing: .13em;
    text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px;
}
.field input[type=text], .field input[type=url], .field input[type=password],
.field input[type=number], .field select, .field textarea {
    width: 100%; padding: 8px 11px;
    background: var(--bg-input); border: 1px solid var(--line);
    border-radius: var(--radius-sm); font-size: .87rem; outline: none;
    transition: border-color var(--fast);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--amber-dim); }
.field input[type=url], .field input[type=password] { font-family: var(--mono); font-size: .82rem; }
.field small { display: block; margin-top: 6px; font-size: .74rem; color: var(--text-dim); line-height: 1.5; }
.field small code {
    font-family: var(--mono); font-size: .95em; color: var(--amber-bright);
    background: var(--bg-sunk); padding: .05em .35em; border-radius: 4px;
}

.check { display: flex; align-items: flex-start; gap: 9px; padding: 5px 0; font-size: .85rem; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--amber); flex: none; }
.check span { color: var(--text-mid); }

.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns > .btn { flex: 1; min-width: 120px; }

.hint { font-size: .82rem; color: var(--text-dim); line-height: 1.6; margin-bottom: 14px; }

/* ── HOST PRESETS ────────────────────────────────────────────────────────── */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.preset {
    padding: 5px 10px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--bg-card);
    font-size: .73rem; color: var(--text-mid);
    transition: border-color var(--fast), color var(--fast);
}
.preset:hover { border-color: var(--line-lit); color: var(--text); }
.preset.is-active { border-color: var(--amber); color: var(--amber); background: var(--amber-glow); }

/* ── DIAGNOSTICS ─────────────────────────────────────────────────────────── */
.diag {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--bg-card); padding: 11px 13px; margin-top: 10px;
    font-size: .8rem; line-height: 1.6;
}
.diag.is-ok   { border-color: rgba(62, 224, 143, .3);  background: rgba(62, 224, 143, .05); }
.diag.is-bad  { border-color: rgba(255, 107, 122, .3); background: rgba(255, 107, 122, .05); }
.diag.is-busy { border-color: rgba(79, 214, 232, .3);  background: rgba(79, 214, 232, .05); }
.diag-title {
    font-size: .64rem; letter-spacing: .12em; text-transform: uppercase;
    margin-bottom: 5px; color: var(--text-mid);
}
.diag.is-ok  .diag-title { color: var(--green); }
.diag.is-bad .diag-title { color: var(--red); }
.diag.is-busy .diag-title { color: var(--teal); }
.diag p { color: var(--text-mid); }
.diag p + p { margin-top: 7px; }
.diag code, .diag pre {
    font-family: var(--mono); font-size: .76rem; color: var(--amber-bright);
    background: var(--bg-sunk); border: 1px solid var(--line-soft);
    border-radius: 6px;
}
.diag code { padding: .1em .38em; overflow-wrap: anywhere; }
.diag pre { display: block; padding: 8px 10px; margin-top: 7px; overflow-x: auto; white-space: pre; }
.diag ol, .diag ul { margin: 6px 0 0 1.2em; color: var(--text-mid); }
.diag li + li { margin-top: 4px; }

/* ── LISTS (memory, files, history) ──────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.list:empty::after {
    content: attr(data-empty); display: block; text-align: center;
    color: var(--text-dim); font-size: .82rem; padding: 26px 10px;
}
.item {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--bg-card); padding: 10px 12px;
    display: flex; align-items: flex-start; gap: 10px;
}
.item-main { flex: 1; min-width: 0; }
.item-key {
    font-family: var(--mono); font-size: .78rem; color: var(--amber);
    overflow-wrap: anywhere;
}
.item-val { font-size: .82rem; color: var(--text-mid); overflow-wrap: anywhere; }
.item-meta { font-family: var(--mono); font-size: .68rem; color: var(--text-dim); margin-top: 3px; }
.item-del {
    color: var(--text-dim); font-size: .9rem; line-height: 1; padding: 3px 5px;
    border-radius: 5px; flex: none;
}
.item-del:hover { color: var(--red); background: rgba(255, 107, 122, .1); }

/* ── TOOL CATALOG ────────────────────────────────────────────────────────── */
.cat-group + .cat-group { margin-top: 16px; }
.cat-head {
    font-size: .64rem; letter-spacing: .13em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: 7px;
    display: flex; align-items: center; gap: 8px;
}
.cat-head::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }
.cat-tool { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-size: .81rem; }
.cat-tool code { font-family: var(--mono); font-size: .78rem; color: var(--text); }
.cat-tool span { color: var(--text-dim); font-size: .76rem; }
.cat-tool.is-off code { color: var(--text-dim); text-decoration: line-through; }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: calc(88px + var(--safe-bottom));
    transform: translateX(-50%); z-index: 60;
    background: var(--bg-card); border: 1px solid var(--line-lit);
    border-radius: 999px; padding: 8px 17px;
    font-size: .82rem; color: var(--text);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
    animation: rise var(--med);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ── PREVIEW FRAME ───────────────────────────────────────────────────────── */
.preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.preview-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; background: var(--bg-raised);
    border-bottom: 1px solid var(--line-soft);
    font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim);
}
.preview-bar .btn-sm { margin-left: auto; }
.preview iframe { display: block; width: 100%; height: 380px; border: none; background: #fff; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 620px) {
    .transcript { padding: 16px 12px 6px; }
    .composer { padding-left: 12px; padding-right: 12px; }
    .approvals { padding: 0 12px; }
    .welcome { padding-top: 14px; }
    .welcome h2 { font-size: 1.24rem; }
    .brand-name { font-size: .72rem; letter-spacing: .08em; }
    .brand-home { display: none; }
    .status-pill { max-width: 34vw; padding: 5px 9px; }
    .topbar { gap: 7px; padding-left: 10px; padding-right: 10px; }
}

/* ── MOTION ──────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important; animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
