:root {
  color-scheme: light;
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  font-synthesis: none;
  --chat-max-width: 780px;

  --paper: #ffffff;
  --panel: #f7f8fa;
  --white: #ffffff;
  --surface-elevated: #ffffff;
  --surface-muted: #f0f2f6;
  --surface-hover: #eaeef4;
  --surface-active: #e2e8f1;
  --line: #e8eaef;
  --input-border: #d7dce5;
  --muted: #666c78;
  --ink: #111318;
  --placeholder: #858c99;
  --error: #b91c1c;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --backdrop: #09090b66;
  --user-bubble: #eef2f8;
  --code-bg: #f6f7f9;
  --inline-code-bg: #eef0f4;
  --table-head: #f5f7fa;
  --table-border: #e1e5ec;
  --drop-bg: #fffffff0;
  --scrollbar-track: #ffffff;
  --scrollbar-thumb: #cfd5df;
  --badge-low-bg: #ecfdf5;
  --badge-low-ink: #065f46;
  --badge-mid-bg: #eff6ff;
  --badge-mid-ink: #1d4ed8;
  --badge-high-bg: #fff7ed;
  --badge-high-ink: #9a3412;
  --shadow-soft: 0 2px 14px #0b12200c, 0 1px 3px #0b122008;
  --shadow-card: 0 12px 40px #0b122014;
  --shadow-dialog: 0 24px 72px #0b122026;
  --green: #18181b;
  --accent-solid: #18181b;
  --accent-hover: #2c2c34;
  --accent-ink: #ffffff;
  --brand-gemini: #1a73e8;
  --brand-gemini-soft: #e8f0fe;
  --brand-gemini-border: #bfd6fb;
  --brand-gemini-grad: linear-gradient(110deg, #1a73e8 0%, #4f46e5 52%, #7c3aed 100%);
  --wash: #f1f3f7;
  --wash-border: #d5dbe6;
  --focus-ring: #3b82f6;
  --pill-bg: #f0f2f6;
  --pill-border: #e2e6ee;
  --pill-active-bg: #ffffff;
  --pill-active-border: #cfd6e3;

  color: var(--ink);
  background: var(--paper);
  accent-color: var(--accent-solid);
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

:root[data-provider="google"] {
  --green: var(--brand-gemini);
  --accent-solid: #1a73e8;
  --accent-hover: #155ec2;
  --accent-ink: #ffffff;
  --wash: var(--brand-gemini-soft);
  --wash-border: var(--brand-gemini-border);
  --focus-ring: #1a73e8;
}

:root[data-provider="openai"] {
  --green: #18181b;
  --accent-solid: #18181b;
  --accent-hover: #2c2c34;
  --accent-ink: #ffffff;
  --wash: #f2f2f5;
  --wash-border: #d6d6de;
  --focus-ring: #3f3f46;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-contrast="strong"] {
  --panel: #f1f2f6;
  --surface-muted: #e5e7ef;
  --line: #c4c8d4;
  --input-border: #969caa;
  --muted: #454954;
  --ink: #000000;
  --table-border: #b4b9c6;
  --green: #000000;
  --accent-solid: #000000;
  --accent-hover: #1f1f24;
  --brand-gemini: #0b57d0;
  --brand-gemini-soft: #dce8fc;
  --brand-gemini-border: #7caaf7;
  --wash: #e8ebf2;
  --wash-border: #a8b0c0;
  --focus-ring: #000000;
  --pill-bg: #e6e8ef;
  --pill-border: #aeb5c4;
  --pill-active-bg: #ffffff;
  --pill-active-border: #687082;
}

:root[data-contrast="strong"][data-provider="google"] {
  --green: #0b57d0;
  --accent-solid: #0b57d0;
  --accent-hover: #0842a0;
  --wash: #dce8fc;
  --wash-border: #7caaf7;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0a0b0e;
  --panel: #101217;
  --white: #15181f;
  --surface-elevated: #13161d;
  --surface-muted: #181c24;
  --surface-hover: #212632;
  --surface-active: #282e3d;
  --line: #232834;
  --input-border: #2f3646;
  --muted: #939bab;
  --ink: #f3f5fa;
  --placeholder: #737b8c;
  --error: #f87171;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --backdrop: #000000c8;
  --user-bubble: #1b202b;
  --code-bg: #0e1016;
  --inline-code-bg: #1e232e;
  --table-head: #151922;
  --table-border: #262c38;
  --drop-bg: #0a0b0eed;
  --scrollbar-track: #0a0b0e;
  --scrollbar-thumb: #333a4a;
  --badge-low-bg: #102a1f;
  --badge-low-ink: #6ee7b7;
  --badge-mid-bg: #12233d;
  --badge-mid-ink: #93c5fd;
  --badge-high-bg: #321d12;
  --badge-high-ink: #fdba74;
  --shadow-soft: 0 4px 20px #00000066;
  --shadow-card: 0 16px 46px #000000a6;
  --shadow-dialog: 0 24px 80px #000000cc;
  --green: #f3f5fa;
  --accent-solid: #f3f5fa;
  --accent-hover: #d8deea;
  --accent-ink: #0a0b0e;
  --brand-gemini: #8ab4f8;
  --brand-gemini-soft: #172742;
  --brand-gemini-border: #2c4a7c;
  --brand-gemini-grad: linear-gradient(110deg, #8ab4f8 0%, #a5b4fc 54%, #c4b5fd 100%);
  --wash: #1d222e;
  --wash-border: #363e52;
  --focus-ring: #8ab4f8;
  --pill-bg: #13161e;
  --pill-border: #252b38;
  --pill-active-bg: #242a38;
  --pill-active-border: #434d63;
}

:root[data-theme="dark"][data-provider="google"] {
  --green: #8ab4f8;
  --accent-solid: #8ab4f8;
  --accent-hover: #aecbfa;
  --accent-ink: #071326;
  --wash: #172742;
  --wash-border: #2c4a7c;
  --focus-ring: #8ab4f8;
}

:root[data-theme="dark"][data-provider="openai"] {
  --green: #f4f4f6;
  --accent-solid: #f4f4f6;
  --accent-hover: #dcdce2;
  --accent-ink: #09090b;
  --wash: #1e2028;
  --wash-border: #3a3d4a;
  --focus-ring: #a1a1aa;
}

:root[data-theme="dark"][data-contrast="strong"] {
  --paper: #000000;
  --panel: #050608;
  --white: #0c0e13;
  --surface-elevated: #050608;
  --surface-muted: #12141b;
  --surface-hover: #1d202b;
  --surface-active: #292e3d;
  --line: #363b48;
  --input-border: #4c5263;
  --muted: #b7bdcc;
  --ink: #ffffff;
  --table-border: #404656;
  --green: #ffffff;
  --accent-solid: #ffffff;
  --accent-hover: #e4e4e7;
  --accent-ink: #000000;
  --brand-gemini: #a8c7fa;
  --brand-gemini-soft: #142b52;
  --brand-gemini-border: #5c8ee6;
  --wash: #1a1e28;
  --wash-border: #52596b;
  --focus-ring: #ffffff;
  --pill-bg: #0f1117;
  --pill-border: #3c4252;
  --pill-active-bg: #2a3040;
  --pill-active-border: #788299;
}

:root[data-theme="dark"][data-contrast="strong"][data-provider="google"] {
  --green: #a8c7fa;
  --accent-solid: #a8c7fa;
  --accent-hover: #d2e3fc;
  --accent-ink: #000000;
  --wash: #142b52;
  --wash-border: #5c8ee6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0a0b0e;
    --panel: #101217;
    --white: #15181f;
    --surface-elevated: #13161d;
    --surface-muted: #181c24;
    --surface-hover: #212632;
    --surface-active: #282e3d;
    --line: #232834;
    --input-border: #2f3646;
    --muted: #939bab;
    --ink: #f3f5fa;
    --placeholder: #737b8c;
    --error: #f87171;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --backdrop: #000000c8;
    --user-bubble: #1b202b;
    --code-bg: #0e1016;
    --inline-code-bg: #1e232e;
    --table-head: #151922;
    --table-border: #262c38;
    --drop-bg: #0a0b0eed;
    --scrollbar-track: #0a0b0e;
    --scrollbar-thumb: #333a4a;
    --badge-low-bg: #102a1f;
    --badge-low-ink: #6ee7b7;
    --badge-mid-bg: #12233d;
    --badge-mid-ink: #93c5fd;
    --badge-high-bg: #321d12;
    --badge-high-ink: #fdba74;
    --shadow-soft: 0 4px 20px #00000066;
    --shadow-card: 0 16px 46px #000000a6;
    --shadow-dialog: 0 24px 80px #000000cc;
    --green: #f3f5fa;
    --accent-solid: #f3f5fa;
    --accent-hover: #d8deea;
    --accent-ink: #0a0b0e;
    --brand-gemini: #8ab4f8;
    --brand-gemini-soft: #172742;
    --brand-gemini-border: #2c4a7c;
    --brand-gemini-grad: linear-gradient(110deg, #8ab4f8 0%, #a5b4fc 54%, #c4b5fd 100%);
    --wash: #1d222e;
    --wash-border: #363e52;
    --focus-ring: #8ab4f8;
    --pill-bg: #13161e;
    --pill-border: #252b38;
    --pill-active-bg: #242a38;
    --pill-active-border: #434d63;
  }

  :root:not([data-theme="light"])[data-provider="google"] {
    --green: #8ab4f8;
    --accent-solid: #8ab4f8;
    --accent-hover: #aecbfa;
    --accent-ink: #071326;
    --wash: #172742;
    --wash-border: #2c4a7c;
  }

  :root:not([data-theme="light"])[data-provider="openai"] {
    --green: #f4f4f6;
    --accent-solid: #f4f4f6;
    --accent-hover: #dcdce2;
    --accent-ink: #09090b;
    --wash: #1e2028;
    --wash-border: #3a3d4a;
    --focus-ring: #a1a1aa;
  }

  :root:not([data-theme="light"])[data-contrast="strong"] {
    --paper: #000000;
    --panel: #050608;
    --white: #0c0e13;
    --surface-elevated: #050608;
    --surface-muted: #12141b;
    --surface-hover: #1d202b;
    --surface-active: #292e3d;
    --line: #363b48;
    --input-border: #4c5263;
    --muted: #b7bdcc;
    --ink: #ffffff;
    --table-border: #404656;
    --green: #ffffff;
    --accent-solid: #ffffff;
    --accent-hover: #e4e4e7;
    --accent-ink: #000000;
    --brand-gemini: #a8c7fa;
    --brand-gemini-soft: #142b52;
    --brand-gemini-border: #5c8ee6;
    --wash: #1a1e28;
    --wash-border: #52596b;
    --focus-ring: #ffffff;
    --pill-bg: #0f1117;
    --pill-border: #3c4252;
    --pill-active-bg: #2a3040;
    --pill-active-border: #788299;
  }

  :root:not([data-theme="light"])[data-contrast="strong"][data-provider="google"] {
    --green: #a8c7fa;
    --accent-solid: #a8c7fa;
    --accent-hover: #d2e3fc;
    --accent-ink: #000000;
    --wash: #142b52;
    --wash-border: #5c8ee6;
  }
}

:root[data-font="google"] { font-family: "Google Sans", "Product Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
:root[data-font="system"] { font-family: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
:root[data-font="serif"] { font-family: "Source Serif 4", "Noto Serif SC", Georgia, "Songti SC", serif; }
:root[data-font-size="14"] { font-size: 14px; }
:root[data-font-size="16"] { font-size: 16px; }
:root[data-font-size="17"] { font-size: 17px; }
:root[data-chat-width="wide"] { --chat-max-width: 1060px; }
:root[data-chat-width="full"] { --chat-max-width: 94%; }
:root[data-hide-meta="1"] .message-meta { display: none; }
:root:not([data-role="admin"]) .admin-only-cost { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-block-size: 100dvh; color: var(--ink); background: var(--paper); }
button, input, textarea, select { font: inherit; }
button, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
button, h1, h2, h3, p { margin: 0; }
a { color: var(--green); }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { display: block; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Login */
.login-view {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 8%, var(--brand-gemini-soft) 0, transparent 58%), var(--paper);
}
.login-card { width: min(100%, 408px); padding: 36px; background: var(--white); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow-card); }
.login-brand { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; color: var(--brand-gemini); background: var(--brand-gemini-soft); border: 1px solid var(--brand-gemini-border); }
.login-brand .icon { width: 26px; height: 26px; }
.login-card h1 { margin: 18px 0 6px; font-size: 25px; font-weight: 660; letter-spacing: -.03em; }
.login-subtitle { margin-bottom: 22px; color: var(--muted); font-size: 13px; text-wrap: balance; }
.stack { display: grid; gap: 14px; }
.stack .button { justify-self: start; }
.login-card .button { justify-self: stretch; margin-top: 2px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 560; }
input, .settings-select { padding: 10px 11px; width: 100%; min-width: 0; min-height: 42px; color: var(--ink); background: var(--white); border: 1px solid var(--input-border); border-radius: 10px; }
input[type="checkbox"] { width: 16px; min-height: 16px; accent-color: var(--green); }
.form-error { color: var(--error); overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
.form-error[data-kind="success"] { color: var(--green); }
.button { padding: 9px 15px; min-height: 38px; color: var(--ink); background: var(--white); border: 1px solid var(--input-border); border-radius: 999px; font-size: 13.5px; font-weight: 580; transition: background .15s, border-color .15s; }
.button:hover:not(:disabled) { background: var(--surface-hover); }
.button.primary { color: var(--accent-ink); background: var(--accent-solid); border-color: var(--accent-solid); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.danger:hover:not(:disabled) { background: var(--danger-hover); }

/* Workspace & Sidebar (Gemini-style crisp rail) */
.workspace { height: 100dvh; display: grid; grid-template-columns: 268px minmax(0, 1fr); overflow: hidden; }
.workspace.sidebar-closed { grid-template-columns: minmax(0, 1fr); }
.workspace.sidebar-closed .sidebar { display: none; }
.sidebar { display: flex; flex-direction: column; padding: 14px 12px 10px; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.sidebar-head, .chat-head, .chat-head-start, .dialog-head, .dialog-foot { display: flex; align-items: center; }
.sidebar-head, .chat-head, .dialog-head { justify-content: space-between; }
.sidebar-head { gap: 8px; padding: 0 2px 14px 6px; }
.brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-size: 16px; font-weight: 660; letter-spacing: -.03em; }
.brand-glyph { display: grid; place-items: center; flex: none; width: 30px; height: 30px; color: var(--brand-gemini); border-radius: 10px; background: var(--brand-gemini-soft); border: 1px solid var(--brand-gemini-border); }
.brand-glyph .icon { width: 17px; height: 17px; }
.icon-button { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; transition: background .15s, color .15s; }
.icon-button:hover:not(:disabled) { color: var(--ink); background: var(--surface-hover); }
.new-chat { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--ink); background: var(--surface-muted); border: 1px solid transparent; border-radius: 999px; text-align: start; font-size: 14px; font-weight: 560; transition: background .15s, border-color .15s; }
.new-chat:hover:not(:disabled) { background: var(--surface-active); border-color: var(--line); }
.new-chat .icon { width: 18px; height: 18px; color: var(--green); }
.history { flex: 1; min-height: 0; margin-top: 20px; display: flex; flex-direction: column; }
.history h2 { color: var(--muted); font-size: 12px; font-weight: 600; padding: 0 12px 8px; }
.chat-list { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; align-content: start; }
.chat-row { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; overflow: hidden; padding: 9px 12px; text-align: start; font-size: 13.5px; color: var(--ink); background: transparent; border: 0; border-radius: 999px; transition: background .12s; }
.chat-row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.chat-row-dot { width: 14px; height: 14px; flex: none; color: var(--muted); opacity: .7; }
.chat-row-dot.is-google { color: var(--brand-gemini); opacity: .95; }
.chat-row:hover:not(:disabled) { background: var(--surface-hover); }
.chat-row[aria-current="true"] { background: var(--wash); font-weight: 600; color: var(--green); }
.chat-row:focus-visible { outline-offset: -2px; }
.empty-history { padding: 8px 12px; color: var(--muted); font-size: 13px; }
.sidebar-foot { padding-top: 8px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.sidebar-button, .account-button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--ink); text-align: start; transition: background .12s; }
.sidebar-button { min-height: 40px; font-size: 13.5px; }
.sidebar-button .icon, .account-chevron { color: var(--muted); }
.sidebar-button:hover, .account-button:hover { background: var(--surface-hover); }
.account-button { border-radius: 14px; margin-top: 2px; }
.avatar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; color: var(--green); background: var(--wash); border: 1px solid var(--wash-border); font-size: 14px; font-weight: 660; }
.account-label { display: grid; flex: 1; min-width: 0; gap: 2px; }
.account-label strong, .account-label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-label strong { font-size: 13px; font-weight: 630; }
.account-label span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.account-label span.account-quota-warn { color: var(--badge-high-ink); font-weight: 580; }
.account-chevron { width: 15px; height: 15px; }
.sidebar-backdrop, .open-sidebar { display: none; }
.sidebar-closed .open-sidebar { display: grid; }

/* Header */
.chat-main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--paper); }
.chat-head { flex: none; min-height: 60px; padding: 10px 18px; }
.chat-head-start { min-width: 0; gap: 10px; }
.chat-head-actions { display: flex; align-items: center; flex: none; gap: 4px; }

.provider-switch { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--pill-border); border-radius: 999px; background: var(--pill-bg); }
.provider-tab { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; min-height: 30px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 560; transition: background .15s, color .15s, border-color .15s, box-shadow .15s; }
.provider-tab .icon { width: 15px; height: 15px; }
.provider-tab:hover:not(:disabled):not([aria-selected="true"]) { color: var(--ink); }
.provider-tab[aria-selected="true"] { background: var(--pill-active-bg); border-color: var(--pill-active-border); color: var(--ink); font-weight: 620; box-shadow: var(--shadow-soft); }
.provider-tab[data-provider-tab="google"][aria-selected="true"] .icon { color: var(--brand-gemini); }
.mock-badge { padding: 3px 8px; border-radius: 999px; background: var(--wash); color: var(--green); font-size: 11px; font-weight: 600; white-space: nowrap; }

