:root {
  color-scheme: dark;
  --bg: #0a0c10;
  --sidebar: #0d1015;
  --surface: #10141a;
  --surface-2: #151a22;
  --surface-3: #1a2029;
  --surface-elevated: #12171e;
  --field: #0e1218;
  --border: rgba(255,255,255,.075);
  --border-strong: rgba(255,255,255,.13);
  --text: #f5f7fa;
  --text-2: #d7dde5;
  --muted: #8f99a7;
  --muted-2: #66707d;
  --accent: #6c7cff;
  --accent-2: #8b97ff;
  --accent-soft: rgba(108,124,255,.12);
  --accent-border: rgba(108,124,255,.28);
  --green: #57d18b;
  --yellow: #e3b84c;
  --red: #f17178;
  --hover: rgba(255,255,255,.045);
  --shadow: 0 24px 80px rgba(0,0,0,.42);
  --composer-shadow: 0 18px 55px rgba(0,0,0,.32);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --sidebar: #f1f3f6;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #edf0f4;
  --surface-elevated: #ffffff;
  --field: #fbfcfd;
  --border: rgba(19,27,38,.085);
  --border-strong: rgba(19,27,38,.14);
  --text: #151922;
  --text-2: #343b47;
  --muted: #6e7887;
  --muted-2: #919aa6;
  --accent: #5367f5;
  --accent-2: #4358ea;
  --accent-soft: rgba(83,103,245,.09);
  --accent-border: rgba(83,103,245,.20);
  --green: #1e9d62;
  --yellow: #a7770a;
  --red: #cf4b53;
  --hover: rgba(19,27,38,.045);
  --shadow: 0 24px 70px rgba(30,39,54,.14);
  --composer-shadow: 0 14px 45px rgba(40,50,66,.12);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, textarea, select { font: inherit; }
button { color: inherit; }
button, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mobile-only { display: none !important; }
.app-shell { display: grid; grid-template-columns: 286px minmax(0,1fr); height: 100dvh; background: var(--bg); }
.sidebar { min-width: 0; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 14px 14px; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 4px 10px; }
.brand { display: flex; align-items: center; gap: 11px; border: 0; background: transparent; padding: 0; cursor: pointer; text-align: left; }
.brand-mark, .mini-brand, .welcome-mark { display: grid; place-items: center; color: white; background: linear-gradient(135deg,#6c7cff,#4659eb); font-weight: 800; letter-spacing: -.04em; box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 8px 24px rgba(80,98,241,.18); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 14px; letter-spacing: -.01em; }
.brand-copy small { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .02em; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); cursor: pointer; color: var(--muted); transition: .16s ease; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.new-chat-btn { width: 100%; height: 44px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--accent-border); border-radius: 12px; padding: 0 12px; background: var(--accent-soft); color: var(--text); font-weight: 680; font-size: 13px; cursor: pointer; transition: .16s ease; }
.new-chat-btn svg { width: 18px; }
.new-chat-btn:hover { background: color-mix(in srgb,var(--accent) 17%, transparent); border-color: color-mix(in srgb,var(--accent) 38%, transparent); }
.shortcut { margin-left: auto; font-size: 10px; color: var(--muted); font-weight: 600; }
.sidebar-section-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 8px 8px; color: var(--muted-2); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .11em; }
.section-count { font-size: 9px; }
.chat-list { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; padding-right: 2px; }
.chat-list::-webkit-scrollbar { width: 5px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
.chat-row { position: relative; display: flex; align-items: center; min-height: 38px; gap: 8px; border-radius: 10px; padding: 8px 35px 8px 10px; cursor: pointer; color: var(--text-2); font-size: 12px; transition: .14s ease; }
.chat-row:hover { background: var(--hover); color: var(--text); }
.chat-row.active { background: var(--surface-2); color: var(--text); }
.chat-row.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--accent); }
.chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chat-delete { position: absolute; right: 5px; width: 27px; height: 27px; border: 0; background: transparent; border-radius: 8px; color: var(--muted-2); opacity: 0; cursor: pointer; font-size: 17px; }
.chat-row:hover .chat-delete { opacity: 1; }
.chat-delete:hover { color: var(--red); background: color-mix(in srgb,var(--red) 10%, transparent); }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-action { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 12px; background: transparent; padding: 9px 8px; cursor: pointer; text-align: left; }
.sidebar-action:hover { background: var(--hover); }
.sidebar-action-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); color: var(--muted); }
.sidebar-action-icon svg { width: 17px; }
.sidebar-action-copy { display: grid; gap: 1px; min-width: 0; }
.sidebar-action-copy strong { font-size: 12px; }
.sidebar-action-copy small { color: var(--muted); font-size: 10px; }
.badge { margin-left: auto; min-width: 25px; height: 22px; display: grid; place-items: center; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-size: 10px; font-weight: 800; }
.vault-note { display: flex; gap: 7px; align-items: center; padding: 8px 8px 2px; color: var(--muted-2); font-size: 9px; }
.vault-note svg { width: 13px; }
.main { min-width: 0; height: 100dvh; display: grid; grid-template-rows: 70px minmax(0,1fr) auto; position: relative; background: var(--bg); }
.topbar { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--border); background: color-mix(in srgb,var(--bg) 92%, transparent); backdrop-filter: blur(18px); z-index: 10; }
.topbar-left, .topbar-actions, .model-picker-group { min-width: 0; display: flex; align-items: center; }
.topbar-left { gap: 12px; flex: 1; }
.model-picker-group { gap: 8px; max-width: min(680px, 60vw); }
.select-shell { position: relative; min-width: 0; height: 46px; display: grid; align-items: center; padding: 7px 34px 6px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); transition: .16s ease; }
.select-shell:hover { border-color: var(--border-strong); }
.provider-shell { width: 170px; }
.model-shell { width: min(350px, 34vw); }
.control-label { position: absolute; top: 6px; left: 12px; color: var(--muted-2); font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; pointer-events: none; }
.select { appearance: none; width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); cursor: pointer; font-size: 12px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; padding: 10px 0 0; }
.select option { color: CanvasText; background: Canvas; }
.chevron { position: absolute; right: 11px; bottom: 11px; width: 15px; color: var(--muted); pointer-events: none; }
.topbar-actions { gap: 8px; }
.status-pill { height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); background: var(--surface); font-size: 10px; font-weight: 650; white-space: nowrap; }
.status-dot, .active-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--muted-2); }
.status-pill.connected .status-dot, .connected-dot, .active-model-label .active-dot { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb,var(--green) 12%, transparent); }
.desktop-theme { background: transparent; }
.moon-icon { display: none; }
html[data-theme="light"] .sun-icon { display: none; }
html[data-theme="light"] .moon-icon { display: block; }
.add-key-btn { height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 13px; border: 1px solid var(--accent-border); border-radius: 11px; background: var(--accent); color: white; cursor: pointer; font-size: 11px; font-weight: 750; box-shadow: 0 7px 22px rgba(83,103,245,.20); }
.add-key-btn:hover { background: var(--accent-2); }
.add-key-btn svg { width: 16px; }
.chat-view { min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.chat-view::-webkit-scrollbar { width: 7px; }
.chat-view::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
.empty-state { min-height: 100%; display: grid; place-content: center; justify-items: center; padding: 54px 28px 160px; text-align: center; }
.welcome-mark { width: 54px; height: 54px; border-radius: 16px; font-size: 17px; margin-bottom: 22px; }
.welcome-copy { max-width: 620px; }
.eyebrow-pill { width: max-content; max-width: 100%; margin: 0 auto 12px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .09em; }
.eyebrow-pill span { width: 6px; height: 6px; border-radius: 99px; background: var(--accent); }
.welcome-copy h1 { margin: 0; font-size: clamp(30px,3.2vw,43px); line-height: 1.08; letter-spacing: -.045em; font-weight: 770; }
.welcome-copy p { margin: 14px auto 0; max-width: 520px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.provider-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; max-width: 710px; margin: 26px auto 0; }
.provider-row span { padding: 6px 9px; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); background: var(--surface); font-size: 9px; font-weight: 680; }
.suggestions { width: min(760px,100%); display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 30px; }
.suggestions button { min-width: 0; display: grid; grid-template-columns: 36px minmax(0,1fr) 18px; align-items: center; gap: 10px; padding: 13px; text-align: left; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); cursor: pointer; transition: .16s ease; }
.suggestions button:hover { transform: translateY(-1px); border-color: var(--border-strong); background: var(--surface-2); }
.suggestion-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--accent); background: var(--accent-soft); }
.suggestion-icon svg { width: 17px; }
.suggestions button > span:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.suggestions strong { font-size: 11px; }
.suggestions small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 9px; }
.suggestions .arrow { width: 15px; color: var(--muted-2); }
.messages { width: min(850px,calc(100% - 40px)); margin: 0 auto; padding: 38px 0 170px; }
.message { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 13px; padding: 17px 0; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 10px; font-weight: 850; }
.message.assistant .avatar { color: white; border-color: transparent; background: var(--accent); }
.message-head { display: flex; align-items: center; gap: 8px; min-height: 23px; }
.message-name { font-size: 11px; font-weight: 800; }
.message-model { max-width: 390px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 9px; padding: 3px 6px; border-radius: 6px; background: var(--surface-2); }
.message-body { color: var(--text-2); font-size: 13px; line-height: 1.72; overflow-wrap: anywhere; }
.message-body p { margin: 7px 0; }
.message.user .message-body { color: var(--text); }
.message-body code { padding: 2px 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); font-family: "SFMono-Regular",Consolas,monospace; font-size: .9em; }
.message-body pre { overflow-x: auto; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #080a0e; }
html[data-theme="light"] .message-body pre { background: #f2f4f7; }
.message-body pre code { border: 0; padding: 0; background: transparent; }
.message-actions { margin-top: 8px; opacity: 0; transition: .15s ease; }
.message:hover .message-actions { opacity: 1; }
.message-actions button { border: 0; background: transparent; color: var(--muted); padding: 3px 0; cursor: pointer; font-size: 9px; }
.message-actions button:hover { color: var(--text); }
.thinking { display: flex; align-items: center; gap: 4px; height: 24px; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: pulse 1.1s infinite ease-in-out; }
.thinking i:nth-child(2){animation-delay:.15s}.thinking i:nth-child(3){animation-delay:.3s}
@keyframes pulse { 0%,80%,100%{opacity:.28;transform:scale(.8)}40%{opacity:1;transform:scale(1)} }
.composer-wrap { position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; padding: 22px 20px 14px; background: linear-gradient(to top,var(--bg) 55%,transparent); pointer-events: none; }
.composer { pointer-events: auto; width: min(850px,100%); margin: 0 auto; border: 1px solid var(--border-strong); border-radius: 17px; background: var(--surface-elevated); box-shadow: var(--composer-shadow); overflow: hidden; transition: border-color .16s ease, box-shadow .16s ease; }
.composer:focus-within { border-color: var(--accent-border); box-shadow: var(--composer-shadow), 0 0 0 3px var(--accent-soft); }
.composer textarea { width: 100%; max-height: 180px; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); padding: 15px 16px 8px; font-size: 13px; line-height: 1.55; }
.composer textarea::placeholder { color: var(--muted-2); }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 7px 7px 13px; }
.active-model-label { min-width: 0; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.send-hint { color: var(--muted-2); font-size: 8px; }
.send-btn { width: 35px; height: 35px; display: grid; place-items: center; border: 0; border-radius: 10px; background: var(--accent); color: white; cursor: pointer; }
.send-btn:hover { background: var(--accent-2); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn svg { width: 17px; }
.composer-note { pointer-events: none; margin: 7px auto 0; text-align: center; color: var(--muted-2); font-size: 8px; }
.scrim { display: none; }
.modal { width: min(760px,calc(100% - 32px)); max-height: min(820px,calc(100dvh - 40px)); padding: 0; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface-elevated); color: var(--text); box-shadow: var(--shadow); overflow: hidden; }
.modal::backdrop { background: rgba(3,5,8,.64); backdrop-filter: blur(7px); }
.modal-card { max-height: min(820px,calc(100dvh - 40px)); overflow-y: auto; padding: 22px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.modal-kicker { display: flex; align-items: center; gap: 7px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-size: 9px; font-weight: 850; }
.modal-header h2 { margin: 8px 0 6px; font-size: 24px; letter-spacing: -.035em; }
.modal-header p { margin: 0; max-width: 520px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.import-card { margin-top: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 12px; }
.field-row > div:first-child { display: grid; gap: 2px; }
.field-row label { font-size: 11px; font-weight: 780; }
.field-row small { color: var(--muted); font-size: 9px; }
.compact-select-shell { width: 190px; height: 40px; padding-top: 0; padding-bottom: 0; background: var(--field); }
.compact-select-shell .select { padding-top: 0; }
.compact-select-shell .chevron { bottom: 12px; }
.key-input { width: 100%; min-height: 150px; resize: vertical; border: 1px solid var(--border); border-radius: 12px; outline: 0; background: var(--field); color: var(--text); padding: 12px 13px; font: 11px/1.6 "SFMono-Regular",Consolas,monospace; }
.key-input:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.key-input::placeholder { color: var(--muted-2); }
.import-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; }
.tiny-note { max-width: 430px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.tiny-note strong { color: var(--text-2); }
.primary-btn { min-height: 39px; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 10px; padding: 0 13px; background: var(--accent); color: white; cursor: pointer; font-size: 10px; font-weight: 800; white-space: nowrap; }
.primary-btn:hover { background: var(--accent-2); }
.primary-btn:disabled { opacity: .5; cursor: wait; }
.primary-btn svg { width: 15px; }
.import-results { display: grid; gap: 7px; margin-top: 12px; }
.result-row, .key-row { display: grid; grid-template-columns: 10px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.result-state { width: 8px; height: 8px; border-radius: 99px; background: var(--muted-2); }
.result-state.ok { background: var(--green); }.result-state.warn{background:var(--yellow)}.result-state.bad{background:var(--red)}
.result-main { min-width: 0; }
.result-title { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 10px; font-weight: 760; }
.result-title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-chip { flex: 0 0 auto; padding: 3px 6px; border-radius: 6px; color: var(--muted); background: var(--surface-3); font-size: 8px; text-transform: capitalize; }
.result-detail { margin-top: 3px; color: var(--muted); font-size: 9px; }
.keys-title-row { display: flex; justify-content: space-between; align-items: end; margin: 22px 1px 9px; }
.keys-section-title { font-size: 11px; font-weight: 800; }
.keys-hint { margin-top: 2px; color: var(--muted); font-size: 9px; }
.saved-keys { display: grid; gap: 7px; }
.key-actions { display: flex; gap: 6px; }
.mini-btn { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text-2); padding: 6px 8px; cursor: pointer; font-size: 8px; }
.mini-btn:hover { border-color: var(--border-strong); }.mini-btn.danger:hover{color:var(--red)}
.empty-list { padding: 26px 12px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--muted); text-align: center; font-size: 10px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 22px; transform: translate(-50%,18px); padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-elevated); color: var(--text); box-shadow: var(--shadow); font-size: 10px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }


/* Attachments */
.chat-view { position: relative; }
.drop-overlay { position: absolute; z-index: 30; inset: 14px; display: grid; place-items: center; border: 1.5px dashed var(--accent-border); border-radius: 18px; background: color-mix(in srgb,var(--bg) 84%, transparent); backdrop-filter: blur(12px); opacity: 0; visibility: hidden; transform: scale(.992); transition: .15s ease; pointer-events: none; }
.drop-overlay.show { opacity: 1; visibility: visible; transform: scale(1); }
.drop-overlay > div { display: grid; justify-items: center; gap: 7px; padding: 24px; text-align: center; }
.drop-overlay svg { width: 28px; height: 28px; color: var(--accent); }
.drop-overlay strong { font-size: 14px; }
.drop-overlay span { color: var(--muted); font-size: 10px; }
.composer-left { min-width: 0; display: flex; align-items: center; gap: 8px; }
.attach-btn { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; transition: .16s ease; }
.attach-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.attach-btn:disabled { opacity: .42; cursor: not-allowed; }
.attach-btn svg { width: 17px; height: 17px; }
.attachment-tray { display: flex; gap: 8px; overflow-x: auto; padding: 10px 11px 2px; scrollbar-width: thin; }
.attachment-tray[hidden] { display: none; }
.attachment-tray::-webkit-scrollbar { height: 4px; }
.attachment-tray::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
.attachment-chip { position: relative; flex: 0 0 auto; width: 176px; min-height: 54px; display: grid; grid-template-columns: 40px minmax(0,1fr) 24px; align-items: center; gap: 8px; padding: 7px 6px 7px 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.attachment-chip.uploading::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: var(--progress, 0%); background: var(--accent); transition: width .12s linear; }
.attachment-thumb { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--muted); overflow: hidden; }
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-thumb svg { width: 18px; }
.attachment-meta { min-width: 0; display: grid; gap: 3px; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9.5px; font-weight: 750; color: var(--text-2); }
.attachment-size { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .03em; }
.attachment-remove { width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted-2); cursor: pointer; font-size: 16px; }
.attachment-remove:hover { color: var(--red); background: color-mix(in srgb,var(--red) 9%, transparent); }
.attachment-remove:disabled { opacity: .35; cursor: wait; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.message-attachment { max-width: 260px; min-width: 150px; display: flex; align-items: center; gap: 9px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text-2); text-decoration: none; transition: .15s ease; }
.message-attachment:hover { border-color: var(--border-strong); background: var(--surface-2); }
.message-attachment.image { width: min(310px,100%); max-width: 310px; padding: 0; overflow: hidden; display: block; }
.message-attachment.image img { display: block; width: 100%; max-height: 240px; object-fit: cover; }
.message-file-icon { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; background: var(--surface-3); color: var(--muted); }
.message-file-icon svg { width: 15px; }
.message-file-copy { min-width: 0; display: grid; gap: 2px; }
.message-file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.message-file-copy small { color: var(--muted); font-size: 8px; }
.messages { padding-bottom: 220px; }

