/* Vega console: night-sky design system for the key holder's portal. The admin page keeps style.css. */
:root {
  --bg: #070a13; --bg-2: #0a0f1d;
  --glow-1: rgba(98, 132, 255, .17); --glow-2: rgba(160, 120, 255, .12); --glow-3: rgba(127, 214, 245, .07);
  --surface: rgba(15, 21, 40, .78); --surface-solid: #0f1528; --surface-2: #141b33; --surface-3: #1b2442;
  --line: rgba(140, 165, 255, .13); --line-2: rgba(140, 165, 255, .24);
  --text: #e9edfb; --muted: #98a2c6; --faint: #6c769c;
  --accent: #82a0ff; --accent-2: #a98cff; --cyan: #7fd6f5; --ok: #45d39b; --warn: #f5c35f; --bad: #ff7d88;
  --grad: linear-gradient(135deg, #6f9bff, #9b7dff);
  --grad-soft: linear-gradient(135deg, rgba(111, 155, 255, .18), rgba(155, 125, 255, .14));
  --code-bg: #060912; --code-text: #d7ddf0;
  --shadow: 0 1px 0 rgba(255, 255, 255, .035) inset, 0 14px 40px rgba(0, 0, 14, .38);
  --shadow-pop: 0 18px 50px rgba(0, 0, 14, .55);
  --radius-lg: 18px; --radius: 13px; --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --side-w: 248px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5fb; --bg-2: #eef1f9;
    --glow-1: rgba(98, 132, 255, .13); --glow-2: rgba(160, 120, 255, .09); --glow-3: rgba(80, 190, 230, .06);
    --surface: rgba(255, 255, 255, .86); --surface-solid: #ffffff; --surface-2: #f0f2fa; --surface-3: #e6eaf6;
    --line: rgba(30, 40, 90, .10); --line-2: rgba(30, 40, 90, .18);
    --text: #121730; --muted: #59617f; --faint: #8b92ae;
    --accent: #4b6af2; --accent-2: #7b5cf0; --cyan: #1f9cc4; --ok: #0f9a6a; --warn: #b7791f; --bad: #d64553;
    --grad: linear-gradient(135deg, #5578f7, #8a64f2);
    --grad-soft: linear-gradient(135deg, rgba(85, 120, 247, .12), rgba(138, 100, 242, .10));
    --code-bg: #0c1122; --code-text: #dfe5f6;
    --shadow: 0 1px 2px rgba(20, 30, 70, .06), 0 10px 30px rgba(20, 30, 70, .07);
    --shadow-pop: 0 18px 50px rgba(20, 30, 70, .18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility; }
body:has(.console:not(.hidden)) {
  background:
    radial-gradient(900px 520px at 12% -8%, var(--glow-1), transparent 70%),
    radial-gradient(800px 500px at 100% 0%, var(--glow-2), transparent 70%),
    radial-gradient(700px 600px at 60% 110%, var(--glow-3), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
code, .mono { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 140px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.flush { margin: 0 !important; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ------------------------------------------------------------------ icons */
i[data-icon], .ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
i[data-icon] svg, .ic svg { width: 100%; height: 100%; }
svg.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- shell */
.console { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); display: flex; flex-direction: column;
  padding: 18px 14px 14px; border-right: 1px solid var(--line); z-index: 30;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-solid) 92%, transparent), color-mix(in srgb, var(--bg-2) 94%, transparent));
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text);
  font-weight: 650; font-size: 19px; letter-spacing: -.01em; }
.side-brand:hover { text-decoration: none; }
.brand-star { width: 34px; height: 34px; filter: drop-shadow(0 0 10px rgba(120, 170, 255, .45)); }
@media (prefers-color-scheme: light) { .brand-star path { fill: #3f5ad8; } }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 10px; color: var(--muted);
  font-weight: 500; position: relative; transition: background .15s, color .15s; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.active { background: var(--grad-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.side-nav a.active::before { content: ""; position: absolute; left: -4px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px;
  background: var(--grad); }
.side-nav a.active i { color: var(--accent); }
.nav-label { padding: 16px 10px 6px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); }
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
.gpu-mini { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.gpu-mini:hover { border-color: var(--line-2); }
.gpu-mini-text { display: grid; line-height: 1.25; min-width: 0; }
.gpu-mini-text b { font-size: 12.5px; font-weight: 600; }
.gpu-mini-text small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px color-mix(in srgb, var(--ok) 70%, transparent); }
.dot.warn { background: var(--warn); box-shadow: 0 0 10px color-mix(in srgb, var(--warn) 60%, transparent); }
.dot.bad { background: var(--bad); }
.dot.live { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.who { display: flex; align-items: center; gap: 10px; padding: 0 4px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 700;
  color: #fff; background: var(--grad); font-size: 14px; }
.who-text { display: grid; line-height: 1.2; min-width: 0; flex: 1; }
.who-text b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text small { color: var(--faint); font-size: 11px; }
.side-actions { display: flex; gap: 6px; }
.side-actions .btn { flex: 1; justify-content: center; }
.scrim { display: none; }
.main { flex: 1; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; }
.mobile-bar { display: none; }
#pages { width: 100%; max-width: 1240px; margin: 0 auto; padding: 30px 36px 60px; }
.page { animation: page-in .28s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page > * + * { margin-top: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 27px; font-weight: 650; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); margin-top: 5px; max-width: 760px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title { font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
  margin: 28px 0 12px; }

/* ---------------------------------------------------------- components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.card.flush { padding: 0; overflow: hidden; }
.card h3 { font-size: 15px; font-weight: 620; margin-bottom: 12px; }
.split { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font: 500 13.5px/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, background .15s, border-color .15s, box-shadow .15s, filter .15s; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff;
  box-shadow: 0 8px 22px color-mix(in srgb, #6f7dff 32%, transparent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 9px; }
.btn.sm i[data-icon] { width: 15px; height: 15px; }
.btn.icon { padding: 7px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; filter: none; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 9px 11px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; line-height: 1.5; }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=range] { padding: 0; background: none; border: 0; accent-color: var(--accent); box-shadow: none; }
.w-port { width: 110px; }
.w-name { width: 170px; }
label.field { display: block; min-width: 0; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 34px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-2);
  position: relative; flex: none; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--accent); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }
.switch input:disabled + span { opacity: .45; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 550; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill:empty { display: none; }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 38%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 38%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 38%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.pill.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 38%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.pill.mono { font-family: var(--mono); font-size: 11px; }
.bar { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .6s ease; }
.notice { padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.notice.info { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line);
  flex-wrap: wrap; }
.seg button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--muted);
  font: 500 13.5px var(--font); padding: 8px 15px; border-radius: 10px; cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-solid); color: var(--text); box-shadow: 0 2px 10px rgba(0, 0, 0, .18), inset 0 0 0 1px var(--line); }
.seg button.active i { color: var(--accent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; color: var(--muted); font: 500 13.5px var(--font); padding: 10px 13px;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); border-radius: 999px;
  padding: 5px 13px; font: 500 12.5px var(--font); cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--grad-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.chip .n { color: var(--faint); margin-left: 4px; }
.kv { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 9px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; color: var(--faint); font-weight: 600; letter-spacing: .03em; background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td, .table tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table td .row { flex-wrap: nowrap; justify-content: flex-end; }
.table-wrap { overflow-x: auto; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
pre.log { margin: 0; background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: 12px;
  max-height: 62vh; overflow: auto; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word;
  border: 1px solid var(--line); }
.code { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--code-bg); }
.code-head { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 14px; font-size: 12px; color: #8f9abd;
  background: color-mix(in srgb, #1a2240 75%, var(--code-bg)); border-bottom: 1px solid rgba(140, 165, 255, .12); }
.code-head .spacer + .btn, .code-head .btn { color: #b9c3e6; }
.code-head .btn:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.code pre { margin: 0; padding: 14px 16px; color: var(--code-text); font: 12.5px/1.6 var(--mono); overflow-x: auto;
  white-space: pre; tab-size: 2; }
.code .c-com { color: #6f7ba3; }
.code .c-str { color: #9fe0b9; }
.code .c-key { color: #9ab8ff; }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--surface-solid); border: 1px solid var(--line-2);
  padding: 11px 16px; border-radius: 12px; z-index: 60; max-width: 440px; box-shadow: var(--shadow-pop);
  animation: toast-in .25s ease both; }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 60%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.modal-back { position: fixed; inset: 0; background: rgba(2, 4, 12, .6); display: flex; align-items: flex-start;
  justify-content: center; padding: 8vh 16px; z-index: 50; overflow-y: auto; }
.modal { width: min(560px, 100%); background: var(--surface-solid); border: 1px solid var(--line-2); border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow-pop); }

/* ------------------------------------------------------------------ home */
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--grad-soft);
  color: var(--accent); border: 1px solid var(--line); }
.stat-icon i { width: 17px; height: 17px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 550; flex: 1; }
.stat-value { font-size: 25px; font-weight: 650; letter-spacing: -.02em; }
.stat-value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat-foot { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.action-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.action { display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: var(--radius-lg); color: var(--text);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .18s ease, border-color .18s, box-shadow .18s; }
.action::after { content: ""; position: absolute; inset: 0; background: var(--grad-soft); opacity: 0; transition: opacity .2s; }
.action:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); text-decoration: none;
  box-shadow: var(--shadow-pop); }
.action:hover::after { opacity: 1; }
.action > * { position: relative; z-index: 1; }
.action .a-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--grad);
  color: #fff; margin-bottom: 6px; box-shadow: 0 8px 20px color-mix(in srgb, #6f7dff 30%, transparent); }
.action .a-icon i { width: 19px; height: 19px; }
.action b { font-size: 15px; font-weight: 620; }
.action span { color: var(--muted); font-size: 13px; }
.scope-list { display: grid; gap: 8px 18px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.scope { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.scope .pill { flex: none; }

/* ------------------------------------------------------------------ chat */
.page-chat { max-width: 960px; margin: 0 auto; }
.chat-shell { display: flex; flex-direction: column; height: calc(100dvh - 60px); min-height: 480px; }
.chat-bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding-bottom: 12px;
  border-bottom: 1px solid var(--line); }
.model-picker { display: flex; gap: 8px; align-items: center; min-width: 0; flex-wrap: wrap; }
.model-picker select { width: auto; max-width: 300px; font-weight: 600; background-color: var(--surface); }
.chat-bar-actions { display: flex; gap: 4px; align-items: center; }
.effort-pick { display: inline-flex; align-items: center; gap: 6px; padding: 0 0 0 10px; border-radius: 10px; color: var(--muted);
  border: 1px solid var(--line-2); background: var(--surface-2); }
.effort-pick select { border: 0; background-color: transparent; width: auto; padding-left: 4px; box-shadow: none; font-size: 13px; }
.effort-pick i { width: 16px; height: 16px; }
.chat-settings { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.settings-row { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 18px; align-items: end; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 22px 4px 12px; scroll-behavior: smooth; }
.chat-empty { text-align: center; padding: 8vh 12px 20px; }
.chat-empty h2 { font-size: 24px; font-weight: 650; margin: 14px 0 6px; letter-spacing: -.02em; }
.empty-star { width: 46px; height: 46px; fill: var(--accent); filter: drop-shadow(0 0 16px color-mix(in srgb, var(--accent) 60%, transparent)); }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; max-width: 720px;
  margin: 26px auto 0; }
.suggestion { text-align: left; padding: 13px 15px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: 13.5px/1.4 var(--font); cursor: pointer; transition: border-color .15s, transform .15s; }
.suggestion:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); transform: translateY(-1px); }
.suggestion small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }
.thread { display: flex; flex-direction: column; gap: 22px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: min(78%, 680px); padding: 11px 15px; border-radius: 16px 16px 4px 16px; background: var(--grad);
  color: #fff; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 6px 18px color-mix(in srgb, #6f7dff 25%, transparent); }
.msg .bubble img { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; margin-bottom: 8px; }
.msg.assistant .m-avatar { width: 30px; height: 30px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); margin-top: 2px; }
.msg.assistant .m-avatar svg { width: 18px; height: 18px; fill: var(--accent); }
.msg .m-body { flex: 1; min-width: 0; }
.msg .m-meta { display: flex; gap: 10px; align-items: center; margin-top: 8px; color: var(--faint); font-size: 12px; flex-wrap: wrap; }
.msg .m-meta .btn { padding: 3px 8px; }
.thinking { border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  margin-bottom: 10px; }
.thinking summary { cursor: pointer; padding: 8px 12px; color: var(--muted); font-size: 12.5px; display: flex; gap: 8px;
  align-items: center; list-style: none; user-select: none; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 15px; line-height: 1; }
.thinking[open] summary::before { transform: rotate(90deg); }
.thinking .t-body { padding: 0 14px 12px; color: var(--muted); font-size: 13px; white-space: pre-wrap; max-height: 340px; overflow-y: auto; }
.thinking.live summary span { background: linear-gradient(90deg, var(--muted), var(--text), var(--muted)); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.md { line-height: 1.65; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md .code, .md table { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; font-weight: 650; line-height: 1.3; }
.md h1 { font-size: 20px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 14.5px; }
.md ul, .md ol { padding-left: 22px; }
.md li + li { margin-top: 4px; }
.md code:not(pre code) { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.md blockquote { border-left: 3px solid var(--line-2); padding-left: 12px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; }
.md th { background: var(--surface-2); }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 15px; margin-left: 2px; vertical-align: -2px;
  background: var(--accent); border-radius: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg-error { color: var(--bad); font-size: 13px; }
.composer { margin-top: 8px; border: 1px solid var(--line-2); border-radius: 18px; background: var(--surface); padding: 10px 12px 8px;
  box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent), var(--shadow); }
.composer textarea { border: 0; background: transparent; padding: 4px 4px; resize: none; max-height: 240px; box-shadow: none;
  font-size: 14.5px; }
.composer textarea:focus { box-shadow: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 2px 8px; }
.attachment { position: relative; width: 58px; height: 58px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.attachment img { width: 100%; height: 100%; object-fit: cover; }
.attachment button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; }

/* ------------------------------------------------------------- studio */
.studio { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 22px; align-items: start; margin-top: 18px; }
.card.studio-form { position: sticky; top: 20px; display: flex; flex-direction: column; padding: 0; overflow: hidden;
  max-height: calc(100dvh - 40px); /* refined in media.js from the panel's position */ }
.studio-head { padding: 18px 20px 12px; display: grid; gap: 6px; border-bottom: 1px solid var(--line); }
.studio-desc { border: 0; background: none; padding: 0; margin: 0; color: var(--muted); font: 12.5px/1.5 var(--font);
  text-align: left; cursor: pointer; }
.studio-desc span { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.studio-desc.open span { -webkit-line-clamp: unset; display: block; }
.studio-desc:hover { color: var(--text); }
.studio-fields { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  padding: 16px 20px 18px; display: grid; gap: 14px; align-content: start; }
.studio-submit { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  border-top: 1px solid var(--line); background: var(--surface-solid); }
.studio-submit #media-msg { min-width: 0; }
div.field { min-width: 0; }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.option small { font-size: 10.5px; color: var(--faint); margin-top: -3px; }
.studio-form .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.studio-form textarea { min-height: 96px; }
.studio-form .hint { font-size: 12px; color: var(--faint); margin-top: 5px; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); gap: 6px; }
.option { border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); border-radius: 10px; padding: 8px 6px;
  font: 500 12.5px var(--font); cursor: pointer; display: grid; place-items: center; gap: 5px; }
.option:hover { color: var(--text); }
.option.active { color: var(--text); border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--grad-soft); }
.option .shape { border: 1.5px solid currentColor; border-radius: 3px; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted);
  cursor: pointer; font-size: 13px; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--grad-soft); }
