:root {
  color-scheme: light;
  --bg: #f1f5f5;
  --surface: #fff;
  --subtle: #eff4f4;
  --border: #d7e2e2;
  --text: #152329;
  --muted: #52686c;
  --accent: #08736d;
  --accent-hover: #065c57;
  --on-accent: #fff;
  --accent-soft: #d9f3ee;
  --error: #a32c46;
  --shadow: 0 16px 54px #14252f14;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #091015;
  --surface: #10191f;
  --subtle: #17252b;
  --border: #2a3b42;
  --text: #eef7f6;
  --muted: #a0b6b9;
  --accent: #61ded1;
  --accent-hover: #91ebe1;
  --on-accent: #0c211f;
  --accent-soft: #173d3b;
  --error: #ff9aaa;
  --shadow: 0 16px 54px #0006;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #091015;
    --surface: #10191f;
    --subtle: #17252b;
    --border: #2a3b42;
    --text: #eef7f6;
    --muted: #a0b6b9;
    --accent: #61ded1;
    --accent-hover: #91ebe1;
    --on-accent: #0c211f;
    --accent-soft: #173d3b;
    --error: #ff9aaa;
    --shadow: 0 16px 54px #0006;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.5 system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button, input, select, textarea { min-height: 42px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.25rem, 3vw, 1.65rem); line-height: 1.25; letter-spacing: -.025em; }
h2 { font-size: 1.1rem; line-height: 1.3; }
p, small { color: var(--muted); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px max(16px, calc((100vw - 1180px)/2)); border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 750; letter-spacing: -.045em; }
.preferences { display: flex; gap: 8px; }
.preferences label { font-size: .71rem; line-height: 1.15; }
.profile-button { align-self: end; border-color: var(--border); }
label { display: grid; gap: 4px; font-size: .85rem; font-weight: 650; }
input, textarea, select { border: 1px solid var(--border); border-radius: 9px; background: var(--surface); padding: 7px 10px; }
select { font-size: .85rem; }
button { border: 1px solid transparent; border-radius: 9px; padding: 8px 14px; font-weight: 650; }
.primary { background: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: .6; cursor: wait; }
.quiet { background: transparent; color: var(--muted); }
.quiet:hover { color: var(--text); background: var(--subtle); }
.secondary { background: var(--accent-soft); color: var(--accent); }
.secondary:hover { border-color: var(--accent); }
.eyebrow { color: var(--accent); font-size: .68rem; text-transform: uppercase; letter-spacing: .13em; font-weight: 750; }
.access { padding: min(10vh, 86px) 16px; display: grid; justify-items: center; }
.access-card { display: grid; gap: 8px; width: min(100%, 430px); padding: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); }
.access-card label { margin-top: 5px; }
.access-card .primary { margin-top: 7px; }
.field-group { display: grid; gap: 5px; }
.error { color: var(--error); font-size: .85rem; }
.success { color: var(--accent); }
.error:empty { display: none; }
.workspace { display: grid; grid-template-columns: 256px minmax(0, 1fr); max-width: 1180px; height: min(820px, calc(100dvh - 123px)); min-height: 420px; margin: 24px auto; border: 1px solid var(--border); border-radius: 19px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.sidebar { display: flex; flex-direction: column; min-width: 0; padding: 20px 15px 10px; border-right: 1px solid var(--border); background: var(--surface); overflow: auto; }
.sidebar-header { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.new-chat, .chat-list { display: grid; gap: 7px; }
.new-chat { grid-template-columns: minmax(0, 1fr); }
.new-chat-row { display: flex; min-width: 0; gap: 6px; }
.new-chat input { flex: 1 1 0; width: 0; min-width: 0; }
.new-chat button { flex: 0 0 auto; }
.chat-list { margin-top: 15px; }
.chat-link { text-align: start; background: var(--subtle); overflow-wrap: anywhere; }
.chat-link:hover { border-color: var(--accent); }
.chat-link[aria-current] { color: var(--accent); background: var(--accent-soft); }
.sidebar-footer { display: grid; justify-items: center; gap: 4px; margin-top: auto; padding-top: 16px; }
.sidebar-footer small { font-size: .72rem; }
dialog { width: min(calc(100% - 32px), 420px); max-height: calc(100dvh - 32px); color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 23px; box-shadow: var(--shadow); }
dialog::backdrop { background: #091015a8; }
.profile-form { display: grid; gap: 10px; }
.language-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 4px 0 0; padding: 0; border: 0; min-width: 0; }
.profile-info { display: grid; gap: 8px; background: var(--subtle); border-radius: 10px; margin: 0 0 5px; padding: 12px; }
.profile-info dt { color: var(--muted); font-size: .76rem; }
.profile-info dd { margin: 0; overflow-wrap: anywhere; }
.profile-form p { font-size: .87rem; }
.profile-form .success { color: var(--accent); }
.profile-actions { display: flex; justify-content: end; gap: 6px; }
.logout { justify-self: start; }
.conversation { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; }
.conversation-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 18px clamp(13px, 3vw, 28px); border-bottom: 1px solid var(--border); }
.conversation-header p { margin-top: 4px; font-size: .85rem; }
.connection { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); background: var(--subtle); border-radius: 18px; padding: 5px 10px; font-size: .72rem; font-weight: 650; }
.connection::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: currentColor; }
.connection[data-state="live"] { background: var(--accent-soft); color: var(--accent); }
.timeline { overflow-y: auto; padding: 18px clamp(12px, 3vw, 28px); background: var(--bg); }
.timeline:focus-visible { outline-offset: -3px; }
.empty { display: grid; place-items: center; align-content: center; text-align: center; gap: 10px; min-height: 100%; }
.empty p { max-width: 33ch; font-size: .9rem; }
.empty-icon { display: grid; place-items: center; width: 47px; height: 47px; background: var(--accent-soft); color: var(--accent); border-radius: 15px; font-size: 1.5rem; }
.messages { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bubble { justify-self: start; max-width: min(88%, 560px); min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px 12px 12px 3px; background: var(--surface); }
.bubble.mine { justify-self: end; border-color: transparent; border-radius: 12px 12px 3px 12px; background: var(--accent-soft); }
.bubble-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 10px; margin-bottom: 3px; font-size: .73rem; color: var(--muted); }
.bubble-meta strong { color: var(--text); }
.bubble p { white-space: pre-wrap; overflow-wrap: anywhere; text-align: start; color: var(--text); }
.bubble .translation-status { font-size: .75rem; color: var(--muted); margin-top: 5px; }
.original-toggle { padding: 4px 0; background: transparent; color: var(--accent); font-size: .76rem; }
.bubble .original { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--muted); }
.composer { display: grid; gap: 7px; padding: 11px clamp(12px, 3vw, 28px) 16px; border-top: 1px solid var(--border); }
.composer-row { display: flex; gap: 9px; align-items: center; justify-content: space-between; }
textarea { width: 100%; min-width: 0; resize: vertical; }
.composer-row .primary { align-self: stretch; }
@media (max-width: 1212px) { .workspace { margin-inline: 16px; } }
@media (max-width: 680px) {
  body:has(.workspace:not([hidden])) { display: flex; flex-direction: column; min-height: 100dvh; }
  .topbar { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .workspace { flex: 1; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); width: 100%; height: auto; min-height: 440px; margin: 0; border: 0; border-radius: 0; }
  .sidebar { padding: 9px 12px 4px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-header h2 { display: none; }
  .new-chat { gap: 3px; }
  .chat-list { display: flex; overflow-x: auto; margin-top: 6px; }
  .chat-link { flex: 0 0 auto; }
  .sidebar-footer { padding-top: 4px; }
  .conversation-header { padding-block: 11px; }
  .connection { max-width: 45%; }
  .timeline { max-height: 55dvh; }
}
