/* Ratifel — a calm, conversation-first workspace for governed AI teammates.

   The monochrome canvas, floating composer, and pill-shaped controls borrow
   their interaction language from Grok while preserving Ratifel's explicit
   policy and approval model. Text contrast and 44px targets are invariants. */

:root {
  color-scheme: light dark;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 20px; --r-xl: 28px; --r-full: 999px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --tap: 44px;
  --side-w: 292px;
  --panel-w: 376px;
  --head-h: 76px;

  --t-fast: 150ms; --t-mid: 220ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --z-side: 40; --z-scrim: 35; --z-panel: 45; --z-toast: 100;

  /* Light is the base. Dark redefines only what changes. */
  --bg:          #fbfbfa;
  --side-bg:     #f3f3f1;
  --surface:     #f0f0ed;
  --surface-2:   #e7e7e3;
  --border:      #d9d9d4;
  --border-soft: #e5e5e0;
  --text:        #171716;
  --text-2:      #555550;
  --text-3:      #64645e;
  --accent:      #171716;
  --accent-fg:   #ffffff;
  --ok:          #176c3c;
  --ok-bg:       #e7f2e9;
  --no:          #ad2525;
  --no-bg:       #f8e9e7;
  --wait:        #825008;
  --wait-bg:     #f7efe1;
  --shadow-1:    0 2px 12px rgba(20,20,18,.045);
  --shadow-2:    0 20px 60px rgba(20,20,18,.11);
  --scrim:       rgba(13,13,12,.54);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #090909;
    --side-bg:     #0f0f0f;
    --surface:     #171717;
    --surface-2:   #222222;
    --border:      #30302e;
    --border-soft: #252524;
    --text:        #f5f4f1;
    --text-2:      #b7b6b1;
    --text-3:      #a19f99;
    --accent:      #f5f4f1;
    --accent-fg:   #111111;
    --ok:          #85dbaa;
    --ok-bg:       #142219;
    --no:          #ffa2a0;
    --no-bg:       #291716;
    --wait:        #f0c36e;
    --wait-bg:     #292015;
    --shadow-1:    0 4px 16px rgba(0,0,0,.28);
    --shadow-2:    0 22px 70px rgba(0,0,0,.54);
    --scrim:       rgba(0,0,0,.68);
  }
}
:root[data-theme="dark"] {
  --bg:          #090909;
  --side-bg:     #0f0f0f;
  --surface:     #171717;
  --surface-2:   #222222;
  --border:      #30302e;
  --border-soft: #252524;
  --text:        #f5f4f1;
  --text-2:      #b7b6b1;
  --text-3:      #a19f99;
  --accent:      #f5f4f1;
  --accent-fg:   #111111;
  --ok:          #85dbaa;
  --ok-bg:       #142219;
  --no:          #ffa2a0;
  --no-bg:       #291716;
  --wait:        #f0c36e;
  --wait-bg:     #292015;
  --shadow-1:    0 4px 16px rgba(0,0,0,.28);
  --shadow-2:    0 22px 70px rgba(0,0,0,.54);
  --scrim:       rgba(0,0,0,.68);
}

