/* MyCrypto — Claude.ai-style light theme: cream bg, terracotta accent, serif AI output. */
* { box-sizing: border-box; }
:root {
  /* surfaces — Claude warm cream palette */
  --bg: #faf9f5;
  --bg-elevated: #ffffff;
  --bg-sidebar: #f0eee6;
  --bg-bubble: #ffffff;            /* user msg bubble */
  --bg-input: #ffffff;
  --bg-code: #f5f4ed;
  --bg-card: #ffffff;
  --bg-hover: rgba(60, 50, 38, 0.05);
  --bg-active: rgba(204, 120, 92, 0.10);

  /* text */
  --fg: #3d3929;                   /* warm near-black */
  --fg-strong: #1f1e1c;
  --fg-muted: #6b6859;
  --fg-faint: #a09c8c;

  /* lines */
  --border: rgba(60, 50, 38, 0.12);
  --border-strong: rgba(60, 50, 38, 0.22);

  /* anthropic terracotta accent */
  --accent: #cc785c;
  --accent-hover: #b56849;
  --accent-fg: #ffffff;
  --accent-soft: rgba(204, 120, 92, 0.12);

  /* status */
  --ok: #3e8e5a;
  --warn: #c08a3e;
  --err: #c54e3c;
  --link: #5e76a8;

  /* fonts — Claude uses Tiempos (serif) for AI body, Styrene (sans) for UI.
     Use Source Serif 4 / Charter as open fallbacks; Chinese chars naturally
     fall through to PingFang/YaHei (sans) via the cascade. */
  --font-serif: 'Source Serif 4', 'Source Serif Pro', Charter, 'Iowan Old Style',
    'Iowan', Palatino, 'Cambria', Georgia, 'PingFang SC', 'Microsoft YaHei',
    'Noto Serif SC', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI',
    'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(60, 50, 38, 0.05);
  --shadow-sm: 0 2px 6px rgba(60, 50, 38, 0.06);
  --shadow-md: 0 6px 20px rgba(60, 50, 38, 0.08);
  --shadow-lg: 0 16px 40px rgba(60, 50, 38, 0.14);

  --t-fast: .12s ease;
  --t-norm: .2s ease;
}

/* dark theme — toggled via <html data-theme="dark"> */
:root[data-theme="dark"] {
  --bg: #262624;
  --bg-elevated: #30302e;
  --bg-sidebar: #1f1e1c;
  --bg-bubble: #3a3937;
  --bg-input: #3a3937;
  --bg-code: #1f1e1c;
  --bg-card: #30302e;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(204, 120, 92, 0.20);
  --fg: #e8e6dc;
  --fg-strong: #faf9f5;
  --fg-muted: #a09c8c;
  --fg-faint: #75716a;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --accent-soft: rgba(204, 120, 92, 0.20);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button { cursor: pointer; font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--link); text-decoration: underline; text-decoration-color: rgba(94, 118, 168, 0.4);
  text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--link); }

/* code styles — used both in chat output and timeline */
code { background: var(--bg-code); padding: 2px 6px; border-radius: 4px;
  font-size: 0.88em; font-family: var(--font-mono); color: var(--fg-strong); }
pre { background: var(--bg-code); padding: 14px 16px 14px 16px; border-radius: var(--radius-md);
  overflow-x: auto; font-size: 13.5px; border: 1px solid var(--border); position: relative;
  font-family: var(--font-mono); line-height: 1.55; }
pre code { background: transparent; padding: 0; font-size: inherit; color: var(--fg-strong); }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* copy button on code blocks */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--fg-strong); background: var(--bg); }
.copy-btn.copied { color: var(--ok); border-color: rgba(62, 142, 90, 0.3); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(60, 50, 38, 0.16); border-radius: 5px;
  border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(60, 50, 38, 0.28); background-clip: padding-box; border: 2px solid transparent; }

/* ---------- login ---------- */
.login-body {
  display: grid;
  place-items: center;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(204, 120, 92, 0.06), transparent 60%),
    var(--bg);
}
.login-card {
  background: var(--bg-elevated);
  padding: 36px 32px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 320px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.login-card h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--fg-strong);
}
.login-card .muted { color: var(--fg-muted); font-size: 13px; margin: -6px 0 6px; }
.login-card input {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--radius-md);
  font-size: 16px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.login-card input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button {
  padding: 12px;
  background: var(--accent);
  border: 0;
  color: var(--accent-fg);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--t-fast);
}
.login-card button:hover { background: var(--accent-hover); }
.login-card .error { color: var(--err); font-size: 13px; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: 260px 1fr; height: 100vh; height: 100dvh; }

