:root {
  color-scheme: dark;
  --bg: #080b12;
  --bg-soft: #0d111b;
  --panel: #111621;
  --panel-elevated: #171d2a;
  --panel-hover: #1b2332;
  --glass: rgba(17, 22, 33, .88);
  --sidebar: #0b0f17;
  --border: #252d3c;
  --border-bright: #354156;
  --text: #edf1f7;
  --text-soft: #c6ceda;
  --muted: #8995a8;
  --faint: #5f6b7d;
  --accent: #7c8cff;
  --accent-strong: #94a0ff;
  --accent-soft: rgba(124, 140, 255, .14);
  --teal: #4fd1c5;
  --success: #57c99b;
  --warning: #f3bc68;
  --danger: #ff7e8f;
  --user: #1b2540;
  --shadow: 0 24px 70px rgba(0, 0, 0, .32);
  --sidebar-width: 284px;
  --topbar-height: 68px;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f7;
  --bg-soft: #f5f7fa;
  --panel: #ffffff;
  --panel-elevated: #f7f9fc;
  --panel-hover: #edf1f7;
  --glass: rgba(255, 255, 255, .9);
  --sidebar: #f8fafc;
  --border: #dce2eb;
  --border-bright: #c8d0dd;
  --text: #172033;
  --text-soft: #38445a;
  --muted: #68758a;
  --faint: #8a95a7;
  --accent: #596fe8;
  --accent-strong: #465bd1;
  --accent-soft: rgba(89, 111, 232, .1);
  --teal: #188f89;
  --success: #18845f;
  --warning: #a76812;
  --danger: #ca4256;
  --user: #eef2ff;
  --shadow: 0 24px 70px rgba(34, 48, 73, .12);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
button, textarea, select, input { color: inherit; font: inherit; }
button, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.app-page { height: 100dvh; overflow: hidden; }
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); height: 100%; min-height: 0; overflow: hidden; }

.sidebar {
  position: relative;
  z-index: 30;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  padding: 18px 14px 14px;
  background:
    radial-gradient(circle at 10% -10%, rgba(124, 140, 255, .13), transparent 34%),
    var(--sidebar);
  border-right: 1px solid var(--border);
}

.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 7px 20px; }
.brand-lockup { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand-lockup > span:last-child { display: grid; gap: 2px; }
.brand-lockup strong { font-size: .98rem; letter-spacing: -.02em; }
.brand-lockup small { color: var(--muted); font-size: .69rem; letter-spacing: .02em; }
.brand-mark {
  display: inline-grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border: 1px solid rgba(124, 140, 255, .52);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(124, 140, 255, .28), rgba(79, 209, 197, .08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 8px 22px rgba(73, 85, 190, .18);
  color: var(--accent-strong);
  font-weight: 800;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
}
.icon-button:hover { background: var(--panel-hover); border-color: var(--border); }
.mobile-only { display: none; }

.new-chat-button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border-bright);
  border-radius: 13px;
  background: linear-gradient(145deg, var(--panel-elevated), var(--panel));
  box-shadow: 0 8px 25px rgba(0, 0, 0, .08);
  text-align: left;
}
.new-chat-button:hover { border-color: var(--accent); background: var(--panel-hover); }
.new-chat-button svg { width: 18px; color: var(--accent-strong); }
.new-chat-button span { font-size: .86rem; font-weight: 650; }
.new-chat-button kbd { color: var(--faint); font: 600 .66rem/1 ui-monospace, monospace; }