* { box-sizing: border-box; }
/* display:grid on .app would otherwise win over the hidden attribute. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  letter-spacing: -.012em; overflow: hidden;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip {
  position: absolute; left: -9999px; top: var(--sp-2); z-index: var(--z-toast);
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--sp-4);
  background: var(--accent); color: var(--accent-fg); border-radius: var(--r-md); text-decoration: none;
}
.skip:focus { left: var(--sp-2); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; } }

/* ---------- app frame ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0,1fr) 0; height: 100dvh; transition: grid-template-columns var(--t-mid) var(--ease); }
.app:has(.panel[data-open="true"]) { grid-template-columns: var(--side-w) minmax(0,1fr) var(--panel-w); }

/* ---------- sidebar ---------- */
.side { display: flex; flex-direction: column; min-height: 0; padding: 0 var(--sp-2); background: var(--side-bg); border-right: 1px solid var(--border-soft); z-index: var(--z-side); }
.side-top { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--head-h); padding: var(--sp-3) var(--sp-2); }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 690; font-size: 15px; letter-spacing: -.035em; flex: 1; }
.brand > span:last-child { display: grid; gap: 1px; }
.brand small { color: var(--text-2); font-size: 11px; font-weight: 450; letter-spacing: -.01em; }
.brand-mark { display: grid; width: 36px; height: 36px; flex: none; place-items: center; overflow: hidden; border: 1px solid color-mix(in srgb, var(--border) 72%, transparent); border-radius: 13px; background: #f5f4f1; }
.brand-mark img { display: block; width: 22px; height: 22px; object-fit: contain; }
.side-create { color: var(--text-2); }
.side .side-theme { display: none; }

.new-chat {
  display: flex; align-items: center; gap: 10px; min-height: 48px; margin: 4px var(--sp-2) var(--sp-3);
  padding: 0 14px; border: 1px solid var(--border-soft); border-radius: var(--r-full);
  background: var(--bg); color: var(--text); font: 560 13px/1 var(--font); text-align: left; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.new-chat:hover:not(:disabled) { background: var(--surface); border-color: var(--border); }
.new-chat:disabled { opacity: .52; cursor: not-allowed; }
.side-history { margin: 0 var(--sp-2) 6px; }
.side-history:disabled { opacity: .52; cursor: not-allowed; }

.side-search { position: relative; padding: 0 var(--sp-2) var(--sp-3); }
.side-search input {
  width: 100%; min-height: var(--tap); padding: 0 var(--sp-3);
  font: inherit; font-size: 14px; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: var(--r-md);
}
.side-search input::placeholder { color: var(--text-2); }
.side-search input:focus { background: var(--bg); border-color: var(--border); outline: none; }
.side-section-title { display: flex; align-items: center; justify-content: space-between; min-height: 36px; padding: 0 12px; color: var(--text-2); font-size: 11px; font-weight: 600; letter-spacing: .01em; }
.side-section-title #botCount { font: 11px/1 var(--mono); }
.side-section-title-foot { min-height: 28px; padding: 0 var(--sp-2); }
.side-empty { padding: var(--sp-3); }

.bots { flex: 1; min-height: 0; overflow-y: auto; padding: 0 2px var(--sp-2); display: flex; flex-direction: column; gap: 3px; }
.bot-row {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 58px; padding: var(--sp-2) 10px;
  background: none; border: 0; border-radius: var(--r-md);
  color: inherit; font: inherit; text-align: left; cursor: pointer; width: 100%;
  transition: background var(--t-fast) var(--ease);
}
.bot-row:hover { background: var(--surface); }
.bot-row[aria-current="page"] { background: var(--surface); }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 13px;
  display: grid; place-items: center;
  font: 660 12px/1 var(--font); color: var(--text);
  background-color: var(--surface-2); border: 1px solid var(--border-soft);
}
.agent-mark {
  position: relative; display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; overflow: hidden; border: 1px solid var(--border-soft);
  border-radius: 13px; background: linear-gradient(145deg, var(--surface-2), var(--surface));
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 10%, transparent), 0 1px 3px rgba(0,0,0,.1);
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.agent-mark:hover { transform: translateY(-1px); }
.agent-mark-image { position: absolute; left: 50%; top: 50%; width: 168%; height: 168%; max-width: none; object-fit: contain; transform: translate(-50%, -34%); }
.agent-mark-small { width: 34px; height: 34px; border-radius: 11px; }
.agent-mark-tiny { width: 26px; height: 26px; border-radius: 9px; }
.agent-mark-large { width: 69px; height: 69px; border-radius: 22px; }
.agent-mark-hero { width: 114px; height: 114px; border-radius: 34px; }
.bot-row .txt { min-width: 0; flex: 1; }
.bot-row .nm { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-role { margin-left: 6px; color: var(--text-2); font-size: 11px; font-weight: 450; }
.bot-row .st { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--text-3); }
.dot.on { background: var(--ok); }
.dot.warn { background: var(--wait); }

.side-foot { border-top: 1px solid var(--border-soft); padding: var(--sp-3) var(--sp-2) var(--sp-2); display: grid; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--tap); padding: 0 var(--sp-2);
  background: none; border: 0; border-radius: var(--r-md);
  color: var(--text-2); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.side-link:hover { background: var(--surface); color: var(--text); }
.side-link[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; }
.side-link .badge { margin-left: auto; font: 700 11px/1 var(--mono); background: var(--wait-bg); color: var(--wait); padding: 4px 7px; border-radius: var(--r-full); }
.side-foot .me { display: flex; align-items: center; gap: 10px; min-height: 62px; margin-top: var(--sp-2); padding: 0 3px; border-top: 1px solid var(--border-soft); font-size: 12px; color: var(--text-2); overflow: hidden; }
.side-foot .me .avatar { width: 34px; height: 34px; border-radius: var(--r-full); font-size: 11px; }
.side-foot .me .avatar.has-mascot { overflow: hidden; border-color: color-mix(in srgb, var(--border) 72%, transparent); background: var(--surface-2); }
.side-foot .me .avatar.has-mascot img { width: 112%; height: 112%; max-width: none; object-fit: contain; object-position: center 18%; transform: translateY(2px); }
.me-copy { display: grid; min-width: 0; flex: 1; gap: 1px; }
.side-foot .me #me { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 11px; font-weight: 550; }
.me-copy small { overflow: hidden; color: var(--text-2); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .me .icon-btn { margin-left: auto; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.head {
  position: relative; display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--head-h); padding: var(--sp-2) var(--sp-5);
  background: var(--bg); flex: none;
}
.head h1 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .sub { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-identity { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: var(--tap); max-width: 32%; padding: 0 6px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.head-identity:hover { background: var(--surface); }
.head-avatar { width: 34px; height: 34px; border-radius: 12px; }
.head-copy { display: grid; min-width: 0; gap: 1px; }
.head-modes { position: absolute; isolation: isolate; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: var(--r-full); background: var(--surface); }
.head-modes::before { content: ""; position: absolute; z-index: -1; left: 3px; top: 3px; bottom: 3px; width: calc((100% - 8px) / 2); border-radius: var(--r-full); background: var(--bg); box-shadow: var(--shadow-1); transform: translateX(0); transition: transform 340ms cubic-bezier(.22,.78,.28,1); }
.head-modes[data-mode="tasks"]::before { transform: translateX(calc(100% + 2px)); }
.mode-btn { position: relative; z-index: 1; min-width: 61px; min-height: var(--tap); padding: 0 14px; border: 0; border-radius: var(--r-full); background: transparent; color: var(--text-2); font: 550 13px/1 var(--font); cursor: pointer; transition: color var(--t-fast) var(--ease); }
.mode-btn:hover { color: var(--text); }
.mode-btn.is-active { color: var(--text); }
.head .acts { margin-left: auto; display: flex; align-items: center; gap: 2px; flex: none; }
.head-new { border: 1px solid var(--border-soft) !important; border-radius: var(--r-full) !important; color: var(--text) !important; }
.view-heading { display: grid; gap: 0; }
.head-kicker { font-size: 10px; color: var(--text-2); }
.head .side-toggle { display: none; }

/* Column so the composer pins to the bottom when the thread is short. */
.body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.body > .thread { flex: 1 0 auto; }
.body > .composer-wrap { flex: none; margin-top: auto; }
.body:focus { outline: none; }

/* Ask and Tasks are sibling workspaces. Keeping both mounted preserves the
   conversation position and draft while the track moves between them. */
.body[data-view="bot"] { overflow: hidden; }
.bot-mode-track { flex: 1; min-height: 0; width: 200%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); transform: translate3d(0,0,0); transition: transform 380ms cubic-bezier(.22,.78,.28,1); will-change: transform; }
.bot-mode-track[data-mode="tasks"] { transform: translate3d(-50%,0,0); }
.bot-mode-page { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.bot-mode-page[aria-hidden="true"] { pointer-events: none; }
.ask-surface { display: flex; flex-direction: column; }
.ask-surface > .thread { flex: 1 0 auto; }
.ask-surface > .composer-wrap { flex: none; margin-top: auto; }
.tasks-surface:focus { outline: none; }
.tasks-loading, .tasks-load-error { min-height: 100%; display: grid; place-content: center; justify-items: center; gap: var(--sp-3); padding: var(--sp-5); color: var(--text-2); font-size: 13px; text-align: center; }
.tasks-load-error strong { color: var(--text); }
.tasks-load-error p { margin: 0; }

/* ---------- conversation ---------- */
.thread { width: min(100%, 824px); margin: 0 auto; padding: var(--sp-6) var(--sp-5) var(--sp-4); display: flex; flex-direction: column; gap: 26px; }
.thread[data-empty="true"] { display: grid; align-content: center; }
.turn { display: flex; flex-direction: column; gap: var(--sp-2); animation: turn-in 220ms var(--ease); }
.turn.me { align-items: flex-end; }
.bubble { max-width: min(88%, 700px); padding: 12px 17px; border-radius: 23px; font-size: 15px; line-height: 1.7; white-space: pre-wrap; }
.turn.me .bubble { background: var(--surface); border-bottom-right-radius: 8px; }
.turn.me .who { padding-right: 5px; }
.turn.bot .bubble { max-width: 100%; padding: 0; background: transparent; border-radius: 0; }
.markdown-body { white-space: normal; overflow-wrap: anywhere; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 .85em; }
.markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin: 1.1em 0 .45em; color: var(--text); line-height: 1.3; letter-spacing: -.025em; }
.markdown-body h3 { font-size: 18px; } .markdown-body h4 { font-size: 16px; }
.markdown-body h5, .markdown-body h6 { font-size: 15px; }
.markdown-body ul, .markdown-body ol { margin: .35em 0 .95em; padding-left: 1.45em; }
.markdown-body li { padding-left: .15em; }
.markdown-body li + li { margin-top: .32em; }
.markdown-body strong { font-weight: 720; color: var(--text); }
.markdown-body a { color: inherit; text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; }
.markdown-body a:hover { text-decoration-color: currentColor; }
.markdown-body blockquote { margin: .8em 0; padding: .1em 0 .1em 1em; border-left: 3px solid var(--border); color: var(--text-2); }
.markdown-body hr { margin: 1.2em 0; border: 0; border-top: 1px solid var(--border-soft); }
.markdown-body .md-code { margin: .8em 0; overflow-x: auto; padding: 13px 14px; border: 1px solid var(--border-soft); border-radius: var(--r-md); background: var(--surface); white-space: pre; }
.markdown-body .md-code code { border: 0; padding: 0; background: transparent; white-space: pre; }
.who { font-size: 11px; font-weight: 620; letter-spacing: .02em; color: var(--text-2); }
@keyframes turn-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.welcome { display: grid; justify-items: center; gap: 11px; max-width: 560px; margin: 0 auto; padding: 0 var(--sp-4); text-align: center; }
.welcome-mark { display: grid; place-items: center; width: 78px; height: 78px; margin-bottom: 7px; border: 1px solid var(--border-soft); border-radius: 28px; background: var(--surface); color: var(--text); }
.welcome-character { display: grid; place-items: center; min-width: 78px; min-height: 78px; margin-bottom: 7px; }
.welcome-kicker { color: var(--text-2); font-size: 12px; font-weight: 550; letter-spacing: .035em; }
.welcome h2 { margin: 0; color: var(--text); font-size: clamp(31px, 4vw, 47px); font-weight: 660; line-height: 1.08; letter-spacing: -.065em; }
.welcome p { max-width: 48ch; margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.7; }
.welcome-description { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.welcome-trust { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; color: var(--text-2); font-size: 11px; }
.welcome-no-bots { flex: 1; align-content: center; }
.welcome-no-bots .btn { margin-top: var(--sp-3); }

.composer-wrap { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 78%, transparent); padding: var(--sp-4) var(--sp-5) max(var(--sp-3), env(safe-area-inset-bottom)); }
.composer-shortcuts { display: flex; gap: var(--sp-2); max-width: 776px; margin: 0 auto 11px; overflow-x: auto; scrollbar-width: none; }
.composer-shortcuts::-webkit-scrollbar { display: none; }
.shortcut-chip { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 13px; border: 1px solid var(--border-soft); border-radius: var(--r-full); background: var(--surface); color: var(--text); font: 530 12px/1 var(--font); white-space: nowrap; cursor: pointer; }
.shortcut-chip:hover { background: var(--surface-2); border-color: var(--border); }
.shortcut-chip svg { flex: none; color: var(--text-2); }
.composer { position: relative; max-width: 776px; margin: 0 auto; border: 1px solid var(--border-soft); background: var(--surface); border-radius: 25px; padding: 5px 7px 7px 15px; box-shadow: var(--shadow-1); transition: border-color var(--t-fast) var(--ease); }
.composer:focus-within { border-color: var(--border); }
.composer textarea { width: 100%; border: 0; background: none; resize: none; color: var(--text); font: inherit; font-size: 15px; min-height: var(--tap); max-height: 200px; padding: 11px 2px 5px; }
.composer textarea::placeholder { color: var(--text-2); }
.composer textarea:focus { outline: none; }
.composer-bar { display: flex; align-items: center; gap: 5px; }
.composer-context { margin-left: -7px; }
.model-chip { display: inline-flex; align-items: center; gap: 6px; min-width: 0; min-height: var(--tap); padding: 0 10px; border: 0; border-radius: var(--r-full); background: var(--surface-2); color: var(--text); font: 560 11px/1 var(--font); cursor: pointer; }
.model-chip:hover, .model-chip[aria-expanded="true"] { background: var(--border); }
.model-chip svg { flex: none; }
.model-chip span { overflow: hidden; max-width: 140px; text-overflow: ellipsis; white-space: nowrap; }
.model-chip svg:last-child { color: var(--text-2); }
.chat-model-picker { position: absolute; z-index: 30; left: 7px; bottom: 59px; width: min(390px,calc(100% - 14px)); overflow: hidden; border: 1px solid var(--border); border-radius: 19px; background: var(--surface); box-shadow: var(--shadow-2); animation: model-picker-in 160ms var(--ease); }
@keyframes model-picker-in { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
.chat-model-picker-head { display: flex; align-items: flex-start; gap: 12px; padding: 15px 15px 11px; }
.chat-model-picker-head > div { display: grid; flex: 1; gap: 3px; }
.chat-model-picker-head strong { font-size: 13px; }
.chat-model-picker-head span { color: var(--text-2); font-size: 10px; }
.chat-model-search { display: flex; align-items: center; gap: 8px; margin: 0 10px 8px; padding: 0 10px; min-height: 36px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface-2); color: var(--text-2); }
.chat-model-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: 12px/1 var(--font); }
.chat-model-scroll { max-height: min(380px,48vh); overflow-y: auto; padding: 2px 7px 7px; }
.chat-model-group + .chat-model-group { margin-top: 7px; padding-top: 8px; border-top: 1px solid var(--border-soft); }
.chat-model-group-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 5px; }
.chat-model-group-head strong { font-size: 10px; font-weight: 650; color: var(--text-2); }
.chat-model-group-head span { font: 10px/1 var(--mono); color: var(--text-3); }
.chat-model-warning { display: flex; gap: 6px; margin: 0 8px 5px; color: var(--wait); font-size: 10px; }
.chat-model-list { display: grid; gap: 2px; }
.chat-model-option { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 42px; padding: 7px 9px; border: 0; border-radius: 11px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.chat-model-option:hover { background: var(--surface-2); }
.chat-model-option.is-active { background: var(--surface-2); }
.chat-model-option > span { display: grid; min-width: 0; flex: 1; gap: 2px; }
.chat-model-option strong, .chat-model-option small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-model-option strong { font-size: 12px; font-weight: 570; }
.chat-model-option small { color: var(--text-2); font: 9px/1.2 var(--mono); }
.chat-model-option em { padding: 4px 6px; border-radius: var(--r-full); background: var(--border-soft); color: var(--text-2); font-size: 8px; font-style: normal; }
.chat-model-option > svg { flex: none; }
.chat-model-manage { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 43px; padding: 0 15px; border: 0; border-top: 1px solid var(--border-soft); background: transparent; color: var(--text-2); font: 550 11px/1 var(--font); cursor: pointer; }
.chat-model-manage:hover { background: var(--surface-2); color: var(--text); }
.chat-model-manage svg:last-child { margin-left: auto; }
.chat-model-loading, .chat-model-load-error, .chat-model-empty { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 110px; padding: 20px; color: var(--text-2); font-size: 11px; text-align: center; }
.composer-bar .spacer { margin-left: auto; }
.composer-hint { color: var(--text-2); font: 11px/1 var(--mono); }
.composer-note { margin: 9px auto 0; color: var(--text-2); font-size: 10px; text-align: center; }
.send { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none; border: 0; border-radius: var(--r-full); background: var(--accent); color: var(--accent-fg); cursor: pointer; transition: filter var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.send:hover:not(:disabled) { filter: brightness(1.12); }
.send:active:not(:disabled) { transform: scale(.94); }
.send:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- the decision language ----------
   permitted / refused / failed / ratify_queued get one treatment everywhere.
   Colour is never the only carrier: each verdict has an icon and a word. */
.verdict { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: var(--r-full); border: 1px solid transparent; white-space: nowrap; }
.verdict svg { flex: none; }
.v-permitted { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 32%, transparent); }
.v-refused, .v-failed { background: var(--no-bg); color: var(--no); border-color: color-mix(in srgb, var(--no) 32%, transparent); }
.v-ratify_queued { background: var(--wait-bg); color: var(--wait); border-color: color-mix(in srgb, var(--wait) 32%, transparent); }

.steps { display: grid; gap: 3px; }
.step { display: flex; align-items: center; gap: var(--sp-2); min-height: 26px; font-size: 13px; color: var(--text-2); }
.step svg { flex: none; color: var(--ok); }
.step code { background: none; border: 0; padding: 0; color: var(--text-2); }
.step .n { font: 11px/1 var(--mono); color: var(--text-2); }

.decision { border: 1px solid var(--border-soft); border-left-width: 3px; border-radius: 15px; background: var(--surface); padding: var(--sp-3) var(--sp-4); }
.decision.d-permitted { border-left-color: var(--ok); }
.decision.d-refused, .decision.d-failed { border-left-color: var(--no); }
.decision.d-ratify_queued { border-left-color: var(--wait); }
.decision-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.decision-tool { font: 700 12px/1 var(--mono); }
.decision-body { margin-top: var(--sp-2); color: var(--text-2); font-size: 13px; }
.decision-note { margin-top: var(--sp-2); font-size: 12px; color: var(--text-2); }
.acts-row { margin-top: var(--sp-3); display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- panel ---------- */
.panel { min-width: 0; overflow: hidden; background: var(--side-bg); border-left: 1px solid var(--border-soft); display: flex; flex-direction: column; }
.panel[data-open="false"] { border-left: 0; }
.panel-in { width: 100%; overflow-y: auto; padding: var(--sp-5); display: grid; gap: var(--sp-5); align-content: start; height: 100%; }
.panel-head { display: flex; align-items: center; gap: var(--sp-2); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 630; letter-spacing: -.025em; color: var(--text); }
.panel-head .close { margin-left: auto; }
.pblock { display: grid; gap: var(--sp-2); }
.pblock h3 { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.pblock p { margin: 0; font-size: 13px; color: var(--text-2); }
.pstats { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp-2); }
.pstat { text-align: center; padding: 12px 6px; background: var(--surface); border-radius: var(--r-md); }
.pstat b { display: block; font: 700 17px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.pstat span { font-size: 10px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.files { display: grid; gap: 1px; }
.file { display: flex; align-items: center; gap: var(--sp-2); min-height: 30px; padding: 0 var(--sp-2); font: 12px/1.3 var(--mono); color: var(--text-2); border-radius: var(--r-sm); }
.file svg { flex: none; color: var(--text-3); }
.tools { display: flex; gap: 5px; flex-wrap: wrap; }
.tool-chip { font: 11px/1.35 var(--mono); background: var(--surface); border: 1px solid var(--border-soft); padding: 5px 7px; border-radius: var(--r-sm); color: var(--text-2); }

/* ---------- shared primitives ---------- */
.page { width: min(100%, 1020px); margin: 0 auto; padding: var(--sp-5) var(--sp-5) var(--sp-7); display: grid; gap: var(--sp-4); }
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--r-lg); padding: var(--sp-5); }
.card h2 { margin: 0 0 var(--sp-1); font-size: 15px; font-weight: 650; }
.card .sub { margin: 0 0 var(--sp-3); color: var(--text-2); font-size: 13px; }
.sec-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); margin: var(--sp-2) 0 0; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: var(--sp-2); }
input, textarea, select {
  width: 100%; min-height: var(--tap); padding: 10px var(--sp-3);
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--r-md);
}
input:focus, textarea:focus, select:focus { border-color: var(--border); }
textarea { min-height: 88px; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none;
  padding: 0 38px 0 12px;
  background-color: var(--bg);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  line-height: 1.2; text-overflow: ellipsis; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
select:hover:not(:disabled) { border-color: var(--border); background-color: var(--surface); }
select:focus, select:focus-visible { outline: none; border-color: var(--text-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 9%, transparent); }
select:disabled { opacity: .52; cursor: not-allowed; }
select option { background: var(--bg); color: var(--text); }
select::-ms-expand { display: none; }
.hint { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.hint.bad { color: var(--no); } .hint.good { color: var(--ok); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-4);
  font: inherit; font-size: 14px; font-weight: 600;
  border-radius: var(--r-full); border: 1px solid transparent;
  background: var(--accent); color: var(--accent-fg); cursor: pointer; white-space: nowrap;
  transition: filter var(--t-fast) var(--ease);
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--surface); }
.btn.danger { background: transparent; color: var(--no); border-color: var(--no); }
.btn.danger:hover:not(:disabled) { background: var(--no-bg); }
.btn.sm { padding: 0 var(--sp-3); font-size: 13px; }
.btn.icon-only { width: var(--tap); padding: 0; }
.text-button {
  display: inline-flex; min-height: var(--tap); align-items: center; justify-content: center;
  padding: 0 var(--sp-2); border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--text); font: inherit; font-size: 12px; font-weight: 620; cursor: pointer;
}
.text-button:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
.text-button.danger { color: var(--no); }
.icon-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none; background: none; border: 0; border-radius: var(--r-full); color: var(--text-2); cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

code { font: 12px/1.4 var(--mono); background: var(--surface-2); border: 1px solid var(--border-soft); padding: 2px 6px; border-radius: var(--r-sm); overflow-wrap: anywhere; }
pre { margin: 0; font: 12px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.rule-chip { display: inline-flex; font: 11px/1.35 var(--mono); color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border-soft); padding: 5px 8px; border-radius: var(--r-sm); overflow-wrap: anywhere; }

.empty { display: grid; place-items: center; gap: var(--sp-3); padding: var(--sp-7) var(--sp-4); text-align: center; color: var(--text-2); height: 100%; align-content: center; }
.empty svg { color: var(--text-3); }
.empty p { margin: 0; max-width: 44ch; font-size: 14px; }
.empty strong { color: var(--text); font-size: 16px; }

.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); padding: 0 var(--sp-3) var(--sp-2); white-space: nowrap; }
td { padding: var(--sp-3); border-top: 1px solid var(--border-soft); vertical-align: top; }
tbody tr:hover { background: var(--surface-2); }
.num { font: 12px/1.5 var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2); }

.tiles { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border-soft); border-left-width: 3px; border-radius: 16px; padding: var(--sp-4); display: grid; gap: 5px; }
.tile.t-permitted { border-left-color: var(--ok); } .tile.t-refused { border-left-color: var(--no); }
.tile.t-ratify_queued { border-left-color: var(--wait); } .tile.t-total { border-left-color: var(--border); }
.tile-n { font: 700 24px/1 var(--mono); font-variant-numeric: tabular-nums; }
.tile.t-permitted .tile-n { color: var(--ok); } .tile.t-refused .tile-n { color: var(--no); } .tile.t-ratify_queued .tile-n { color: var(--wait); }
.tile-l { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 5px; }

.chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 var(--sp-4); font: inherit; font-size: 13px; background: var(--bg); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-full); cursor: pointer; }
.chip:hover { background: var(--surface); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--surface-2); color: var(--text); border-color: var(--text-3); font-weight: 650; }
.chip .n { font: 700 11px/1 var(--mono); color: var(--text-2); }

.presets { display: grid; gap: var(--sp-2); }
.preset { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); padding: 0 var(--sp-3); background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.preset:hover { border-color: var(--accent); }
.preset .spacer { margin-left: auto; }
.rule-plain { font-size: 13px; }
.rule-raw { font: 11px/1.5 var(--mono); color: var(--text-2); margin-top: 3px; overflow-wrap: anywhere; }

