/* Lumina app (/app): a chat-style env logger. Markup in app.html, logic in app.js. */
:root {
    color-scheme: dark;
    /* surfaces */
    --bg: #111113;
    --side: #0c0c0e;
    --panel: #1c1c1f;
    --panel-2: #232327;
    --panel-3: #2a2a2f;
    --composer: #1d1d21;
    --line: #2a2a2f;
    --line-soft: rgba(255,255,255,0.06);
    --line-strong: rgba(255,255,255,0.12);
    --hover: rgba(255,255,255,0.06);
    /* text */
    --text: #ececef;
    --text-2: #b9b9c0;
    --muted: #8b8b93;
    --faint: #5d5d66;
    /* accent + status */
    --accent: #3b8bf5;
    --accent-2: #2b6fd6;
    --accent-soft: rgba(59,139,245,0.14);
    --error: #ff6b6b;
    --warn: #e5b84a;
    --ok: #3ecf8e;
    --sol: #f2b84b;
    /* shape */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --ring: 0 0 0 2px rgba(59,139,245,0.55);
    /* type + motion */
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Code", "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --spring: cubic-bezier(0.3, 1.35, 0.5, 1);
    --fast: 120ms;
    --med: 180ms;
    --side-w: 264px;
    --col: 800px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--bg); }
html, body { height: 100%; margin: 0; }
body {
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
::selection { background: rgba(59,139,245,0.35); }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; color: inherit; color-scheme: dark; }
button { cursor: pointer; }
[hidden] { display: none !important; }
/* a solid 2px ring (>= 3:1 on the dark surfaces); also shows in forced-colors mode */
:focus-visible { outline: 2px solid #6aa8ff; outline-offset: 2px; }
.sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
svg { flex: 0 0 auto; }

/* dark scrollbars */
::-webkit-scrollbar { width: 12px; height: 12px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border: 3px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); background-clip: padding-box; }
@supports not selector(::-webkit-scrollbar) {
    * { scrollbar-color: rgba(255,255,255,0.18) transparent; scrollbar-width: thin; }
}

/* ── shell ── */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex: 0 0 auto; padding: 0;
    border: 0; border-radius: 10px; background: transparent; color: var(--muted);
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.round { border-radius: 50%; }

/* ── sidebar ── */
.sidebar {
    position: relative; z-index: 20;
    display: flex; flex-direction: column;
    width: var(--side-w); flex: 0 0 var(--side-w);
    background: var(--side);
    border-right: 1px solid var(--line-soft);
    transition: margin-left 220ms var(--ease), visibility 0s;
}
.app.collapsed .sidebar {
    margin-left: calc(-1 * var(--side-w));
    visibility: hidden;
    transition: margin-left 220ms var(--ease), visibility 0s 220ms;
}
.side-head {
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 8px 0 16px; flex: 0 0 auto;
}
.brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 650; font-size: 16px; letter-spacing: -0.01em;
    text-decoration: none; color: var(--text); border-radius: 6px;
}
.brand svg { width: 18px; height: 18px; color: var(--accent); }
.brand span { color: var(--accent); margin-left: -8px; }
.side-new {
    display: flex; align-items: center; gap: 10px;
    margin: 2px 8px 6px; height: 40px; padding: 0 10px;
    border: 0; border-radius: 10px;
    background: rgba(255,255,255,0.05); color: var(--text);
    font: 500 14px/1 var(--sans); text-align: left;
    transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.side-new:hover { background: rgba(255,255,255,0.08); }
.side-new:active { transform: scale(0.985); }
.side-new svg { width: 18px; height: 18px; color: var(--text-2); }
.side-new span { flex: 1; }
.side-new kbd {
    font: 500 11px/1 var(--sans); color: var(--faint); letter-spacing: 0.02em;
    opacity: 0; transition: opacity var(--fast) var(--ease);
}
.side-new:hover kbd, .side-new:focus-visible kbd { opacity: 1; }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 6px 8px 12px; }
.side-label { margin: 10px 10px 6px; color: var(--muted); font: 500 12.5px/1.4 var(--sans); }
.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-item {
    position: relative; display: flex; align-items: center;
    border-radius: 10px;
    transition: background-color var(--fast) var(--ease);
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: rgba(255,255,255,0.09); }
.chat-item::before {
    content: ""; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0;
    background: var(--accent); opacity: 0; transform: scaleY(0.4);
    transition: opacity var(--med) var(--ease), transform 220ms var(--spring);
}
.chat-item.active::before { opacity: 1; transform: none; }
.chat-link {
    flex: 1; min-width: 0; height: 36px; padding: 0 10px;
    border: 0; border-radius: 10px; background: transparent;
    color: var(--text-2); font: 14px/36px var(--sans); text-align: left;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-item.active .chat-link, .chat-item:hover .chat-link { color: var(--text); }
.chat-link:focus-visible { outline-offset: -2px; }
.chat-more {
    width: 28px; height: 28px; margin-right: 4px; border-radius: 7px;
    opacity: 0;
}
.chat-more svg { width: 16px; height: 16px; }
.chat-item:hover .chat-more, .chat-item:focus-within .chat-more, .chat-item.active .chat-more,
.chat-more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .chat-more { opacity: 1; } }
.side-empty { margin: 4px 10px; color: var(--faint); font-size: 13px; }

