:root {
  --app-h: 100vh;
  --bg: #edf3f8;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, .82);
  --fg: #1e2c38;
  --muted: #627487;
  --line: #d7e2eb;
  --line-strong: #bdcedb;
  --accent: #d7e9f7;
  --accent-hover: #c6def0;
  --accent-active: #b2d2e8;
  --accent-fg: #17384f;
  --accent-strong: #356f96;
  --strong-fg: #ffffff;
  --bubble: #f2f6f9;
  --user-bubble: #dcecf7;
  --thought-bg: #f3f7fa;
  --thought-line: #d7e2eb;
  --code-bg: #f1f5f8;
  --danger: #b44552;
  --danger-bg: #fbeaed;
  --overlay: rgba(26, 42, 55, .32);
  --shadow: 0 16px 44px rgba(41, 63, 80, .09);
  --control-h: 40px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #111922;
  --panel: #1a2430;
  --panel-soft: rgba(26, 36, 48, .9);
  --fg: #e4edf5;
  --muted: #a4b4c3;
  --line: #2d3b49;
  --line-strong: #415466;
  --accent: #abcfe8;
  --accent-hover: #c1ddef;
  --accent-active: #96bdd8;
  --accent-fg: #122b3d;
  --accent-strong: #b1d5ec;
  --strong-fg: #122b3d;
  --bubble: #222f3b;
  --user-bubble: #29465a;
  --thought-bg: #202d38;
  --thought-line: #344654;
  --code-bg: #151f29;
  --danger: #f1a6b0;
  --danger-bg: #3c2730;
  --overlay: rgba(0, 0, 0, .52);
  --shadow: 0 18px 48px rgba(0, 0, 0, .28);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; max-width: 100%; overflow-x: hidden; }
