:root {
  --bg: #ffffff;
  --side: #fafafa;
  --panel: #ffffff;
  --bubble: #f0f0ef;
  --code-bg: #f6f6f6;
  --pill: #f0f0ef;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --composer-ring: rgba(0, 0, 0, 0.12);
  --text: rgba(0, 0, 0, 0.9);
  --text-2: rgba(0, 0, 0, 0.62);
  --text-3: rgba(0, 0, 0, 0.45);
  --accent: #d97757;
  --accent-hover: #c6613f;
  --accent-soft: rgba(217, 119, 87, 0.14);
  --ring: rgba(0, 0, 0, 0.55);
  --blue: #1757ac;
  --green: #629987;
  --upgrade: #1757ac;
  --banner-bg: #fafafa;
  --banner-text: var(--text);
  --banner-btn-border: rgba(0, 0, 0, 0.16);
  --hover: rgba(0, 0, 0, 0.045);
  --active: rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 6px 24px rgba(0, 0, 0, 0.05);
  --clay-dark: #c6613f;
  --danger: #bf4d43;

  --font-sans: "General Sans", Archivo, "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --lh-loose: 1.6;
  --lh-relaxed: 1.5;
  --lh-snug: 1.2;
}

[data-theme="dark"] {
  --bg: #191919;
  --side: #1f1f1f;
  --panel: #303030;
  --bubble: #2a2a2a;
  --code-bg: #242424;
  --pill: #262626;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --composer-ring: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.92);
  --text-2: rgba(255, 255, 255, 0.62);
  --text-3: rgba(255, 255, 255, 0.45);
  --accent-soft: rgba(217, 119, 87, 0.16);
  --upgrade: #6aabf1;
  --banner-bg: rgba(255, 255, 255, 0.06);
  --banner-text: var(--text);
  --banner-btn-border: rgba(255, 255, 255, 0.2);
  --hover: rgba(255, 255, 255, 0.06);
  --active: rgba(255, 255, 255, 0.1);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 6px 24px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .new-btn { background: #404040; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: var(--lh-loose);
  font-feature-settings: "pnum" on, "lnum" on, "liga" on;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
svg { display: block; flex: none; }
::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 4px; border-radius: 6px; }

.app { display: flex; height: 100dvh; }

.sidebar {
  width: 288px; flex: none;
  display: flex; flex-direction: column;
  background: var(--side);
  border-right: 1px solid var(--border);
  padding: 10px 12px 10px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 8px 8px 12px; color: var(--text); }
.brand-mark img { display: block; height: 24px; width: auto; }
.logo-d { display: none !important; }
[data-theme="dark"] .logo-l { display: none !important; }
[data-theme="dark"] .logo-d { display: block !important; }
.brand-name { font-family: var(--font-serif); font-size: 19px; font-weight: 600; letter-spacing: -0.2px; }

.new-btn {
  display: flex; align-items: center; gap: 9px;
  height: 30px; padding: 0 12px; border-radius: var(--br-8, 8px);
  background: #e1e1e1; color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1;
  box-shadow: 0 1px 2px rgba(20, 20, 19, 0.06);
  transition: color 0.1s ease-in-out, background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.new-btn:hover { background: var(--hover); }
.new-btn svg { width: 15px; height: 15px; }

.side-nav { margin-top: 12px; display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 10px; border-radius: 8px;
  font-size: 14px; color: var(--text); text-align: left;
  transition: background-color 0.15s ease;
}
.nav-item:hover { background: var(--hover); }
.nav-item svg { width: 17px; height: 17px; color: var(--text); }
.nav-badge { margin-left: auto; font-size: 12px; color: var(--upgrade); }

.chats-controls { display: flex; align-items: center; gap: 2px; margin-top: 14px; }
.chats-head {
  flex: 1;
  display: flex; align-items: center;
  padding: 6px 8px 6px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text);
  transition: background-color 0.15s ease;
}
.chats-head:hover { background: var(--hover); }
.chats-title { display: flex; align-items: center; gap: 6px; }
.chats-chevron { width: 13px; height: 13px; color: var(--text-2); transition: transform 0.15s ease; }
.chats-hidden .chats-chevron { transform: rotate(-90deg); }
.chats-filter { flex: none; }
.chats-filter[aria-expanded="true"] { background: var(--active); }
.chats-filter svg { width: 16px; height: 16px; }
.chats-filter-input {
  margin: 4px 0; padding: 6px 9px; min-width: 0;
  font: inherit; font-size: 13px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
}

.recents { flex: 1 1 auto; overflow-y: auto; margin-top: 2px; min-height: 0; }
.chats-hidden .recents, .chats-hidden .view-all { display: none; }
.recents-empty { font-size: 13px; color: var(--text-3); padding: 6px 10px; }
.recent-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px 6px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text);
  cursor: pointer; user-select: none;
}
.recent-item:hover { background: var(--hover); }
.recent-item.active { background: var(--active); }
.recent-ring { width: 9px; height: 9px; border: 1.5px solid var(--text-3); border-radius: 50%; flex: none; }
.recent-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-del { display: none; color: var(--text-3); border-radius: 6px; padding: 3px; }
.recent-del svg { width: 15px; height: 15px; }
.recent-item:hover .recent-del, .recent-del:focus-visible { display: block; }
.recent-del:hover { color: var(--accent); background: var(--hover); }