.history-label { display: flex; justify-content: space-between; padding: 22px 8px 9px; color: var(--faint); font-size: .68rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.history-list { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-bright) transparent; }
.history-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; margin: 2px 0; border-radius: 12px; }
.history-row:hover, .history-row.active { background: var(--panel-elevated); }
.history-row.active::before { position: absolute; left: 0; width: 2px; height: 24px; border-radius: 2px; background: var(--accent); content: ""; }
.history-open, .history-delete { border: 0; background: transparent; }
.history-open { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px; min-width: 0; padding: 10px 5px 10px 10px; text-align: left; }
.history-icon { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 9px; color: var(--muted); }
.history-icon svg { width: 16px; }
.history-copy { display: grid; min-width: 0; gap: 4px; }
.history-copy strong { overflow: hidden; font-size: .79rem; font-weight: 580; text-overflow: ellipsis; white-space: nowrap; }
.history-copy small { display: flex; align-items: center; gap: 5px; overflow: hidden; color: var(--faint); font-size: .65rem; text-overflow: ellipsis; white-space: nowrap; }
.job-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.history-delete { display: grid; width: 32px; height: 32px; margin-right: 5px; padding: 0; place-items: center; border-radius: 8px; color: var(--faint); opacity: 0; }
.history-row:hover .history-delete, .history-delete:focus-visible { opacity: 1; }
.history-delete:hover { background: rgba(255, 126, 143, .1); color: var(--danger); }
.history-delete svg { width: 15px; }

.sidebar-footer { display: grid; gap: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-action { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-height: 39px; padding: 0 9px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; }
.sidebar-action:hover { background: var(--panel-elevated); color: var(--text); }
.sidebar-action svg { width: 17px; }
.sidebar-action span:last-child { color: var(--faint); font-size: .7rem; }
.private-badge { display: flex; align-items: center; gap: 7px; padding: 9px 10px 2px; color: var(--faint); font-size: .65rem; }
.private-badge span { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); }

.workspace { position: relative; min-width: 0; min-height: 0; height: 100%; overflow: hidden; display: grid; grid-template-rows: var(--topbar-height) minmax(0, 1fr) auto; background: var(--bg-soft); }
.workspace::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% -20%, rgba(124, 140, 255, .1), transparent 38%),
    linear-gradient(rgba(255, 255, 255, .012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .012) 1px, transparent 1px);
  background-size: auto, 36px 36px, 36px 36px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 65%);
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(16px);
}
.topbar-left, .topbar-tools { display: flex; align-items: center; gap: 12px; min-width: 0; }
.model-control { position: relative; display: grid; grid-template-columns: auto minmax(120px, 270px); align-items: center; gap: 9px; min-width: 0; }
.model-label { color: var(--faint); font-size: .67rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.model-button {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;
  background: var(--panel);
  font-size: .79rem;
  font-weight: 590;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.model-button:hover, .model-button:focus-visible { border-color: var(--accent); }
.model-button span { color: var(--muted); flex: none; }
.model-menu { position: absolute; z-index: 40; top: calc(100% + 9px); left: 40px; width: min(420px, calc(100vw - 32px)); padding: 12px; border: 1px solid var(--border-bright); border-radius: 15px; background: var(--panel); box-shadow: var(--shadow); }
.model-menu label { display: block; padding: 0 3px 8px; color: var(--muted); font-size: .75rem; }
.model-menu input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-bright); border-radius: 9px; outline: 0; background: var(--bg-soft); }
.model-menu input:focus { border-color: var(--accent); }
.model-options { max-height: min(52dvh, 390px); margin: 8px -4px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.model-option { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 2px 9px; padding: 10px 12px; border: 0; border-radius: 9px; background: transparent; text-align: left; }
.model-option strong { overflow-wrap: anywhere; font-size: .81rem; font-weight: 600; }
.model-option small { grid-column: 1; color: var(--faint); font-size: .68rem; overflow-wrap: anywhere; }
.model-option:hover, .model-option:focus-visible, .model-option.selected { background: var(--panel-hover); outline: 0; }
.model-loaded { grid-column: 2; grid-row: 1 / span 2; color: var(--success); font-size: .68rem; }
.model-check { grid-column: 3; grid-row: 1 / span 2; color: var(--accent-strong); }
.model-count, .model-empty { padding: 7px 4px 2px; color: var(--faint); font-size: .69rem; }

.search-toggle { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--muted); cursor: pointer; font-size: .73rem; font-weight: 600; }
.search-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.search-toggle svg { width: 15px; }
.toggle-track { display: flex; width: 26px; height: 15px; align-items: center; padding: 2px; border-radius: 20px; background: var(--border-bright); transition: background .18s ease; }
.toggle-track span { width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: transform .18s ease; }
.search-toggle input:checked + .toggle-track { background: var(--accent); }
.search-toggle input:checked + .toggle-track span { transform: translateX(11px); }
.search-toggle:has(input:checked) { border-color: rgba(124, 140, 255, .38); color: var(--accent-strong); }
.connection { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .68rem; }
.connection span { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px rgba(243, 188, 104, .09); }
.connection.online span { background: var(--success); box-shadow: 0 0 0 4px rgba(87, 201, 155, .09); }
.connection.sleeping span { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 126, 143, .09); }
.connection.reconnecting span { animation: pulse 1s ease infinite; }
.connection b { font-weight: 600; }

