:root {
  color-scheme: dark;
  --bg: #0b0e15;
  --bg-soft: #111521;
  --panel: rgba(21, 26, 39, 0.88);
  --panel-solid: #151a28;
  --panel-hover: #1b2233;
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #f6f7fb;
  --muted: #96a0b4;
  --muted-strong: #c0c7d5;
  --accent: #9b7bff;
  --accent-2: #24d3ee;
  --success: #36d399;
  --warning: #f6c969;
  --danger: #ff768d;
  --shadow: 0 22px 80px rgba(0, 0, 0, .35);
  --radius: 18px;
  --radius-sm: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fa;
  --bg-soft: #e9ecf4;
  --panel: rgba(255, 255, 255, .9);
  --panel-solid: #fff;
  --panel-hover: #f1f3f8;
  --line: rgba(52, 64, 87, .13);
  --line-strong: rgba(52, 64, 87, .23);
  --text: #182033;
  --muted: #69748a;
  --muted-strong: #4b566d;
  --shadow: 0 22px 80px rgba(35, 45, 75, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-root { min-height: 100vh; }
.boot-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(circle at 50% 10%, rgba(139, 92, 246, .18), transparent 34%), var(--bg);
}
.boot-copy { display: flex; flex-direction: column; gap: 4px; }
.boot-copy strong { font-size: 20px; letter-spacing: -.02em; }
.boot-copy span { color: var(--muted); font-size: 13px; }

.brand-mark {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 18px;
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  box-shadow: 0 8px 24px rgba(124, 92, 246, .34);
}
.brand-mark--large { width: 48px; height: 48px; border-radius: 16px; font-size: 23px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.shell--chat { height: 100vh; min-height: 0; overflow: hidden; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 17px;
  padding: 22px 16px 16px; border-right: 1px solid var(--line); background: rgba(10, 13, 21, .72);
  backdrop-filter: blur(24px); z-index: 4;
}
:root[data-theme="light"] .sidebar { background: rgba(250, 251, 254, .84); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-title { display: flex; flex-direction: column; gap: 2px; }
.brand-title strong { font-size: 15px; letter-spacing: -.02em; }
.brand-title span { color: var(--muted); font-size: 11px; }
.new-chat {
  width: fit-content; min-width: 126px; min-height: 34px; margin: 0 4px; display: flex; align-items: center; justify-content: flex-start; gap: 7px; padding: 7px 10px;
  border: 1px solid rgba(155, 123, 255, .4); border-radius: 10px; color: #fff; font-size: 12px; font-weight: 600;
  background: linear-gradient(135deg, rgba(139, 92, 246, .9), rgba(70, 160, 236, .9));
  box-shadow: 0 7px 18px rgba(110, 80, 220, .16); transition: transform .16s, filter .16s;
}
.new-chat svg { width: 15px; height: 15px; }
.new-chat:hover { transform: translateY(-1px); filter: brightness(1.08); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; padding: 0 10px 7px; }
.nav-item {
  border: 0; display: flex; align-items: center; gap: 10px; width: 100%; border-radius: 11px; padding: 10px;
  color: var(--muted-strong); background: transparent; text-align: left; transition: background .16s, color .16s;
}
.nav-item:hover, .nav-item.active { color: var(--text); background: var(--panel-hover); }
.nav-item.active { box-shadow: inset 3px 0 var(--accent); }
.nav-item svg { width: 18px; height: 18px; color: var(--muted); }
.nav-item.active svg { color: var(--accent); }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.quota-card {
  padding: 13px; border: 1px solid var(--line); border-radius: 14px;
  background: linear-gradient(145deg, rgba(36, 211, 238, .08), rgba(155, 123, 255, .08));
}
.quota-card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quota-card__top span { color: var(--muted); font-size: 11px; }
.quota-card__top strong { font-size: 13px; }
.quota-track { height: 6px; border-radius: 99px; background: var(--line); margin: 10px 0 7px; overflow: hidden; }
.quota-track > span { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
.quota-card small { color: var(--muted); font-size: 10px; }
.profile-mini {
  display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 6px 7px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; min-width: 0; text-align: left; transition: background .16s, border-color .16s;
}
.profile-mini:hover { background: var(--panel-hover); border-color: var(--line-strong); }
.profile-mini > svg { width: 14px; height: 14px; margin-left: auto; color: var(--muted); }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; font-size: 10px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #f97316, #ec4899); }
.profile-mini__copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-mini__copy strong, .profile-mini__copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-mini__copy strong { font-size: 12px; }
.profile-mini__copy span { color: var(--muted); font-size: 10px; }
.icon-button { border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; padding: 6px; border-radius: 9px; }
.icon-button:hover { color: var(--text); background: var(--panel-hover); }
.icon-button svg { width: 18px; height: 18px; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.shell--chat .main { height: 100vh; }
.shell--chat .content { flex: 1 1 auto; min-height: 0; overflow: hidden; padding-bottom: 26px; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 32px; border-bottom: 1px solid var(--line); }
.topbar__title { display: flex; flex-direction: column; gap: 4px; }
.topbar__title strong { font-size: 18px; letter-spacing: -.03em; }
.topbar__title span { color: var(--muted); font-size: 12px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 30px 32px 48px; }

.view-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.view-header__copy { display: flex; flex-direction: column; gap: 7px; }
.eyebrow { color: var(--accent-2); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.view-header h1 { margin: 0; font-size: clamp(24px, 3vw, 35px); letter-spacing: -.05em; }
.view-header p { margin: 0; max-width: 650px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view-actions--sync { align-items: center; justify-content: flex-end; }

.button {
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 13px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); color: var(--text);
  transition: border-color .16s, transform .16s, background .16s, opacity .16s;
}
.button:hover { border-color: var(--accent); background: var(--panel-hover); transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button--primary { border-color: transparent; color: #fff; background: linear-gradient(135deg, #8b5cf6, #3b82f6); }
.button--danger { color: #fff; border-color: rgba(255, 118, 141, .42); background: rgba(255, 118, 141, .15); }
.button--ghost { border-color: transparent; background: transparent; }
.button svg { width: 17px; height: 17px; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: rgba(12, 16, 25, .55);
  outline: 0; transition: border-color .16s, box-shadow .16s, background .16s; padding: 11px 12px;
}
:root[data-theme="light"] .input, :root[data-theme="light"] .select, :root[data-theme="light"] .textarea { background: #fff; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(155, 123, 255, .13); }
.textarea { resize: vertical; min-height: 95px; line-height: 1.5; }
.label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; }
.label strong { color: var(--muted-strong); font-size: 12px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }

.filters { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 18px; }
.search-box { position: relative; min-width: 230px; flex: 1; max-width: 390px; }
.search-box svg { position: absolute; top: 50%; left: 12px; width: 17px; transform: translateY(-50%); color: var(--muted); }
.search-box .input { padding-left: 38px; }
.filter-select { width: auto; min-width: 135px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.segmented button { border: 0; border-radius: 8px; padding: 7px 10px; color: var(--muted); background: transparent; font-size: 12px; }
.segmented button.active { color: var(--text); background: var(--panel-hover); }

.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.model-card {
  display: flex; flex-direction: column; min-height: 225px; gap: 13px; padding: 17px; border: 1px solid var(--line);
  border-radius: var(--radius); background: linear-gradient(150deg, rgba(25, 31, 48, .92), rgba(15, 19, 29, .92));
  transition: border-color .2s, transform .2s, box-shadow .2s; cursor: pointer;
}
:root[data-theme="light"] .model-card { background: #fff; }
.model-card:hover { border-color: rgba(155, 123, 255, .55); transform: translateY(-3px); box-shadow: var(--shadow); }
.model-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.model-card__identity { display: flex; gap: 11px; min-width: 0; }
.provider-dot { width: 35px; height: 35px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: #fff; font-size: 13px; font-weight: 800; background: linear-gradient(145deg, #7c3aed, #06b6d4); }
.provider-dot[data-provider*="Google"] { background: linear-gradient(145deg, #4285f4, #34a853); }
.provider-dot[data-provider*="OpenAI"] { background: linear-gradient(145deg, #0f766e, #14b8a6); }
.provider-dot[data-provider*="Qwen"] { background: linear-gradient(145deg, #f97316, #facc15); }
.model-card h3 { margin: 0; font-size: 15px; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-card__provider { color: var(--muted); font-size: 11px; margin-top: 3px; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 5px 8px; color: var(--muted-strong); background: rgba(148, 163, 184, .1); font-size: 10px; white-space: nowrap; }
.badge--free { color: #8ef0c7; background: rgba(54, 211, 153, .11); }
.badge--warning { color: var(--warning); background: rgba(246, 201, 105, .12); }
.model-card__description { flex: 1; color: var(--muted); font-size: 12px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { color: var(--muted-strong); border: 1px solid var(--line); border-radius: 7px; padding: 4px 7px; font-size: 10px; }
.model-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 7px; border-top: 1px solid var(--line); }
.model-card__footer small { color: var(--muted); font-size: 10px; }
.empty-state { display: grid; place-items: center; min-height: 300px; padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty-state h3 { color: var(--text); margin: 12px 0 5px; }
.empty-state p { max-width: 420px; margin: 0; line-height: 1.5; font-size: 13px; }
.empty-state svg { width: 34px; height: 34px; color: var(--accent); }

.chat-layout { height: 100%; min-height: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr) 260px; gap: 16px; }
.chat-layout--simple { grid-template-columns: 220px minmax(0, 1fr); }
.chat-list, .chat-panel, .chat-options { min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.chat-list { display: flex; flex-direction: column; padding: 12px; overflow: hidden; }
.chat-list__header { display: flex; align-items: center; justify-content: space-between; padding: 3px 4px 11px; color: var(--muted); font-size: 11px; }
.chat-list__items { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.chat-row { display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 0; border-radius: 10px; color: var(--muted-strong); background: transparent; text-align: left; }
.chat-row:hover, .chat-row.active { color: var(--text); background: var(--panel-hover); }
.chat-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.chat-row small { color: var(--muted); font-size: 10px; }
.chat-panel { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 64px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-panel__model { display: flex; align-items: center; gap: 9px; min-width: 0; }
.chat-panel__model strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.chat-panel__model span { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.chat-panel__controls { min-width: 0; }
.chat-category-select { width: auto; max-width: 135px; }
.chat-model-select { width: auto; min-width: 150px; max-width: 230px; }
.chat-messages { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 24px; }
.welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 280px; text-align: center; color: var(--muted); }
.welcome .brand-mark { margin-bottom: 15px; }
.welcome h2 { margin: 0 0 7px; color: var(--text); font-size: 20px; letter-spacing: -.03em; }
.welcome p { max-width: 420px; margin: 0; line-height: 1.55; font-size: 13px; }
.chat-loading .thinking-dots { margin-bottom: 14px; transform: scale(1.5); }
.message { display: flex; gap: 10px; max-width: 88%; animation: rise .22s ease-out; }
.message--user { align-self: flex-end; flex-direction: row-reverse; }
.message__avatar { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; font-size: 11px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #f97316, #ec4899); }
.message--assistant .message__avatar { background: linear-gradient(135deg, #8b5cf6, #06b6d4); }
.message__body { min-width: 0; }
.message__meta { display: flex; align-items: center; gap: 8px; margin: 0 2px 5px; color: var(--muted); font-size: 10px; }
.message--user .message__meta { justify-content: flex-end; }
.message__bubble { padding: 11px 13px; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; background: rgba(28, 34, 51, .8); color: var(--muted-strong); font-size: 13px; line-height: 1.62; overflow-wrap: anywhere; }
:root[data-theme="light"] .message__bubble { background: #fff; }
.message--user .message__bubble { border-radius: 14px 4px 14px 14px; color: var(--text); background: linear-gradient(145deg, rgba(112, 77, 214, .48), rgba(50, 114, 188, .46)); }
.message__bubble p { margin: 0 0 9px; }
.message__bubble p:last-child { margin-bottom: 0; }
.message__bubble pre { overflow-x: auto; padding: 10px; border-radius: 8px; background: rgba(0,0,0,.22); font-size: 11px; }
.message__attachments { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.message-attachment { display: inline-flex; flex-direction: column; gap: 5px; max-width: 220px; }
.message-attachment__image { display: block; width: min(220px, 100%); max-height: 180px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.message-error { color: var(--danger); }
.thinking-indicator { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.thinking-dots { display: inline-flex; align-items: center; gap: 3px; }
.thinking-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .35; animation: thinking 1s infinite ease-in-out; }
.thinking-dots i:nth-child(2) { animation-delay: .16s; }
.thinking-dots i:nth-child(3) { animation-delay: .32s; }
.attachment-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 210px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted-strong); background: rgba(0,0,0,.12); font-size: 10px; }
.attachment-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-top: 10px; }
.result-media { width: 100%; max-height: 360px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #080b12; }
.result-download { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; color: var(--accent-2); font-size: 11px; }
.chat-composer { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.attachment-preview { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.upload-preview-card { position: relative; width: 118px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 11px; background: rgba(0,0,0,.14); }
.upload-preview-card > img { display: block; width: 118px; height: 82px; object-fit: cover; }
.upload-preview-card__foot { display: flex; align-items: center; gap: 4px; padding: 4px 5px 4px 7px; }
.upload-preview-card__foot > span { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-strong); font-size: 10px; }
.upload-preview-card__foot .icon-button { padding: 3px; }
.upload-preview-card__foot .icon-button svg { width: 13px; height: 13px; }
.upload-preview-card__status { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(4,7,13,.48); font-size: 10px; }
.composer-box { position: relative; display: flex; align-items: flex-end; gap: 8px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 15px; background: rgba(8, 12, 20, .46); }
:root[data-theme="light"] .composer-box { background: #fff; }
.composer-box textarea { flex: 1; min-height: 41px; max-height: 180px; field-sizing: content; overflow-y: auto; padding: 8px 4px; border: 0; resize: none; background: transparent; color: var(--text); outline: none; line-height: 1.5; }
.composer-actions { display: flex; align-items: center; gap: 2px; }
.send-button { width: 38px; height: 38px; border: 0; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #8b5cf6, #3b82f6); }
.send-button:disabled { opacity: .45; cursor: not-allowed; }
.send-button svg { width: 18px; height: 18px; }
.composer-hint { display: flex; justify-content: space-between; gap: 8px; padding: 7px 2px 0; color: var(--muted); font-size: 10px; }
.chat-options { padding: 16px; overflow-y: auto; scrollbar-width: thin; }
.chat-options h3 { margin: 0 0 13px; font-size: 13px; }
.option-group { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.option-group:first-of-type { padding-top: 0; border-top: 0; }
.option-label { color: var(--muted); font-size: 11px; }
.range-line { display: flex; align-items: center; gap: 8px; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.number-badge { min-width: 35px; text-align: right; color: var(--muted-strong); font-size: 11px; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.panel__head h2 { margin: 0; font-size: 15px; }
.panel__body { padding: 18px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.stat-card span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.stat-card strong { font-size: 23px; letter-spacing: -.04em; }
.key-list { display: flex; flex-direction: column; gap: 8px; }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.key-row__main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.key-row__copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.key-row__copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.key-row__copy span { color: var(--muted); font-size: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px rgba(148, 163, 184, .09); }
.status-dot.healthy { background: var(--success); box-shadow: 0 0 0 4px rgba(54, 211, 153, .11); }
.status-dot.cooldown { background: var(--warning); box-shadow: 0 0 0 4px rgba(246, 201, 105, .11); }
.status-dot.invalid { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 118, 141, .11); }
.notice { padding: 12px 13px; border: 1px solid rgba(36, 211, 238, .22); border-radius: 12px; color: var(--muted-strong); background: rgba(36, 211, 238, .07); font-size: 12px; line-height: 1.55; }
.sync-panel-line { margin-top: 14px; }
.sync-status { display: inline-flex; align-items: center; gap: 7px; max-width: 430px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.sync-status svg { width: 15px; height: 15px; flex: 0 0 auto; }
.sync-status--running { color: var(--accent-2); }
.sync-status--ready { color: var(--success); }
.sync-status--error { color: var(--danger); }
.sync-status .spinner { width: 14px; height: 14px; flex: 0 0 auto; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); background: radial-gradient(circle at 16% 10%, rgba(139, 92, 246, .2), transparent 34%), radial-gradient(circle at 90% 80%, rgba(34, 211, 238, .12), transparent 30%), var(--bg); }
.auth-visual { position: relative; display: flex; align-items: center; padding: 8vw; overflow: hidden; }
.auth-visual::after { content: ""; position: absolute; width: 480px; height: 480px; right: -180px; top: 20%; border: 1px solid rgba(155, 123, 255, .15); border-radius: 50%; box-shadow: 0 0 0 50px rgba(155, 123, 255, .035), 0 0 0 100px rgba(155, 123, 255, .02); }
.auth-visual__copy { position: relative; z-index: 1; max-width: 560px; }
.auth-visual h1 { margin: 24px 0 14px; font-size: clamp(36px, 5vw, 68px); line-height: .98; letter-spacing: -.07em; }
.auth-visual p { margin: 0; max-width: 470px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.feature-list { display: grid; gap: 9px; margin-top: 28px; color: var(--muted-strong); font-size: 12px; }
.feature-list span { display: flex; align-items: center; gap: 9px; }
.feature-list i { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 7px; color: var(--accent-2); background: rgba(34, 211, 238, .11); font-style: normal; }
.auth-card-wrap { display: grid; place-items: center; padding: 30px; border-left: 1px solid var(--line); background: rgba(12, 15, 24, .35); }
.auth-card { width: min(430px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 23px; background: var(--panel); box-shadow: var(--shadow); }
.auth-card__head { margin-bottom: 22px; }
.auth-card__head h2 { margin: 0 0 7px; font-size: 24px; letter-spacing: -.04em; }
.auth-card__head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; margin-bottom: 18px; border-radius: 11px; background: var(--bg-soft); }
.auth-tabs button { border: 0; border-radius: 8px; padding: 9px; color: var(--muted); background: transparent; font-size: 12px; }
.auth-tabs button.active { color: var(--text); background: var(--panel); box-shadow: 0 3px 10px rgba(0,0,0,.14); }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form .button { width: 100%; margin-top: 3px; }
.auth-footnote { margin-top: 16px; color: var(--muted); font-size: 10px; line-height: 1.5; text-align: center; }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 20; display: flex; align-items: flex-start; gap: 10px;
  max-width: min(390px, calc(100vw - 44px)); padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 13px;
  background: var(--panel-solid); box-shadow: var(--shadow); animation: rise .2s ease-out;
}
.toast strong { display: block; margin-bottom: 2px; font-size: 12px; }
.toast span { color: var(--muted); font-size: 11px; line-height: 1.4; }
.toast--error { border-color: rgba(255, 118, 141, .4); }
.toast--success { border-color: rgba(54, 211, 153, .4); }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.22); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.mobile-only { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes thinking { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

@media (max-width: 1180px) {
  .chat-layout { grid-template-columns: 190px minmax(0, 1fr); }
  .chat-options { display: none; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: 278px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .topbar { height: 64px; padding: 0 16px; }
  .content { padding: 22px 16px 36px; }
  .topbar__title span { display: none; }
  .view-header { align-items: flex-start; flex-direction: column; margin-bottom: 19px; }
  .shell--chat .content { overflow: hidden; padding-bottom: 16px; }
  .chat-layout, .chat-layout--simple { height: 100%; min-height: 0; grid-template-columns: 1fr; }
  .chat-list { display: none; }
  .chat-messages { padding: 17px 13px; }
  .message { max-width: 95%; }
  .chat-panel__head { padding: 10px 12px; }
  .chat-panel__controls { flex-wrap: wrap; justify-content: flex-end; }
  .chat-category-select { max-width: 118px; }
  .chat-model-select { min-width: 130px; max-width: 180px; }
  .chat-composer { padding: 10px 11px 13px; }
  .auth-shell { display: block; }
  .auth-visual { min-height: 260px; padding: 42px 28px 32px; }
  .auth-visual h1 { font-size: 42px; margin-top: 18px; }
  .auth-visual p, .feature-list { display: none; }
  .auth-card-wrap { min-height: calc(100vh - 260px); padding: 22px 16px 35px; border-left: 0; border-top: 1px solid var(--line); }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .form-grid, .stat-grid { grid-template-columns: 1fr; }
  .model-grid { grid-template-columns: 1fr; }
  .filters { align-items: stretch; }
  .search-box, .filter-select { max-width: none; width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .auth-card { padding: 22px 18px; }
}

/* Product workflow extensions: existing visual language, broader chat workspace. */
.shell--chat .content { max-width: none; }
.chat-layout--simple { grid-template-columns: minmax(230px, 270px) minmax(0, 1fr); }
.chat-search { position: relative; display: flex; align-items: center; margin-bottom: 9px; }
.chat-search svg { position: absolute; left: 9px; width: 14px; color: var(--muted); pointer-events: none; }
.chat-search input { width: 100%; min-width: 0; padding: 8px 8px 8px 30px; border: 1px solid var(--line); border-radius: 9px; outline: 0; color: var(--text); background: transparent; font-size: 11px; }
.chat-search input:focus { border-color: var(--accent); }
.chat-row-wrap { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-radius: 11px; }
.chat-row-wrap:hover, .chat-row-wrap.active { background: var(--panel-hover); }
.chat-row-wrap .chat-row { min-width: 0; width: 100%; background: transparent; }
.chat-row-actions { display: flex; align-items: center; opacity: 0; transition: opacity .16s; padding-right: 4px; }
.chat-row-wrap:hover .chat-row-actions, .chat-row-wrap:focus-within .chat-row-actions, .chat-row-wrap.active .chat-row-actions { opacity: 1; }
.chat-row-actions .icon-button { padding: 4px; }
.chat-row-actions svg { width: 13px; height: 13px; }
.chat-row__title { display: flex; align-items: center; gap: 5px; min-width: 0; }
.chat-row__title strong { min-width: 0; flex: 1; }
.generation-dot, .unread-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; }
.generation-dot { background: var(--accent-2); box-shadow: 0 0 0 3px rgba(36,211,238,.12); animation: generationPulse 1.2s infinite; }
.unread-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(155,123,255,.12); }
.favorite-button { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; padding: 0; border: 0; border-radius: 9px; color: var(--muted); background: transparent; }
.favorite-button:hover { color: var(--warning); background: var(--panel-hover); }
.favorite-button.active { color: var(--warning); }
.favorite-button.active svg { fill: currentColor; }
.favorite-button svg { width: 17px; height: 17px; }
.filter-check { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted-strong); font-size: 11px; background: var(--panel); }
.filter-check input { accent-color: var(--accent); }
.model-id-line { max-width: min(560px, 50vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; opacity: .72; }
.chat-panel__controls { display: flex; align-items: center; gap: 7px; }
.chat-panel__controls .badge svg { width: 13px; height: 13px; }
.message__bubble h1, .message__bubble h2, .message__bubble h3, .message__bubble h4 { margin: 13px 0 7px; color: var(--text); line-height: 1.3; }
.message__bubble h1 { font-size: 20px; }
.message__bubble h2 { font-size: 18px; }
.message__bubble h3 { font-size: 16px; }
.message__bubble h4 { font-size: 14px; }
.message__bubble ul, .message__bubble ol { margin: 8px 0; padding-left: 22px; }
.message__bubble li + li { margin-top: 4px; }
.message__bubble blockquote { margin: 9px 0; padding: 8px 11px; border-left: 3px solid var(--accent); color: var(--muted); background: rgba(155,123,255,.07); }
.message__bubble > code, .message__bubble p code, .message__bubble li code { padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; color: var(--accent-2); background: rgba(0,0,0,.18); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.message__bubble a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.message-actions { display: flex; align-items: center; gap: 5px; margin-top: 5px; opacity: .75; }
.message--user .message-actions { justify-content: flex-end; }
.message-actions button { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 10px; }
.message-actions button:hover { color: var(--text); background: var(--panel-hover); }
.message-actions svg { width: 13px; height: 13px; }
.message-status { border-radius: 99px; padding: 2px 6px; }
.message-status--queued, .message-status--streaming { color: var(--accent-2); background: rgba(36,211,238,.1); }
.message-status--failed { color: var(--danger); background: rgba(255,118,141,.1); }
.message-status--cancelled { color: var(--warning); background: rgba(246,201,105,.1); }
.error-card { display: flex; flex-direction: column; gap: 4px; margin-top: 9px; padding: 9px 10px; border: 1px solid rgba(255,118,141,.24); border-radius: 9px; color: var(--muted-strong); background: rgba(255,118,141,.07); }
.error-card strong { color: var(--danger); font-size: 11px; }
.error-card span { font-size: 10px; line-height: 1.5; }
.code-block { margin: 10px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #080b12; }
.code-block__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.025); font-size: 10px; }
.code-copy { display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px; border: 0; border-radius: 6px; color: var(--muted-strong); background: transparent; font-size: 10px; }
.code-copy:hover { color: #fff; background: rgba(255,255,255,.07); }
.code-copy svg { width: 12px; height: 12px; }
.code-block pre { margin: 0; border-radius: 0; background: transparent; }
.code-block code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.syntax-keyword { color: #c792ea; }
.syntax-string { color: #c3e88d; }
.syntax-number { color: #f78c6c; }
.syntax-comment { color: #69748a; font-style: italic; }
.markdown-table-wrap { width: 100%; margin: 10px 0; overflow-x: auto; }
.markdown-table-wrap table { width: 100%; min-width: 360px; border-collapse: collapse; }
.markdown-table-wrap th, .markdown-table-wrap td { padding: 7px 9px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.markdown-table-wrap th { color: var(--text); background: rgba(148,163,184,.08); }
.result-item { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.preview-button { padding: 0; border: 0; color: inherit; background: transparent; text-align: left; }
.result-preview { width: 100%; }
.result-download--compact { min-height: 28px; width: auto; margin-top: 6px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 10px; background: rgba(0,0,0,.1); }
.result-download--compact svg { width: 13px; height: 13px; }
.file-card-icon { height: 82px; display: grid; place-items: center; color: var(--accent-2); background: rgba(36,211,238,.06); }
.file-card-icon svg { width: 31px; height: 31px; }
.file-meta-mini { display: flex; flex-direction: column; gap: 2px; min-height: 31px; padding: 0 7px 7px; color: var(--muted); font-size: 9px; line-height: 1.35; overflow-wrap: anywhere; }
.upload-progress { width: 78%; height: 4px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.15); }
.upload-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--accent),var(--accent-2)); }
.upload-error { color: var(--danger); }
.stop-button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,118,141,.35); border-radius: 11px; color: var(--danger); background: rgba(255,118,141,.1); }
.stop-button:hover { background: rgba(255,118,141,.18); }
.stop-button svg { width: 16px; height: 16px; }
.api-pool-mini { display: flex; align-items: center; gap: 7px; margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); }
.api-pool-mini .status-dot { flex: 0 0 auto; }
.media-modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 22px; background: rgba(2,5,10,.82); backdrop-filter: blur(10px); }
.media-modal__dialog { width: min(1100px, 96vw); max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--panel-solid); box-shadow: var(--shadow); }
.media-modal__head, .media-modal__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.media-modal__foot { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.media-modal__body { min-height: 0; display: grid; place-items: center; overflow: auto; padding: 12px; background: #05070c; }
.media-modal__body img { display: block; max-width: 100%; max-height: calc(94vh - 126px); object-fit: contain; }
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 11px; }
.admin-table th, .admin-table td { padding: 8px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table td code { word-break: break-all; }
.admin-section-gap { margin-top: 16px; }
.admin-top-gap { margin-top: 16px; }
.key-actions { display: flex; align-items: center; gap: 4px; }
.usage-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.usage-columns > div { min-width: 0; }
.usage-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.usage-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-strong); }
.mobile-chat-switch { display: none; }
@keyframes generationPulse { 50% { opacity: .42; transform: scale(.8); } }

@media (max-width: 820px) {
  .mobile-chat-switch { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; }
  .mobile-chat-switch .select { min-width: 0; }
  .chat-layout--simple { height: calc(100% - 48px); }
  .chat-panel__head { align-items: flex-start; }
  .chat-panel__controls .badge:first-child { display: none; }
  .model-id-line { max-width: 58vw; }
  .usage-columns { grid-template-columns: 1fr; }
  .message-actions { opacity: 1; }
}

@media (max-width: 520px) {
  .chat-panel__model .provider-dot { display: none; }
  .chat-panel__controls { max-width: 92px; }
  .chat-panel__controls .badge { white-space: normal; text-align: center; }
  .composer-hint span:last-child { display: none; }
  .result-grid { grid-template-columns: 1fr; }
  .media-modal { padding: 8px; }
}

/* CSP-safe progress widths (no inline style attributes). */
.progress-p0 { width: 0%; }
.progress-p5 { width: 5%; }
.progress-p10 { width: 10%; }
.progress-p15 { width: 15%; }
.progress-p20 { width: 20%; }
.progress-p25 { width: 25%; }
.progress-p30 { width: 30%; }
.progress-p35 { width: 35%; }
.progress-p40 { width: 40%; }
.progress-p45 { width: 45%; }
.progress-p50 { width: 50%; }
.progress-p55 { width: 55%; }
.progress-p60 { width: 60%; }
.progress-p65 { width: 65%; }
.progress-p70 { width: 70%; }
.progress-p75 { width: 75%; }
.progress-p80 { width: 80%; }
.progress-p85 { width: 85%; }
.progress-p90 { width: 90%; }
.progress-p95 { width: 95%; }
.progress-p100 { width: 100%; }

/* Provider artwork is served through the authenticated local proxy route. */
.provider-dot { overflow: hidden; isolation: isolate; }
.provider-dot img { width: 100%; height: 100%; display: block; object-fit: contain; padding: 6px; background: rgba(255,255,255,.96); border-radius: inherit; }
:root[data-theme="light"] .provider-dot img { background: #fff; }

/* Keep frequent live updates visually calm without changing the layout. */
.chat-row, .message__bubble, .composer-box, .panel, .model-card, .button, .icon-button, .send-button, .stop-button {
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease, opacity .16s ease;
}
.chat-panel, .chat-list { contain: layout paint; }
.chat-messages { scroll-behavior: smooth; }
.key-row { align-items: flex-start; }
.key-actions { flex-wrap: wrap; justify-content: flex-end; }
.key-actions .button { min-height: 31px; padding: 6px 9px; font-size: 10px; }
.label small { color: var(--muted); font-size: 10px; line-height: 1.45; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