.view-all { padding: 6px 10px; font-size: 13px; color: var(--text-2); text-align: left; border-radius: 8px; }
.view-all:hover { background: var(--hover); }

.side-footer {
  display: flex; align-items: center; gap: 4px;
  margin-top: auto; padding-top: 6px;
}
.side-footer .icon-btn { flex: none; }
.side-user {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0; text-align: left;
  padding: 3px 4px 3px 8px;
  border-radius: 10px;
  transition: background-color 0.15s ease;
}
.side-user:hover { background: var(--hover); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.user-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 13px; color: var(--text-2); white-space: nowrap; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

.backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.menu-btn { display: none; }

.banner {
  display: none;
}
.banner-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-btn {
  height: 26px; padding: 0 12px; flex: none;
  border-radius: 7px; border: 1px solid var(--banner-btn-border);
  font-size: 13px; color: var(--banner-text);
  transition: background-color 0.15s ease;
}
.banner-btn:hover { background: var(--hover); }

.topbar { height: 44px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.topbar-title {
  flex: 1; min-width: 0; text-align: center;
  font-size: 13.5px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu-btn + .topbar-title { text-align: left; }
.topbar-actions { display: flex; gap: 4px; }

.stage {
  --composer-width: 600px;
  flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative;
}

.scroll-pill {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 96px; z-index: 6;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.scroll-pill:hover { background: var(--hover); }
.scroll-pill[hidden] { display: none; }
.scroll-pill:active { transform: translateX(-50%) scale(0.94); }
.scroll-pill svg { width: 16px; height: 16px; }

.chat-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; overscroll-behavior: contain; }
.chat-inner {
  flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  padding: 16px 20px 24px;
  display: flex; flex-direction: column;
}

.msg { animation: rise 0.28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }

.msg-user { display: flex; justify-content: flex-end; margin: 14px 0; }
.bubble {
  max-width: 78%;
  background: var(--bubble);
  padding: 10px 16px;
  border-radius: 18px;
  border-bottom-right-radius: 6px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.msg-assistant { margin: 18px 0 6px; position: relative; }
.msg-body {
  font-family: var(--font-serif);
  line-height: 1.6;
  overflow-wrap: break-word;
}
.msg-body > :first-child { margin-top: 0; }
.msg-body > :last-child { margin-bottom: 0; }
.msg-body p { margin: 0.65em 0; }
.md-h { font-size: 16px; font-weight: 600; margin: 0.9em 0 0.35em; }
.msg-body ul, .msg-body ol { margin: 0.6em 0; padding-left: 1.4em; }
.msg-body li { margin: 0.3em 0; }
.msg-body blockquote {
  margin: 0.8em 0; padding: 2px 0 2px 14px;
  border-left: 2px solid var(--accent); color: var(--text-2);
}
.msg-body code { font-family: var(--mono); font-size: 0.82em; background: var(--code-bg); border-radius: 5px; padding: 0.12em 0.4em; }
.msg-body pre { background: var(--code-bg); border-radius: 10px; padding: 13px 15px; overflow-x: auto; margin: 0.7em 0; }
.msg-body pre code { background: none; padding: 0; font-size: 13px; }
.msg-body a { color: var(--blue); text-underline-offset: 2px; }

.msg-actions {
  position: absolute; top: -4px; right: 0;
  display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s ease;
}
.msg-assistant:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.act-copy:hover { color: var(--accent); }
.act-copy.copy-ok { color: var(--green); }

.thinking { display: inline-flex; align-items: center; gap: 8px; padding: 10px 2px; color: var(--text-2); font-size: 14px; }
.tdot { display: flex; align-items: center; width: 20px; }
.tdot img { height: 15px; width: auto; animation: tpulse 1.1s ease-in-out infinite; }
@keyframes tpulse { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.1); } }

.disclaimer { display: flex; align-items: flex-start; justify-content: center; gap: 10px; margin-top: 16px; font-size: 13px; line-height: 1.45; letter-spacing: 0.01em; color: var(--text-3); text-align: left; }
.disc-brand { font-family: var(--font-serif); font-weight: 600; font-size: 14px; letter-spacing: 0.02em; color: var(--text-2); }

.page-disclaimer {
  display: none;
  align-items: baseline; justify-content: center; gap: 16px;
  max-width: 600px; margin: 0 auto;
  padding: 10px 4px 6px;
  font-size: 13px; color: var(--text-3);
}
.page-disclaimer .pd-model { color: var(--text-2); white-space: nowrap; }
@media (min-width: 641px) {
  body.in-convo .page-disclaimer { display: flex; }
  .msg-assistant .disclaimer { display: none; }
}
.disc-mark { flex: none; display: flex; align-items: center; margin-top: 3px; }
.disc-mark img { height: 13px; width: auto; }

.msg-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 78%; min-width: 0; }
.msg-user .bubble { max-width: 100%; }
.msg-meta { display: flex; align-items: center; gap: 2px; margin-top: 2px; opacity: 0; transition: opacity 0.2s ease; }
.msg:hover .msg-meta, .msg-meta:focus-within { opacity: 1; }
.msg-user .msg-meta { justify-content: flex-end; }
.mtime { margin: 0 4px; font-size: 12px; color: var(--text-3); }
.act-like[aria-pressed="true"] { color: var(--accent); }
.act-dislike[aria-pressed="true"] { color: var(--danger); }
@media (max-width: 640px) { .msg-meta { opacity: 1; } }
@keyframes blink {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

.msg-error {
  background: var(--accent-soft);
  border: 1px solid rgba(217, 119, 87, 0.3);
  color: var(--danger);
  border-radius: 12px; padding: 11px 14px; font-size: 13.5px; line-height: 1.5;
}
.msg-error-hint { color: var(--text-2); }

.welcome {
  margin: 0 auto;
  width: 100%; max-width: var(--composer-width);
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: clamp(48px, 8vh, 110px) 0 24px;
}
.greeting {
  display: block;
  font-family: var(--font-serif);
  font-size: 34px; font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0;
  margin: 0; max-width: 100%;
  text-align: center;
  text-wrap: balance;
}
.greet-mark {
  display: inline-block;
  vertical-align: -0.16em;
  margin-right: 11px;
  color: var(--accent);
}
.greet-mark img { height: 36px; display: block; }
.greeting-text { overflow-wrap: anywhere; }

.suggestions {
  width: 100%; max-width: var(--composer-width); margin: 14px auto 0; text-align: left;
}
.sug-caption {
  margin: 0 0 14px; padding: 0;
  font-family: var(--font-serif); font-size: 18px; font-weight: 400;
  line-height: 1.35; color: var(--text-2); text-align: center;
}
.sug-list { display: flex; flex-direction: column; gap: 8px; border-top: none; }
.sug-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px;
  background: var(--side);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px; line-height: 1.45; color: var(--text-2); text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sug-item:hover, .sug-item:focus-visible {
  background: var(--hover); border-color: var(--border-strong); color: var(--text);
}
.sug-item:focus-visible { outline: 2px solid var(--text-2); outline-offset: -2px; }
.sug-arrow {
  width: 16px; height: 16px; flex: none; color: var(--text-2);
  transition: transform 0.15s ease, color 0.15s ease;
}
.sug-item:hover .sug-arrow, .sug-item:focus-visible .sug-arrow {
  transform: translateX(3px); color: var(--accent);
}
@media (prefers-reduced-motion: reduce) { .sug-arrow { transition: none; } }

.welcome .composer-zone { width: 100%; margin-top: 20px; }

.composer-zone { flex: none; }
body.in-convo .composer-zone { padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); }
.composer-col { max-width: var(--composer-width); margin: 0 auto; }
.composer {
  background: var(--panel);
  border: 1px solid var(--composer-ring);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, background-color 0.2s ease;
}
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea {
  display: block; width: 100%;
  background: transparent; border: none; outline: none; resize: none;
  font: inherit; color: var(--text); line-height: 1.5;
  padding: 14px 16px 4px;
  max-height: 220px; overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer-row { display: flex; align-items: center; gap: 6px; padding: 6px 10px 10px 12px; }
.composer-count {
  margin-left: auto; color: var(--text-2); font-size: 12px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.composer-count.over-limit { color: var(--danger); }
.composer-count:not([hidden]) + .send-btn { margin-left: 0; }

.comp-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  width: 30px; height: 30px; border-radius: 7px; color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.comp-icon:hover { background: var(--hover); color: var(--text); }
.comp-icon > svg:first-child { width: 17px; height: 17px; }
.comp-icon .chev { width: 10px; height: 10px; }

.mode-pills { display: flex; gap: 6px; margin-left: 2px; }
.mode-pill {
  height: 28px; padding: 0 12px; border-radius: 8px;
  border: 1px solid transparent;
  background: var(--pill); color: var(--text-2); font-size: 13.5px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.mode-pill:hover { color: var(--text); }
.mode-pill.active {
  background: var(--panel); border-color: var(--border-strong);
  color: var(--text); font-weight: 500;
  box-shadow: 0 0 0 1px var(--border-strong);
}

.comp-spacer { flex: 1; }

.model-name {
  font-size: 13.5px; color: var(--text-2);
  padding: 5px 7px; border-radius: 7px;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.model-name:hover { background: var(--hover); color: var(--text); }
.model-effort {
  font-size: 13px; color: var(--text-2);
  background: var(--pill);
  border-radius: 7px; padding: 5px 9px;
  white-space: nowrap;
}

.send-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 47px; height: 34px; border-radius: 999px; flex: none;
  margin-left: auto;
  background: var(--accent); color: #fff;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.send-btn svg { width: 17px; height: 17px; }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn.streaming { background: var(--text); color: var(--bg); }

.gate-overlay {
  position: fixed; inset: 0; z-index: 120;
  display: none; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(20, 20, 19, 0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.gate-overlay.open { display: flex; }
body.gate-locked { overflow: hidden; }
.gate-modal {
  position: relative;
  width: min(430px, 100%);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  padding: 26px 24px 18px;
  max-height: calc(100vh - 32px); overflow: auto;
}
.gate-head { text-align: center; margin-bottom: 18px; }
.gate-close { position: absolute; top: 8px; right: 8px; }
.gate-logo { display: inline-flex; margin-bottom: 10px; }
.gate-logo img { height: 34px; width: auto; }
.gate-title { margin: 0 0 6px; font-family: var(--font-serif); font-weight: 600; font-size: 22px; line-height: 1.2; }
.gate-sub { margin: 0; font-size: 13.5px; color: var(--text-2); }
.gate-field { display: block; margin: 0 0 10px; }
.gate-field span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.gate-field input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--composer-ring); border-radius: 10px;
  background: var(--bg); color: var(--text);
  font-family: var(--mono); font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase;
}
.gate-field input:focus { outline: 2px solid var(--clay-dark); outline-offset: 1px; }
.gate-error { margin: 0 0 10px; font-size: 12.5px; line-height: 1.45; color: var(--danger); }
[data-theme="dark"] .gate-error { color: #f2a49b; }
.gate-agree {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 10px; cursor: pointer;
  font-size: 12.5px; line-height: 1.5; color: var(--text-2);
}
.gate-agree:last-of-type { margin-bottom: 16px; }
.gate-agree input {
  appearance: none; -webkit-appearance: none;
  margin-top: 2px; width: 16px; height: 16px; flex: none;
  border: 1.5px solid var(--border-strong); border-radius: 4px;
  background: var(--bg); cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.gate-agree input:focus-visible { outline: 2px solid var(--clay-dark); outline-offset: 2px; }
.gate-agree input:checked {
  background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 12px 12px; background-position: center; background-repeat: no-repeat;
}
.gate-agree a { color: var(--blue); }
.gate-submit {
  width: 100%; height: 44px; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600; font-family: inherit;
  transition: background-color 0.2s ease;
}
.gate-submit:hover:not(:disabled) { background: var(--accent-hover); }
.gate-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.send-btn.gate-cta { width: auto; padding: 0 14px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em; }
.send-btn.gate-cta .gate-cta-label { line-height: 1; white-space: nowrap; }
.gate-contact {
  display: flex; align-items: center; justify-content: center;
  min-height: 44px; margin-top: 10px; padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--side); color: var(--text);
  font-size: 14px; font-weight: 600; line-height: 1.35;
  text-align: center; text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.gate-contact[hidden], .gate-badge[hidden] { display: none; }
.gate-contact:hover { background: var(--hover); border-color: var(--accent); }
.gate-contact:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gate-foot { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.gate-foot p { margin: 0 0 8px; font-size: 11.5px; line-height: 1.5; color: var(--text-3); }
.gate-links { text-align: center; }
.gate-links a { color: var(--text-2); }
.gate-badge {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent-hover);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
[data-theme="dark"] .gate-badge { background: rgba(217, 119, 87, 0.22); color: #e8a08a; }
.gate-change {
  border: none; background: transparent; cursor: pointer;
  height: 30px; padding: 0 10px; border-radius: 8px;
  font-family: inherit; font-size: 12.5px; color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.gate-change:hover { background: var(--hover); color: var(--text); }
@media (max-width: 560px) { .gate-badge { display: none; } .gate-change { padding: 0 8px; } }
.ai-reminder {
  max-width: 600px; margin: 0 auto; padding: 9px 12px 0;
  font-size: 12px; line-height: 1.45; color: var(--text-3); text-align: center;
}
.ai-legal { display: block; margin-top: 3px; font-size: 11.5px; }
.ai-legal a { color: var(--text-3); text-decoration: none; }
.ai-legal a:hover { color: var(--text-2); text-decoration: underline; }

.settings {
  border: none; border-radius: 16px;
  background: var(--panel); color: var(--text);
  width: min(520px, calc(100vw - 32px));
  max-height: min(680px, calc(100dvh - 32px));
  padding: 0; box-shadow: 0 24px 80px rgba(20, 20, 19, 0.28);
}
[data-theme="dark"] .settings { background: var(--panel); }
.settings::backdrop { background: rgba(20, 20, 19, 0.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 4px; }
.dialog-head h2 { margin: 0; font-family: var(--font-serif); font-size: 21px; font-weight: 400; }
.dialog-body { padding: 12px 24px 4px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.field > span { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--ring); }
.seg { display: flex; background: var(--pill); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; padding: 7px 6px; border-radius: 8px; font-size: 13px; color: var(--text-2); }
.seg button.active { background: var(--panel); color: var(--text); font-weight: 500; box-shadow: 0 1px 3px rgba(20, 20, 19, 0.08); }
[data-theme="dark"] .seg button.active { background: var(--bubble); }
.field-note { margin: 2px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-2); }
.legal-links { margin: 6px 0 0; font-size: 12px; color: var(--text-3); }
.legal-links a { color: var(--text-2); text-decoration: none; border-bottom: 1px solid var(--border); }
.legal-links a:hover { color: var(--accent-hover); }
.dialog-foot { display: flex; align-items: center; padding: 14px 24px 20px; gap: 10px; }
.btn-primary {
  margin-left: auto; height: 38px; padding: 0 22px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { height: 38px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); }
.btn-ghost.confirm { color: var(--danger); }

.chat-archive { padding-top: 12px; border-top: 1px solid var(--border); }
.chat-archive h3 { margin: 0; font-size: 13px; font-weight: 600; }
.chat-archive .btn-ghost { margin-top: 8px; border: 1px solid var(--border); color: var(--text); }
.chat-archive-status { margin-top: 8px; }
.chat-archive-status:empty { margin: 0; }
.chat-archive-status[data-error] { color: var(--danger); }
[data-theme="dark"] .chat-archive-status[data-error] { color: #f2a49b; }

.search-body { padding-bottom: 20px; }
.search-results { max-height: min(360px, 50dvh); overflow-y: auto; }
.search-result {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; overflow-wrap: anywhere;
}
.search-result:hover { background: var(--hover); }

@media (min-width: 901px) {
  body.side-collapsed .sidebar { display: none; }
}

@media (max-width: 900px) {
  body:not(.in-convo) .composer-zone { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .sidebar {
    position: fixed; z-index: 20; top: 0; bottom: 0; left: 0;
    width: min(300px, 84vw);
    transform: translateX(-105%); transition: transform 0.22s ease;
  }
  body.side-open .sidebar { transform: translateX(0); box-shadow: 0 0 60px rgba(0, 0, 0, 0.25); }
  body.side-open .backdrop { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(20, 20, 19, 0.4); }
  .menu-btn { display: inline-flex; }
  .collapse-btn-desktop { display: none; }
}

@media (max-width: 640px) {
  .greeting { font-size: 26px; }
  .greet-mark { margin-right: 8px; }
  .greet-mark img { height: 28px; }
  .sug-caption { font-size: 16px; margin-bottom: 10px; }
  .disclaimer > span:last-child { text-align: center; }
  .model-effort { display: none; }
  .banner { font-size: 12.5px; gap: 8px; }
  .chat-inner { padding: 12px 14px 16px; }
}