@media (max-width: 1040px) {
  .status-pill { display: none; }
  .model-picker-group { max-width: 66vw; }
  .provider-shell { width: 145px; }
  .model-shell { width: min(310px,36vw); }
}

@media (max-width: 820px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .app-shell { display: block; height: 100dvh; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw,330px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); border-right-color: var(--border-strong); padding-top: max(14px,env(safe-area-inset-top)); }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; z-index: 35; inset: 0; display: block; background: rgba(0,0,0,.48); opacity: 0; visibility: hidden; transition: .2s ease; }
  .scrim.show { opacity: 1; visibility: visible; }
  .main { height: 100dvh; grid-template-rows: auto minmax(0,1fr) auto; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar { min-height: 64px; padding: max(8px,env(safe-area-inset-top)) 12px 8px; gap: 8px; align-items: center; }
  .topbar-left { gap: 8px; width: 100%; }
  .topbar-left > .icon-btn { flex: 0 0 auto; width: 38px; height: 38px; background: transparent; border-color: transparent; }
  .mobile-brand { align-items: center; gap: 7px; flex: 0 0 auto; }
  .mobile-brand strong { font-size: 13px; }
  .mini-brand { width: 28px; height: 28px; border-radius: 8px; font-size: 9px; }
  .model-picker-group { margin-left: auto; max-width: none; flex: 1; gap: 6px; overflow: hidden; }
  .provider-shell { width: 106px; height: 40px; padding: 5px 28px 4px 10px; }
  .provider-shell .control-label { top: 5px; left: 10px; font-size: 7px; }
  .provider-shell .select { font-size: 10px; padding-top: 9px; }
  .provider-shell .chevron { right: 8px; bottom: 10px; width: 13px; }
  .model-shell { flex: 1; width: auto; height: 40px; padding: 5px 30px 4px 10px; }
  .model-shell .control-label { top: 5px; left: 10px; font-size: 7px; }
  .model-shell .select { font-size: 10px; padding-top: 9px; }
  .model-shell .chevron { right: 9px; bottom: 10px; width: 14px; }
  .topbar-actions { display: none; }
  .empty-state { padding: 35px 17px 130px; align-content: center; }
  .welcome-mark { width: 48px; height: 48px; border-radius: 14px; font-size: 15px; margin-bottom: 18px; }
  .welcome-copy h1 { font-size: clamp(27px,8vw,35px); }
  .welcome-copy p { font-size: 12px; line-height: 1.6; }
  .provider-row { margin-top: 20px; max-width: 520px; gap: 5px; }
  .provider-row span { padding: 5px 7px; font-size: 8px; }
  .suggestions { grid-template-columns: 1fr; width: min(480px,100%); margin-top: 23px; gap: 8px; }
  .suggestions button { padding: 11px; grid-template-columns: 34px minmax(0,1fr) 16px; }
  .suggestion-icon { width: 34px; height: 34px; }
  .messages { width: calc(100% - 28px); padding: 24px 0 210px; }
  .message { grid-template-columns: 30px minmax(0,1fr); gap: 10px; padding: 14px 0; }
  .avatar { width: 28px; height: 28px; }
  .message-body { font-size: 12px; line-height: 1.68; }
  .message-model { max-width: 45vw; }
  .composer-wrap { bottom: calc(64px + env(safe-area-inset-bottom)); padding: 18px 10px 8px; }
  .composer { border-radius: 16px; }
  .composer textarea { font-size: 13px; padding: 13px 13px 7px; }
  .attachment-chip { width: 158px; }
  .attachment-tray { padding-left: 9px; padding-right: 9px; }
  .message-attachment.image { max-width: min(290px,100%); }
  .composer-note { display: none; }
  .active-model-label { max-width: calc(100vw - 110px); font-size: 8px; }
  .mobile-tabbar { position: absolute; z-index: 20; left: 0; right: 0; bottom: 0; min-height: calc(64px + env(safe-area-inset-bottom)); padding: 6px 12px max(6px,env(safe-area-inset-bottom)); align-items: center; justify-content: space-around; border-top: 1px solid var(--border); background: color-mix(in srgb,var(--bg) 94%, transparent); backdrop-filter: blur(18px); }
  .mobile-tab { min-width: 58px; height: 48px; display: grid !important; justify-items: center; align-content: center; gap: 3px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 8px; font-weight: 700; }
  .mobile-tab svg { width: 18px; }
  .mobile-tab.active { color: var(--text); }
  .mobile-tab-primary { margin-top: -13px; color: var(--text); }
  .mobile-plus { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: white; box-shadow: 0 8px 22px rgba(83,103,245,.28); }
  .mobile-tab-primary > span:last-child { margin-top: 1px; }
  .modal { width: 100%; max-width: none; max-height: 91dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .modal-card { max-height: 91dvh; padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); }
  .modal-header h2 { font-size: 21px; }
  .field-row { align-items: stretch; flex-direction: column; }
  .compact-select-shell { width: 100%; }
  .import-actions { align-items: stretch; flex-direction: column; }
  .primary-btn { justify-content: center; min-height: 44px; }
  .result-row, .key-row { grid-template-columns: 10px minmax(0,1fr); }
  .key-actions { grid-column: 2; justify-content: flex-start; }
  .toast { bottom: calc(74px + env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .topbar { padding-left: 8px; padding-right: 8px; }
  .mobile-brand { display: none !important; }
  .model-picker-group { max-width: calc(100vw - 54px); }
  .provider-shell { width: 92px; }
  .model-shell { min-width: 0; }
  .eyebrow-pill { font-size: 8px; }
  .provider-row span:nth-last-child(-n+3) { display: none; }
}

/* Authentication — CZ AI v7 */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  min-height: 100dvh;
  overflow: auto;
  background: var(--bg);
  color: var(--text);
}
.auth-gate[hidden], .app-shell[hidden] { display: none !important; }
.auth-layout {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(420px, .88fr);
}
.auth-showcase {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100dvh;
  padding: clamp(34px, 4.6vw, 72px);
  border-right: 1px solid var(--border);
  background:
    radial-gradient(900px 540px at 12% 0%, color-mix(in srgb,var(--accent) 18%, transparent), transparent 63%),
    radial-gradient(680px 500px at 90% 100%, color-mix(in srgb,var(--accent) 10%, transparent), transparent 66%),
    linear-gradient(145deg, color-mix(in srgb,var(--surface) 64%, var(--bg)), var(--bg));
}
.auth-showcase::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image:
    linear-gradient(color-mix(in srgb,var(--text) 6%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb,var(--text) 6%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}
.auth-showcase-top, .auth-trust-grid { position: relative; z-index: 1; }
.auth-brand-row { display: flex; align-items: center; gap: 12px; }
.auth-brand-row > div, .auth-mobile-brand > div { display: grid; gap: 2px; }
.auth-brand-row strong, .auth-mobile-brand strong { font-size: 17px; letter-spacing: -.025em; }
.auth-brand-row small, .auth-mobile-brand small { color: var(--muted); font-size: 10px; font-weight: 650; }
.auth-brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg,#7786ff,#4c5ff2 62%,#4052d8);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -.04em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 16px 38px rgba(75,91,231,.24);
}
.auth-hero-copy { max-width: 720px; margin-top: clamp(80px, 13vh, 150px); }
.auth-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.auth-kicker span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px color-mix(in srgb,var(--green) 12%, transparent); }
.auth-hero-copy h1 {
  margin: 18px 0 0;
  max-width: 760px;
  font-size: clamp(43px, 5vw, 76px);
  line-height: .98;
  letter-spacing: -.065em;
  font-weight: 790;
}
.auth-hero-copy h1 em { color: var(--muted); font-style: normal; font-weight: 680; }
.auth-hero-copy > p { max-width: 640px; margin: 24px 0 0; color: var(--text-2); font-size: clamp(13px,1.2vw,16px); line-height: 1.75; }
.auth-provider-cloud { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 30px; }
.auth-provider-cloud span {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb,var(--surface) 72%, transparent);
  color: var(--muted);
  font-size: 9px;
  font-weight: 730;
  backdrop-filter: blur(12px);
}
.auth-trust-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-top: 54px; }
.auth-trust-grid > div {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0,1fr);
  gap: 10px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb,var(--surface) 72%, transparent);
  backdrop-filter: blur(12px);
}
.auth-trust-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.auth-trust-icon svg { width: 16px; }
.auth-trust-grid > div > span:last-child { min-width: 0; display: grid; gap: 4px; }
.auth-trust-grid strong { font-size: 10px; }
.auth-trust-grid small { color: var(--muted); font-size: 8px; line-height: 1.5; }