/* ---------- sidebar ---------- */
#sidebar {
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-bottom: var(--safe-bottom);
  border-right: 1px solid var(--border);
}
.sidebar-head { padding: 14px 12px 8px; }
.sidebar-head button {
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.sidebar-head button:hover { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--fg-strong); }
.sidebar-head button .plus { font-size: 16px; line-height: 1; opacity: .7; }

/* model selector — sidebar between "+ 新对话" and the session list */
.model-bar {
  position: relative;
  padding: 0 12px 8px;
}
.model-toggle {
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.model-toggle:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.model-toggle .label-pre { color: var(--fg-faint); font-weight: 400; }
.model-toggle strong { color: var(--fg-strong); font-weight: 500; flex: 1; }
.model-toggle .chevron {
  font-size: 11px;
  color: var(--fg-faint);
  transition: transform .15s ease;
  flex-shrink: 0;
}
.model-toggle.open .chevron { transform: rotate(180deg); color: var(--accent); }

.model-popover {
  display: none;
  position: absolute;
  top: calc(100% - 4px);
  left: 12px;
  right: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 30;
  padding: 4px;
}
.model-popover.open { display: block; animation: fadeIn .12s ease; }
.model-opt {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--t-fast);
}
.model-opt:hover { background: var(--bg-hover); }
.model-opt.active { background: var(--accent-soft); }
.model-opt .model-name { font-size: 13px; color: var(--fg-strong); font-weight: 500; }
.model-opt .model-desc { font-size: 11.5px; color: var(--fg-muted); }
.model-opt.active .model-name { color: var(--accent); }
.model-opt.active::after {
  content: '✓';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.model-opt { position: relative; padding-right: 28px; }

#sessionList {
  list-style: none;
  margin: 0;
  padding: 4px 8px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#sessionList li {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--fg-muted);
  margin-bottom: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--t-fast), color var(--t-fast);
  overflow: hidden;
}
#sessionList li .sess-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#sessionList li:hover { background: var(--bg-hover); color: var(--fg); }
#sessionList li.active { background: var(--bg-elevated); color: var(--fg-strong); }
#sessionList li .del {
  opacity: 0.85;
  color: var(--fg-muted);
  font-size: 14px;
  margin-left: auto;
  padding: 2px 7px;
  min-width: 26px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  background: rgba(60, 50, 38, 0.05);
  transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
}
#sessionList li:hover .del { opacity: 1; color: var(--fg); background: rgba(60, 50, 38, 0.1); }
#sessionList li.active .del { opacity: 1; color: var(--fg-strong); background: rgba(60, 50, 38, 0.1); }
#sessionList li .del:hover { color: var(--err) !important; background: rgba(197, 78, 60, 0.16) !important; opacity: 1; }

.sidebar-foot {
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-foot .foot-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.sidebar-foot .foot-row button:not(.foot-icon-btn) { flex: 1; }
.sidebar-foot button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  text-align: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-foot button:hover { background: var(--bg-hover); color: var(--fg); }
.foot-icon-btn {
  width: 36px;
  flex-shrink: 0;
  font-size: 15px !important;
  padding: 8px !important;
}

.budget {
  font-size: 11.5px;
  color: var(--fg-muted);
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  line-height: 1.5;
}
.budget .bar {
  height: 4px;
  background: rgba(60, 50, 38, 0.08);
  border-radius: 2px;
  margin: 6px 0;
  overflow: hidden;
}
.budget .bar > div { height: 100%; background: var(--ok); transition: width .3s ease; border-radius: 2px; }
.budget.warn .bar > div { background: var(--warn); }
.budget.err .bar > div { background: var(--err); }

#scrim { display: none; position: fixed; inset: 0; background: rgba(60, 50, 38, 0.4); z-index: 40;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#scrim.show { display: block; }

/* ---------- chat main ---------- */
#chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  padding-top: var(--safe-top);
  padding-right: var(--safe-right);
  background: var(--bg);
}
#chatHead {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  background: var(--bg);
  z-index: 1;
}
#chatHead h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--fg-strong);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#hamburger {
  display: none;
  background: transparent;
  border: 0;
  color: var(--fg);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  font-size: 20px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--t-fast);
}
#hamburger:hover { background: var(--bg-hover); }
.cap-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.cap-toggle:hover { background: var(--bg-elevated); color: var(--fg); border-color: var(--border-strong); }