.quota-alert-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: min(calc(100% - 28px), var(--chat-max-width)); margin: 0 auto 8px; padding: 8px 10px 8px 14px; border: 1px solid var(--badge-high-ink); border-radius: 14px; background: var(--badge-high-bg); color: var(--badge-high-ink); font-size: 12.5px; line-height: 1.45; }
.quota-alert-banner .icon-button { width: 28px; height: 28px; color: inherit; }
.quota-alert-banner .icon { width: 15px; height: 15px; }
.quota-alert-card { padding: 12px 14px; border: 1px solid var(--badge-high-ink); border-radius: 14px; background: var(--badge-high-bg); color: var(--badge-high-ink); font-size: 13px; line-height: 1.55; }
.quota-alert-card strong { display: block; margin-bottom: 3px; font-size: 13.5px; }

/* Chat Surface & Official Gemini Empty Welcome Layout */
.chat-surface { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-surface.empty { justify-content: center; align-items: center; gap: 22px; padding: 16px 16px min(10dvh, 72px); }
.welcome { display: grid; justify-items: center; gap: 10px; max-width: 680px; text-align: center; }
.welcome-top { display: inline-flex; align-items: center; gap: 10px; }
.welcome-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; color: var(--green); background: var(--wash); border: 1px solid var(--wash-border); }
.welcome-icon .icon { width: 20px; height: 20px; }
.welcome-greeting { font-size: clamp(22px, 3.6vw, 30px); font-weight: 620; letter-spacing: -.03em; color: var(--ink); }
:root[data-provider="google"]:not([data-contrast="strong"]) .welcome-greeting {
  background: var(--brand-gemini-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome-heading { font-size: clamp(24px, 4.4vw, 36px); letter-spacing: -.04em; font-weight: 560; color: var(--ink); line-height: 1.2; }
.welcome-sub { color: var(--muted); font-size: 13.5px; line-height: 1.55; max-width: 560px; }

.welcome-prompts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 740px; }
.prompt-chip { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-elevated); color: var(--ink); font-size: 13px; transition: border-color .15s, background .15s, transform .15s; }
.prompt-chip:hover { border-color: var(--wash-border); background: var(--wash); color: var(--green); transform: translateY(-1px); }