.chat-scroll { position: relative; z-index: 1; min-height: 0; overflow-y: scroll; overscroll-behavior-y: contain; scrollbar-width: auto; scrollbar-color: var(--border-bright) var(--bg-soft); }
.chat-scroll::-webkit-scrollbar { width: 11px; }
.chat-scroll::-webkit-scrollbar-track { background: var(--bg-soft); }
.chat-scroll::-webkit-scrollbar-thumb { border: 3px solid var(--bg-soft); border-radius: 12px; background: var(--border-bright); }
.messages { width: min(860px, calc(100% - 40px)); margin: 0 auto; padding: 35px 0 42px; }
.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 13px; padding: 20px 0; }
.message + .message { border-top: 1px solid color-mix(in srgb, var(--border) 62%, transparent); }
.message-rail { padding-top: 1px; }
.message-avatar { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--border-bright); border-radius: 10px; background: var(--panel-elevated); color: var(--accent-strong); font-size: .76rem; font-weight: 800; }
.message.user .message-avatar { border-color: rgba(79, 209, 197, .25); background: rgba(79, 209, 197, .08); color: var(--teal); }
.message-content { min-width: 0; }
.message-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-height: 30px; margin-bottom: 7px; }
.message-meta strong { font-size: .8rem; }
.model-pill, .search-pill { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 0 7px; border: 1px solid var(--border); border-radius: 20px; color: var(--muted); font-size: .61rem; font-weight: 650; }
.search-pill { border-color: rgba(124, 140, 255, .22); background: var(--accent-soft); color: var(--accent-strong); }
.search-pill svg { width: 11px; height: 11px; }
.message-body { overflow-wrap: anywhere; color: var(--text-soft); font-size: .93rem; line-height: 1.68; white-space: pre-wrap; }
.message.user .message-body { display: inline-block; max-width: min(100%, 710px); padding: 12px 15px; border: 1px solid rgba(124, 140, 255, .16); border-radius: 5px 15px 15px; background: var(--user); color: var(--text); }
.token-usage { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; color: var(--muted); font-size: .68rem; font-variant-numeric: tabular-nums; }
.token-metric { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); }
.token-metric strong { color: var(--text-soft); font-weight: 700; }