.header-icon-btn {
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.header-icon-btn:hover { background: var(--bg-hover); color: var(--fg-strong); }
.cap-popover {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 18px;
  z-index: 10;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  width: min(440px, calc(100vw - 24px));
  color: var(--fg);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.6;
}
.cap-popover.open { display: block; animation: fadeIn .14s ease; }
.cap-popover strong { font-family: var(--font-sans); font-size: 11.5px; color: var(--fg-muted);
  display: block; margin-top: 8px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.cap-popover strong:first-child { margin-top: 0; }
.cap-popover ul { margin: 6px 0 14px 18px; padding: 0; font-size: 13px; color: var(--fg); }
.cap-popover ul:last-child { margin-bottom: 0; }
.cap-popover li { margin: 4px 0; }

/* ---------- messages: user-right-bubble + assistant-left-naked-serif ---------- */
#messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px 32px;
  scroll-behavior: smooth;
}
.msg-stream {
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.msg {
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  animation: fadeUp .22s ease;
}
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: stretch; }

/* role labels — visual distinction comes from alignment + bubble vs naked serif */
.msg .role { display: none; }

.msg.user .body {
  background: var(--bg-bubble);
  padding: 11px 16px;
  border-radius: 18px;
  border-bottom-right-radius: 6px;
  max-width: 80%;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.msg.assistant .body {
  background: transparent;
  padding: 4px 2px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  /* THE Claude reading vibe: serif for AI output */
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.72;
  color: var(--fg);
  letter-spacing: -.005em;
}
.msg.assistant .body img { max-width: 100%; height: auto; border-radius: var(--radius-md); }
.msg .body p { margin: 0.6em 0; }
.msg .body p:first-child { margin-top: 0; }
.msg .body p:last-child { margin-bottom: 0; }
.msg .body h1, .msg .body h2, .msg .body h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  margin: 1.4em 0 .5em;
  line-height: 1.3;
  letter-spacing: -.01em;
  color: var(--fg-strong);
}
.msg .body h1 { font-size: 1.5em; }
.msg .body h2 { font-size: 1.25em; }
.msg .body h3 { font-size: 1.08em; }
.msg .body ul, .msg .body ol { padding-left: 1.6em; margin: 0.5em 0; }
.msg .body li { margin: .35em 0; }
.msg .body strong { color: var(--fg-strong); font-weight: 600; }
.msg .body em { font-style: italic; }
.msg .body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 1em 0;
  color: var(--fg-muted);
  font-style: italic;
}
.msg .body table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: .94em;
  font-family: var(--font-sans);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.msg .body th, .msg .body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.msg .body th { background: var(--bg-code); font-weight: 600; color: var(--fg-strong); }

.msg .meta {
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--fg-faint);
  margin-top: 8px;
  word-break: break-all;
  align-self: flex-start;
}
.msg.user .meta { align-self: flex-end; }
.msg.error .body { color: var(--err); }

.msg.pending-hint {
  color: var(--fg-muted);
  font-size: 13px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  align-items: center;
  flex-direction: row;
  gap: 8px;
}

/* typing dots — replaces "正在分析..." text spinner */
.typing-dots { display: inline-flex; gap: 5px; align-items: center; padding: 4px 0; }
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-faint);
  animation: typingDot 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }
@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); background: var(--accent); }
}

/* Claude-style thinking block: collapsible <details> with summary + content */
.thinking-block {
  align-self: stretch;
  margin-bottom: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast);
}
.thinking-block:hover { border-color: var(--border-strong); }
.thinking-block summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-muted);
  user-select: none;
  font-size: 13px;
  transition: background var(--t-fast), color var(--t-fast);
}
.thinking-block summary:hover { background: var(--bg-hover); color: var(--fg); }
.thinking-block summary::-webkit-details-marker { display: none; }
.thinking-block summary::before {
  content: '›';
  display: inline-block;
  font-size: 18px;
  line-height: 1;
  color: var(--fg-faint);
  transition: transform .18s ease;
  width: 12px;
  text-align: center;
}
.thinking-block[open] summary::before { transform: rotate(90deg); }
.thinking-block summary strong { color: var(--fg); font-weight: 600; }
.thinking-block .thinking-icon { color: var(--accent); font-size: 13px; line-height: 1; }
.thinking-block .thinking-label { color: var(--fg); font-style: italic; }
.thinking-block .thinking-content {
  padding: 4px 14px 12px 36px;  /* indent past the chevron */
  border-top: 1px solid var(--border);
  background: rgba(60, 50, 38, 0.015);
  max-height: 360px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
}
.thinking-row {
  padding: 3px 0;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--fg-muted);
}
.thinking-row.ok { color: var(--ok); }
.thinking-row.err { color: var(--err); }
.thinking-row.llm { color: var(--accent); }
.thinking-row.status { color: var(--fg-muted); font-style: italic; font-family: var(--font-sans); }
.thinking-row .name { color: var(--fg-strong); font-weight: 500; }
.thinking-row .muted { color: var(--fg-faint); }