.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.working { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--text-2); font-size: 13px; }

.toasts { position: fixed; right: var(--sp-4); bottom: var(--sp-4); display: grid; gap: var(--sp-2); z-index: var(--z-toast); max-width: min(380px, calc(100vw - var(--sp-6))); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-2); font-size: 13px; animation: rise var(--t-mid) var(--ease); }
.toast.bad { border-left-color: var(--no); } .toast.good { border-left-color: var(--ok); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.scrim { display: none; }

/* ---------- Grok Bot-style agent creation and profiles ---------- */
.main:has(.body[data-surface^="agent-"]) > .head { display: none; }
.body[data-surface^="agent-"] { background: var(--bg); }
.agent-create { flex: none; width: min(100%, 548px); min-height: 100%; margin: 0 auto; padding: var(--sp-5) var(--sp-5) var(--sp-7); }
.agent-create-top { min-height: 54px; display: flex; align-items: center; gap: var(--sp-3); }
.agent-create-top > span { flex: 1; font-size: 14px; font-weight: 620; }
.agent-create-top > .icon-btn:first-child { margin-left: -8px; }
.agent-top-save { min-width: 73px; padding: 0 16px; }

.agent-create-templates { display: flex; flex-direction: column; }
.template-stage { display: grid; place-items: center; align-content: center; flex: 1; min-height: 430px; text-align: center; }
.profile-eyebrow { color: var(--text-2); font-size: 12px; }
.template-stage h2 { margin: 10px 0 0; font-size: clamp(31px, 5vw, 41px); line-height: 1.08; letter-spacing: -.065em; }
.template-character { display: grid; place-items: center; width: 100%; min-height: 215px; }
.template-character .agent-mark-hero { width: 148px; height: 148px; }
.template-copy h3 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
.template-copy p { max-width: 37ch; min-height: 48px; margin: 7px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.template-nav { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); }
.template-dots { display: flex; align-items: center; gap: 0; }
.template-dot { width: var(--tap); height: var(--tap); display: grid; place-items: center; padding: 0; border: 0; background: transparent; cursor: pointer; }
.template-dot span { width: 7px; height: 7px; border-radius: var(--r-full); background: var(--border); }
.template-dot[aria-pressed="true"] span { width: 9px; height: 9px; background: var(--text); }
.template-actions { display: grid; gap: 6px; margin-top: var(--sp-4); }
.template-start, .agent-create-submit { width: 100%; }
.template-own { min-height: var(--tap); border: 0; border-radius: var(--r-full); background: transparent; color: var(--text-2); font: 550 14px/1 var(--font); cursor: pointer; }
.template-own:hover { color: var(--text); background: var(--surface); }

.agent-create-custom, .agent-profile, .agent-instructions-view { display: grid; align-content: start; gap: var(--sp-5); }
.profile-hero { display: grid; place-items: center; min-height: 156px; }
.profile-fields { overflow: hidden; border-radius: var(--r-md); background: var(--surface); }
.profile-fields input { min-height: 49px; border: 0; border-radius: 0; background: transparent; text-align: center; }
.profile-fields input + label + input { border-top: 1px solid var(--border-soft); }
.profile-name { font-size: 17px; font-weight: 680; }
.profile-title { font-size: 14px; color: var(--text-2); }
.profile-section, .character-picker { display: grid; gap: var(--sp-2); }
.profile-section-label { display: block; margin: 0 0 1px 4px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.character-card { overflow: hidden; display: grid; gap: 7px; padding: 9px; border-radius: var(--r-md); background: var(--surface); }
.character-colors { display: grid; grid-template-columns: repeat(6, minmax(44px, 1fr)); gap: 2px; }
.character-symbols { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 2px; }
.character-option-label { margin: 2px 4px -1px; color: var(--text-2); font-size: 10px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; }
.agent-avatar-options { grid-template-columns: repeat(6, minmax(44px, 1fr)); }
.agent-avatar-wardrobes { grid-template-columns: repeat(5, minmax(44px, 1fr)); }
.character-choice { width: 100%; min-width: var(--tap); height: var(--tap); display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--r-md); background: transparent; cursor: pointer; }
.character-choice:hover { background: var(--surface-2); }
.agent-avatar-choice { position: relative; height: 54px; overflow: hidden; border: 1px solid transparent; background: var(--bg); }
.agent-avatar-choice img { position: absolute; left: 50%; top: 50%; width: 154%; height: 154%; max-width: none; object-fit: contain; transform: translate(-50%, -34%); }
.agent-avatar-choice[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.character-reset { min-height: var(--tap); width: 100%; margin-top: 3px; padding: 0 var(--sp-2); border: 0; border-top: 1px solid var(--border-soft); background: transparent; color: var(--text); font: 550 13px/1 var(--font); text-align: left; cursor: pointer; }
.profile-caption { margin: 0 4px; color: var(--text-2); font-size: 12px; line-height: 1.55; }
.profile-instructions { min-height: 105px; border: 0; background: var(--surface); }
.agent-access { overflow: hidden; border-radius: var(--r-md); background: var(--surface); }
.agent-access summary { display: flex; min-height: 52px; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-3); list-style: none; cursor: pointer; }
.agent-access summary::-webkit-details-marker { display: none; }
.agent-access summary > svg { flex: none; color: var(--text-2); }
.agent-access summary > span:not(.agent-access-note) { flex: 1; font-size: 13px; font-weight: 560; }
.agent-access-note { color: var(--text-2); font-size: 12px; }
.agent-access-body { display: grid; gap: var(--sp-3); padding: 0 var(--sp-3) var(--sp-3); }
.agent-access-body > label { margin-bottom: -5px; }
.agent-tools-label { margin-top: var(--sp-2); }
.agent-tool-list { display: grid; gap: 1px; }
.agent-tool-option { display: flex; min-height: 55px; align-items: center; gap: var(--sp-3); margin: 0; padding: var(--sp-2) 0; color: var(--text); }
.agent-tool-option > input { width: 18px; height: 18px; min-height: 18px; margin: 0; flex: none; accent-color: var(--accent); }
.agent-tool-option > span { display: grid; min-width: 0; gap: 3px; }
.agent-tool-option strong { font-size: 12px; font-weight: 650; }
.agent-tool-option small { color: var(--text-2); font-size: 11px; font-weight: 450; }
.agent-create-submit { margin-top: 2px; }

.profile-link { display: flex; align-items: center; gap: var(--sp-3); min-height: 51px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-md); background: var(--surface); color: var(--text); font: 550 14px/1 var(--font); text-align: left; cursor: pointer; }
.profile-link > span { flex: 1; }
.profile-link > svg { color: var(--text-2); flex: none; }
.profile-routines { display: grid; padding: 0 var(--sp-3); border-radius: var(--r-md); background: var(--surface); }
.profile-empty, .profile-routine-name { display: flex; min-height: 47px; align-items: center; color: var(--text-2); font-size: 13px; }
.profile-routine-name { color: var(--text); }
.profile-routine-name + .profile-routine-name { border-top: 1px solid var(--border-soft); }
.profile-add { display: flex; min-height: var(--tap); align-items: center; gap: 8px; padding: 0; border: 0; border-top: 1px solid var(--border-soft); background: transparent; color: var(--text); font: 550 13px/1 var(--font); cursor: pointer; }
.profile-toggle { display: flex; min-height: 52px; align-items: center; justify-content: space-between; margin: 0; padding: 0 var(--sp-3); border-radius: var(--r-md); background: var(--surface); color: var(--text); font-size: 14px; }
.profile-toggle input { width: 20px; height: 20px; min-height: 20px; margin: 0; accent-color: var(--ok); }
.profile-toggle + .profile-caption { margin-top: -17px; }
.profile-plugins { margin-top: -3px; }
.agent-instructions-view { gap: var(--sp-3); }
.instruction-editor { min-height: 260px; border: 0; background: var(--surface); line-height: 1.65; }

/* Desktop's settings-oriented agent controls deliberately keep quick edits
   compact; the richer character editor remains available as a full profile. */
.desktop-agent-manager { display: grid; gap: var(--sp-6); min-width: 0; padding: 4px 0; }
.desktop-agent-heading { display: flex; align-items: center; gap: var(--sp-3); }
.desktop-agent-heading > span { flex: 1; min-width: 0; }
.desktop-agent-heading h2, .desktop-agent-heading h3 { margin: 0; font-size: 17px; letter-spacing: -.035em; }
.desktop-agent-heading p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.desktop-agent-group { display: grid; gap: var(--sp-3); padding: 20px 22px; border: 1px solid var(--border-soft); border-radius: 18px; background: color-mix(in srgb, var(--surface) 58%, var(--bg)); box-shadow: var(--shadow-1); }
.desktop-group-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.desktop-group-heading h3 { margin: 0; font-size: 13px; font-weight: 660; }
.desktop-group-heading > span { color: var(--text-2); font-size: 12px; }
.desktop-agent-grid, .desktop-available-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); gap: var(--sp-2); }
.desktop-agent-card { display: flex; min-width: 0; align-items: center; border: 1px solid var(--border-soft); border-radius: var(--r-md); background: var(--surface); }
.desktop-agent-main { display: flex; flex: 1; min-width: 0; min-height: 68px; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-md); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.desktop-agent-main:hover, .desktop-available-agent:hover { background: var(--surface-2); }
.desktop-agent-copy { display: grid; min-width: 0; gap: 3px; }
.desktop-agent-copy > strong, .desktop-agent-copy > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desktop-agent-copy > strong { font: 630 13px/1.2 var(--font); }
.desktop-agent-copy > small { color: var(--text-2); font: 11px/1.35 var(--font); }
.desktop-agent-order { display: flex; flex: none; }
.desktop-agent-order .icon-btn:disabled { opacity: .4; cursor: default; }
.desktop-available-agent { display: flex; min-width: 0; min-height: 68px; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-3); border: 1px solid var(--border-soft); border-radius: var(--r-md); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.desktop-available-agent > .desktop-agent-copy { flex: 1; }
.desktop-available-agent > svg { flex: none; color: var(--text-2); }
.desktop-agent-foot { padding-top: var(--sp-3); border-top: 1px solid var(--border-soft); color: var(--text-2); font-size: 12px; }

.desktop-agent-overlay { position: fixed; z-index: 90; inset: 0; display: grid; place-items: center; padding: var(--sp-4); background: var(--scrim); }
.desktop-agent-dialog { width: min(100%, 540px); display: grid; gap: var(--sp-3); padding: var(--sp-5); border: 1px solid var(--border-soft); border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow-2); }
.desktop-dialog-heading { display: flex; min-height: var(--tap); align-items: center; justify-content: space-between; }
.desktop-dialog-heading > span { display: flex; min-width: 0; align-items: center; gap: var(--sp-3); }
.desktop-dialog-heading h2 { overflow: hidden; margin: 0; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.desktop-agent-dialog > label { margin: 2px 0 -7px; }
.desktop-agent-dialog > textarea { min-height: 135px; }
.response-styles { display: flex; flex-wrap: wrap; gap: 5px; }
.response-style { min-width: var(--tap); min-height: var(--tap); padding: 0 10px; border: 1px solid transparent; border-radius: var(--r-full); background: var(--surface); color: var(--text); font: 550 12px/1 var(--font); cursor: pointer; }
.response-style[aria-pressed="true"] { border-color: var(--border); background: var(--surface-2); }
.desktop-dialog-actions { display: flex; justify-content: space-between; gap: var(--sp-2); margin-top: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app:has(.panel[data-open="true"]) { grid-template-columns: var(--side-w) minmax(0,1fr) 0; }
  .panel[data-open="true"] { position: fixed; inset: 0 0 0 auto; width: min(var(--panel-w), 92vw); z-index: var(--z-panel); box-shadow: var(--shadow-2); border-left: 1px solid var(--border); }
  .panel[data-open="true"] .panel-in { width: 100%; }
}

@media (max-width: 900px) {
  .app, .app:has(.panel[data-open="true"]) { grid-template-columns: minmax(0,1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: min(var(--side-w), 86vw); transform: translateX(-100%); transition: transform var(--t-mid) var(--ease); box-shadow: var(--shadow-2); }
  .side[data-open="true"] { transform: none; }
  .head .side-toggle, .side .side-theme { display: inline-grid; }
  .scrim[data-open="true"] { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: var(--z-scrim); }
  .thread, .composer, .page { max-width: none; }
}

/* ---------- gates: sign-in, onboarding, one-time reveals ---------- */
.gate {
  position: fixed; inset: 0; z-index: var(--z-toast);
  display: grid; place-items: center; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 36%, var(--surface) 0%, var(--bg) 58%); padding: var(--sp-5) var(--sp-4);
}
.gate-card {
  width: 100%; max-width: 452px; background: var(--bg);
  border: 1px solid var(--border-soft); border-radius: 27px;
  padding: 38px; box-shadow: var(--shadow-2);
}
.gate-card.wide { max-width: 596px; }
.gate-brand { flex: none; justify-content: flex-start; margin-bottom: 34px; }
.gate-eyebrow { display: block; margin-bottom: 10px; color: var(--text-2); font-size: 11px; font-weight: 600; letter-spacing: .035em; }
.gate-title { margin: 0; font-size: clamp(29px, 5vw, 38px); font-weight: 670; line-height: 1.1; letter-spacing: -.065em; }
.gate-sub { margin: 11px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.72; }
.gate-points { list-style: none; margin: var(--sp-5) 0 0; padding: 0; display: grid; gap: var(--sp-3); }
.gate-points li { display: flex; gap: var(--sp-3); font-size: 14px; color: var(--text-2); }
.gate-points svg { flex: none; margin-top: 3px; color: var(--ok); }
.gate-points b { color: var(--text); font-weight: 650; }
.gate-help { margin-top: var(--sp-5); border-top: 1px solid var(--border-soft); padding-top: var(--sp-3); }
.gate-help summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-size: 13px; color: var(--text-2); }
.gate-help p { font-size: 13px; color: var(--text-2); margin: var(--sp-2) 0; }
.gate-help pre { background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); }

/* Authentication is a product entry point, not an admin prompt. The left side
   establishes the workspace; the right side keeps each credential decision in
   a compact, linear flow. */