/* Messages */
.messages-scroll { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.messages { display: flex; flex-direction: column; gap: 28px; max-width: var(--chat-max-width); margin: 0 auto; padding: 20px 22px 36px; }
.message { max-width: 100%; min-width: 0; }
.message-user { align-self: flex-end; max-width: min(86%, 700px); padding: 12px 17px; border-radius: 22px 22px 6px 22px; background: var(--user-bubble); }
.message-text { font-size: 1rem; line-height: 1.78; overflow-wrap: anywhere; }
.message-plain { white-space: pre-wrap; }
.message-assistant { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: start; column-gap: 12px; }
.message-mark { display: grid; place-items: center; grid-column: 1; width: 30px; height: 30px; color: var(--ink); border: 1px solid var(--line); background: var(--surface-elevated); border-radius: 50%; margin-top: 2px; }
.message-mark.is-google { color: var(--brand-gemini); border-color: var(--brand-gemini-border); background: var(--brand-gemini-soft); }
.message-mark.spinning .icon { animation: sparkle-pulse 1.8s ease-in-out infinite; }
.message-mark .icon { width: 17px; height: 17px; }
@keyframes sparkle-pulse { 0%, 100% { transform: scale(.92) rotate(0deg); opacity: .85; } 50% { transform: scale(1.1) rotate(45deg); opacity: 1; } }

.message-assistant > :not(.message-mark) { grid-column: 2; }
.message-assistant .message-text { min-height: 27px; }
.message-actions { display: flex; gap: 4px; margin: 8px 0 0 -6px; }
.message-actions .icon-button { width: 32px; height: 30px; }
.message-actions .icon { width: 16px; height: 16px; }

/* Gemini Official-style Collapsible Thinking Summary Drawer */
.thought-drawer { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; }
.thought-drawer summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 13px; cursor: pointer; font-size: 13px; font-weight: 580; color: var(--muted); user-select: none; }
.thought-drawer summary::-webkit-details-marker { display: none; }
.thought-drawer summary:hover { color: var(--ink); background: var(--surface-hover); }
.thought-drawer .thought-spark { width: 15px; height: 15px; color: var(--brand-gemini); flex: none; }
.thought-drawer .thought-caret { width: 15px; height: 15px; margin-inline-start: auto; transition: transform .18s ease; }
.thought-drawer[open] .thought-caret { transform: rotate(180deg); }
.thought-drawer.live .thought-spark { animation: sparkle-pulse 1.5s ease-in-out infinite; }
.thought-body { padding: 2px 14px 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow-y: auto; scrollbar-width: thin; }