.auth-panel {
  position: relative;
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 54px clamp(30px,5vw,78px);
  background: var(--bg);
}
.auth-panel-inner { width: min(100%, 430px); }
.auth-mobile-brand { display: none; align-items: center; gap: 11px; margin-bottom: 36px; }
.auth-card-head { margin-bottom: 24px; }
.auth-mode-badge {
  width: max-content;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 8px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .09em;
}
.auth-card-head h2 { margin: 14px 0 8px; font-size: clamp(30px,3.1vw,42px); line-height: 1.05; letter-spacing: -.05em; }
.auth-card-head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 22px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
}
.auth-tabs button {
  height: 37px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  font-weight: 780;
  cursor: pointer;
  transition: .16s ease;
}
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.auth-tabs button[hidden] { display: none; }
.auth-form { display: grid; gap: 15px; }
.auth-field { display: grid; gap: 7px; }
.auth-field > span { color: var(--text-2); font-size: 10px; font-weight: 750; }
.auth-input-shell {
  position: relative;
  height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.auth-input-shell:focus-within { border-color: color-mix(in srgb,var(--accent) 68%, var(--border)); box-shadow: 0 0 0 4px color-mix(in srgb,var(--accent) 10%, transparent); background: var(--surface-elevated); }
.auth-input-shell > svg { width: 17px; flex: 0 0 auto; color: var(--muted-2); }
.auth-input-shell input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.auth-input-shell input::placeholder { color: var(--muted-2); }
.auth-password-toggle { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.auth-password-toggle:hover { color: var(--text); background: var(--hover); }
.auth-password-toggle svg { width: 16px; }
.auth-password-toggle .eye-closed { display: none; }
.auth-password-toggle.showing .eye-open { display: none; }
.auth-password-toggle.showing .eye-closed { display: block; }
.auth-submit {
  height: 50px;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg,var(--accent),#5264ed);
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(83,103,245,.25);
  transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}
.auth-submit:hover { transform: translateY(-1px); filter: brightness(1.04); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: .58; cursor: wait; transform: none; }
.auth-submit svg { width: 16px; }
.auth-message { min-height: 20px; margin-top: 10px; color: var(--red); font-size: 10px; line-height: 1.55; }
.auth-message.ok { color: var(--green); }
.auth-security-note {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 9px;
  align-items: start;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
}
.auth-security-note svg { width: 16px; color: var(--green); }
.auth-panel-footer { position: absolute; bottom: 24px; color: var(--muted-2); font-size: 8px; font-weight: 700; letter-spacing: .04em; }
.auth-theme-toggle {
  position: fixed;
  z-index: 10001;
  top: 20px;
  right: 20px;
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: color-mix(in srgb,var(--surface) 90%, transparent);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.auth-theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.auth-theme-toggle .moon-icon { display: none; }
html[data-theme="light"] .auth-theme-toggle .sun-icon { display: none; }
html[data-theme="light"] .auth-theme-toggle .moon-icon { display: block; }

.account-row { display: grid; grid-template-columns: 34px minmax(0,1fr) 32px; align-items: center; gap: 9px; margin-top: 8px; padding: 9px; border: 1px solid var(--border); border-radius: 13px; background: var(--bg-soft, var(--surface-2)); }
.account-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.account-copy { min-width: 0; display: grid; gap: 2px; }
.account-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.account-copy small { color: var(--muted); font-size: 8px; }
.logout-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 9px; cursor: pointer; }
.logout-btn:hover { background: var(--hover); color: var(--text); }
.logout-btn svg { width: 16px; }

@media (max-width: 1050px) {
  .auth-layout { grid-template-columns: 1fr minmax(390px,.9fr); }
  .auth-showcase { padding: 38px; }
  .auth-hero-copy h1 { font-size: clamp(40px,5vw,58px); }
  .auth-trust-grid { grid-template-columns: 1fr; max-width: 420px; }
  .auth-trust-grid > div:nth-child(n+3) { display: none; }
}
@media (max-width: 820px) {
  .auth-layout { display: block; min-height: 100dvh; }
  .auth-showcase { display: none; }
  .auth-panel { min-height: 100dvh; padding: 68px 24px 54px; background:
    radial-gradient(620px 420px at 50% -120px, color-mix(in srgb,var(--accent) 17%, transparent), transparent 65%),
    var(--bg); }
  .auth-mobile-brand { display: flex; }
  .auth-panel-inner { width: min(100%, 430px); }
  .auth-panel-footer { bottom: 18px; }
}
@media (max-width: 520px) {
  .auth-panel { align-content: start; padding: 28px 18px 58px; }
  .auth-mobile-brand { margin-bottom: 42px; }
  .auth-brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .auth-card-head h2 { font-size: 33px; }
  .auth-card-head p { font-size: 11px; }
  .auth-input-shell, .auth-submit { height: 48px; }
  .auth-theme-toggle { top: 15px; right: 15px; width: 37px; height: 37px; }
}

/* Owner panel */
.owner-badge { margin-left: auto; padding: 3px 6px; border: 1px solid var(--accent-border); border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 7px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.admin-modal { width: min(880px,calc(100% - 32px)); }
.owner-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 18px; }
.owner-stats > div { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); display: grid; gap: 3px; }
.owner-stats strong { font-size: 20px; letter-spacing: -.04em; }
.owner-stats span { color: var(--muted); font-size: 8px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.owner-create-card { margin-top: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 13px; background: var(--bg-soft); display: grid; gap: 12px; }
.owner-create-form { display: grid; grid-template-columns: minmax(120px,1fr) minmax(150px,1.2fr) auto; gap: 8px; }
.owner-create-form input { min-width: 0; height: 39px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); padding: 0 10px; outline: 0; font: inherit; font-size: 10px; }
.owner-create-form input:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.owner-users { display: grid; gap: 10px; }
.owner-user-card { overflow: hidden; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.owner-user-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.owner-user-identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.owner-user-identity > span { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: var(--text); color: var(--bg); font-size: 10px; font-weight: 900; }
.owner-user-identity > div { display: grid; gap: 2px; min-width: 0; }
.owner-user-identity strong { font-size: 11px; }
.owner-user-identity small { color: var(--muted); font-size: 8px; }
.owner-provider-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.owner-provider-list span { padding: 3px 6px; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: 7px; text-transform: capitalize; }
.owner-key-list { display: grid; gap: 0; }
.owner-key-row { display: grid; grid-template-columns: 10px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 11px 12px; border-top: 1px solid var(--border); }
.owner-key-row:first-child { border-top: 0; }
.owner-no-keys { padding: 14px 12px; color: var(--muted); font-size: 9px; }
.health-chip { padding: 3px 6px; border-radius: 6px; font-size: 7px; font-weight: 800; }
.health-chip.healthy { background: color-mix(in srgb,var(--green) 12%, transparent); color: var(--green); }
.health-chip.unhealthy { background: color-mix(in srgb,var(--red) 10%, transparent); color: var(--red); }
@media (max-width: 620px) {
  .owner-stats { grid-template-columns: 1fr 1fr; }
  .owner-create-form { grid-template-columns: 1fr; }
  .owner-user-head { align-items: flex-start; flex-direction: column; }
  .owner-provider-list { justify-content: flex-start; }
  .owner-key-row { grid-template-columns: 10px minmax(0,1fr); }
  .owner-key-row > .mini-btn { grid-column: 2; justify-self: start; }
}
