:root { --bg: #f5f6f8; --paper: #fff; --ink: #1f2328; --muted: #606b77; --line: #dce1e6; --accent: #0969da; --teal: #0e7465; --danger: #b42332; }
* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; }
button, input, textarea { font: inherit; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 6px; padding: 10px 16px; background: var(--accent); color: white; cursor: pointer; }
button:hover { filter: brightness(.94); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, textarea { min-width: 0; width: 100%; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 6px; padding: 10px 12px; }
textarea { resize: vertical; line-height: 1.6; }
label { display: grid; gap: 8px; }
svg { width: 19px; height: 19px; flex-shrink: 0; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 18px; }
.brand svg { color: var(--teal); width: 26px; height: 26px; }
.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #f5f6f8, #eaf2f1); }
.login-form { width: min(100%, 360px); display: grid; gap: 24px; }
.login-form .brand { margin-bottom: 20px; }
.login-form input { height: 44px; }
.workspace { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: 100dvh; }
.sidebar { background: #f0f3f5; border-right: 1px solid var(--line); padding: 24px 16px 12px; display: flex; flex-direction: column; gap: 20px; min-height: 0; min-width: 0; }
.new-chat { background: var(--paper); color: var(--ink); border-color: var(--line); }
.search { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.search input { background: transparent; padding: 8px; }
#conversation-list { flex: 1; overflow-y: auto; min-height: 0; }
.conversation-link { display: block; width: 100%; text-align: left; color: var(--muted); background: transparent; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; padding: 12px; }
.conversation-link.active { color: var(--ink); background: #e1e9f0; border-left: 3px solid var(--accent); padding-left: 10px; }
.account { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 12px; gap: 8px; }
#account-name { overflow-wrap: anywhere; }
.conversation { background: var(--paper); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.conversation-head { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 18px 24px; min-width: 0; }
.heading { flex: 1; min-width: 0; }
.heading h1 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#model-label { display: block; font-size: 12px; color: var(--teal); margin-top: 5px; overflow-wrap: anywhere; }
.tools { display: flex; flex-shrink: 0; gap: 4px; }
.icon-button { width: 36px; height: 36px; padding: 0; background: transparent; color: var(--muted); flex-shrink: 0; }
.icon-button:hover { background: var(--bg); }
.danger { color: var(--danger); }
.chat-window { overflow-y: auto; min-height: 0; padding: 24px max(24px, calc((100% - 820px) / 2)); scroll-behavior: smooth; }
.empty-state { min-height: 200px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; color: var(--teal); }
.message { padding: 18px 0; border-bottom: 1px solid #edf0f2; }
.message-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.message-head strong { color: var(--teal); overflow-wrap: anywhere; }
.message.user .message-head strong { color: var(--accent); }
.message-head time { color: var(--muted); font-size: 11px; flex: 1; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; font-size: 15px; }
.usage, .call-status { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.call-status.failed, .call-status.unknown, .call-status.incomplete { color: var(--danger); }
.call-status.pending { color: var(--teal); }
.compose-area { padding: 12px 24px max(12px, env(safe-area-inset-bottom)); width: min(100%, 868px); justify-self: center; }
summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
#system { margin-bottom: 12px; max-height: 140px; }
.compose { display: flex; align-items: flex-end; gap: 8px; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
#input { border: 0; background: transparent; min-height: 70px; max-height: 180px; resize: vertical; }
#send { background: var(--accent); color: white; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attachment { position: relative; width: 72px; height: 72px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--paper); }
.attachment img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attachment .icon-button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 4px; background: rgb(20 30 40 / 60%); color: white; }
.attachment .icon-button:hover { background: rgb(20 30 40 / 82%); }
.attachment svg { width: 14px; height: 14px; }
.gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gallery img { max-width: 220px; max-height: 220px; border: 1px solid var(--line); border-radius: 6px; display: block; }
.voice-panel { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--teal); border-radius: 8px; background: #edf7f5; }
#voice-state { color: var(--teal); font-size: 12px; font-weight: 650; }
.voice-transcript { flex: 1; min-width: 160px; max-height: 60px; overflow-y: auto; margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.danger-button { background: var(--danger); padding: 8px 12px; font-size: 12px; }
.status { margin: 8px 0 0; min-height: 20px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.status.err { color: var(--danger); }
dialog { border: 1px solid var(--line); border-radius: 8px; padding: 24px; width: min(420px, calc(100% - 32px)); color: var(--ink); }
dialog::backdrop { background: rgb(20 30 40 / 35%); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.secondary { background: var(--bg); color: var(--ink); }
.mobile-only { display: none; }
@media (max-width: 700px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: fixed; z-index: 5; top: 76px; bottom: 0; left: 0; width: min(290px, 85vw); box-shadow: 8px 0 24px rgb(0 0 0 / 12%); }
  .sidebar.open { display: flex; }
  .mobile-only { display: inline-flex; }
  .conversation-head { padding: 12px 8px; gap: 4px; min-height: 76px; }
  .heading h1 { font-size: 15px; }
  .tools { gap: 0; }
  .icon-button { width: 32px; height: 36px; }
  .chat-window { padding: 12px 16px; }
  .compose-area { padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }
  .gallery img { max-width: 140px; max-height: 140px; }
  input, textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { .chat-window { scroll-behavior: auto; } }