/* Tool Activity Chips (Search queries & Fetched URLs) */
.tool-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.tool-chip { display: inline-flex; align-items: center; gap: 5px; max-width: min(36ch, 100%); padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-size: 11.5px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-chip .icon { width: 13px; height: 13px; color: var(--green); }
a.tool-chip:hover { border-color: var(--wash-border); background: var(--wash); color: var(--green); }

/* Sources Drawer (Grounding Citations) */
.sources-drawer { margin-top: 12px; }
.sources-drawer summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-muted); color: var(--ink); font-size: 12px; font-weight: 560; cursor: pointer; }
.sources-drawer summary::-webkit-details-marker { display: none; }
.sources-drawer summary:hover { border-color: var(--wash-border); background: var(--wash); color: var(--green); }
.sources-drawer summary .icon { width: 14px; height: 14px; color: var(--green); }
.sources-drawer[open] summary .sources-caret { transform: rotate(180deg); }
.sources-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.source-card { display: inline-flex; align-items: center; gap: 6px; max-width: min(34ch, 100%); padding: 5px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-elevated); color: var(--ink); font-size: 12px; text-decoration: none; transition: border-color .14s, background .14s; }
.source-card:hover { border-color: var(--wash-border); background: var(--wash); color: var(--green); }
.source-card-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-card-host { color: var(--muted); font-size: 11px; flex: none; }