.auth-gate { padding: 24px; background: var(--bg); }
.auth-shell {
  width: min(100%, 1040px); min-height: min(680px, calc(100vh - 48px));
  display: grid; grid-template-columns: minmax(0, .92fr) minmax(420px, 1.08fr);
  overflow: hidden; border: 1px solid var(--border-soft); border-radius: 30px;
  background: var(--bg); box-shadow: var(--shadow-2);
}
.auth-story {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  min-width: 0; overflow: hidden; padding: 38px;
  color: #f7f8fb; background:
    radial-gradient(circle at 82% 17%, rgba(95,105,255,.34), transparent 34%),
    linear-gradient(150deg, #171a24 0%, #101116 58%, #0b0c10 100%);
}
.auth-story::after {
  content: ""; position: absolute; right: -92px; bottom: -126px; width: 360px; height: 360px;
  border: 1px solid rgba(255,255,255,.08); border-radius: 50%; box-shadow: 0 0 0 54px rgba(255,255,255,.018), 0 0 0 108px rgba(255,255,255,.012);
  pointer-events: none;
}
.auth-brand { position: relative; z-index: 1; color: #fff; }
.auth-brand small { color: rgba(255,255,255,.48); }
.auth-story-copy { position: relative; z-index: 1; max-width: 390px; margin: 76px 0 auto; }
.auth-kicker { display: block; margin-bottom: 16px; color: rgba(255,255,255,.55); font-size: 11px; font-weight: 680; letter-spacing: .08em; text-transform: uppercase; }
.auth-story h1 { margin: 0; font-size: clamp(38px, 4.4vw, 58px); font-weight: 650; line-height: .98; letter-spacing: -.065em; }
.auth-story-copy > p { max-width: 38ch; margin: 20px 0 0; color: rgba(255,255,255,.58); font-size: 14px; line-height: 1.7; }
.auth-agent-stack { position: relative; z-index: 1; display: flex; align-items: center; min-height: 64px; margin-top: 42px; }
.auth-agent-stack > span {
  width: 58px; height: 58px; overflow: hidden; margin-left: -12px;
  border: 3px solid #12141b; border-radius: 20px; background: #242732;
}
.auth-agent-stack > span:first-child { margin-left: 0; }
.auth-agent-stack img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; transform: scale(1.18); }
.auth-agent-stack > p { display: grid; gap: 3px; margin: 0 0 0 15px; }
.auth-agent-stack b { font-size: 12px; font-weight: 650; }
.auth-agent-stack small { color: rgba(255,255,255,.43); font-size: 10px; line-height: 1.35; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 5vw, 62px); background: var(--bg); }
.auth-mobile-brand { display: none; }
.auth-heading { margin-bottom: 28px; }
.auth-heading h2 { margin: 0; font-size: 32px; font-weight: 670; line-height: 1.1; letter-spacing: -.045em; }
.auth-heading p { margin: 10px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.65; }
.auth-methods {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px;
  border: 1px solid var(--border-soft); border-radius: 13px; background: var(--surface);
}
.auth-methods::before {
  content: ""; position: absolute; inset: 4px 50% 4px 4px; border: 1px solid var(--border-soft);
  border-radius: 9px; background: var(--bg); box-shadow: var(--shadow-1);
  transition: transform var(--t-mid) var(--ease);
}
.auth-methods:has(button:nth-child(2)[aria-selected="true"])::before { transform: translateX(calc(100% - 4px)); }
.auth-methods button {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 10px; border: 0; background: transparent;
  color: var(--text-2); font: inherit; font-size: 12px; font-weight: 620; cursor: pointer;
}
.auth-methods button[aria-selected="true"] { color: var(--text); }
.auth-form { min-height: 0; padding-top: 4px; }
.auth-form label { margin-bottom: 8px; color: var(--text); font-size: 12px; font-weight: 620; }
.auth-form input { min-height: 50px; border-radius: 13px; background: var(--surface); font-size: 14px; }
.auth-label-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 19px 0 8px; }
.auth-label-row label { margin: 0; }
.auth-label-row button {
  min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--text-2);
  font: inherit; font-size: 11px; font-weight: 620; cursor: pointer;
}
.auth-label-row button:hover { color: var(--text); }
.auth-progress { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -2px 0 22px; }
.auth-progress > span { color: var(--text-3); font-size: 10px; font-weight: 680; letter-spacing: .06em; text-transform: uppercase; }
.auth-progress > div { display: grid; grid-template-columns: repeat(3, 30px); gap: 5px; }
.auth-progress i { height: 3px; border-radius: var(--r-full); background: var(--border); }
.auth-progress i.is-active { background: var(--text); }
.auth-code-input { font-family: var(--mono); font-size: 17px !important; font-weight: 650; letter-spacing: .12em; text-align: center; text-transform: uppercase; }
.auth-device-label { margin-top: 19px; }
.auth-secret-field { position: relative; }
.auth-secret-field input { padding-right: 70px; }
.auth-secret-field button {
  position: absolute; inset: 5px 5px 5px auto; width: 58px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2); font: inherit; font-size: 11px; font-weight: 620; cursor: pointer;
}
.auth-secret-field button:hover { background: var(--surface-2); color: var(--text); }
.auth-submit { width: 100%; margin-top: 22px; }
.auth-error { margin: 0 0 17px; padding: 11px 13px; border: 1px solid color-mix(in srgb, var(--no) 28%, transparent); border-radius: 11px; background: var(--no-bg); color: var(--no); font-size: 11px; line-height: 1.5; }
.auth-provider-note { margin: 8px 0 0; color: var(--text-3); font-size: 10px; text-align: center; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-3); font-size: 10px; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--border-soft); }
.auth-provider-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-provider-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 47px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--text);
  font-size: 12px; font-weight: 620; text-decoration: none;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.auth-provider-btn:hover { border-color: var(--text-3); background: var(--surface-2); transform: translateY(-1px); }
.auth-provider-btn svg { color: var(--text-3); }
.auth-provider-btn small { color: var(--text-3); font-size: 9px; font-weight: 560; }
.auth-provider-btn[aria-disabled="true"] { color: var(--text-2); }
.auth-provider-btn[aria-disabled="true"]:hover { transform: none; }
.auth-back, .auth-resend, .auth-help-action {
  display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--text-2);
  min-height: 44px; font: inherit; font-size: 11px; cursor: pointer;
}
.auth-back { margin: -10px 0 14px; padding: 0; }
.auth-back:hover, .auth-resend:hover, .auth-help-action:hover { color: var(--text); }
.auth-resend { width: 100%; justify-content: center; margin-top: 13px; }
.auth-code-form .auth-code-input { margin-top: 2px; }
.auth-dev-code { margin: 11px 0 0; padding: 9px 11px; border: 1px solid var(--border-soft); border-radius: 9px; background: var(--surface); color: var(--text-2); font: 10px/1.45 var(--mono); }
.auth-dev-code b { color: var(--text); letter-spacing: .12em; }
.auth-assurance { display: flex; align-items: flex-start; gap: 10px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border-soft); color: var(--text-2); font-size: 10px; line-height: 1.55; }
.auth-assurance svg { flex: none; margin-top: 1px; }
.auth-assurance b { color: var(--text); font-weight: 650; }
.auth-recovery { margin-top: 13px; padding-top: 8px; }
.auth-recovery summary { min-height: 44px; font-size: 11px; }
.auth-help-action { width: 100%; padding: 0; }
.auth-recovery-key { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.auth-recovery-key label { grid-column: 1 / -1; margin: 0; color: var(--text-2); font-size: 10px; }
.auth-recovery-key .auth-secret-field input { min-height: 50px; }
.auth-recovery-key .auth-secret-field button { inset-block: 3px; }
.auth-recovery-key .btn { min-height: 44px; padding: 0 14px; font-size: 11px; }
.pairing-code-out { margin: 24px 0 0; padding: 18px; font-size: clamp(18px, 4vw, 27px); font-weight: 680; letter-spacing: .12em; text-align: center; }
.pairing-steps { margin: 20px 0 0; padding-left: 20px; color: var(--text-2); font-size: 13px; line-height: 1.7; }
.pairing-steps b { color: var(--text); }

.steps-dots { display: flex; gap: 6px; justify-content: flex-start; margin-bottom: var(--sp-5); }
.dot-step { width: 31px; height: 4px; border-radius: var(--r-full); background: var(--border); }
.dot-step.on { background: var(--accent); }
.dot-step.done { background: var(--ok); }

/* First-run setup borrows the useful part of Grok Bot's onboarding rhythm:
   visible progress and one job per screen, while keeping Ratifel's controls and
   security explanations concrete. */
.onboarding-gate { padding: 24px; background: var(--bg); }
.onboarding-shell {
  width: min(100%, 720px); min-height: min(720px, calc(100dvh - 48px)); overflow: hidden;
  border: 1px solid var(--border-soft); border-radius: 30px; background: var(--bg); box-shadow: var(--shadow-2);
}
.onboarding-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 86px; padding: 22px 34px; border-bottom: 1px solid var(--border-soft); }
.onboarding-head .gate-brand { margin: 0; }
.onboarding-progress { display: flex; align-items: center; gap: 14px; }
.onboarding-progress > span { color: var(--text-3); font: 650 10px/1 var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.onboarding-progress .steps-dots { margin: 0; }
.onboarding-body { display: flex; flex-direction: column; align-items: stretch; max-width: 600px; margin: 0 auto; padding: 42px 42px 48px; }
.onboarding-body > .gate-eyebrow, .onboarding-body > .gate-title, .onboarding-body > .gate-sub { text-align: center; }
.onboarding-body > .gate-title { max-width: 570px; margin-inline: auto; }
.onboarding-body > .gate-sub { max-width: 540px; margin-inline: auto; }
.onboarding-portrait-stack { display: flex; align-items: center; justify-content: center; height: 112px; margin: 0 0 22px; }
.onboarding-portrait-stack > span, .onboarding-agent-preview {
  width: 88px; height: 88px; overflow: hidden; margin-left: -15px; border: 4px solid var(--bg); border-radius: 28px; background: var(--surface-2); box-shadow: var(--shadow-1);
}
.onboarding-portrait-stack > span:first-child { margin-left: 0; transform: rotate(-4deg) translateY(6px); }
.onboarding-portrait-stack > span:last-child { transform: rotate(4deg) translateY(6px); }
.onboarding-portrait-stack > span.is-primary { z-index: 1; width: 104px; height: 104px; border-radius: 33px; }
.onboarding-portrait-stack img, .onboarding-agent-preview img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; transform: scale(1.14); }
.onboarding-agent-preview { width: 96px; height: 96px; margin: 0 auto 20px; border-radius: 31px; }
.onboarding-trust-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 28px; }
.onboarding-trust-row span { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 8px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface); color: var(--text-2); font-size: 10px; font-weight: 620; }
.onboarding-trust-row svg { color: var(--text-3); }
.onboarding-primary { width: 100%; margin-top: 26px; }
.onboarding-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 28px; }
.onboarding-form-grid label { margin: 0; }
.onboarding-form-grid label > span { display: block; margin-bottom: 8px; color: var(--text); font-size: 11px; font-weight: 650; }
.onboarding-form-grid .is-wide { grid-column: 1 / -1; }
.onboarding-form-grid input, .onboarding-form-grid select { min-height: 48px; border-radius: 13px; background-color: var(--surface); }
.onboarding-form-grid textarea { min-height: 92px; border-radius: 13px; background: var(--surface); }
.onboarding-form-grid small { display: block; margin-top: 6px; color: var(--text-3); font-size: 10px; line-height: 1.45; }
.onboarding-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 4px; }
.onboarding-actions .onboarding-primary { margin-top: 0; }
.onboarding-skip { grid-column: 1 / -1; min-height: 44px; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 11px; cursor: pointer; }
.onboarding-skip:hover { color: var(--text); }
.onboarding-warning { display: flex; gap: 7px; margin-top: 18px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent); border-radius: 12px; background: var(--warn-bg); color: var(--text-2); font-size: 10px; line-height: 1.45; }
.onboarding-warning b { flex: none; color: var(--text); }
.onboarding-tools { margin-top: 14px; border: 1px solid var(--border-soft); border-radius: 13px; background: var(--surface); }
.onboarding-tools summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 14px; color: var(--text); font-size: 11px; font-weight: 650; cursor: pointer; }
.onboarding-tools summary span { color: var(--text-3); font-size: 9px; font-weight: 560; }
.onboarding-tools .presets { max-height: 190px; overflow: auto; padding: 0 12px 12px; }
.onboarding-tools .preset input { width: auto; min-height: 0; margin: 0; }
.onboarding-tools > .hint { margin: 0; padding: 0 14px 14px; }

.token-out {
  margin-top: var(--sp-4); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3); font-size: 13px; user-select: all;
}