body { background: var(--bg); color: var(--fg); font: 15px/1.65 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; overscroll-behavior-y: none; }
button { min-height: var(--control-h); font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: 8px 13px; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; }
button:hover { background: var(--bubble); border-color: var(--line-strong); }
button:active { background: var(--accent-active); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .button-like { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.primary:hover, .button-like:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:active, .button-like:active { background: var(--accent-active); }
button.text { border-color: transparent; background: transparent; color: var(--muted); padding: 7px 9px; }
button.text:hover { background: var(--bubble); color: var(--fg); border-color: transparent; }
button.icon { width: var(--control-h); height: var(--control-h); min-height: var(--control-h); padding: 0; display: inline-grid; place-items: center; flex: none; border-color: transparent; background: transparent; color: var(--muted); }
button.icon:hover { background: var(--bubble); color: var(--fg); }
button.block { width: 100%; }
button.danger-text { color: var(--danger); }
input, textarea, select { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0; }
input, select { min-height: var(--control-h); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .82; }
input:focus, textarea:focus, select:focus { border-color: var(--accent-strong); }
a { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent-strong); color: var(--strong-fg); padding: 6px 12px; border-radius: 8px; z-index: 50; }
.skip-link:focus { left: 8px; }
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 120px; width: auto; }
.shortcut-list { display: grid; gap: 8px; margin: 0; }
.shortcut-list > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.shortcut-list dt { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.shortcut-list dd { margin: 0; color: var(--muted); font-size: 13px; }
.login-wrap { min-height: 100vh; min-height: var(--app-h); display: grid; place-items: center; padding: 24px; background: var(--bg); }
.card { width: min(420px, 100%); display: grid; gap: 14px; border: 1px solid var(--line); border-radius: 18px; padding: 30px; background: var(--panel-soft); box-shadow: var(--shadow); }
.card h1 { margin: 0; font-size: 19px; font-weight: 600; }
.card label { display: grid; gap: 7px; font-size: 13px; color: var(--muted); }
.login-card { padding: 34px; gap: 16px; }
.login-brand { color: var(--accent-strong); font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -.045em; }
.login-card #submit { width: 100%; margin-top: 4px; }
.login-card #switch { justify-self: center; }
.login-content { width: min(440px, 100%); }
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: 100vh; min-width: 0; }
.sidebar { border-right: 1px solid var(--line); background: var(--panel-soft); padding: 14px 12px; display: flex; flex-direction: column; gap: 11px; min-height: 0; min-width: 0; }
.sidebar-head { display: grid; gap: 9px; }
.conversations { flex: 1; min-height: 0; overflow: auto; overflow-x: hidden; display: grid; gap: 4px; align-content: start; padding: 1px; }
.conv-row { display: flex; align-items: center; min-width: 0; border-radius: 10px; }
.conv-row:hover, .conv-row.menu-open { background: var(--bubble); }
.conv-row.active { background: var(--bubble); }
.conv { flex: 1; min-width: 0; min-height: 40px; text-align: left; border: 0; background: transparent; padding: 9px 4px 9px 10px; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv:hover, .conv.active { background: transparent; }
.conv.active { font-weight: 600; color: var(--accent-strong); }
.conv-menu-trigger { width: 34px; min-width: 34px; height: 36px; min-height: 36px; margin-right: 2px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); opacity: .68; }
.conv-menu-trigger svg { width: 18px; height: 18px; fill: currentColor; }
.conv-menu-trigger:hover, .conv-menu-trigger:focus-visible, .conv-menu-trigger[aria-expanded="true"] { color: var(--accent-strong); background: var(--accent); opacity: 1; }
.conv-row.active .conv-menu-trigger { color: var(--accent-strong); opacity: 1; }
.conv-menu { position: fixed; z-index: 1200; display: grid; gap: 2px; min-width: 136px; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.conv-menu button { width: 100%; min-height: 38px; border: 0; background: transparent; text-align: left; padding: 8px 11px; }
.conv-menu button:hover, .conv-menu button:focus-visible { background: var(--bubble); }
.me { border-top: 1px solid var(--line); padding-top: 11px; display: grid; gap: 11px; }
.me-row { display: flex; justify-content: flex-start; gap: 8px; min-height: 20px; padding: 0 8px; font-size: 13px; color: var(--muted); }
.sidebar-label { margin: 0; padding: 0 8px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.sidebar-group { display: grid; gap: 4px; }
.me-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
.me-actions .text { display: inline-flex; align-items: center; min-width: 0; min-height: 36px; padding: 7px 9px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 12px; white-space: nowrap; }
.me-actions .text:hover { background: var(--bubble); color: var(--fg); }
.badge { background: var(--accent); color: var(--accent-fg); border-radius: 999px; font-size: 10px; padding: 0 5px; margin-left: 4px; }
.model-note { margin: 3px 0 0; padding: 9px 10px; border-radius: 9px; background: #314b5f; color: rgba(255, 255, 255, .88); font-size: 10px; line-height: 1.55; letter-spacing: .01em; overflow-wrap: anywhere; }
[data-theme="dark"] .model-note { background: #0d161e; color: rgba(255, 255, 255, .86); }
.usage-notice { padding: 0 8px; color: var(--muted); font-size: 10px; line-height: 1.65; }
.usage-notice summary { min-height: 24px; cursor: pointer; color: var(--muted); font-size: 11px; }
.usage-notice summary:hover { color: var(--fg); }
.usage-notice p { max-height: 190px; overflow: auto; margin: 5px 0 0; overflow-wrap: anywhere; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 18px; border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.conv-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.busy-indicator { color: var(--muted); font-size: 12px; white-space: nowrap; }
#model-select { width: auto; max-width: 180px; padding: 6px 9px; font-size: 13px; }
#menu { display: none; }
.messages { flex: 1; min-width: 0; overflow: auto; overflow-x: hidden; padding: 26px clamp(16px, 5vw, 72px); display: grid; grid-template-columns: minmax(0, 860px); justify-content: center; gap: 20px; align-content: start; }
.msg { min-width: 0; max-width: 100%; justify-self: start; }
.msg.assistant { width: 100%; }
.msg.user { justify-self: end; max-width: min(82%, 640px); }
.msg .bubble, .msg .response { min-width: 0; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user-bubble); padding: 10px 15px; border: 1px solid rgba(98, 116, 135, .08); border-radius: 15px 15px 5px 15px; white-space: pre-wrap; }
.msg.assistant .bubble { max-width: 100%; }
.msg.assistant .bubble.streaming.has-response::after { content: ''; display: inline-block; width: 1px; height: 1em; margin-left: 4px; vertical-align: -.12em; background: var(--muted); animation: blink 1.15s steps(2) infinite; }
.typing-dots { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: typing-bounce 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: .16s; }
.typing-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.msg-actions { display: flex; gap: 4px; margin-top: 5px; opacity: .58; transition: opacity .15s; flex-wrap: wrap; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions button { min-height: 32px; font-size: 12px; padding: 4px 8px; border-color: transparent; background: transparent; color: var(--muted); }
.msg-actions button:hover { background: var(--bubble); color: var(--fg); }
.versions { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; }
.versions .hint { font-size: 11px; }
.version-note { margin: 6px 0 0; }
.thought { background: transparent; border: 0; padding: 0; margin: 0 0 8px; font-size: 13px; color: inherit; }
.thought > div { max-height: 320px; overflow: auto; padding-top: 6px; }
.thought summary { cursor: pointer; color: inherit; }
.thought summary::marker { color: inherit; }
.tool { display: inline-block; background: var(--bubble); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.annotations { display: grid; gap: 6px; margin-top: 8px; }
.annotation { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: 12px; background: var(--bubble); border-radius: 10px; padding: 4px 7px; color: var(--muted); }
.annotation button { border: 0; background: transparent; color: var(--muted); padding: 4px 7px; font-size: 12px; }
.annotation .annotation-view { color: var(--fg); text-align: left; }
#annotate-quote { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; margin: 0; padding: 8px 12px; border-left: 3px solid var(--line); }
.load-older { align-self: center; margin: 10px auto 0; }
.sidebar-overlay { display: none; }
.assets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; justify-content: flex-end; }
.asset-chip { font-size: 12px; background: var(--bubble); border: 1px solid var(--line); border-radius: 9px; padding: 4px 9px; text-decoration: none; color: var(--fg); display: inline-flex; gap: 6px; align-items: center; }
.asset-chip button { border: 0; background: transparent; color: var(--muted); padding: 0 2px; }
.response > :first-child, .thought > div > :first-child, .writing-body > :first-child { margin-top: 0; }
.response > :last-child { margin-bottom: 0; }
.response h1, .response h2, .response h3, .response h4 { margin: 14px 0 8px; line-height: 1.35; }
.response h1 { font-size: 20px; }
.response h2 { font-size: 18px; }
.response h3 { font-size: 16px; }
.response p { margin: 8px 0; }
.response ul, .response ol { margin: 8px 0; padding-left: 22px; }
.response blockquote { margin: 10px 0; padding: 6px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.response hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.response code { background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; word-break: break-word; }
.response a { word-break: break-all; }
.table-wrap { overflow: auto; margin: 10px 0; }
.table-wrap table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.table-wrap th, .table-wrap td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.code-block { min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 10px 0; background: var(--code-bg); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 11px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.code-head button, .writing-head button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 3px 7px; }
.code-block pre { margin: 0; padding: 12px 14px; overflow: auto; }
.code-block pre code { background: transparent; border: 0; padding: 0; }
.code-block pre.nowrap { white-space: pre; overflow-x: auto; }
.writing-card { border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; background: var(--panel); overflow: hidden; }
.writing-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--bubble); font-size: 13px; }
.writing-title { font-weight: 600; }
.writing-body { margin: 0; padding: 12px 14px; white-space: pre-wrap; font-family: inherit; }
.composer { border-top: 1px solid var(--line); padding: 12px clamp(14px, 5vw, 72px); background: var(--panel-soft); }
.composer-row { display: flex; gap: 7px; align-items: flex-end; width: min(860px, 100%); min-width: 0; margin: 0 auto; }
.composer textarea { flex: 1; min-width: 0; width: auto; resize: none; max-height: 180px; min-height: var(--control-h); line-height: 1.5; }
.send, .stop { width: var(--control-h); height: var(--control-h); min-height: var(--control-h); padding: 0; flex: none; font-size: 16px; }
.stop { background: var(--danger); border-color: var(--danger); color: var(--panel); }
#mic svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#mic.recording { color: var(--danger); background: var(--danger-bg); }
.attachments { display: flex; gap: 6px; flex-wrap: wrap; width: min(860px, 100%); margin: 0 auto 7px; }
.attachments:empty { display: none; }
.status { width: min(860px, 100%); margin: 6px auto 0; min-height: 16px; font-size: 12px; color: var(--muted); }
dialog.sheet { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--panel); color: var(--fg); width: min(620px, 94vw); max-width: calc(100vw - 24px); box-shadow: var(--shadow); }
dialog.sheet::backdrop { background: var(--overlay); }
.sheet-content { padding: 20px; display: grid; gap: 13px; max-height: 82vh; overflow: auto; }
.sheet-content h2 { margin: 0; font-size: 17px; }
.sheet-content h3 { margin: 4px 0; font-size: 13px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.button-like { display: inline-block; text-align: center; text-decoration: none; padding: 9px 14px; border: 1px solid var(--accent); border-radius: 10px; }
.usage-segments { display: flex; gap: 6px; flex-wrap: wrap; }
.usage-segments button { font-size: 13px; padding: 6px 11px; }
.usage-segments button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.usage-overview { display: flex; gap: 18px; justify-content: space-between; flex-wrap: wrap; align-items: center; }
.usage-cost { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.usage-metrics { display: flex; gap: 16px; margin: 0; flex-wrap: wrap; }
.usage-metrics dt { font-size: 12px; color: var(--muted); }
.usage-metrics dd { margin: 0; font-size: 15px; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.usage-table th, .usage-table td { text-align: left; padding: 8px 7px; border-bottom: 1px solid var(--line); }
.list { display: grid; gap: 7px; max-height: 280px; overflow: auto; }
.list-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font-size: 13px; }
.list-row span { color: var(--muted); flex: 1; min-width: 120px; }
.list-row.unread { border-color: var(--accent-strong); }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.theme-swatch { display: flex; align-items: center; gap: 9px; justify-content: flex-start; }
.theme-swatch[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.theme-swatch span { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-strong); display: inline-block; flex: none; }
.sw-light { background: #edf3f8; }
.sw-dark { background: #1a2430; }
.preview-body { min-height: 120px; max-height: 60vh; overflow: auto; }
#browser-shot img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); margin-top: 8px; }
.preview-image { max-width: 100%; border-radius: 10px; }
.preview-frame { width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: 10px; }
.preview-text { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.editor-preview { border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 46vh; overflow: auto; margin-top: 8px; }
#editor-dialog textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.link-row { display: flex; gap: 8px; width: 100%; justify-content: space-between; text-align: left; }
.file-dir { font-size: 11px; color: var(--muted); margin: 8px 0 2px; padding-left: 2px; border-bottom: 1px dashed var(--line); }
.file-row { margin-left: 10px; }
.file-row b { font-weight: 500; }
dialog.wide { width: min(880px, 96vw); }
.wb-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; }
.ws-list { display: grid; gap: 4px; max-height: 340px; overflow: auto; }
.ws-item { display: grid; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 9px; border: 1px solid transparent; background: transparent; }
.ws-item:hover { background: var(--bubble); }
.ws-item.active { border-color: var(--accent-strong); background: var(--bubble); }
.ws-item b { font-size: 13px; }
.ws-item .hint { font-size: 11px; }
.messages, .conversations, .list, .ws-list, .sheet-content { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.dialog-fallback { position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); margin: 0 !important; z-index: 1000; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
html.dialog-open::after { content: ''; position: fixed; inset: 0; background: var(--overlay); z-index: 999; }
.compat-warn { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 2000; background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
@supports (height: 100dvh) { :root { --app-h: 100dvh; } }
html, body, .app { height: var(--app-h); }
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: 310px; z-index: 20; transform: translateX(-102%); transition: transform .18s; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 15; border: 0; border-radius: 0; padding: 0; background: var(--overlay); }
  #menu { display: inline-grid; }
  .topbar { padding-left: 10px; padding-right: 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .messages, .composer { padding-left: 12px; padding-right: 12px; }
  .messages { padding-top: 18px; }
  .msg.user { max-width: 92%; }
  .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .sidebar { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  input, textarea, select { font-size: 16px; }
  .wb-grid { grid-template-columns: minmax(0, 1fr); }
  .login-card { padding: 26px 22px; }
}
@media (max-width: 420px) {
  .topbar { gap: 7px; }
  .conv-title { font-size: 13px; }
  .busy-indicator { font-size: 11px; }
  .composer-row { gap: 5px; }
  .theme-grid { gap: 7px; }
}
@media (pointer: coarse) {
  button, .conv, .asset-chip { min-height: 44px; }
  button.icon, .send, .stop { width: 44px; height: 44px; min-height: 44px; }
  .composer textarea { min-height: 44px; }
  .me-actions .text, .conv-menu button { min-height: 44px; }
  .conv-menu-trigger { width: 40px; min-width: 40px; min-height: 42px; }
  .msg-actions { opacity: 1; }
  .msg-actions button { min-height: 40px; padding: 5px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