/* Markdown Typography */
.message-text>p, .message-text>ul, .message-text>ol, .message-text>.code-block, .message-text>pre, .message-text>blockquote { margin: 0 0 .82em; }
.message-text>:last-child { margin-bottom: 0; }
.message-text :is(h2, h3, h4) { margin: .65em 0 .35em; font-size: 1.13em; font-weight: 650; }
.message-text :is(ul, ol) { padding-inline-start: 1.55em; }
.message-text blockquote { border-inline-start: 2px solid var(--wash-border); padding-inline-start: 12px; color: var(--muted); }
.message-text code { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace; font-size: .87em; }
.message-text :not(pre)>code { border-radius: 5px; padding: 2px 5px; background: var(--inline-code-bg); }
.message-text pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; overflow-x: auto; line-height: 1.55; }
.code-block { position: relative; }
.code-block pre { margin: 0; padding-top: 34px; }
.code-copy { position: absolute; top: 7px; right: 8px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--muted); font-size: 11px; font-weight: 560; }
.code-copy:hover { color: var(--ink); background: var(--surface-hover); }
.message-text a { text-underline-offset: 3px; }
.message-text a.citation { display: inline-block; max-width: min(32ch, 100%); vertical-align: baseline; margin: 0 3px; padding: 1px 7px; border: 1px solid var(--wash-border); border-radius: 999px; background: var(--wash); color: var(--green); text-decoration: none; font-size: 11px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-text a.citation:hover { text-decoration: underline; }
.message-meta { margin-top: 10px; color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; line-height: 1.45; }
.message-meta span+span::before { content: "·"; margin-inline-end: 8px; }
.message-files, .composer-files { display: flex; flex-wrap: wrap; gap: 6px; }
.message-files { margin-bottom: 8px; }
.message-files .attachment-chip { max-width: 100%; }
.attachment-chip { display: inline-flex; align-items: center; max-width: min(250px, 100%); min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-muted); overflow: hidden; }
.attachment-chip button { display: inline-flex; align-items: center; min-width: 0; min-height: 29px; gap: 5px; padding: 3px 8px; border: 0; background: transparent; color: var(--ink); text-align: start; font-size: 12px; }
.attachment-chip button:hover { background: var(--wash); color: var(--green); }
.attachment-chip button:focus-visible { outline-offset: -2px; }
.attachment-chip .icon { width: 14px; height: 14px; color: var(--green); }
.attachment-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attachment-chip .attachment-remove { color: var(--muted); padding: 3px 5px; }
.attachment-chip .attachment-remove .icon { color: inherit; }

.table-scroll { overflow-x: auto; margin: .6em 0 1em; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table :is(th, td) { min-width: 65px; padding: 7px 10px; border: 1px solid var(--table-border); text-align: start; vertical-align: top; overflow-wrap: anywhere; }
.data-table thead th, .preview-table tbody th { background: var(--table-head); color: var(--ink); font-weight: 640; }
.preview-table td { min-width: 86px; max-width: 240px; }
.preview-table :is(thead, tbody) th:first-child { min-width: 34px; }
.math-block { margin: .65em 0; padding: 4px; overflow-x: auto; }
.math-inline { white-space: nowrap; }
.pending { color: var(--muted); font-size: 14px; }

/* Official Gemini Floating Composer */
.composer-area { width: min(100%, var(--chat-max-width)); margin: 0 auto; padding: 0 20px max(18px, env(safe-area-inset-bottom)); }
.chat-surface.empty .composer-area { padding-bottom: 0; }
.chat-error { padding: 6px 6px 10px; }
.composer { position: relative; display: grid; gap: 6px; border: 1px solid var(--input-border); border-radius: 26px; padding: 12px 12px 10px 14px; background: var(--white); box-shadow: var(--shadow-soft); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--focus-ring); box-shadow: 0 6px 24px #0b122014; }
.composer textarea { width: 100%; min-width: 0; min-height: 40px; max-height: 185px; padding: 4px 4px 6px; border: 0; background: transparent; color: var(--ink); line-height: 1.55; outline: 0; resize: none; }
.composer textarea::placeholder { color: var(--placeholder); }
.composer textarea:focus-visible { outline: 0; }
.composer-files { padding: 2px 0 2px; }
.composer-active-tools { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 2px; }
.active-tool-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px 3px 9px; border: 1px solid var(--wash-border); border-radius: 999px; background: var(--wash); color: var(--green); font-size: 12px; font-weight: 560; }
.active-tool-pill .icon { width: 13px; height: 13px; }
.active-tool-remove { display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--green); }
.active-tool-remove:hover { background: var(--surface-active); }
.active-tool-remove .icon { width: 12px; height: 12px; }

.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.composer-left, .composer-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.popover-anchor { position: relative; }

.composer-icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); transition: background .15s, color .15s; }
.composer-icon-btn:hover:not(:disabled), .composer-icon-btn[aria-expanded="true"] { background: var(--surface-hover); color: var(--ink); }
.composer-pill-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 560; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.composer-pill-btn .icon { width: 16px; height: 16px; }
.composer-pill-btn:hover:not(:disabled), .composer-pill-btn[aria-expanded="true"] { background: var(--surface-hover); color: var(--ink); }
.composer-pill-btn.has-active { background: var(--wash); border-color: var(--wash-border); color: var(--green); }
.tools-badge { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px; background: var(--accent-solid); color: var(--accent-ink); font-size: 11px; font-weight: 660; }