.dropzone img { max-height: 120px; max-width: 100%; border-radius: 8px; display: block; margin: 0 auto 8px; }
details.advanced > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; user-select: none; }
details.advanced[open] > summary { margin-bottom: 10px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 12px; }
.creation { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.creation .preview { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; position: relative; overflow: hidden; }
.creation .preview img, .creation .preview video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.creation .preview audio { width: calc(100% - 28px); }
.creation .preview .working { display: grid; place-items: center; gap: 10px; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }
.creation .preview .orbit { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.creation .c-body { padding: 13px 15px 14px; display: grid; gap: 8px; }
.creation .c-title { font-weight: 600; font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.creation .c-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--faint); flex-wrap: wrap; }
.creation .c-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.creation .c-actions .danger { margin-left: auto; }
.btn .btn-sub { font-size: 11px; font-weight: 500; opacity: .75; margin-left: 2px; }
.expiry { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.expiry i[data-icon] { width: 15px; height: 15px; }
.expiry.soon { color: var(--warn); font-weight: 550; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 15px 0; }
.thumbs img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 1px solid var(--line); }

/* ------------------------------------------------------------- models */
.model-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-top: 16px; }
.model-card { display: flex; flex-direction: column; gap: 10px; }
.model-card .mc-top { display: flex; gap: 12px; align-items: flex-start; }
.model-card .mc-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--grad-soft); border: 1px solid var(--line); color: var(--accent); }
.model-card .mc-name { font-weight: 620; font-size: 15px; line-height: 1.3; }
.model-card .mc-id { font: 11.5px var(--mono); color: var(--faint); margin-top: 2px; overflow-wrap: anywhere; }
.model-card .mc-desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.model-card .mc-desc.open { -webkit-line-clamp: unset; display: block; }
.model-card .mc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.model-card .mc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.model-card .progress { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------- connect */
.connect-top { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.connect-top .field { min-width: 180px; }
.model-status { font-size: 13px; }
.tool-intro { color: var(--muted); font-size: 13.5px; max-width: 820px; }
.tool-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: 13.5px; }
.tool-steps b { color: var(--text); font-weight: 600; }
.tool-steps code, .guide code, .link-row code, .inline-code { font-family: var(--mono); font-size: 12px; background: var(--surface-3);
  padding: 1px 6px; border-radius: 6px; color: var(--text); overflow-wrap: anywhere; }
.test-result { font-size: 13px; }
.guide { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.guide li { line-height: 1.6; padding-left: 4px; }
.guide li::marker { color: var(--accent); font-weight: 650; }
.link-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: 13.5px; }
.crumbs button { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; padding: 4px 6px; border-radius: 7px; }
.crumbs button:hover { background: var(--surface-2); }
.crumbs .sep { color: var(--faint); }
.file-name { display: inline-flex; align-items: center; gap: 9px; border: 0; background: none; color: var(--text); font: inherit;
  cursor: pointer; padding: 0; text-align: left; }
.file-name i { color: var(--muted); }
.file-name.dir i { color: var(--accent); }
.file-name.dir:hover span { text-decoration: underline; }
#terminal { height: calc(100dvh - 210px); min-height: 380px; background: #000; border-radius: var(--radius-lg); padding: 10px;
  overflow: hidden;
  border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.term-status { min-height: 18px; margin-bottom: 8px; }
.page:has(#ssh-panel:not(.hidden)) #terminal { height: calc(100dvh - 268px); }
.ssh-panel { padding: 0; margin-bottom: 4px; min-width: 0; }
.ssh-panel > summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; list-style: none;
  border-radius: var(--radius-lg); }
.ssh-panel > summary::-webkit-details-marker { display: none; }
.ssh-panel > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; flex: none; }
.ssh-panel[open] > summary::after { transform: rotate(-135deg); }
.ssh-panel > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ssh-panel > summary i { color: var(--accent); flex: none; }
.ssh-body { padding: 0 16px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.ssh-body h3 { margin: 4px 0 0; }
.ssh-uses { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--muted); }
.ssh-uses code { color: var(--text); }
.ssh-key { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.ssh-key:first-child { border-top: 0; }
.ssh-key code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ------------------------------------------------- sign-in (night sky) */
.login { max-width: 460px; margin: 10vh auto; }
html:has(.sky-login:not(.hidden)), body:has(.sky-login:not(.hidden)) { background: #02040c; }
.login.sky-login { max-width: none; margin: 0; position: relative; min-height: 100vh; min-height: 100dvh; display: grid; place-items: start center;
  padding: max(11vh, 56px) 16px 0; color-scheme: dark; color: #e8ecff; overflow: hidden; }
#sky { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
.login-card { position: relative; z-index: 1; width: min(440px, 100%); padding: 30px 28px 24px;
  background: linear-gradient(160deg, rgba(22, 30, 62, .62), rgba(8, 12, 30, .58));
  border: 1px solid rgba(160, 190, 255, .18); border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 10, .55), inset 0 1px 0 rgba(255, 255, 255, .07);
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
  animation: login-rise .9s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes login-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-star { width: 58px; height: 58px; flex: none; filter: drop-shadow(0 0 14px rgba(120, 170, 255, .45)); }
.login-brand h1 { margin: 0; font-size: 32px; font-weight: 650; letter-spacing: -.02em; line-height: 1.05;
  background: linear-gradient(180deg, #ffffff, #b9c8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-tag { margin: 4px 0 0; color: #9aa6cf; font-size: 13px; }
.login-lead { margin: 22px 0 12px; color: #c9d2f2; }
.sky-login #login-form { display: grid; gap: 10px; }
.sky-login #login-key { padding: 13px 14px; font: 15px/1.2 var(--mono); color: #eef2ff; letter-spacing: .02em;
  background: rgba(4, 8, 22, .65); border: 1px solid rgba(150, 175, 255, .22); border-radius: 12px; }
.sky-login #login-key::placeholder { color: #6f7aa3; }
.sky-login #login-key:focus { outline: none; border-color: rgba(127, 214, 245, .7); box-shadow: 0 0 0 4px rgba(127, 214, 245, .14); }
.sky-login button.primary { padding: 12px 14px; justify-content: center; font: 600 15px var(--font); border: 0; border-radius: 12px;
  color: #fff; cursor: pointer; background: linear-gradient(135deg, #6f9bff, #9b7dff); box-shadow: 0 10px 30px rgba(110, 120, 255, .35);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease; }
.sky-login button.primary:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 14px 34px rgba(110, 120, 255, .45); }
.sky-login button.primary:active { transform: translateY(0); }
.sky-login .notice.bad { margin-top: 12px; background: rgba(60, 10, 20, .55); border-color: rgba(248, 113, 113, .6); color: #ffb4b4; }
.login-foot { margin: 16px 0 0; font-size: 12px; color: #7f8ab3; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .studio { grid-template-columns: 1fr; }
  .card.studio-form { position: static; max-height: none; overflow: visible; }
  .studio-fields { overflow: visible; }
  .studio-submit { position: sticky; bottom: 0; z-index: 3; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding-bottom: max(12px, env(safe-area-inset-bottom)); box-shadow: 0 -12px 28px rgba(0, 0, 12, .28); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-102%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-pop); }
  .console.nav-open .sidebar { transform: none; }
  .console.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(2, 4, 12, .55); z-index: 25; }
  .main { margin-left: 0; }
  .mobile-bar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .mobile-title { font-weight: 620; }
  #pages { padding: 20px 16px 48px; }
  .chat-shell { height: calc(100dvh - 100px); }
  #terminal { height: calc(100dvh - 250px); }
  .page:has(#ssh-panel:not(.hidden)) #terminal { height: calc(100dvh - 300px); }
  .ssh-panel > summary .muted { display: none; }
  .ssh-key { flex-wrap: wrap; row-gap: 2px; }
  .ssh-key code { flex: 1 1 100%; order: 3; }
  .ssh-key .ssh-when { display: none; }
}
@media (max-width: 640px) {
  .page-head h1 { font-size: 23px; }
  .split, .scope-list { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .settings-row { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .chat-bar { gap: 8px; }
  .model-picker { flex: 1 1 100%; flex-wrap: nowrap; }
  .model-picker select { flex: 1; max-width: none; min-width: 0; }
  .chat-bar-actions { flex: 1 1 100%; justify-content: space-between; }
  .msg .bubble { max-width: 88%; }
  .studio-form .field-row { grid-template-columns: 1fr; }
  .table th, .table td { padding: 10px 12px; }
  .card { padding: 16px; border-radius: 16px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}
@media (max-width: 480px) {
  .login.sky-login { padding-top: max(8vh, 40px); }
  .login-card { padding: 24px 20px 20px; border-radius: 20px; }
  .login-brand h1 { font-size: 28px; }
  .login-star { width: 50px; height: 50px; }
}
@media (max-height: 500px) and (orientation: landscape) { .login.sky-login { padding-top: 20px; padding-bottom: 20px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.nowrap { white-space: nowrap; }

.agent-prompt { white-space: pre-wrap; word-break: break-word; margin: 0; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 12.5px/1.5 var(--mono);
  max-height: 340px; overflow: auto; }