.account {
    display: flex; align-items: center; gap: 10px;
    margin: 0 8px 8px; padding: 9px 10px;
    border-radius: 12px; text-decoration: none; color: var(--text);
    transition: background-color var(--fast) var(--ease);
}
.side-foot { flex: 0 0 auto; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.report-entry {
    display: flex; align-items: center; gap: 9px; width: calc(100% - 16px);
    min-height: 36px; margin: 0 8px 4px; padding: 0 10px; border: 0; border-radius: 9px;
    color: var(--muted); background: transparent; text-align: left; font: 500 13px/1 var(--sans);
}
.report-entry svg { width: 16px; height: 16px; }
.report-entry:hover { color: var(--text); background: var(--hover); }
.account:hover { background: var(--hover); }
.avatar {
    display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto;
    border-radius: 50%; background: linear-gradient(160deg, #3b8bf5, #2859c4);
    color: #fff; font: 600 13px/1 var(--sans);
}
.account-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.account-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 500; }
.account-plan { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.usage-bar { display: block; height: 3px; margin-top: 4px; overflow: hidden; border-radius: 999px; background: var(--panel-3); }
.usage-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width var(--med) var(--ease); }
.account.warn .usage-bar i { background: var(--warn); }
.account.full .usage-bar i { background: var(--error); }

.scrim {
    position: fixed; inset: 0; z-index: 19;
    background: rgba(0,0,0,0.55);
    animation: fadeIn var(--med) var(--ease);
}

/* ── main column ── */
.main { position: relative; display: flex; flex-direction: column; flex: 1; min-width: 0; height: 100%; }
/* a little depth behind the empty state: a soft light above the composer */
.main::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
    background: radial-gradient(620px 300px at 50% 38%, rgba(59,139,245,0.10), transparent 70%);
    transition: opacity 500ms var(--ease);
}
.main.is-empty::before { opacity: 1; }
.main > * { position: relative; }
.topbar {
    display: flex; align-items: center; gap: 4px;
    height: 56px; padding: 0 10px; flex: 0 0 auto;
}
.chat-title {
    flex: 1; min-width: 0; margin: 0 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--text-2); font: 500 14.5px/1.4 var(--sans);
}
.stage { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-padding-bottom: 24px; }
.thread { width: 100%; max-width: var(--col); margin: 0 auto; padding: 4px 16px 32px; }
.greeting { display: none; margin: 0 0 26px; text-align: center; }
.greeting h2 {
    margin: 0; color: var(--text);
    font: 500 28px/1.25 var(--sans); letter-spacing: -0.015em;
    animation: riseIn 320ms var(--ease) both;
}
.messages { list-style: none; margin: 0; padding: 0; }
.main.is-empty .stage { justify-content: center; padding-bottom: 9vh; }
.main.is-empty .scroll { flex: 0 0 auto; overflow: visible; }
.main.is-empty .thread { padding-bottom: 0; }
.main.is-empty .greeting { display: block; }
.main.is-empty .messages, .main.is-empty .disclaimer { display: none; }
.main:not(.is-empty) .suggestions { display: none; }