.model-picker-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; max-width: min(300px, 46vw); padding: 0 11px 0 10px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 580; transition: background .15s, border-color .15s; }
.model-picker-btn:hover:not(:disabled), .model-picker-btn[aria-expanded="true"] { background: var(--surface-hover); border-color: var(--line); }
.picker-glyph { display: inline-grid; place-items: center; color: var(--green); }
.picker-glyph .icon { width: 15px; height: 15px; }
.picker-model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-sep { color: var(--muted); }
.picker-effort { color: var(--muted); font-size: 12px; font-weight: 540; white-space: nowrap; }
.picker-caret { width: 15px; height: 15px; color: var(--muted); }

/* Composer Popovers (+, Tools, Model Picker) */
.composer-popover { position: absolute; bottom: calc(100% + 10px); left: 0; z-index: 30; width: 296px; max-width: calc(100vw - 28px); padding: 6px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-elevated); box-shadow: var(--shadow-dialog); display: grid; gap: 2px; }
.model-popover { left: auto; right: 0; width: 388px; max-width: calc(100vw - 24px); padding: 10px; gap: 10px; }
.popover-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); text-align: start; transition: background .12s; }
.popover-item:hover:not(:disabled) { background: var(--surface-hover); }
.popover-item > .icon { width: 18px; height: 18px; color: var(--muted); }
.popover-item[aria-checked="true"] { background: var(--wash); }
.popover-item[aria-checked="true"] > .icon { color: var(--green); }
.popover-copy { display: grid; gap: 2px; flex: 1; min-width: 0; }
.popover-copy strong { font-size: 13px; font-weight: 590; color: var(--ink); }
.popover-copy small { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.popover-check { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; border: 1.5px solid var(--input-border); border-radius: 6px; background: var(--white); color: transparent; transition: background .14s, border-color .14s, color .14s; }
.popover-check .icon { width: 13px; height: 13px; color: inherit; stroke-width: 2.2; }
.popover-item[aria-checked="true"] .popover-check { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--accent-ink); }
.popover-item[aria-checked="true"] .popover-check .icon { color: var(--accent-ink); }
.popover-divider { height: 1px; background: var(--line); margin: 4px 8px; }

.popover-provider-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 3px; border: 1px solid var(--pill-border); border-radius: 12px; background: var(--pill-bg); }
.popover-provider-tab { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); text-align: start; transition: background .14s, color .14s, border-color .14s; }
.popover-provider-tab:hover:not([aria-selected="true"]) { color: var(--ink); }
.popover-provider-tab[aria-selected="true"] { background: var(--pill-active-bg); border-color: var(--pill-active-border); color: var(--ink); box-shadow: var(--shadow-soft); }
.popover-provider-tab-head { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 620; }
.popover-provider-tab-head .icon { width: 14px; height: 14px; }
.popover-provider-tab[data-tab="google"][aria-selected="true"] .icon { color: var(--brand-gemini); }
.popover-provider-tab-sub { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.popover-model-list { display: grid; gap: 4px; max-height: 280px; overflow-y: auto; scrollbar-width: thin; }
.popover-model-item { display: grid; gap: 3px; width: 100%; padding: 9px 11px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ink); text-align: start; transition: background .12s, border-color .12s; }
.popover-model-item:hover:not(:disabled) { background: var(--surface-hover); }
.popover-model-item[aria-checked="true"] { background: var(--wash); border-color: var(--wash-border); }
.popover-model-head { display: flex; align-items: center; gap: 6px; }
.popover-model-head strong { font-size: 13.5px; font-weight: 630; color: var(--ink); }
.popover-model-head .guide-badge { font-size: 10.5px; padding: 1px 6px; }
.popover-model-head .popover-model-check { margin-inline-start: auto; width: 16px; height: 16px; color: var(--green); }
.popover-model-tagline { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

.popover-effort-bar { display: grid; gap: 7px; padding-top: 8px; border-top: 1px solid var(--line); }
.popover-effort-title { font-size: 11.5px; font-weight: 600; color: var(--muted); padding-inline: 2px; }
.popover-effort-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.effort-pill { flex: 1; min-width: 52px; padding: 5px 8px; border: 1px solid var(--pill-border); border-radius: 999px; background: var(--pill-bg); color: var(--muted); font-size: 12px; font-weight: 560; text-align: center; transition: background .12s, color .12s, border-color .12s; }
.effort-pill:hover:not(:disabled):not([aria-checked="true"]) { color: var(--ink); background: var(--surface-hover); }
.effort-pill[aria-checked="true"] { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--accent-ink); font-weight: 620; }

.send-button { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--accent-ink); background: var(--accent-solid); transition: background .15s, transform .12s; }
.send-button:hover:not(:disabled) { background: var(--accent-hover); transform: scale(1.03); }
.send-button:disabled { background: var(--surface-hover); color: var(--muted); opacity: 1; transform: none; }
.composer.working .send-button .icon { display: none; }
.composer.working .send-button::after { content: ""; width: 14px; height: 14px; border: 2px solid var(--wash-border); border-top-color: var(--green); border-radius: 50%; animation: working 1s linear infinite; }
@keyframes working { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .composer.working .send-button::after, .message-mark.spinning .icon, .thought-drawer.live .thought-spark { animation: none; }
}

/* Thinking Status Indicator */
.thinking-status { display: inline-grid; gap: 5px; padding: 10px 14px; border: 1px solid var(--wash-border); border-radius: 14px; background: linear-gradient(135deg, var(--surface-muted) 0%, var(--surface-elevated) 100%); color: var(--ink); max-width: 100%; }
.thinking-row { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 560; color: var(--green); }
.thinking-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 var(--wash-border); animation: pulse-dot 1.4s ease-out infinite; flex: none; }
.thinking-timer { color: var(--muted); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.thinking-hint { color: var(--muted); font-size: 12px; line-height: 1.4; }
.message-text.streaming>:last-child::after { content: "▍"; display: inline-block; margin-inline-start: 2px; color: var(--green); animation: blink-caret .9s steps(1) infinite; }
@keyframes pulse-dot { 0% { transform: scale(.92); box-shadow: 0 0 0 0 var(--wash-border); } 70% { transform: scale(1); box-shadow: 0 0 0 7px transparent; } 100% { transform: scale(.92); box-shadow: 0 0 0 0 transparent; } }
@keyframes blink-caret { 50% { opacity: 0; } }

/* Dialogs */
.dialog { width: min(100% - 24px, 468px); max-height: min(calc(100dvh - 32px), 800px); margin: auto; padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-elevated); color: var(--ink); box-shadow: var(--shadow-dialog); overflow-y: auto; }
.dialog::backdrop { background: var(--backdrop); }
.dialog-head { gap: 8px; margin: -4px -4px 14px 0; }
.dialog-head h2 { font-size: 19px; font-weight: 660; }
.dialog h3 { font-size: 14px; font-weight: 650; margin-bottom: 8px; }
.dialog .stack h3 { margin-bottom: 0; }
.dialog-foot { justify-content: flex-end; gap: 8px; margin-top: 18px; }