.url-hints {
  background: var(--accent-soft);
  border: 1px solid rgba(204, 120, 92, 0.22);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin: 6px 0 8px;
  word-break: break-all;
  font-family: var(--font-sans);
  line-height: 1.6;
}
.url-hints .h { font-weight: 600; color: var(--accent); margin-bottom: 4px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; }
.url-hints .err { color: var(--err); }

/* ---------- composer ---------- */
#composer {
  padding: 14px 20px calc(18px + var(--safe-bottom));
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.composer-wrap {
  width: 100%;
  max-width: 740px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 10px 12px 10px 18px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.composer-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}
#composer textarea {
  flex: 1;
  resize: none;
  min-height: 26px;
  max-height: 200px;
  background: transparent;
  color: var(--fg-strong);
  border: 0;
  padding: 6px 0;
  font: inherit;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  outline: none;
}
#composer textarea::placeholder { color: var(--fg-faint); }
#sendBtn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
#sendBtn:hover:not(:disabled) { background: var(--accent-hover); }
#sendBtn:active:not(:disabled) { transform: scale(.94); }
#sendBtn:disabled { background: rgba(60, 50, 38, 0.15); color: var(--fg-faint); cursor: not-allowed; }
#sendBtn .arrow { line-height: 1; }
#sendBtn .stop-icon { display: none; width: 11px; height: 11px; background: white; border-radius: 2px; }
#sendBtn.sending {
  background: var(--err);
  cursor: pointer;
  animation: stopPulse 1.6s ease-in-out infinite;
}
#sendBtn.sending:hover:not(:disabled) { background: #a23a2c; }
#sendBtn.sending .arrow { display: none; }
#sendBtn.sending .stop-icon { display: inline-block; }
@keyframes stopPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(197, 78, 60, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(197, 78, 60, 0); }
}

.composer-hint {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--fg-faint);
  text-align: center;
  max-width: 740px;
  width: 100%;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
  vertical-align: middle;
}
.spinner-mini {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--accent-fg);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* welcome / empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--fg-muted);
  padding: 60px 20px;
}
.empty-state .greet {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--fg-strong);
  margin-bottom: 14px;
}
.empty-state .greet .accent { color: var(--accent); font-style: italic; }
.empty-state .sub { font-size: 14px; max-width: 460px; line-height: 1.6; }

/* ---------- mobile (<=720px) ---------- */
@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(82vw, 320px);
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    padding-top: var(--safe-top);
    padding-left: var(--safe-left);
    padding-bottom: var(--safe-bottom);
  }
  #sidebar.open { transform: translateX(0); }
  #hamburger { display: inline-flex; }
  #chatHead { padding: 10px 12px; gap: 10px; }
  #chatHead h2 { font-size: 16px; }
  .cap-toggle { padding: 4px 10px; font-size: 11.5px; }
  #messages { padding: 14px 14px 24px; }
  .msg.user .body { max-width: 88%; font-size: 15px; }
  .msg.assistant .body { font-size: 16px; line-height: 1.7; }
  #composer { padding: 10px 12px calc(14px + var(--safe-bottom)); }
  .composer-wrap { padding: 8px 8px 8px 14px; border-radius: 20px; }
  #composer textarea { font-size: 16px; }
  .composer-hint { display: none; }
  /* delete button always visible on touch (no hover) */
  #sessionList li .del { opacity: 0.8; }
  #sessionList li { padding: 10px 10px; font-size: 14px; }
  .empty-state .greet { font-size: 26px; }
  /* always show copy button on mobile (no hover) */
  .copy-btn { opacity: 1; }
}