/* ── composer ── */
.dock { width: 100%; max-width: var(--col); margin: 0 auto; padding: 0 16px calc(10px + env(safe-area-inset-bottom)); flex: 0 0 auto; }
.composer {
    position: relative; display: flex; flex-direction: column;
    padding: 10px; border: 1px solid rgba(255,255,255,0.08); border-radius: 26px;
    background: var(--composer);
    box-shadow: 0 10px 32px -14px rgba(0,0,0,0.7), 0 1px 0 rgba(255,255,255,0.03) inset;
    transition: border-color var(--med) var(--ease), box-shadow 220ms var(--ease), opacity var(--med) var(--ease), background-color var(--med) var(--ease);
}
.composer:focus-within { border-color: rgba(255,255,255,0.15); }
/* the main input: a ring at >= 3:1 against the box while the textarea has focus, with a soft glow */
.composer:has(textarea:focus) {
    border-color: #73737d;
    box-shadow: 0 0 0 1px #73737d, 0 0 0 5px rgba(120,150,210,0.07), 0 14px 38px -14px rgba(0,0,0,0.75);
}
.composer.dragging { border-color: rgba(59,139,245,0.6); background: #1f2330; }
.composer.full { opacity: 0.6; }
.composer textarea {
    display: block; width: 100%; min-height: 40px; max-height: 40vh; margin: 0;
    padding: 8px 10px 4px; border: 0; outline: none; resize: none;
    background: transparent; color: var(--text);
    font: 15.5px/1.5 var(--sans); overflow-y: auto;
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea.code { font: 13px/1.6 var(--mono); tab-size: 4; }
.composer textarea:disabled { cursor: not-allowed; }
.main:not(.is-empty) .composer textarea { max-height: min(34vh, 320px); }
.composer-row { display: flex; align-items: center; gap: 4px; margin-top: 4px; min-width: 0; }
.composer-row .spacer { flex: 1; min-width: 0; }
.attachment {
    display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
    max-width: 100%; margin: 2px 4px 4px; padding: 5px 6px 5px 10px;
    border: 1px solid var(--line-soft); border-radius: 12px;
    background: var(--panel-2); color: var(--text-2); font: 500 12.5px/1.2 var(--sans);
}
.attachment svg { width: 15px; height: 15px; color: var(--accent); }
.attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.attachment button {
    display: grid; place-items: center; width: 20px; height: 20px; padding: 0;
    border: 0; border-radius: 6px; background: transparent; color: var(--muted);
}
.attachment button:hover { background: var(--hover); color: var(--text); }
.attachment button svg { width: 13px; height: 13px; color: inherit; }
.send {
    display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; padding: 0;
    border: 0; border-radius: 50%; background: #ececef; color: #111113;
    transition: background-color var(--med) var(--ease), color var(--med) var(--ease), transform 200ms var(--spring), box-shadow var(--med) var(--ease);
    box-shadow: 0 2px 10px -2px rgba(255,255,255,0.18);
}
.send svg { width: 18px; height: 18px; transition: transform 200ms var(--spring); }
.send:hover:not([aria-disabled="true"]) svg { transform: translateY(-1.5px); }
.send:hover:not([aria-disabled="true"]) { background: #fff; }
.send:active:not([aria-disabled="true"]) { transform: scale(0.94); }
.send[aria-disabled="true"] { background: rgba(255,255,255,0.12); color: var(--faint); cursor: default; transform: scale(0.94); box-shadow: none; }
.send.busy[aria-disabled="true"] { background: rgba(255,255,255,0.18); color: var(--text-2); }

/* model pill + menu */
.model { position: relative; min-width: 0; }
.model-button {
    display: flex; align-items: center; gap: 6px;
    height: 36px; max-width: 100%; padding: 0 10px 0 11px;
    border: 0; border-radius: 999px; background: transparent;
    color: var(--text-2); font: 500 13.5px/1 var(--sans); white-space: nowrap;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.model-button:hover, .model-button[aria-expanded="true"] { background: var(--hover); color: var(--text); }
.model-button .model-icon { display: inline-flex; }
.model-button svg { width: 15px; height: 15px; }
.model-button .chev { width: 12px; height: 12px; color: var(--muted); transition: transform var(--fast) var(--ease); }
.model-button[aria-expanded="true"] .chev { transform: rotate(180deg); }
.menu {
    position: fixed; z-index: 1000; min-width: 168px; padding: 5px;
    border: 1px solid var(--line-strong); border-radius: 12px;
    background: rgba(35,35,39,0.98); box-shadow: 0 14px 40px rgba(0,0,0,0.55);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    animation: menuIn var(--fast) var(--ease);
}
.menu button {
    display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
    border: 0; border-radius: 8px; background: transparent; color: var(--text-2);
    font: 500 13.5px/1 var(--sans); text-align: left;
}
.menu button svg { width: 15px; height: 15px; }
.menu button:hover, .menu button:focus-visible { background: rgba(255,255,255,0.07); color: var(--text); }
.menu button:focus { outline: none; }
.menu button:focus-visible { outline: 2px solid #6aa8ff; outline-offset: -2px; background: rgba(255,255,255,0.1); }
.menu button.danger { color: var(--error); }
.menu button.danger:hover, .menu button.danger:focus-visible { background: rgba(255,107,107,0.1); }

/* popovers: the model menu and the permissions panel. They grow out of the
   button that opened them (transform-origin is set in app.js) and shrink back. */
.pop {
    position: fixed; z-index: 1000; padding: 6px;
    border: 1px solid var(--line-strong); border-radius: 16px;
    background: rgba(30,30,34,0.92);
    box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset, 0 24px 60px -12px rgba(0,0,0,0.7), 0 6px 18px rgba(0,0,0,0.35);
    backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3);
    transform-origin: 100% 100%; overflow-y: auto; overscroll-behavior: contain;
    animation: popIn 190ms var(--spring) both;
}
.pop { scrollbar-width: none; }
.pop::-webkit-scrollbar { display: none; }
.pop.closing { animation: popOut 130ms var(--ease) both; pointer-events: none; }
.pop-title {
    display: flex; align-items: center; justify-content: space-between;
    height: 30px; padding: 0 10px; color: var(--muted);
    font: 500 12px/1 var(--sans); letter-spacing: 0.01em;
}
.pop-reset {
    height: 22px; padding: 0 8px; border: 0; border-radius: 999px;
    background: transparent; color: #9cc4ff; font: 500 12px/1 var(--sans);
    transition: background-color var(--fast) var(--ease);
}
.pop-reset:hover { background: var(--accent-soft); }
.pop-glider {
    position: absolute; left: 6px; right: 6px; top: 0; height: 0; border-radius: 11px;
    background: rgba(255,255,255,0.07); opacity: 0; pointer-events: none;
    transition: transform 170ms var(--ease), height 170ms var(--ease), opacity 120ms var(--ease);
}
.pop-glider.on { opacity: 1; }
.pop-glider.jump { transition: opacity 120ms var(--ease); }
.pop-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin: 6px 0 0; padding: 0 10px; height: 36px;
    border-top: 1px solid var(--line-soft); border-radius: 0 0 11px 11px;
    color: var(--muted); font: 500 12.5px/1 var(--sans); text-decoration: none;
    transition: color var(--fast) var(--ease);
}
.pop-foot svg { width: 14px; height: 14px; transition: transform var(--med) var(--ease); }
.pop-foot:hover { color: var(--text); }
.pop-foot:hover svg { transform: translateX(3px); }
.pop-note {
    display: flex; gap: 8px; margin: 6px 0 0; padding: 10px 10px 6px;
    border-top: 1px solid var(--line-soft); color: var(--muted); font: 12px/1.45 var(--sans);
}
.pop-note svg { width: 14px; height: 14px; margin-top: 1px; color: var(--faint); }

.model-menu { width: min(322px, calc(100vw - 16px)); }
.model-option {
    position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 16px; align-items: center; gap: 11px;
    width: 100%; min-height: 54px; padding: 7px 10px; border: 0; border-radius: 11px;
    background: transparent; color: var(--text-2); font: 13.5px/1.3 var(--sans); text-align: left;
}
.model-option:focus { outline: none; }
.model-option:focus-visible { outline: 2px solid #6aa8ff; outline-offset: -2px; }
.model-tile {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
    background: rgba(255,255,255,0.06); color: var(--text-2);
    box-shadow: inset 0 0 0 1px var(--line-soft);
    transition: background-color var(--med) var(--ease), color var(--med) var(--ease), box-shadow var(--med) var(--ease), transform var(--med) var(--spring);
}
.model-tile svg { width: 16px; height: 16px; }
.model-option:hover .model-tile, .model-option:focus-visible .model-tile { transform: scale(1.06); color: var(--text); }
.model-option[data-model="sol"] .model-tile { color: var(--sol); }
.model-option[data-model="eclipse"] .model-tile { color: #b9a4ff; }
.model-option[aria-selected="true"] .model-tile {
    background: var(--accent-soft); color: #8fbcff; box-shadow: inset 0 0 0 1px rgba(59,139,245,0.35);
}
.model-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.model-line { display: flex; align-items: center; gap: 7px; }
.model-line b { color: var(--text); font-weight: 600; }
.model-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-option .tag {
    padding: 2px 6px; border-radius: 999px; background: rgba(255,255,255,0.06);
    color: var(--muted); font: 500 10.5px/1.2 var(--sans); letter-spacing: 0.02em;
}
.model-time { color: var(--faint); font: 500 11.5px/1 var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; }
.model-option .check { width: 15px; height: 15px; color: var(--accent); opacity: 0; transform: scale(0.6); transition: opacity var(--med) var(--ease), transform var(--med) var(--spring); }
.model-option[aria-selected="true"] .check { opacity: 1; transform: none; }
.model-option.locked .model-line b, .model-option.locked .model-tile { color: var(--muted); }
.model-option.locked .model-sub, .model-option.locked .model-time { color: var(--faint); }
.model-option.locked .tag { background: var(--accent-soft); color: #9cc4ff; }

/* the model pill: its icon and name swap with a short cross-fade */
.model-button .model-icon, .model-button #model-name { transition: opacity 110ms var(--ease), transform 160ms var(--ease); }
.model-button.swapping .model-icon, .model-button.swapping #model-name { opacity: 0; transform: translateY(3px); }

/* permissions: the pill in the composer and its panel of switches */
.perm-button {
    position: relative; display: inline-flex; align-items: center; gap: 6px;
    height: 36px; padding: 0 11px 0 9px; border: 0; border-radius: 999px;
    background: transparent; color: var(--muted); font: 500 13.5px/1 var(--sans); white-space: nowrap;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.perm-button svg { width: 17px; height: 17px; }
.perm-button:hover, .perm-button[aria-expanded="true"] { background: var(--hover); color: var(--text); }
.perm-button:active { transform: scale(0.97); }
.perm-button.changed { color: #e9c46a; }
.perm-button.changed:hover, .perm-button.changed[aria-expanded="true"] { background: rgba(229,184,74,0.1); color: #f0cf7c; }
.perm-menu { width: min(340px, calc(100vw - 16px)); padding: 8px; transform-origin: 0 100%; }
.perm-menu .pop-title { height: 32px; padding: 0 6px 0 8px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.perm-menu .perm-section-title { margin-top: 4px; }
/* the switches sit together in one inset group, like a settings list */
.perm-group {
    overflow: hidden; border: 1px solid var(--line-soft); border-radius: 12px;
    background: rgba(255,255,255,0.025);
}
.perm-row {
    display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 11px;
    padding: 9px 12px; cursor: pointer;
    transition: background-color var(--fast) var(--ease);
}
.perm-row + .perm-row { border-top: 1px solid var(--line-soft); }
.perm-row:hover { background: rgba(255,255,255,0.035); }
.perm-icon {
    display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
    background: rgba(255,255,255,0.06); color: var(--muted);
    transition: background-color var(--med) var(--ease), color var(--med) var(--ease);
}
.perm-icon svg { width: 15px; height: 15px; }
.perm-row:has(.switch:checked) .perm-icon { background: var(--accent-soft); color: #8fbcff; }
.perm-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.perm-text b { color: var(--text); font: 500 13.5px/1.3 var(--sans); }
.perm-text span { color: var(--muted); font: 12px/1.35 var(--sans); }
.perm-menu .pop-note { margin: 0; padding: 10px 8px 4px; border-top: 0; }
.switch {
    appearance: none; -webkit-appearance: none; position: relative; flex: 0 0 auto;
    width: 36px; height: 22px; margin: 0; border-radius: 999px; cursor: pointer;
    background: rgba(255,255,255,0.14);
    transition: background-color 200ms var(--ease);
}
.switch::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
    background: #f4f4f6; box-shadow: 0 1px 3px rgba(0,0,0,0.45);
    transition: transform 220ms var(--spring), width 160ms var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
.switch:active::after { width: 21px; }
.switch:checked:active::after { transform: translateX(11px); }
.switch:focus-visible { outline: 2px solid #6aa8ff; outline-offset: 2px; }

/* context notice, hints, suggestions */
.context-notice {
    display: flex; align-items: center; gap: 12px;
    margin: 0 6px 8px; padding: 9px 9px 9px 14px;
    border: 1px solid rgba(229,184,74,0.22); border-radius: 16px;
    background: linear-gradient(180deg, rgba(229,184,74,0.07), rgba(229,184,74,0.035));
    color: var(--text-2); font-size: 13px; line-height: 1.45;
    animation: riseIn 240ms var(--ease) both;
}
.context-notice.full { border-color: rgba(255,107,107,0.24); background: linear-gradient(180deg, rgba(255,107,107,0.08), rgba(255,107,107,0.035)); }
.context-ring { width: 22px; height: 22px; flex: 0 0 auto; transform: rotate(-90deg); }
.context-ring circle { fill: none; stroke-width: 3; }
.context-ring .track { stroke: rgba(255,255,255,0.1); }
.context-ring .fill { stroke: var(--warn); stroke-linecap: round; transition: stroke-dashoffset var(--med) var(--ease); }
.context-notice.full .context-ring .fill { stroke: var(--error); }
.context-notice p { flex: 1; min-width: 0; margin: 0; }
.context-notice b { color: var(--text); font-weight: 600; }
.pill-btn {
    flex: 0 0 auto; height: 32px; padding: 0 14px;
    border: 0; border-radius: 999px; background: #ececef; color: #111113;
    font: 600 12.5px/1 var(--sans); white-space: nowrap;
    transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.pill-btn:hover { background: #fff; }
.pill-btn:active { transform: scale(0.97); }
.disclaimer, .hint {
    margin: 8px 0 0; text-align: center; color: var(--faint); font-size: 12px; line-height: 1.4;
}
.hint { color: var(--warn); }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.suggestion {
    display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
    border: 1px solid var(--line-soft); border-radius: 999px; background: transparent;
    color: var(--text-2); font: 500 13.5px/1 var(--sans); text-decoration: none; white-space: nowrap;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--med) var(--ease);
}
.suggestion:hover { background: var(--hover); color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }
.suggestion:active { transform: scale(0.98); }
.suggestion:hover svg { color: var(--text-2); }
.suggestions .suggestion { animation: riseIn 360ms var(--ease) both; }
.suggestions .suggestion:nth-child(2) { animation-delay: 50ms; }
.suggestions .suggestion:nth-child(3) { animation-delay: 100ms; }
.suggestion svg { width: 16px; height: 16px; color: var(--muted); }

/* ── messages ── */
.envlog { margin: 0 0 30px; animation: riseIn 260ms var(--ease) both; }
.envlog.static { animation: none; }
.user-msg { display: flex; flex-direction: column; align-items: flex-end; margin: 10px 0 18px; min-width: 0; }
.code-card {
    width: fit-content; max-width: min(100%, 680px); min-width: min(100%, 280px);
    overflow: hidden; border: 1px solid var(--line-soft); border-radius: 18px;
    background: var(--panel-2);
}
.code-head {
    display: flex; align-items: center; gap: 8px; min-width: 0;
    padding: 8px 10px 8px 13px; border-bottom: 1px solid var(--line-soft);
    color: var(--muted); font-size: 12.5px;
}
.code-head svg { width: 14px; height: 14px; color: var(--text-2); }
.code-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-weight: 500; }
.code-lines { white-space: nowrap; }
.code-head .spacer { flex: 1; }
.chip {
    display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
    height: 22px; padding: 0 8px; border-radius: 999px;
    background: rgba(255,255,255,0.05); border: 1px solid var(--line-soft);
    color: var(--text-2); font: 500 11.5px/1 var(--sans); white-space: nowrap;
}
.chip svg { width: 11px; height: 11px; }
.code-body {
    margin: 0; padding: 11px 14px 12px; overflow-x: auto;
    color: #d8d8dc; font: 12.5px/1.6 var(--mono); white-space: pre; tab-size: 4;
}
.code-card.truncated:not(.expanded) .code-body {
    -webkit-mask-image: linear-gradient(#000 55%, transparent);
    mask-image: linear-gradient(#000 55%, transparent);
}
.code-cut { margin: 0; padding: 0 14px 8px; color: var(--muted); font-size: 12px; }
.code-toggle {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 14px;
    border: 0; border-top: 1px solid var(--line-soft); background: transparent;
    color: var(--muted); font: 500 12.5px/1.2 var(--sans); text-align: left;
}
.code-toggle:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.code-toggle:focus-visible { outline-offset: -2px; }
.code-toggle svg { width: 13px; height: 13px; transition: transform var(--fast) var(--ease); }
.code-card.expanded .code-toggle svg { transform: rotate(180deg); }
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity var(--fast) var(--ease); }
.user-msg:hover .msg-actions, .user-msg:focus-within .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.msg-actions .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.msg-actions .icon-btn svg { width: 15px; height: 15px; }

.reply { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; }
.reply-avatar {
    display: grid; place-items: center; width: 28px; height: 28px;
    border: 1px solid var(--line-strong); border-radius: 50%; color: var(--accent);
}
.reply-avatar svg { width: 14px; height: 14px; }
.reply-body { min-width: 0; padding-top: 2px; }

/* the working status: shimmering text, no dots */
.status { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; min-height: 26px; padding-top: 1px; font-size: 15px; }
.status-text { color: var(--text-2); transition: opacity 200ms var(--ease); }
.status-text.shimmer {
    background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 38%, #f6f6f8 50%, var(--muted) 62%, var(--muted) 100%);
    background-size: 260% 100%;
    -webkit-background-clip: text; background-clip: text;
    color: transparent; -webkit-text-fill-color: transparent;
    animation: shimmer 2.4s linear infinite;
}
.status-text.fading { opacity: 0; }
.status-time { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* result card */
.result {
    overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 14px 34px -22px rgba(0,0,0,0.7);
}
.result-head {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    padding: 6px 6px 6px 6px; border-bottom: 1px solid var(--line-soft);
}
.rtabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; }
.rtabs::-webkit-scrollbar { display: none; }
.rtabs.fade-end { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.rtab {
    display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
    height: 30px; padding: 0 11px; border: 0; border-radius: 8px;
    background: transparent; color: var(--muted); font: 500 13px/1 var(--sans); white-space: nowrap;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.rtab:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.rtab:active, .ghost:active { transform: scale(0.97); }
.rtab[aria-selected="true"] { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-soft); }
.rtab:focus-visible { outline-offset: -2px; }
.rtab .count { color: var(--faint); font: 500 11px/1 var(--mono); }
.rtab[aria-selected="true"] .count { color: var(--muted); }
.result-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.ghost {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 10px;
    border: 1px solid var(--line-soft); border-radius: 8px;
    background: transparent; color: var(--muted); font: 500 12.5px/1 var(--sans); white-space: nowrap; text-decoration: none;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.ghost:hover { color: var(--text); background: var(--hover); border-color: var(--line-strong); }
.ghost svg { width: 14px; height: 14px; }
.ghost:disabled { opacity: 0.45; cursor: default; background: transparent; border-color: var(--line-soft); color: var(--muted); }
.result-extra { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.result-extra p { margin: 4px 0 0; color: var(--muted); }
.run-summary, .scenario-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.run-summary { color: var(--muted); }
.scenario-offer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.scenario-actions { gap: 6px; }
.scenario-accept { color: var(--text); background: var(--panel-3); border-color: var(--line-strong); }
.result-disclosure summary { cursor: pointer; color: var(--text); }
.result-disclosure > select {
    margin-top: 10px; max-width: 100%; min-height: 32px; padding: 4px 8px;
    border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--panel-3); font: inherit;
}
.version-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 8px; margin-top: 8px; }
.version-columns > div { min-width: 0; border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; }
.version-columns h3 { margin: 0; padding: 6px 8px; font-size: 13px; }
.version-columns p { padding: 0 8px 8px; }
label.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; cursor: pointer; white-space: nowrap; padding: 0 4px; }
label.toggle input { accent-color: var(--accent); margin: 0; }
.result-body { max-height: min(62vh, 560px); overflow: auto; }
.lines {
    margin: 0; padding: 12px 16px 14px;
    color: #d8d8dc; font: 12.5px/1.65 var(--mono);
    white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4;
}
.line.error { color: var(--error); }
.line.warn { color: var(--warn); }
.line.note { color: var(--muted); }
.line.nested { color: var(--muted); }
.log-details { margin: 0; padding: 9px 16px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
.line .clip { color: var(--faint); font-family: var(--sans); font-style: italic; }
.more-lines {
    display: block; margin: 0 16px 14px; padding: 0; border: 0; background: none;
    color: var(--accent); font: 500 12.5px/1.4 var(--sans);
}
.more-lines:hover { text-decoration: underline; }
.chunk + .chunk { border-top: 1px solid var(--line-soft); }
.chunk-head { padding: 10px 16px 0; color: var(--muted); font: 500 12px/1.5 var(--mono); }
.chunk .lines { padding-top: 6px; }
.panel-empty {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 34px 20px; text-align: center; color: var(--muted); font-size: 13px;
}
.panel-empty svg { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: var(--panel-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-soft); }
.gui-wrap { padding: 12px; }
.gui-wrap .gui-preview { margin: 0; }
.result-foot {
    display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
    margin-top: 9px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.result-foot svg { width: 14px; height: 14px; }
.result-foot .ok { color: var(--ok); }
.result-foot .sep { color: var(--muted); }
.result-foot .paste-link { color: var(--accent, #3b8bf5); text-decoration: none; }
.result-foot .paste-link:hover, .result-foot .paste-link:focus-visible { text-decoration: underline; }
.result-foot .bad { color: var(--error); }
.result-foot .perm-note {
    padding: 2px 8px; border-radius: 999px; background: rgba(229,184,74,0.1); color: #e9c46a; font-size: 11.5px; font-weight: 500;
}
.result-foot .sep { color: var(--faint); }

/* friendly error replies */
.reply-error { max-width: 620px; }
.reply-error .err-title { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; color: var(--text); font-size: 15px; font-weight: 600; }
.reply-error .err-title svg { width: 16px; height: 16px; color: var(--warn); }
.reply-error.bad .err-title svg { color: var(--error); }
.reply-error .err-detail { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.err-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.err-actions .pill-btn { display: inline-flex; align-items: center; text-decoration: none; height: 32px; }
.err-actions .ghost { height: 32px; border-radius: 999px; padding: 0 14px; }

/* jump to the latest envlog (shown when scrolled well up) */
.to-latest {
    position: absolute; left: 50%; bottom: 132px; z-index: 5;
    display: grid; place-items: center; width: 34px; height: 34px; padding: 0; margin-left: -17px;
    border: 1px solid var(--line-strong); border-radius: 50%;
    background: rgba(35,35,39,0.92); color: var(--text-2);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    animation: popIn 190ms var(--spring) both;
    transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.to-latest:hover { color: var(--text); background: rgba(48,48,54,0.96); }
.to-latest:active { transform: scale(0.94); }
.to-latest.leaving { animation: popOut 140ms var(--ease) both; }
.to-latest svg { width: 16px; height: 16px; }
.stage { position: relative; }

/* ── tooltip + dialogs ── */
.ui-tooltip {
    position: fixed; z-index: 2000; max-width: min(280px, calc(100vw - 16px)); padding: 6px 9px;
    border: 1px solid var(--line-strong); border-radius: 7px;
    background: #2a2a2f; color: var(--text); box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    font: 500 12px/1.4 var(--sans); white-space: pre-line; overflow-wrap: anywhere;
    pointer-events: none; animation: tooltipIn var(--fast) var(--ease);
}
dialog.modal {
    width: min(380px, calc(100vw - 32px)); padding: 20px; margin: auto;
    border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
    background: var(--panel); color: var(--text);
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
dialog.modal[open] { animation: popIn 220ms var(--spring); }
dialog.modal[open]::backdrop { animation: fadeIn 200ms var(--ease); }
dialog.modal::backdrop { background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal h2 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.modal p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.modal input {
    width: 100%; height: 40px; margin-top: 6px; padding: 0 12px; outline: none;
    border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--text);
    font: 14px/1 var(--sans);
}
.modal input:focus { border-color: rgba(106,168,255,0.7); }
dialog.report-dialog { width: min(440px, calc(100vw - 32px)); }
.report-label { display: block; margin: 15px 0 6px; font-size: 13px; font-weight: 550; }
.report-dialog textarea {
    display: block; width: 100%; min-height: 120px; max-height: 42vh; resize: vertical; padding: 10px 12px;
    border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--text);
    font: 14px/1.5 var(--sans);
}
.report-dialog textarea::placeholder { color: var(--muted); }
.report-dialog .report-status:not(:empty) { margin-top: 10px; }
.report-dialog .report-status[data-state="error"] { color: var(--error); }
.report-dialog .report-status[data-state="sent"] { color: var(--ok); }
.report-dialog #report-send:disabled { opacity: .55; cursor: default; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions .ghost { height: 34px; border-radius: 999px; padding: 0 14px; }
.modal-actions .pill-btn { height: 34px; }
.pill-btn.danger { background: #e5484d; color: #fff; }
.pill-btn.danger:hover { background: #f05055; }

@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes popOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(4px) scale(0.96); } }
@keyframes menuIn { from { opacity: 0; transform: translateY(-3px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes tooltipIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── phones and narrow windows ── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
        width: min(300px, 86vw); margin-left: 0 !important;
        transform: translateX(-100%); visibility: hidden;
        box-shadow: 0 0 40px rgba(0,0,0,0.5);
        transition: transform 240ms var(--ease), visibility 0s 240ms;
    }
    .app.drawer-open .sidebar { transform: none; visibility: visible; transition: transform 240ms var(--ease), visibility 0s; }
    .scrim { z-index: 29; }
    .side-new kbd { display: none; }
    .greeting h2 { font-size: 24px; }
    .main.is-empty .stage { padding-bottom: 4vh; }
}
@media (max-width: 480px) {
    .thread { padding: 4px 12px 28px; }
    .dock { padding-left: 10px; padding-right: 10px; }
    .composer { border-radius: 22px; padding: 8px; }
    .reply { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .reply-avatar { display: none; }
    .result-head { padding: 5px; }
    .rtab { padding: 0 8px; gap: 5px; }
    .result-tools .ghost span { display: none; }
    .result-tools .ghost { width: 32px; padding: 0; justify-content: center; }
    .result-head:has(.toggle:not([hidden])) .rtabs { flex-basis: 100%; }
    .result-head:has(.toggle:not([hidden])) .result-tools { width: 100%; justify-content: flex-end; }
    .code-card { min-width: 0; width: 100%; }
    .context-notice { flex-wrap: wrap; padding: 10px 12px; }
    .context-notice .pill-btn { margin-left: 34px; }
    .suggestion { padding: 0 12px; font-size: 13px; }
    /* the permissions pill keeps its icon; the label would crowd the model name */
    .perm-button { padding: 0; width: 36px; justify-content: center; }
    .perm-button #perms-label { display: none; }
    .perm-button.changed::after {
        content: ""; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%;
        background: #e9c46a; box-shadow: 0 0 0 2px var(--composer);
    }
}
/* iOS zooms in on a focused field under 16px: keep the prompt box at 16px (code too) on
   phones and touch screens. Monospace stays; only the size holds. */
@media (max-width: 480px), (pointer: coarse) {
    .composer textarea, .composer textarea.code { font-size: 16px; }
    .composer textarea.code { line-height: 1.5; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .status-text.shimmer {
        animation: none !important; background: none;
        color: var(--text-2); -webkit-text-fill-color: currentColor;
    }
}
@media (forced-colors: active) {
    .status-text.shimmer { background: none; color: CanvasText; -webkit-text-fill-color: currentColor; }
}

/* A-Ads unit under a running envlog's status line (free plan; see adSlot in app.js) */
.ad-slot { margin-top: 14px; max-width: 728px; }
.ad-slot .ad-label { display: block; margin-bottom: 4px; color: var(--faint); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

/* ad bonus: the sidebar button and the 15-second ad dialog (watchAd in app.js) */
.ad-earn {
    display: block; width: calc(100% - 16px); margin: -2px 8px 10px; padding: 7px 10px; cursor: pointer;
    border: 1px dashed var(--line-strong); border-radius: 10px; background: transparent;
    color: var(--text-2); font: 500 12.5px/1.3 var(--sans); text-align: left;
}
.ad-earn:hover { background: var(--hover); color: var(--text); }
.ad-earn:disabled { cursor: default; opacity: 0.55; background: transparent; color: var(--muted); }
dialog.modal.ad-dialog { width: min(560px, calc(100vw - 32px)); }
.ad-frame { margin-top: 14px; min-height: 90px; display: flex; justify-content: center; }
.ad-frame iframe { max-width: 100% !important; }
.ad-dialog .pill-btn:disabled { opacity: 0.6; cursor: default; }

/* short windows: one line per switch, so the whole panel fits without scrolling */
@media (max-height: 680px) {
    .perm-text span { display: none; }
    .perm-row { padding: 7px 12px; }
    .perm-icon { width: 24px; height: 24px; }
}
@media (max-height: 600px) { .perm-menu .pop-note { display: none; } }