/* ---------- settings ---------- */
.settings-shell.page { width: min(100%, 1180px); gap: 28px; padding: 30px 32px 72px; }
.settings-page-head { max-width: 720px; }
.settings-kicker { display: block; color: var(--text-2); font-size: 10px; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.settings-page-head h1 { margin: 4px 0 0; font-size: clamp(30px, 4vw, 40px); font-weight: 680; line-height: 1.05; letter-spacing: -.06em; }
.settings-page-head p { margin: 9px 0 0; color: var(--text-2); font-size: 14px; }
.settings-layout { display: grid; grid-template-columns: 218px minmax(0, 1fr); align-items: start; gap: 46px; }
.set-sidebar { min-width: 0; }
.set-nav { position: sticky; top: var(--sp-4); display: grid; gap: var(--sp-5); }
.set-nav-group { display: grid; gap: 3px; }
.set-nav-label { padding: 0 11px 5px; color: var(--text-3); font-size: 10px; font-weight: 680; letter-spacing: .07em; text-transform: uppercase; }
.set-nav-item {
  display: flex; width: 100%; min-height: var(--tap); align-items: center; gap: 11px; padding: 0 11px;
  border: 0; border-radius: 11px; background: transparent; color: var(--text-2);
  font: 540 13px/1 var(--font); text-align: left; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.set-nav-item svg { flex: none; opacity: .78; }
.set-nav-item:hover { background: var(--surface); color: var(--text); }
.set-nav-item[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: inset 0 0 0 1px var(--border-soft); }
.set-nav-item[aria-current="page"] svg { opacity: 1; }
.set-mobile-switcher { display: none; }
.set-body { min-width: 0; }
.set-section-head { display: flex; min-height: 78px; align-items: flex-start; gap: 14px; padding: 0 2px 22px; border-bottom: 1px solid var(--border-soft); }
.set-section-icon { display: grid; width: 44px; height: 44px; flex: none; place-items: center; border: 1px solid var(--border-soft); border-radius: 14px; background: var(--surface); color: var(--text); }
.set-section-head > div { min-width: 0; }
.set-section-head .settings-kicker { margin: 1px 0 4px; }
.set-section-head h2 { margin: 0; font-size: 26px; font-weight: 670; line-height: 1.05; letter-spacing: -.045em; }
.set-section-head p { max-width: 620px; margin: 7px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.55; }
.set-stack { display: grid; gap: var(--sp-4); padding-top: var(--sp-4); }

.setting-card { min-width: 0; overflow: hidden; border: 1px solid var(--border-soft); border-radius: 18px; background: color-mix(in srgb, var(--surface) 58%, var(--bg)); box-shadow: var(--shadow-1); }
.setting-card-head { display: flex; min-height: 82px; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); padding: 20px 22px; }
.setting-card-head > div { min-width: 0; }
.setting-card-head h3 { margin: 0; font-size: 15px; font-weight: 670; letter-spacing: -.025em; }
.setting-card-head p { max-width: 590px; margin: 5px 0 0; color: var(--text-2); font-size: 12px; line-height: 1.55; }
.setting-status { display: inline-flex; min-height: 29px; flex: none; align-items: center; gap: 6px; padding: 0 10px; border-radius: var(--r-full); font-size: 11px; font-weight: 650; white-space: nowrap; }
.setting-status:not(.is-ready):not(.is-blocked) { background: var(--wait-bg); color: var(--wait); }
.setting-status.is-ready { background: var(--ok-bg); color: var(--ok); }
.setting-status.is-blocked { background: var(--no-bg); color: var(--no); }
.setting-count { display: grid; min-width: 29px; height: 29px; place-items: center; padding: 0 8px; border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2); font: 600 11px/1 var(--mono); }

.setting-facts { margin: 0; border-top: 1px solid var(--border-soft); }
.setting-facts > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: var(--sp-4); align-items: start; min-height: 56px; padding: 16px 22px; }
.setting-facts > div + div { border-top: 1px solid var(--border-soft); }
.setting-facts dt { color: var(--text-2); font-size: 11px; font-weight: 600; }
.setting-facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: var(--text); font-size: 12px; }
.setting-facts dd small { display: block; margin-top: 5px; color: var(--text-2); font-size: 10px; }
.muted-value { color: var(--text-2); }

.setting-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px var(--sp-4); padding: 2px 22px 22px; }
.setting-field-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.setting-field { min-width: 0; margin: 0; }
.setting-field > span, .access-grant-form label > span { display: block; margin-bottom: 7px; color: var(--text-2); font-size: 11px; font-weight: 620; }
.setting-field input, .setting-field select { width: 100%; min-height: 46px; background-color: var(--bg); }
.setting-field small { display: block; margin-top: 6px; color: var(--text-3); font-size: 10px; font-weight: 450; line-height: 1.5; }
.setting-field-wide { grid-column: 1 / -1; }
.setting-card-actions { display: flex; min-height: 76px; align-items: center; gap: var(--sp-2); padding: 15px 22px; border-top: 1px solid var(--border-soft); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.setting-danger-action { margin-left: auto; }
.setting-notice { display: flex; align-items: flex-start; gap: 9px; margin: 0 22px 20px; padding: 11px 12px; border-radius: 11px; background: var(--surface); color: var(--text-2); font-size: 11px; line-height: 1.5; }
.setting-notice svg { flex: none; margin-top: 1px; }
.setting-notice b { color: var(--text); font-weight: 650; }
.setting-notice.is-warning { background: var(--wait-bg); color: var(--wait); }
.setting-notice.is-warning b { color: var(--wait); }
.setting-notice.is-danger { background: var(--no-bg); color: var(--no); }
.setting-notice.is-danger b { color: var(--no); }
.setting-status-card > .setting-notice { margin-top: var(--sp-4); }

.setting-list { border-top: 1px solid var(--border-soft); }
.setting-person-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 156px; align-items: center; gap: 12px; min-height: 72px; padding: 12px 22px; }
.setting-person-row + .setting-person-row { border-top: 1px solid var(--border-soft); }
.setting-avatar { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface-2); color: var(--text); font: 650 10px/1 var(--font); }
.setting-person-copy { display: grid; min-width: 0; gap: 3px; }
.setting-person-copy strong { overflow: hidden; font-size: 12px; font-weight: 640; text-overflow: ellipsis; white-space: nowrap; }
.setting-person-copy > span { color: var(--text-2); font-size: 10px; }
.setting-person-copy > span b { color: var(--text); font-weight: 640; }
.setting-row-control { margin: 0; }
.setting-row-control > span { display: block; margin-bottom: 4px; color: var(--text-3); font-size: 9px; text-transform: uppercase; }
.setting-row-control select { min-height: var(--tap); background-color: var(--bg); font-size: 12px; }
.setting-inline-form { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto; align-items: end; gap: var(--sp-3); padding: 0 22px 20px; }
.setting-inline-form .btn { min-height: 46px; }