.rich-text { white-space: normal; }
.rich-text > :first-child { margin-top: 0; }
.rich-text > :last-child { margin-bottom: 0; }
.rich-text p { margin: 0 0 1em; }
.rich-text h1, .rich-text h2, .rich-text h3, .rich-text h4, .rich-text h5, .rich-text h6 { margin: 1.35em 0 .55em; color: var(--text); line-height: 1.25; letter-spacing: -.025em; }
.rich-text h1 { font-size: 1.55rem; }
.rich-text h2 { font-size: 1.3rem; }
.rich-text h3 { font-size: 1.1rem; }
.rich-text h4, .rich-text h5, .rich-text h6 { font-size: 1rem; }
.rich-text ul, .rich-text ol { margin: .65em 0 1em; padding-left: 1.45em; }
.rich-text li { margin: .25em 0; padding-left: .18em; }
.rich-text a { color: var(--accent-strong); text-decoration-color: rgba(124, 140, 255, .45); text-underline-offset: 3px; }
.rich-text a:hover { text-decoration-color: currentColor; }
.rich-text code { padding: .13em .36em; border: 1px solid var(--border); border-radius: 5px; background: var(--panel-elevated); color: #d4a7ff; font: .86em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:root[data-theme="light"] .rich-text code { color: #7b3ba8; }
.rich-text blockquote { margin: 1em 0; padding: .65em 1em; border-left: 3px solid var(--accent); border-radius: 0 9px 9px 0; background: var(--accent-soft); color: var(--text-soft); }
.rich-text hr { height: 1px; margin: 1.5em 0; border: 0; background: var(--border); }
.code-block { margin: 1.05em 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: #090d15; }
:root[data-theme="light"] .code-block { background: #172033; }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 10px 0 13px; border-bottom: 1px solid rgba(255, 255, 255, .08); color: #8490a3; font: 600 .65rem/1 ui-monospace, monospace; text-transform: lowercase; }
.code-head button { padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; color: #a8b1c1; font-size: .65rem; }
.code-head button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.code-block pre { margin: 0; padding: 15px 17px; overflow-x: auto; }
.code-block pre code { padding: 0; border: 0; background: transparent; color: #d8deea; font-size: .79rem; line-height: 1.65; white-space: pre; }
.table-wrap { margin: 1em 0; overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; }
.rich-text table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.rich-text th, .rich-text td { padding: 9px 11px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.rich-text th { background: var(--panel-elevated); color: var(--text); font-size: .72rem; }
.rich-text tr:last-child td { border-bottom: 0; }
.rich-text th:last-child, .rich-text td:last-child { border-right: 0; }

.message-files { display: flex; flex-wrap: wrap; gap: 7px; margin: 1px 0 9px; }
.message-file { display: inline-flex; align-items: center; gap: 6px; max-width: 250px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--muted); font-size: .68rem; }
.message-file svg { width: 13px; flex: none; }
.message-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-label { margin-top: 9px; color: var(--muted); font-size: .7rem; }
.pending-label::before { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); content: ""; animation: pulse 1.2s ease infinite; }
.message-failure { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 10px; border: 1px solid rgba(255, 126, 143, .2); border-radius: 9px; background: rgba(255, 126, 143, .07); color: var(--danger); font-size: .7rem; }
.message-failure svg { width: 14px; flex: none; }
.message-failure span { flex: 1; }
.message-failure button { padding: 5px 9px; border: 1px solid rgba(255, 126, 143, .28); border-radius: 7px; background: transparent; color: var(--danger); font-size: .68rem; font-weight: 700; }

.sources { margin-top: 18px; padding-top: 13px; border-top: 1px solid var(--border); }
.sources-title { margin-bottom: 9px; color: var(--faint); font-size: .66rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.source-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 7px; }
.source-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; min-width: 0; padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text-soft); text-decoration: none; }
.source-card:hover { border-color: var(--border-bright); background: var(--panel-elevated); }
.source-number { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent-strong); font-size: .64rem; font-weight: 750; }
.source-copy { display: grid; min-width: 0; gap: 2px; }
.source-copy strong, .source-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-copy strong { font-size: .69rem; }
.source-copy small { color: var(--faint); font-size: .6rem; }
.source-card > svg { width: 13px; color: var(--faint); }

.welcome { width: min(820px, calc(100% - 34px)); margin: 0 auto; padding: clamp(50px, 10vh, 110px) 0 40px; text-align: center; }
.welcome-symbol { position: relative; display: grid; width: 69px; height: 69px; margin: 0 auto 23px; place-items: center; border: 1px solid rgba(124, 140, 255, .34); border-radius: 23px; background: linear-gradient(145deg, rgba(124, 140, 255, .22), rgba(79, 209, 197, .06)); box-shadow: 0 20px 55px rgba(83, 96, 210, .14), inset 0 1px rgba(255, 255, 255, .13); }
.welcome-symbol::before, .welcome-symbol::after { position: absolute; border: 1px solid rgba(124, 140, 255, .12); border-radius: 28px; content: ""; }
.welcome-symbol::before { inset: -10px; }
.welcome-symbol::after { inset: -20px; opacity: .55; }
.welcome-symbol span { color: var(--accent-strong); font-size: 1.65rem; font-weight: 850; }
.eyebrow { margin: 0 0 9px; color: var(--accent-strong); font-size: .67rem; font-weight: 800; letter-spacing: .16em; }
.welcome h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.55rem); letter-spacing: -.055em; }
.welcome-copy { max-width: 610px; margin: 14px auto 30px; color: var(--muted); font-size: .88rem; line-height: 1.65; }
.suggestion-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.suggestion-grid button { display: grid; gap: 6px; min-height: 94px; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(145deg, var(--panel), color-mix(in srgb, var(--panel-elevated) 70%, transparent)); text-align: left; }
.suggestion-grid button:hover { transform: translateY(-1px); border-color: var(--border-bright); box-shadow: 0 10px 30px rgba(0, 0, 0, .08); }
.suggestion-grid span { font-size: .8rem; font-weight: 670; }
.suggestion-grid small { color: var(--muted); font-size: .68rem; line-height: 1.45; }