.dual-quota-stack { display: grid; gap: 10px; margin-bottom: 18px; }
.quota-panel { padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); }
.quota-panel:empty { display: none; }
.quota-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.quota-head strong { font-size: 13px; font-weight: 640; color: var(--ink); }
.quota-caption { color: var(--muted); font-size: 11.5px; }
.quota-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 8px; margin: 0; }
.quota-grid dt { color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.quota-grid dd { min-width: 0; margin: 0; font-size: 14px; font-weight: 630; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.admin-dialog { width: min(100% - 24px, 720px); }
.section-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-head-row h3 { margin: 0; }
.tab-pill { padding: 5px 12px; min-height: 30px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 560; transition: background .14s, color .14s, border-color .14s; }
.tab-pill:hover:not([aria-selected="true"]) { color: var(--ink); }
.tab-pill[aria-selected="true"] { background: var(--pill-active-bg); border-color: var(--pill-active-border); color: var(--ink); font-weight: 620; box-shadow: var(--shadow-soft); }
.admin-hint { margin: 8px 0 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.two-col-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.files-dialog { width: min(100% - 24px, 740px); }
.files-dialog #files-status { margin-bottom: 12px; }
.file-list { display: grid; gap: 6px; margin-top: 14px; }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--white); }
.file-row .button, .file-preview-actions .button { min-height: 32px; padding: 4px 11px; font-size: 12px; }
.file-open { display: flex; align-items: center; min-width: 0; gap: 8px; padding: 7px 4px; border: 0; background: transparent; color: var(--green); text-align: start; }
.file-open .icon { width: 18px; height: 18px; }
.file-open small { color: var(--muted); }
.file-open span span, .file-open span small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-open>span { min-width: 0; }
.file-back { margin: 0 0 14px; padding: 4px 0; border: 0; background: transparent; color: var(--green); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.file-preview-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: start; margin-bottom: 13px; }
.file-preview-head h3 { overflow-wrap: anywhere; }
.file-preview-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.file-preview-actions a.button { display: inline-flex; align-items: center; text-decoration: none; }
.file-preview-description { color: var(--muted); font-size: 12px; line-height: 1.5; }
.file-pages { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.file-pages li { padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--white); }
.file-pages li p { margin-top: 4px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.file-page-link { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; text-underline-offset: 3px; }
.file-page-link .icon { width: 14px; height: 14px; }
.file-image { display: block; max-width: 100%; max-height: 52vh; margin: 0 auto; object-fit: contain; }
.file-text-preview { max-height: 52vh; margin: 10px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--code-bg); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace; font-size: 12.5px; line-height: 1.55; }
.sheet-select { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sheet-select select { max-width: min(280px, 56vw); padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink); }
.admin-section+.admin-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.admin-dialog>#admin-status { margin-bottom: 12px; }
.inline-form { display: flex; align-items: flex-end; gap: 8px; }
.inline-form>label { flex: 1; }
.budget-form { flex-wrap: wrap; }
.budget-form>label { min-width: min(185px, 100%); }
.member-list { display: grid; gap: 8px; }
.member, .add-member { padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.member summary, .add-member summary { color: var(--ink); cursor: pointer; font-size: 14px; font-weight: 630; overflow-wrap: anywhere; }
.member-summary { color: var(--muted); padding-inline-start: 7px; font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
.member .stack, .add-member .stack { margin-top: 13px; }
.member .active-label { display: flex; align-items: center; }
.member-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.add-member { margin-top: 10px; }
#password-status:empty { display: none; }

.login-title { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.brand-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 660; letter-spacing: -.03em; }
.brand-pill { display: inline-flex; align-items: center; padding: 2px 8px; border: 1px solid var(--wash-border); border-radius: 999px; background: var(--wash); color: var(--green); font-size: 11px; font-weight: 620; letter-spacing: .01em; line-height: 1.4; }
.login-title .brand-pill { font-size: 12px; padding: 3px 9px; }

/* Guide & Changelog Dialogs */
.guide-trigger { padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--muted); font-size: 12px; font-weight: 560; white-space: nowrap; transition: border-color .14s, background .14s, color .14s; }
.guide-trigger:hover { border-color: var(--wash-border); background: var(--wash); color: var(--green); }
.guide-dialog { width: min(100% - 24px, 740px); }
.guide-tabs { display: inline-flex; gap: 3px; padding: 3px; margin-bottom: 14px; border: 1px solid var(--pill-border); border-radius: 999px; background: var(--pill-bg); }
.guide-section+.guide-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.guide-card { display: grid; gap: 7px; align-content: start; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.guide-card-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.guide-card-head strong { font-size: 14px; font-weight: 660; color: var(--ink); }
.guide-badge { padding: 2px 7px; border-radius: 999px; background: var(--wash); color: var(--green); font-size: 11px; font-weight: 600; white-space: nowrap; }
.guide-badge.cost-low { background: var(--badge-low-bg); color: var(--badge-low-ink); }
.guide-badge.cost-mid { background: var(--badge-mid-bg); color: var(--badge-mid-ink); }
.guide-badge.cost-high { background: var(--badge-high-bg); color: var(--badge-high-ink); }
.guide-desc { font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.guide-apply { justify-self: start; margin-top: 2px; min-height: 30px; padding: 4px 11px; font-size: 12px; }
.guide-efforts { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.guide-efforts li { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); font-size: 12.5px; line-height: 1.5; }
.guide-efforts strong { color: var(--green); font-weight: 630; }
.guide-tips { margin: 0; padding-inline-start: 1.25em; display: grid; gap: 6px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }

.drop-overlay { position: absolute; inset: 10px; z-index: 25; display: grid; place-items: center; padding: 24px; border: 2px dashed var(--green); border-radius: 20px; background: var(--drop-bg); backdrop-filter: blur(4px); pointer-events: none; }
.drop-card { display: grid; justify-items: center; gap: 8px; max-width: 380px; text-align: center; color: var(--green); }
.drop-card .icon { width: 34px; height: 34px; }
.drop-card strong { font-size: 16px; font-weight: 660; }
.drop-card span { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.changelog-list { display: grid; gap: 12px; }
.changelog-item { padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.changelog-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.changelog-head strong { font-size: 14px; font-weight: 660; color: var(--ink); }
.changelog-items { margin: 0; padding-inline-start: 1.25em; display: grid; gap: 5px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.changelog-items strong { color: var(--ink); font-weight: 600; }

/* Settings Dialog Controls */
.settings-dialog { width: min(100% - 24px, 600px); padding: 24px 26px; }
.settings-subtitle { margin: -4px 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.settings-groups { display: grid; gap: 20px; }
.settings-section { display: grid; gap: 8px; }
.dialog .settings-section-title { margin: 0 0 0 2px; font-size: 13.5px; font-weight: 620; color: var(--ink); }
.settings-card { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); overflow: hidden; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 54px; padding: 12px 18px; }
.settings-row + .settings-row { border-top: 1px solid var(--line); }
.settings-row-copy { display: grid; gap: 3px; min-width: 0; }
.settings-row-title { font-size: 14px; font-weight: 560; color: var(--ink); line-height: 1.35; }
label.settings-row-title { display: inline; cursor: pointer; }
.settings-row-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }

.pill-segmented { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--pill-border); border-radius: 999px; background: var(--pill-bg); flex: none; }
.pill-option { position: relative; display: inline-flex; margin: 0; font-weight: 560; }
.pill-option input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; cursor: pointer; }
.pill-option span { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 0 13px; border: 1px solid transparent; border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap; transition: background .15s, color .15s, border-color .15s, box-shadow .15s; }
.theme-segmented .pill-option span { width: 38px; padding: 0; }
.theme-segmented .pill-option .icon { width: 16px; height: 16px; }
.pill-option:hover input:not(:checked) + span { color: var(--ink); }
.pill-option input:checked + span { background: var(--pill-active-bg); border-color: var(--pill-active-border); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-soft); }
.pill-option input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.pill-select { flex: none; width: auto; min-width: 152px; max-width: 230px; min-height: 34px; padding: 6px 14px; border: 1px solid var(--pill-border); border-radius: 999px; background: var(--pill-bg); color: var(--ink); font-size: 13px; font-weight: 560; cursor: pointer; }
.pill-select:hover { border-color: var(--pill-active-border); background: var(--surface-hover); }
.settings-dialog .dialog-foot { justify-content: space-between; margin-top: 20px; }

/* Responsive */
@media (max-width: 700px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: min(290px, 86vw); box-shadow: var(--shadow-card); }
  .workspace:not(.sidebar-closed) .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 15; border: 0; background: var(--backdrop); }
  .chat-head { min-height: 52px; padding: 7px 10px; gap: 6px; }
  .chat-head-start { gap: 5px; }
  .provider-tab { padding: 4px 8px; min-height: 28px; font-size: 12px; gap: 4px; }
  .provider-tab .icon { width: 13px; height: 13px; }
  .mock-badge { display: none; }
  .chat-head-actions { gap: 2px; }
  .chat-head-actions .guide-trigger { padding: 4px 7px; font-size: 11px; }
  #changelog-button { display: none; }
  .chat-head-actions .icon-button { width: 30px; height: 30px; }
  .dialog { max-height: calc(100dvh - 24px); padding: 18px 16px; }
  .messages { padding: 14px 13px 26px; gap: 22px; }
  .composer-area { padding-inline: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .composer { border-radius: 22px; padding: 10px 10px 8px 12px; }
  .message-assistant { grid-template-columns: 26px minmax(0, 1fr); column-gap: 8px; }
  .message-mark { width: 26px; height: 26px; }
  .message-mark .icon { width: 15px; height: 15px; }
  .composer textarea { font-size: 16px; }
  .model-picker-btn { max-width: 175px; padding-inline: 8px; font-size: 12px; }
  .picker-sep, .picker-effort { display: none; }
  .model-popover { right: -42px; width: min(356px, calc(100vw - 20px)); }
  .login-card { padding: 28px; }
  .guide-grid, .two-col-inputs { grid-template-columns: minmax(0, 1fr); }
  .guide-efforts li { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .settings-dialog { padding: 20px 16px; }
  .settings-row { flex-wrap: wrap; align-items: flex-start; gap: 10px; padding: 12px 14px; }
  .pill-select { width: 100%; max-width: 100%; }
}

@supports not (scrollbar-color: auto) {
  .chat-list, .messages-scroll, .thought-body, .popover-model-list { scrollbar-width: auto; }
  .chat-list::-webkit-scrollbar, .messages-scroll::-webkit-scrollbar, .thought-body::-webkit-scrollbar, .popover-model-list::-webkit-scrollbar { width: 8px; height: 8px; }
  .chat-list::-webkit-scrollbar-thumb, .messages-scroll::-webkit-scrollbar-thumb, .thought-body::-webkit-scrollbar-thumb, .popover-model-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
  .chat-list::-webkit-scrollbar-track, .messages-scroll::-webkit-scrollbar-track, .thought-body::-webkit-scrollbar-track, .popover-model-list::-webkit-scrollbar-track { background: var(--scrollbar-track); }
}