.character-studio-head { align-items: flex-start; }
.character-studio-layout { display: grid; grid-template-columns: minmax(250px, .72fr) minmax(0, 1.55fr); align-items: start; gap: 24px; padding: 0 22px 18px; }
.character-preview-card { position: sticky; top: 18px; overflow: hidden; border: 1px solid var(--border-soft); border-radius: 18px; background: var(--bg); }
.character-preview-stage { position: relative; display: grid; min-height: 390px; place-items: end center; overflow: hidden; background: radial-gradient(circle at 50% 29%, color-mix(in srgb, #7151ff 15%, transparent), transparent 46%), linear-gradient(145deg, var(--surface-2), var(--surface)); }
.character-composite { position: relative; display: block; width: 100%; aspect-ratio: 1; }
.character-composite img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; object-position: center bottom; pointer-events: none; }
.character-composite-image { filter: drop-shadow(0 18px 20px rgba(0,0,0,.12)); }
.character-preview-composite { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; }
.character-preview-copy { position: relative; z-index: 3; display: grid; gap: 3px; padding: 15px 16px; border-top: 1px solid var(--border-soft); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); }
.character-preview-copy small { color: var(--text-3); font-size: 9px; font-weight: 680; letter-spacing: .06em; text-transform: uppercase; }
.character-preview-copy strong { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.character-preview-copy > span { overflow: hidden; color: var(--text-2); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.character-controls { display: grid; min-width: 0; gap: 16px; }
.character-control-group { display: grid; min-width: 0; gap: 8px; padding-bottom: 15px; border-bottom: 1px solid var(--border-soft); }
.character-control-group:last-child { padding-bottom: 0; border-bottom: 0; }
.character-control-heading { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 12px; }
.character-control-heading > div { display: grid; min-width: 0; gap: 2px; }
.character-control-heading > div > span { color: var(--text); font-size: 12px; font-weight: 670; }
.character-control-heading small { color: var(--text-3); font-size: 9px; line-height: 1.4; }
.character-control-heading > b { color: var(--text-2); font-size: 10px; font-weight: 620; }
.character-option { position: relative; min-width: 0; min-height: 44px; border: 1px solid transparent; background: transparent; color: var(--text-2); font: 590 10px/1.2 var(--font); cursor: pointer; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.character-option:hover { color: var(--text); }
.character-option[aria-checked="true"] { border-color: var(--border-soft); background: var(--bg); color: var(--text); box-shadow: var(--shadow-1); }
.character-option > i { position: absolute; top: 6px; right: 6px; display: none; width: 18px; height: 18px; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-fg); }
.character-option[aria-checked="true"] > i { display: grid; }
.character-role-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.character-role-fields label { display: grid; gap: 6px; margin: 0; color: var(--text-2); font-size: 9px; font-weight: 620; }
.character-role-fields select { width: 100%; min-height: 44px; background-color: var(--bg); font-size: 11px; }
.character-skin-options { display: flex; flex-wrap: wrap; gap: 7px; }
.character-option-skinColor { display: grid; width: 62px; min-height: 58px; place-items: center; gap: 3px; padding: 7px 5px 5px; border-radius: 12px; }
.character-option-skinColor > span:not(.character-swatch) { font-size: 8px; }
.character-swatch { display: block; width: 25px; height: 25px; border: 2px solid color-mix(in srgb, var(--swatch) 64%, #fff); border-radius: 50%; background: var(--swatch); box-shadow: inset 0 -4px 7px rgba(0,0,0,.16); }
.character-visual-options { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.character-option-hairstyle, .character-option-wardrobe { display: grid; min-height: 96px; align-content: end; gap: 4px; overflow: hidden; padding: 0 4px 7px; border-color: var(--border-soft); border-radius: 12px; background: var(--bg); }
.character-option-hairstyle:hover, .character-option-wardrobe:hover { transform: translateY(-1px); border-color: var(--border); }
.character-option-hairstyle[aria-checked="true"], .character-option-wardrobe[aria-checked="true"] { border-color: color-mix(in srgb, #7457ff 58%, var(--border)); background: color-mix(in srgb, #7457ff 7%, var(--bg)); box-shadow: inset 0 0 0 1px color-mix(in srgb, #7457ff 18%, transparent); }
.character-option-art { display: grid; height: 70px; place-items: end center; overflow: hidden; border-bottom: 1px solid var(--border-soft); background: linear-gradient(145deg, var(--surface-2), var(--surface)); }
.character-option-composite { width: 90px; height: 90px; aspect-ratio: auto; transform: translateY(10px); }
.character-studio-actions { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 22px; border-top: 1px solid var(--border-soft); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.character-studio-actions > span { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 10px; }
.character-studio-actions > span svg { flex: none; }
.character-studio-actions > div { display: flex; gap: 7px; }
.character-studio-actions .btn:disabled { cursor: default; opacity: .48; }

.token-groups { border-top: 1px solid var(--border-soft); }
.token-group { padding: 20px 22px; }
.token-group + .token-group { border-top: 1px solid var(--border-soft); }
.token-group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.token-group-head > span { display: grid; min-width: 0; gap: 2px; }
.token-group-head b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.token-group-head small { color: var(--text-2); font-size: 10px; }
.token-list { display: grid; gap: 7px; margin-top: var(--sp-3); }
.token-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 57px; padding: 8px 9px 8px 12px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--bg); }
.token-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 10px; background: var(--surface); color: var(--text-2); }
.token-row > div { display: grid; min-width: 0; gap: 3px; }
.token-row strong { font-size: 12px; }
.token-row small { color: var(--text-2); font-size: 10px; }
.setting-empty { margin: var(--sp-3) 0 0; padding: 13px; border: 1px dashed var(--border); border-radius: 11px; color: var(--text-2); font-size: 11px; text-align: center; }

/* Model provider catalog ------------------------------------------------- */
.model-marketplace { display: grid; gap: 14px; }
.model-active-bar {
  display: flex; min-height: 70px; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border-soft); border-radius: 17px;
  background: color-mix(in srgb, var(--surface) 64%, var(--bg)); box-shadow: var(--shadow-1);
}
.model-active-mark { display: grid; width: 40px; height: 40px; flex: none; place-items: center; border-radius: 13px; background: var(--ok-bg); color: var(--ok); }
.model-active-bar > div:nth-child(2) { display: grid; min-width: 0; gap: 3px; }
.model-active-bar > div:nth-child(2) > span { color: var(--text-3); font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.model-active-bar strong { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.model-marketplace-stats { display: flex; margin-left: auto; gap: 7px; }
.model-marketplace-stats span, .model-capabilities span { padding: 6px 9px; border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2); font-size: 10px; white-space: nowrap; }
.model-browser { display: grid; min-height: 610px; grid-template-columns: 288px minmax(0, 1fr); overflow: hidden; border: 1px solid var(--border-soft); border-radius: 19px; background: color-mix(in srgb, var(--surface) 52%, var(--bg)); box-shadow: var(--shadow-1); }
.model-provider-pane { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--border-soft); background: color-mix(in srgb, var(--surface) 38%, var(--bg)); }
.model-search { position: relative; display: flex; align-items: center; margin: 13px; }
.model-search svg { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.model-search input { width: 100%; min-height: var(--tap); padding-left: 36px; border-radius: 12px; background: var(--bg); font-size: 11px; }
.model-provider-list { min-height: 0; flex: 1; overflow-y: auto; border-top: 1px solid var(--border-soft); }
.model-provider-item { display: grid; width: 100%; min-height: 64px; grid-template-columns: 36px minmax(0, 1fr) 18px; align-items: center; gap: 10px; padding: 10px 13px; border: 0; border-bottom: 1px solid var(--border-soft); border-radius: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.model-provider-item:hover { background: var(--surface); }
.model-provider-item[aria-current="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--text); }
.model-provider-logo, .model-detail-logo { display: grid; place-items: center; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-weight: 720; letter-spacing: -.03em; }
.model-provider-logo { width: 36px; height: 36px; border-radius: 11px; font-size: 10px; }
.model-provider-item > span:nth-child(2) { display: grid; min-width: 0; gap: 3px; }
.model-provider-item strong { overflow: hidden; font-size: 11px; font-weight: 640; text-overflow: ellipsis; white-space: nowrap; }
.model-provider-item small { color: var(--text-3); font-size: 9px; }
.model-provider-item i { display: grid; width: 17px; height: 17px; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--text-3); font-style: normal; }
.model-provider-item i.is-active { background: var(--ok-bg); color: var(--ok); }
.model-provider-detail { min-width: 0; padding: 22px; overflow: hidden; }
.model-detail-head { display: flex; align-items: center; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--border-soft); }
.model-detail-logo { width: 46px; height: 46px; flex: none; border-radius: 14px; font-size: 13px; }
.model-detail-head > div { min-width: 0; }
.model-detail-head h3 { margin: 0; font-size: 18px; font-weight: 680; letter-spacing: -.035em; }
.model-detail-head p { margin: 4px 0 0; color: var(--text-2); font-size: 10px; line-height: 1.45; }
.model-detail-head .setting-status { margin-left: auto; }
.model-connection-strip { display: flex; min-height: 44px; align-items: center; gap: 9px; margin: 14px 0 0; padding: 8px 10px; border-radius: 11px; background: var(--ok-bg); color: var(--ok); font-size: 10px; }
.model-connection-strip code { max-width: 40%; overflow: hidden; color: inherit; text-overflow: ellipsis; white-space: nowrap; }
.model-connection-strip .text-button { margin-left: auto; }
.model-connect-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; padding: 22px 0 4px; }
.model-connect-form .setting-field input, .model-connect-form .setting-field select { min-height: 44px; background: var(--bg); }
.model-connect-form .setting-field em { color: var(--text-3); font-size: 9px; font-style: normal; font-weight: 500; }
.model-field-wide, .model-form-actions, .model-capabilities, .model-probe-row { grid-column: 1 / -1; }
.model-capabilities { display: flex; flex-wrap: wrap; gap: 6px; }
.model-form-actions, .model-probe-row { display: flex; align-items: center; gap: 8px; }
.model-probe-row { margin-top: -5px; color: var(--text-3); font-size: 10px; }
.model-auth-panel { display: grid; gap: 10px; margin-top: 18px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.model-auth-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.model-auth-panel-head > div { display: grid; gap: 3px; }
.model-auth-panel-head strong { font-size: 12px; }
.model-auth-panel-head span { color: var(--text-2); font-size: 10px; line-height: 1.45; }
.model-auth-event { display: flex; min-height: 38px; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--bg); color: var(--text-2); font-size: 10px; }
.model-auth-event > span { display: grid; flex: 1; gap: 3px; }
.model-auth-event small { color: var(--text-3); }
.model-device-code code { padding: 5px 8px; border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 14px; letter-spacing: .1em; }
.model-auth-panel > .setting-field { margin-top: 2px; }
.model-auth-panel > .setting-field input, .model-auth-panel > .setting-field select { width: 100%; min-height: var(--tap); background: var(--bg); }
.model-provider-detail #modelTestResult { margin-top: 14px; }
.model-provider-detail #modelTestResult .working { margin: 0; }

.access-agent-list { display: grid; gap: 10px; padding: 0 22px 22px; }
.access-agent-card { overflow: hidden; border: 1px solid var(--border-soft); border-radius: 14px; background: var(--bg); }
.access-agent-head { display: flex; align-items: center; gap: 11px; min-height: 65px; padding: 11px 14px; }
.access-agent-head > div { display: grid; min-width: 0; gap: 2px; }
.access-agent-head strong { font-size: 12px; }
.access-agent-head small { color: var(--text-2); font-size: 10px; }
.agent-access-avatar { color: var(--text-2); }
.access-grants { border-top: 1px solid var(--border-soft); }
.access-grant-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; min-height: 54px; padding: 7px 9px 7px 14px; }
.access-grant-row + .access-grant-row { border-top: 1px solid var(--border-soft); }
.access-grant-row > span:first-child { display: grid; min-width: 0; gap: 2px; }
.access-grant-row strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.access-grant-row small { color: var(--text-2); font-size: 9px; }
.access-agent-card > .setting-empty { margin: 0 14px 14px; }
.access-grant-form { display: grid; grid-template-columns: minmax(0, 1fr) 130px auto; align-items: end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border-soft); background: var(--surface); }
.access-grant-form label { margin: 0; }
.access-grant-form select { min-height: var(--tap); background-color: var(--bg); font-size: 11px; }
.access-grant-form .btn { min-height: var(--tap); }

@media (max-width: 940px) {
  .settings-layout { grid-template-columns: 190px minmax(0, 1fr); gap: 28px; }
  .model-browser { grid-template-columns: 236px minmax(0, 1fr); }
  .character-visual-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .character-option-wardrobe { min-height: 122px; }
  .character-option-wardrobe .character-option-art { height: 96px; }
  .character-option-composite { width: 132px; height: 132px; transform: translateY(20px); }
}
@media (max-width: 760px) {
  .auth-gate { align-items: start; padding: 0; }
  .auth-shell { min-height: 100dvh; grid-template-columns: 1fr; border: 0; border-radius: 0; box-shadow: none; }
  .auth-story { min-height: 148px; padding: max(18px, env(safe-area-inset-top)) 24px 18px; }
  .auth-story-copy { margin: 18px 0 0; }
  .auth-kicker { display: none; }
  .auth-story h1 { font-size: 26px; line-height: .96; }
  .auth-story-copy > p { display: none; }
  .auth-agent-stack { display: none; }
  .auth-panel { justify-content: flex-start; padding: 34px 24px max(34px, env(safe-area-inset-bottom)); }
  .auth-mobile-brand { display: none; }
  .auth-heading { margin-bottom: 22px; }
  .auth-heading h2 { font-size: 28px; }
  .auth-form { min-height: 0; padding-top: 22px; }
  .auth-provider-list { grid-template-columns: 1fr; }
  .auth-provider-btn { min-height: 50px; }
  .auth-recovery-key { grid-template-columns: 1fr; }
  .auth-recovery-key .btn { width: 100%; }
  .auth-assurance { margin-top: 26px; }
  .onboarding-gate { align-items: start; padding: 0; }
  .onboarding-shell { min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .onboarding-head { min-height: 72px; padding: max(16px, env(safe-area-inset-top)) 20px 16px; }
  .onboarding-progress { gap: 9px; }
  .onboarding-progress > span { display: none; }
  .dot-step { width: 24px; }
  .onboarding-body { padding: 32px 22px max(36px, env(safe-area-inset-bottom)); }
  .onboarding-body > .gate-title { font-size: 31px; }
  .onboarding-portrait-stack { height: 94px; margin-bottom: 18px; }
  .onboarding-portrait-stack > span { width: 72px; height: 72px; border-radius: 23px; }
  .onboarding-portrait-stack > span.is-primary { width: 88px; height: 88px; border-radius: 28px; }
  .onboarding-trust-row { grid-template-columns: 1fr; gap: 7px; margin-top: 22px; }
  .onboarding-trust-row span { justify-content: flex-start; padding-inline: 14px; }
  .onboarding-form-grid { grid-template-columns: 1fr; gap: 14px; margin-top: 24px; }
  .onboarding-form-grid .is-wide { grid-column: auto; }
  .onboarding-actions { grid-template-columns: 1fr; }
  .onboarding-actions .btn { width: 100%; }
  .onboarding-actions .onboarding-skip { grid-column: auto; }
  .onboarding-warning { display: grid; }
  .onboarding-tools summary span { display: none; }
  .settings-shell.page { gap: 18px; padding: 18px 16px 64px; }
  .settings-page-head h1 { font-size: 30px; }
  .model-active-bar { align-items: flex-start; flex-wrap: wrap; }
  .model-marketplace-stats { width: 100%; margin-left: 52px; }
  .model-browser { display: block; min-height: 0; }
  .model-provider-pane { max-height: 300px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .model-provider-detail { padding: 17px 15px; }
  .model-detail-head { align-items: flex-start; }
  .model-detail-head .setting-status { display: none; }
  .model-connect-form { grid-template-columns: 1fr; }
  .model-field-wide, .model-form-actions, .model-capabilities, .model-probe-row { grid-column: auto; }
  .model-form-actions { flex-wrap: wrap; }
  .model-form-actions .btn { flex: 1 1 auto; }
  .model-connection-strip { flex-wrap: wrap; }
  .model-connection-strip code { max-width: 65%; }
  .model-connection-strip .text-button { margin-left: 0; }
  .settings-page-head p { margin-top: 6px; font-size: 12px; }
  .settings-layout { grid-template-columns: 1fr; gap: 0; }
  .set-sidebar { display: none; }
  .set-mobile-switcher { display: grid; gap: 7px; margin: 0; }
  .set-mobile-switcher > span:first-child { color: var(--text-3); font-size: 10px; font-weight: 680; letter-spacing: .06em; text-transform: uppercase; }
  .set-mobile-select-wrap { position: relative; display: flex; align-items: center; }
  .set-mobile-select-wrap > svg { position: absolute; left: 14px; z-index: 1; color: var(--text-2); pointer-events: none; }
  .set-mobile-select-wrap select { width: 100%; min-height: 48px; padding-left: 44px; border-radius: 14px; background-color: var(--surface); font-size: 13px; font-weight: 620; }
  .set-section-head { min-height: 72px; padding: 3px 0 18px; }
  .set-section-icon { width: 40px; height: 40px; border-radius: 13px; }
  .set-section-head h2 { font-size: 23px; }
  .set-section-head p { margin-top: 5px; font-size: 12px; }
  .set-stack { padding-top: 12px; }
  .setting-card { border-radius: 16px; }
  .setting-card-head { min-height: 0; padding: 17px 16px; }
  .setting-card-head p { font-size: 11px; }
  .setting-facts > div { grid-template-columns: 104px minmax(0, 1fr); gap: 10px; padding: 14px 16px; }
  .setting-field-grid, .setting-field-grid-three { grid-template-columns: 1fr; gap: 15px; padding: 0 16px 18px; }
  .setting-field-wide { grid-column: auto; }
  .setting-card-actions { min-height: 0; flex-wrap: wrap; padding: 14px 16px; }
  .setting-card-actions .btn { flex: 1 1 auto; }
  .setting-danger-action { width: 100%; margin-left: 0; }
  .setting-notice { margin: 0 16px 16px; }
  .setting-person-row { grid-template-columns: 38px minmax(0, 1fr); gap: 10px; padding: 13px 16px; }
  .setting-row-control { grid-column: 1 / -1; }
  .setting-row-control select { width: 100%; }
  .setting-inline-form { grid-template-columns: 1fr; padding: 0 16px 17px; }
  .setting-inline-form .btn { width: 100%; }
  .character-studio-layout { grid-template-columns: 1fr; gap: 20px; padding: 0 16px 20px; }
  .character-preview-card { position: relative; top: auto; }
  .character-preview-stage { min-height: 340px; }
  .character-control-heading { align-items: flex-start; }
  .character-visual-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .character-studio-actions { align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .character-studio-actions > div { width: 100%; }
  .character-studio-actions .btn { flex: 1; }
  .token-group { padding: 17px 16px; }
  .token-row small { white-space: normal; }
  .access-agent-list { padding: 0 16px 17px; }
  .access-grant-form { grid-template-columns: 1fr 108px; }
  .access-grant-form .btn { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 420px) {
  .settings-page-head { display: none; }
  .setting-card-head { align-items: flex-start; }
  .setting-status { min-height: 25px; padding: 0 8px; font-size: 10px; }
  .setting-facts > div { grid-template-columns: 1fr; gap: 4px; }
  .token-group-head { align-items: flex-start; }
  .token-group-head .btn { padding: 0 10px; }
  .access-grant-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .access-grant-form { grid-template-columns: 1fr; }
  .access-grant-form .btn { grid-column: auto; }
  .character-role-fields { grid-template-columns: 1fr; }
  .character-visual-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .character-option-hairstyle, .character-option-wardrobe { min-height: 118px; }
  .character-preview-stage { min-height: 300px; }
}

/* ---------- bot row menu ---------- */
.bot-slot { position: relative; display: flex; align-items: center; }
.bot-slot .bot-row { flex: 1; min-width: 0; }
.row-menu { position: absolute; right: 2px; opacity: 0; }
.bot-slot:hover .row-menu, .row-menu:focus-visible { opacity: 1; }

/* ---------- floating menu ---------- */
.menu {
  position: fixed; z-index: var(--z-toast); min-width: 190px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: var(--sp-1);
  display: grid; gap: 1px;
}
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--tap); padding: 0 var(--sp-3);
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--no); }
.menu-item svg { flex: none; color: var(--text-2); }
.menu-item.danger svg { color: var(--no); }

/* ---------- conversations ---------- */
.threads { display: grid; gap: 2px; }
.thread-row { display: flex; align-items: stretch; gap: 2px; border-radius: var(--r-md); }
.thread-row:hover { background: var(--surface); }
.thread-row.on { background: var(--surface-2); }
.thread-open {
  flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left;
  background: none; border: 0; color: inherit; font: inherit;
  padding: var(--sp-2) var(--sp-3); min-height: var(--tap); cursor: pointer; border-radius: var(--r-md);
}
.t-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-meta { font: 11px/1.3 var(--mono); color: var(--text-2); }
.t-prev { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-menu { align-self: center; opacity: 0; }
.thread-row:hover .t-menu, .t-menu:focus-visible { opacity: 1; }

/* ---------- command palette ---------- */
.palette { position: fixed; inset: 0; z-index: var(--z-toast); background: var(--scrim); padding: 10vh var(--sp-4) var(--sp-4); overflow-y: auto; }
.palette-box { max-width: 560px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2); overflow: hidden; }
.palette-in { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-4); border-bottom: 1px solid var(--border-soft); }
.palette-in svg { flex: none; color: var(--text-2); }
.palette-in input { border: 0; background: none; min-height: 56px; font-size: 16px; padding: 0; }
.palette-in input:focus { outline: none; }
.palette-in kbd { font: 11px/1 var(--mono); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 6px; flex: none; }
.palette-results { max-height: 56vh; overflow-y: auto; padding: var(--sp-2); }
.pgroup + .pgroup { margin-top: var(--sp-3); }
.pgroup-l { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); padding: var(--sp-2) var(--sp-3) var(--sp-1); }
.pitem { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: var(--tap); padding: 0 var(--sp-3); background: none; border: 0; border-radius: var(--r-md); color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.pitem:hover { background: var(--surface-2); }
.pitem svg { flex: none; color: var(--text-2); }
.pi-main { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-sub { font: 11px/1.3 var(--mono); color: var(--text-2); flex: none; }

/* ---------- tasks ---------- */
.tasks-page { min-height: 100%; padding: clamp(24px,4vw,48px) var(--sp-5) var(--sp-7); }
.tasks-shell { width: min(100%, 980px); margin: 0 auto; display: grid; gap: var(--sp-5); }
.tasks-hero { display: flex; align-items: end; justify-content: space-between; gap: var(--sp-6); padding: 10px 4px var(--sp-2); }
.tasks-hero-copy { max-width: 650px; }
.tasks-kicker { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 10px; font-weight: 650; letter-spacing: .075em; text-transform: uppercase; }
.tasks-hero h2 { margin: 0; font-size: clamp(30px,4.1vw,48px); font-weight: 660; line-height: 1.02; letter-spacing: -.065em; }
.tasks-hero p { max-width: 620px; margin: 13px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.65; }
.tasks-create { flex: none; margin-bottom: 4px; }
.task-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: var(--sp-3); }
.task-metrics article { min-width: 0; min-height: 124px; display: grid; align-content: space-between; padding: var(--sp-4); border: 1px solid var(--border-soft); border-radius: var(--r-lg); background: var(--surface); }
.task-metrics article > span { color: var(--text-2); font-size: 11px; font-weight: 580; }
.task-metrics strong { overflow: hidden; font: 650 31px/1 var(--font); letter-spacing: -.05em; text-overflow: ellipsis; white-space: nowrap; }
.task-metrics .task-next-value { font-size: 22px; }
.task-metrics small { overflow: hidden; color: var(--text-2); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.tasks-list-card { overflow: hidden; border: 1px solid var(--border-soft); border-radius: var(--r-lg); background: var(--bg); }
.tasks-section-head { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-soft); }
.tasks-section-head h3, .task-form-heading h3 { margin: 0; font-size: 16px; font-weight: 640; letter-spacing: -.03em; }
.tasks-section-head .tasks-kicker { margin-bottom: 2px; }
.tasks-count { flex: none; padding: 6px 9px; border-radius: var(--r-full); background: var(--surface); color: var(--text-2); font: 10px/1 var(--mono); }
.routines { display: grid; }
.routine { min-width: 0; min-height: 104px; display: grid; grid-template-columns: 42px minmax(0,1fr) var(--tap); align-items: start; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); background: var(--bg); border-bottom: 1px solid var(--border-soft); }
.routine:last-child { border-bottom: 0; }
.routine.off { background: color-mix(in srgb, var(--surface) 48%, var(--bg)); }
.routine-glyph { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: var(--surface); color: var(--text-2); }
.routine.off .routine-glyph { color: var(--text-3); }
.routine-copy { min-width: 0; display: grid; gap: 5px; padding-top: 1px; }
.r-top { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.r-name { min-width: 0; overflow: hidden; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.r-enabled { flex: none; padding: 4px 7px; border-radius: var(--r-full); background: var(--ok-bg); color: var(--ok); font: 10px/1 var(--mono); }
.routine.off .r-enabled { background: var(--surface-2); color: var(--text-2); }
.r-menu { flex: none; margin-top: -2px; }
.r-when { overflow: hidden; color: var(--text-2); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.r-foot { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.r-foot .verdict { padding: 4px 7px; font-size: 10px; }
.r-next { color: var(--text-2); font: 10px/1.3 var(--mono); }
.r-state { color: var(--text-2); font: 10px/1.3 var(--mono); }
.r-err { margin-top: 2px; padding: 6px var(--sp-2); border-radius: var(--r-sm); background: var(--wait-bg); color: var(--wait); font-size: 12px; }
.tasks-empty { min-height: 250px; display: grid; place-content: center; justify-items: center; padding: var(--sp-6); color: var(--text-2); text-align: center; }
.tasks-empty svg { margin-bottom: var(--sp-3); }
.tasks-empty strong { color: var(--text); font-size: 14px; }
.tasks-empty p { max-width: 380px; margin: 6px 0 0; font-size: 12px; }
.r-new { overflow: hidden; border: 1px solid var(--border-soft); border-radius: var(--r-lg); background: var(--surface); scroll-margin-top: var(--sp-5); }
.r-new summary { min-height: 62px; display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-5); cursor: pointer; color: var(--text); font-size: 13px; font-weight: 600; list-style: none; }
.r-new summary::-webkit-details-marker { display: none; }
.r-new[open] summary { border-bottom: 1px solid var(--border-soft); }
.task-form { display: grid; gap: var(--sp-4); padding: var(--sp-5); background: var(--bg); }
.task-form-heading { display: grid; }
.task-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--sp-3); }
.task-form label { display: grid; gap: 6px; color: var(--text-2); font-size: 11px; font-weight: 600; }
.task-form textarea { min-height: 124px; resize: vertical; }
.task-form .hint { margin: -7px 0 0; }
.task-form-actions { display: flex; justify-content: flex-end; }

/* ---------- MCP ---------- */
.mcp { border: 1px solid var(--border-soft); border-radius: var(--r-md); padding: var(--sp-3); margin-top: var(--sp-3); }
.mcp-top { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.mcp-name { font-size: 14px; font-weight: 650; }
.mcp-top .spacer { margin-left: auto; }
.mcp-err { margin-top: var(--sp-2); font-size: 12px; color: var(--no); background: var(--no-bg); border-radius: var(--r-sm); padding: 6px var(--sp-2); display: flex; align-items: center; gap: var(--sp-2); }

/* ---------- plugin marketplace ---------- */
@media (min-width: 761px) {
  .settings-shell.page:has(.plugin-marketplace) { width: min(100%, 1360px); padding-right: 28px; padding-left: 28px; }
  .settings-layout:has(.plugin-marketplace) { grid-template-columns: 190px minmax(0, 1fr); gap: 36px; }
}
.set-body:has(.plugin-marketplace) .set-section-icon { display: none; }
.set-body:has(.plugin-marketplace) .set-section-head { gap: 0; }
.plugin-marketplace { display: grid; min-width: 0; gap: 18px; }
.plugin-marketplace-nav { display: flex; min-width: 0; align-items: end; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--border-soft); }
.plugin-tabs { display: flex; min-width: 0; align-items: flex-end; gap: 6px; }
.plugin-tabs button { position: relative; min-width: 70px; min-height: 45px; padding: 0 14px 13px; border: 0; background: transparent; color: var(--text-2); font: 590 13px/1 var(--font); cursor: pointer; }
.plugin-tabs button::after { position: absolute; right: 12px; bottom: -1px; left: 12px; height: 2px; border-radius: var(--r-full); background: transparent; content: ""; transform: scaleX(.35); transition: background var(--t-fast) var(--ease), transform 180ms var(--ease); }
.plugin-tabs button:hover { color: var(--text); }
.plugin-tabs button[aria-pressed="true"] { color: var(--text); font-weight: 680; }
.plugin-tabs button[aria-pressed="true"]::after { background: var(--text); transform: scaleX(1); }
.plugin-add-mcp { min-height: var(--tap); margin-bottom: 4px; padding: 0 13px; white-space: nowrap; }
.plugin-toolbar { display: grid; min-width: 0; }
.plugin-search { display: flex; min-width: 0; min-height: 46px; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface); color: var(--text-2); transition: border var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.plugin-search:focus-within { border-color: var(--border); background: var(--bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 6%, transparent); }
.plugin-search input { width: 100%; min-height: 44px; padding: 0; border: 0; background: transparent; font-size: 13px; }
.plugin-search input:focus { outline: none; }
.plugin-view-frame { min-width: 0; overflow: hidden; }
.plugin-view { min-width: 0; animation: plugin-view-in 230ms var(--ease) both; }
@keyframes plugin-view-in { from { opacity: .2; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }
.plugin-marketplace-layout { display: grid; min-width: 0; gap: 20px; }
.plugin-sync-strip { display: flex; min-width: 0; min-height: 48px; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface); color: var(--text-2); font-size: 11px; }
.plugin-sync-strip > svg { flex: none; color: var(--ok); }
.plugin-sync-strip > span { min-width: 0; }
.plugin-sync-strip strong { color: var(--text); font-weight: 650; }
.plugin-sync-strip .text-button { min-height: var(--tap); flex: none; margin-left: auto; padding: 0 8px; }
.plugin-catalog-section, .plugin-yours, .plugin-sources-section { display: grid; min-width: 0; gap: 13px; }
.plugin-section-heading, .plugin-list-heading { display: flex; min-width: 0; align-items: end; justify-content: space-between; gap: 18px; }
.plugin-section-heading > div, .plugin-list-heading > div { min-width: 0; }
.plugin-section-heading > div > span, .plugin-list-heading > div > span, .plugin-subsection-kicker { color: var(--text-3); font-size: 9px; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.plugin-section-heading h3, .plugin-list-heading h3 { margin: 3px 0 0; font-size: 15px; font-weight: 690; letter-spacing: -.025em; }
.plugin-section-heading p, .plugin-list-heading p { margin: 4px 0 0; color: var(--text-2); font-size: 11px; line-height: 1.45; }
.plugin-section-heading > strong, .plugin-list-heading > strong { display: grid; min-width: 27px; height: 27px; place-items: center; padding: 0 8px; border-radius: var(--r-full); background: var(--surface); color: var(--text-2); font: 10px/1 var(--mono); }
.plugin-catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.plugin-catalog-card { display: flex; min-width: 0; min-height: 190px; flex-direction: column; gap: 12px; padding: 15px; border: 1px solid var(--border-soft); border-radius: 16px; background: var(--bg); transition: border var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.plugin-catalog-card:hover { border-color: var(--border); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.plugin-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.plugin-logo { display: grid; width: 40px; height: 40px; flex: none; place-items: center; overflow: hidden; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface); color: var(--text); font: 680 11px/1 var(--font); }
.plugin-app-logo { font-size: 11px; letter-spacing: -.02em; }
.plugin-app-logo.has-image { background: #fff; }
.plugin-app-logo img { width: 65%; height: 65%; object-fit: contain; background: transparent; }
.plugin-card-copy { display: grid; min-width: 0; gap: 5px; }
.plugin-card-copy h3, .source-card h3 { overflow: hidden; margin: 0; font-size: 14px; font-weight: 670; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.plugin-card-copy p { display: -webkit-box; min-height: 34px; overflow: hidden; margin: 0; color: var(--text-2); font-size: 11px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.plugin-card-foot { display: flex; min-width: 0; min-height: 34px; align-items: center; gap: 7px; margin-top: auto; padding-top: 11px; border-top: 1px solid var(--border-soft); }
.plugin-card-foot .btn { flex: none; }
.plugin-source-pill, .plugin-provider-count { overflow: hidden; max-width: 126px; padding: 5px 7px; border-radius: 7px; background: var(--surface); color: var(--text-2); font-size: 9px; font-weight: 590; text-overflow: ellipsis; white-space: nowrap; }
.plugin-provider-count { background: transparent; color: var(--text-3); }
.plugin-provider-label { display: grid; min-width: 0; gap: 4px; margin-top: 4px; }
.plugin-provider-label > span:first-child { color: var(--text-3); font-size: 8px; font-weight: 680; letter-spacing: .065em; text-transform: uppercase; }
.plugin-select-wrap { position: relative; display: block; min-width: 0; }
.plugin-select-wrap > svg { position: absolute; top: 50%; right: 11px; pointer-events: none; color: var(--text-3); transform: translateY(-50%) rotate(90deg); }
.plugin-provider-label select { width: 100%; min-height: var(--tap); padding: 0 32px 0 10px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 10px; appearance: none; cursor: pointer; }
.plugin-provider-label select:focus { border-color: var(--border); outline: 3px solid color-mix(in srgb, var(--text) 6%, transparent); }
.plugin-state { display: inline-flex; flex: none; align-items: center; gap: 6px; margin-left: auto; color: var(--text-2); font: 10px/1 var(--mono); text-transform: capitalize; white-space: nowrap; }
.plugin-state-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.plugin-state.state-connected { color: var(--ok); }
.plugin-state.state-connected .plugin-state-dot { background: var(--ok); }
.plugin-state.state-waiting { color: var(--wait); }
.plugin-state.state-waiting .plugin-state-dot { background: var(--wait); animation: pulse 1.3s ease-in-out infinite; }
.plugin-state.state-failed, .plugin-state.state-expired { color: var(--no); }
.plugin-state.state-failed .plugin-state-dot, .plugin-state.state-expired .plugin-state-dot { background: var(--no); }
.plugin-error { display: flex; align-items: flex-start; gap: 6px; margin: -2px 0 var(--sp-2); padding: 7px 9px; border-radius: var(--r-sm); background: var(--no-bg); color: var(--no); font-size: 11px; line-height: 1.4; }
.plugin-error svg { flex: none; margin-top: 1px; }
.plugin-card-error { margin: 0; }
.plugin-connected-list { display: grid; min-width: 0; gap: 7px; }
.plugin-connection-columns { display: grid; grid-template-columns: minmax(218px, 1fr) 170px 130px 78px; gap: 12px; padding: 0 17px; color: var(--text-3); font-size: 8px; font-weight: 680; letter-spacing: .07em; text-transform: uppercase; }
.plugin-connection-item { min-width: 0; border: 1px solid var(--border-soft); border-radius: 13px; background: var(--bg); }
.plugin-connection-item summary { display: grid; grid-template-columns: 42px minmax(160px, 1fr) 170px 130px 60px 15px; min-height: 68px; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; list-style: none; }
.plugin-connection-item summary::-webkit-details-marker { display: none; }
.plugin-connection-item summary > svg { color: var(--text-3); transition: transform var(--t-fast) var(--ease); }
.plugin-connection-item[open] summary > svg { transform: rotate(90deg); }
.plugin-connection-logo { width: 36px; height: 36px; border-radius: 11px; }
.plugin-connection-copy { display: grid; min-width: 0; gap: 3px; }
.plugin-connection-copy strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.plugin-connection-copy small { overflow: hidden; color: var(--text-2); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.plugin-connection-provider { display: grid; min-width: 0; gap: 3px; }
.plugin-connection-provider small { color: var(--text-3); font-size: 8px; font-weight: 650; text-transform: uppercase; }
.plugin-connection-provider strong { overflow: hidden; font-size: 11px; font-weight: 590; text-overflow: ellipsis; white-space: nowrap; }
.plugin-manage-label { color: var(--text-2); font-size: 10px; font-weight: 590; }
.plugin-connection-panel { display: grid; gap: 13px; padding: 15px 16px 16px 68px; border-top: 1px solid var(--border-soft); background: var(--surface); border-radius: 0 0 13px 13px; }
.plugin-connection-description { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 20px; }
.plugin-connection-description > p { max-width: 540px; margin: 0; color: var(--text-2); font-size: 10px; line-height: 1.55; }
.plugin-connection-facts { display: flex; gap: 18px; }
.plugin-connection-facts > span { display: grid; gap: 3px; }
.plugin-connection-facts small { color: var(--text-3); font-size: 8px; font-weight: 650; letter-spacing: .055em; text-transform: uppercase; }
.plugin-connection-facts strong { color: var(--text-2); font-size: 10px; font-weight: 590; white-space: nowrap; }
.plugin-connection-panel .plugin-error { margin: 0; }
.plugin-manage-actions { display: flex; align-items: end; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.plugin-manage-actions .plugin-provider-label { width: min(260px, 100%); margin: 0 auto 0 0; }
.plugin-source-attention { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid color-mix(in srgb, var(--wait) 17%, transparent); border-radius: 12px; background: var(--wait-bg); color: var(--wait); }
.plugin-source-attention > svg { margin-top: 1px; }
.plugin-source-attention p { display: grid; gap: 3px; margin: 0; font-size: 10px; line-height: 1.45; }
.plugin-source-attention p strong { font-size: 11px; }
.plugin-source-attention .btn { min-height: var(--tap); }
.plugin-empty-state { display: grid; min-height: 270px; place-items: center; align-content: center; gap: 7px; padding: var(--sp-6); border: 1px dashed var(--border); border-radius: var(--r-lg); color: var(--text-2); text-align: center; }
.plugin-empty-state h3 { margin: 5px 0 0; color: var(--text); font-size: 15px; }
.plugin-empty-state p, .plugin-empty { margin: 0; color: var(--text-2); font-size: 12px; }
.source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.source-card { display: grid; min-width: 0; min-height: 148px; gap: 14px; padding: 15px; border: 1px solid var(--border-soft); border-radius: 15px; background: var(--bg); }
.source-card > header { display: flex; min-width: 0; align-items: flex-start; gap: 11px; }
.source-card > footer { display: flex; min-width: 0; min-height: 32px; align-items: center; gap: 7px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.source-logo { width: 38px; height: 38px; border-radius: 11px; }
.ratifel-source-logo { background: #f5f4f1; }
.ratifel-source-logo img { width: 20px; height: 20px; object-fit: contain; }
.source-copy { min-width: 0; }
.source-copy .row { justify-content: flex-start; gap: 7px; }
.source-copy p { display: -webkit-box; overflow: hidden; margin: 4px 0 0; color: var(--text-2); font-size: 10px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.source-card > .plugin-error { margin: -3px 0 0; }
.source-status { display: inline-flex; flex: none; align-items: center; gap: 5px; padding: 6px 9px; border-radius: var(--r-full); background: var(--surface); color: var(--text-2); font-size: 10px; font-weight: 600; white-space: nowrap; }
.source-status.ready { background: var(--ok-bg); color: var(--ok); }
.source-status.needs-setup { background: var(--wait-bg); color: var(--wait); }
.plugin-sources-section + .plugin-subsection { margin-top: 18px; }
.plugin-subsection { display: grid; gap: 12px; }
.plugin-subsection > div:first-child h3 { margin: 3px 0 0; font-size: 14px; }
.plugin-subsection > div:first-child p { margin: 4px 0 0; color: var(--text-2); font-size: 11px; line-height: 1.5; }
.plugin-registry-section { margin-top: 22px; padding-top: 19px; border-top: 1px solid var(--border-soft); }
.registry-list { display: grid; gap: 6px; }
.registry-row { display: flex; min-width: 0; align-items: center; gap: var(--sp-3); padding: 11px 12px; border: 1px solid var(--border-soft); border-radius: 13px; }
.registry-row > div { min-width: 0; }
.registry-row h4 { overflow: hidden; margin: 0; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.registry-row p { overflow: hidden; margin: 2px 0 0; color: var(--text-2); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.registry-row .plugin-logo { width: 34px; height: 34px; border-radius: 10px; }
.registry-row .spacer { flex: 1; }
.plugin-registry-empty { display: flex; min-height: 78px; align-items: center; justify-content: center; gap: 9px; padding: 14px; border: 1px dashed var(--border); border-radius: 13px; color: var(--text-2); font-size: 11px; text-align: center; }
.custom-mcp-card { display: flex; align-items: center; gap: 13px; padding: 16px; border: 1px solid var(--border-soft); border-radius: 16px; background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--surface) 78%, var(--bg))); }
.custom-mcp-card > div { flex: 1; min-width: 0; }
.custom-mcp-card h3 { margin: 3px 0 0; font-size: 14px; font-weight: 680; letter-spacing: -.02em; }
.custom-mcp-card p { margin: 4px 0 0; color: var(--text-2); font-size: 11px; line-height: 1.5; }
.custom-mcp-card > .btn { flex: none; }
.custom-mcp-logo { background: var(--surface-2); color: var(--text); }
.custom-mcp-dialog { width: min(100%, 590px); display: grid; max-height: min(790px, calc(100dvh - 32px)); overflow: auto; gap: 16px; padding: 20px; border: 1px solid var(--border-soft); border-radius: 20px; background: var(--bg); box-shadow: var(--shadow-2); }
.custom-mcp-dialog-head { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: var(--sp-3); }
.custom-mcp-dialog-head h2 { margin: 0; font-size: 17px; letter-spacing: -.035em; }
.custom-mcp-dialog-head p { margin: 3px 0 0; color: var(--text-2); font-size: 12px; }
.custom-mcp-form-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(180px,.75fr); gap: var(--sp-3); }
.custom-mcp-form-grid label, .custom-mcp-secret-fields label { display: grid; min-width: 0; gap: 6px; color: var(--text-2); font-size: 11px; font-weight: 600; }
.custom-mcp-form-grid input, .custom-mcp-form-grid select, .custom-mcp-secret-fields input { min-height: var(--tap); background-color: var(--surface); font-size: 12px; }
.custom-mcp-form-grid .custom-mcp-url { grid-column: 1 / -1; }
.custom-mcp-auth-note { min-height: 36px; margin: -3px 0 0; padding: 9px 11px; border-radius: var(--r-sm); background: var(--surface); color: var(--text-2); font-size: 11px; line-height: 1.5; }
.custom-mcp-secret-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--sp-3); }
.custom-mcp-secret-fields:not(.custom-mcp-api-key-fields) { grid-template-columns: 1fr; }
.custom-mcp-secret-fields small { margin-left: 4px; color: var(--text-3); font-weight: 500; }
.custom-mcp-scopes { grid-column: 1 / -1; }
.custom-mcp-advanced { border: 1px solid var(--border-soft); border-radius: var(--r-md); background: var(--surface); }
.custom-mcp-advanced summary { display: flex; min-height: var(--tap); align-items: center; padding: 0 var(--sp-3); color: var(--text-2); font-size: 11px; font-weight: 600; cursor: pointer; list-style: none; }
.custom-mcp-advanced summary::-webkit-details-marker { display: none; }
.custom-mcp-advanced summary::after { width: 7px; height: 7px; margin-left: auto; border: solid currentColor; border-width: 0 1.5px 1.5px 0; content: ""; transform: rotate(45deg) translateY(-2px); transition: transform var(--t-fast) var(--ease); }
.custom-mcp-advanced[open] summary::after { transform: rotate(225deg) translate(-2px,-1px); }
.custom-mcp-advanced[open] summary { border-bottom: 1px solid var(--border-soft); }
.custom-mcp-advanced > .custom-mcp-secret-fields { padding: var(--sp-3); }
.custom-mcp-safety { display: flex; align-items: flex-start; gap: 8px; color: var(--text-2); font-size: 11px; line-height: 1.45; }
.custom-mcp-safety svg { flex: none; margin-top: 1px; color: var(--ok); }
.custom-mcp-dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border-soft); }
.custom-mcp-dialog #customMcpOutput:empty { display: none; }
.custom-mcp-dialog #customMcpOutput .working, .custom-mcp-dialog #customMcpOutput .hint { margin: 0; }

@media (min-width: 1041px) {
  .plugin-connection-provider small { display: none; }
}

@media (max-width: 1040px) {
  .plugin-catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plugin-connection-columns { display: none; }
  .plugin-connection-item summary { grid-template-columns: 42px minmax(150px, 1fr) 140px auto 54px 15px; }
  .plugin-connection-description { grid-template-columns: 1fr; }
  .plugin-connection-facts { justify-content: flex-start; }
}

@media (max-width: 680px) {
  .plugin-marketplace-nav { align-items: center; gap: 8px; }
  .plugin-tabs { flex: 1; }
  .plugin-tabs button { min-width: 0; flex: 1; padding-right: 8px; padding-left: 8px; }
  .plugin-add-mcp { width: var(--tap); min-width: var(--tap); max-width: var(--tap); flex: 0 0 var(--tap); overflow: hidden; justify-content: center; padding: 0; color: transparent; font-size: 0; gap: 0; }
  .plugin-add-mcp svg { color: var(--text); }
  .plugin-catalog-grid, .source-list { grid-template-columns: 1fr; }
  .plugin-sync-strip { align-items: flex-start; flex-wrap: wrap; }
  .plugin-sync-strip .text-button { margin-left: 25px; }
  .plugin-section-heading p, .plugin-list-heading p { max-width: 290px; }
  .plugin-connection-item summary { grid-template-columns: 38px minmax(0, 1fr) auto 15px; padding: 10px 12px; }
  .plugin-connection-provider, .plugin-connection-item summary .plugin-manage-label { display: none; }
  .plugin-connection-logo { width: 34px; height: 34px; }
  .plugin-connection-panel { padding: 14px; }
  .plugin-connection-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .plugin-manage-actions { align-items: stretch; flex-direction: column; }
  .plugin-manage-actions .plugin-provider-label { width: 100%; margin: 0; }
  .plugin-manage-actions .btn { width: 100%; }
  .custom-mcp-card { align-items: flex-start; flex-wrap: wrap; }
  .custom-mcp-card > div { min-width: calc(100% - 58px); }
  .custom-mcp-card > .btn { width: 100%; }
  .plugin-source-attention { grid-template-columns: 20px minmax(0, 1fr); }
  .plugin-source-attention .btn { grid-column: 2; justify-self: start; }
  .custom-mcp-overlay { align-items: end; padding: 0; }
  .custom-mcp-dialog { width: 100%; max-height: 94dvh; padding: var(--sp-4); border-width: 1px 0 0; border-radius: 22px 22px 0 0; }
  .custom-mcp-form-grid, .custom-mcp-secret-fields { grid-template-columns: 1fr; }
  .custom-mcp-form-grid .custom-mcp-url, .custom-mcp-scopes { grid-column: auto; }
  .custom-mcp-dialog-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .plugin-view { animation: none; }
  .plugin-catalog-card { transition: none; }
}

/* ---------- memory ---------- */
.mems { display: grid; gap: var(--sp-2); }
.mem { background: var(--surface); border: 1px solid var(--border-soft); border-left-width: 2px; border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); display: grid; gap: 4px; }
.mem.pinned { border-left-color: var(--ok); }
.mem-text { font-size: 13px; }
.mem-foot { display: flex; align-items: center; gap: 4px; }
.mem-src { font: 11px/1.3 var(--mono); color: var(--text-2); flex: 1; }
.mem-act { width: var(--tap); height: var(--tap); }
.mem:hover .mem-act, .mem-act:focus-visible { opacity: 1; }
.mem-act { opacity: 0; }

/* ---------- voice ---------- */
.mic.recording { background: var(--no-bg); color: var(--no); }
.mic.recording svg { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.speak-btn { opacity: 0; }
.turn:hover .speak-btn, .speak-btn:focus-visible { opacity: 1; }
.turn-tools { display: flex; gap: 2px; align-items: center; }

/* The small-screen layout intentionally follows the referenced iOS pattern:
   menu, centered Ask/Tasks switch, and a single new-conversation action. */
@media (max-width: 720px) {
  :root { --head-h: 68px; }
  .head { padding: var(--sp-2) var(--sp-4); }
  .head .desktop-only { display: none; }
  .head-identity { max-width: 28%; }
  .thread { padding: var(--sp-5) var(--sp-4) var(--sp-4); }
  .composer-wrap { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .page { padding: var(--sp-4) var(--sp-4) var(--sp-7); }
  .card { padding: var(--sp-4); }
  .panel-in { padding: var(--sp-4); }
  .welcome h2 { font-size: 36px; }
  .gate-card { padding: 28px; }
  .agent-create { padding: var(--sp-3) var(--sp-4) var(--sp-6); }
  .agent-create-custom, .agent-profile { gap: 20px; }
  .template-stage { min-height: 390px; }
  .profile-hero { min-height: 140px; }
  .desktop-agent-heading { align-items: flex-start; flex-direction: column; }
  .desktop-agent-heading > .btn { align-self: stretch; }
  .desktop-agent-dialog { padding: var(--sp-4); }
  .desktop-dialog-actions { flex-wrap: wrap; }
  .tasks-page { padding: var(--sp-4) var(--sp-4) var(--sp-7); }
  .tasks-hero { align-items: flex-start; flex-direction: column; gap: var(--sp-4); padding-top: 4px; }
  .tasks-hero p { font-size: 13px; }
  .tasks-create { align-self: stretch; justify-content: center; margin: 0; }
  .task-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .task-metrics article:last-child { grid-column: 1 / -1; }
  .tasks-section-head { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .routine { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .r-new summary, .task-form { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

@media (max-width: 520px) {
  .head-identity { display: none; }
  .head-modes { gap: 0; }
  .mode-btn { min-width: 59px; padding: 0 11px; }
  .composer-wrap { padding-left: 12px; padding-right: 12px; }
  .composer-hint { display: none; }
  .model-chip span { max-width: 104px; }
  .welcome { gap: 10px; padding: 0; }
  .welcome-mark { width: 68px; height: 68px; border-radius: 24px; }
  .welcome h2 { font-size: 32px; }
  .bubble { max-width: 94%; }
  .agent-mark-hero { width: 98px; height: 98px; }
  .template-character .agent-mark-hero { width: 127px; height: 127px; }
  .template-stage { min-height: 360px; }
  .character-card { padding-left: 5px; padding-right: 5px; }
  .tasks-hero h2 { font-size: 34px; }
  .task-metrics article { min-height: 112px; padding: var(--sp-3); }
  .task-metrics strong { font-size: 27px; }
  .task-metrics .task-next-value { font-size: 20px; }
  .routine { grid-template-columns: 38px minmax(0,1fr) var(--tap); gap: 10px; padding: var(--sp-3); }
  .routine-glyph { width: 38px; height: 38px; }
  .r-top { align-items: flex-start; flex-direction: column; gap: 5px; }
  .r-enabled { order: 2; }
  .r-foot { align-items: flex-start; flex-direction: column; gap: 5px; }
  .task-form-grid { grid-template-columns: 1fr; }
  .task-form-actions .btn { width: 100%; }
}

@media (hover: none) {
  .row-menu, .t-menu, .mem-act, .speak-btn { opacity: 1; }
}