.composer-zone { position: relative; z-index: 10; padding: 0 max(18px, env(safe-area-inset-right)) calc(13px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: linear-gradient(to top, var(--bg-soft) 78%, transparent); }
.composer-zone > * { width: min(860px, 100%); margin-right: auto; margin-left: auto; }
.activity { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin-bottom: 6px; padding: 0 9px; color: var(--muted); font-size: .7rem; }
.activity-copy { display: flex; align-items: center; gap: 8px; }
.activity-spinner { width: 13px; height: 13px; border: 2px solid var(--border-bright); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.activity button { padding: 5px 10px; border: 1px solid rgba(255, 126, 143, .23); border-radius: 8px; background: rgba(255, 126, 143, .07); color: var(--danger); font-size: .68rem; font-weight: 680; }

.file-tray { display: flex; gap: 8px; margin-bottom: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.file-card { display: grid; grid-template-columns: auto minmax(110px, 1fr) auto; align-items: center; gap: 8px; min-width: 225px; max-width: 285px; padding: 8px; border: 1px solid var(--border); border-radius: 11px; background: var(--glass); backdrop-filter: blur(12px); }
.file-card.processing { border-color: rgba(243, 188, 104, .25); }
.file-card.error { border-color: rgba(255, 126, 143, .3); }
.file-symbol { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent-strong); }
.file-card.processing .file-symbol { background: rgba(243, 188, 104, .1); color: var(--warning); }
.file-card.error .file-symbol { background: rgba(255, 126, 143, .1); color: var(--danger); }
.file-symbol svg { width: 16px; }
.file-copy { display: grid; min-width: 0; gap: 3px; }
.file-copy strong, .file-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-copy strong { font-size: .7rem; }
.file-copy small { color: var(--muted); font-size: .6rem; }
.file-remove { display: grid; width: 27px; height: 27px; padding: 0; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--faint); }
.file-remove:hover { background: rgba(255, 126, 143, .09); color: var(--danger); }
.file-remove svg { width: 13px; }

.composer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 8px; border: 1px solid var(--border-bright); border-radius: 17px; background: var(--glass); box-shadow: var(--shadow); backdrop-filter: blur(18px); transition: border-color .18s ease, box-shadow .18s ease; }
.composer:focus-within, .composer.dragging { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.composer-tool, .send-button { display: grid; width: 39px; height: 39px; padding: 0; place-items: center; border-radius: 11px; }
.composer-tool { border: 0; background: transparent; color: var(--muted); }
.composer-tool:hover { background: var(--panel-hover); color: var(--text); }
.composer-tool svg { width: 19px; }
.composer textarea { width: 100%; min-height: 39px; max-height: 180px; padding: 9px 3px 7px; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.45; }
.composer textarea::placeholder { color: var(--faint); }
.send-button { border: 1px solid rgba(124, 140, 255, .32); background: linear-gradient(145deg, var(--accent), #6878e8); color: white; box-shadow: 0 7px 18px rgba(79, 93, 210, .25); }
.send-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.send-button svg { width: 18px; }
.composer-hint { display: flex; justify-content: space-between; padding: 7px 7px 0; color: var(--faint); font-size: .6rem; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 20px; display: grid; width: min(360px, calc(100% - 36px)); gap: 8px; pointer-events: none; }
.toast { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 9px; padding: 11px 12px; border: 1px solid var(--border-bright); border-radius: 12px; background: var(--glass); box-shadow: var(--shadow); color: var(--text-soft); backdrop-filter: blur(18px); font-size: .72rem; line-height: 1.45; animation: toast-in .2s ease; }
.toast svg { width: 15px; color: var(--accent-strong); }
.toast.error { border-color: rgba(255, 126, 143, .34); }
.toast.error svg { color: var(--danger); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 960px) {
  :root { --sidebar-width: 260px; }
  .connection b { display: none; }
  .model-control { grid-template-columns: minmax(120px, 230px); }
  .model-label { display: none; }
  .model-menu { left: 0; }
}

@media (max-width: 760px) {
  .mobile-only { display: inline-grid; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 310px); transform: translateX(-104%); box-shadow: 24px 0 70px rgba(0, 0, 0, .28); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; z-index: 25; inset: 0; background: rgba(2, 5, 10, .62); backdrop-filter: blur(2px); }
  .topbar { padding: 0 13px; }
  .topbar-left { flex: 1; }
  .model-control { flex: 1; grid-template-columns: minmax(0, 1fr); }
  .model-button { max-width: 260px; }
  .search-toggle > span:last-child { display: none; }
  .connection { display: none; }
  .messages { width: min(100% - 26px, 760px); padding-top: 20px; }
  .message { grid-template-columns: 29px minmax(0, 1fr); gap: 9px; padding: 17px 0; }
  .message-avatar { width: 27px; height: 27px; border-radius: 8px; font-size: .69rem; }
  .composer-zone { padding-right: 10px; padding-left: 10px; }
  .welcome { padding-top: 54px; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .suggestion-grid button { min-height: 72px; }
}

@media (max-width: 440px) {
  :root { --topbar-height: 61px; }
  .topbar { gap: 7px; padding: 0 8px; }
  .topbar-left, .topbar-tools { gap: 5px; }
  .icon-button { width: 36px; height: 36px; }
  .model-button { height: 36px; max-width: 190px; font-size: .71rem; }
  .search-toggle { width: 38px; height: 36px; justify-content: center; padding: 0; }
  .search-toggle svg { display: none; }
  .toggle-track { width: 25px; }
  .messages { width: calc(100% - 18px); }
  .message-body { font-size: .87rem; }
  .message.user .message-body { padding: 10px 12px; }
  .welcome { width: calc(100% - 24px); padding-top: 45px; }
  .welcome-symbol { width: 58px; height: 58px; border-radius: 19px; }
  .welcome-copy { margin-bottom: 22px; font-size: .8rem; }
  .suggestion-grid button:nth-child(n+3) { display: none; }
  .composer { gap: 4px; padding: 6px; border-radius: 15px; }
  .composer-tool, .send-button { width: 37px; height: 37px; }
  .composer textarea { min-height: 37px; padding-top: 8px; font-size: .9rem; }
  .composer-hint span:first-child { display: none; }
  .composer-hint { justify-content: flex-end; }
  .file-card { min-width: 205px; }
  .source-list { grid-template-columns: 1fr; }
  .toast-region { right: 10px; bottom: 10px; width: calc(100% - 20px); }
}

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