:root {
  color-scheme: dark;
  --bg: #121715;
  --panel: #1a221e;
  --raised: #242e28;
  --line: #354239;
  --text: #eff5ef;
  --muted: #aebcb2;
  --accent: #d3f992;
  --ink: #182613;
  --error: #ffbdb0;
  --warning: #f0cd89;
  font: 16px/1.55 Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
input, textarea, select { color: var(--text); border: 1px solid var(--line); border-radius: .65rem; background: var(--bg); }
input, textarea { padding: .65rem .75rem; width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: inline-block; margin: .6rem 0 .3rem; }
h1, h2, p { margin: 0; }
a { color: var(--accent); }
.shell {
  max-width: 48rem;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.shell.chat { display: flex; flex-direction: column; min-height: 0; height: 100vh; height: 100dvh; height: var(--chat-height, 100dvh); padding-bottom: max(.5rem, env(safe-area-inset-bottom)); }
.shell.chat > main, #conversation { flex: 1 1 0; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.masthead, .brand, .brand-title, .field-row, .composer-actions, .pref-actions { display: flex; align-items: center; gap: .65rem; }
.masthead {
  flex: none;
  justify-content: space-between;
  padding: max(.8rem, env(safe-area-inset-top)) 0 .7rem;
  border-bottom: 1px solid var(--line);
}
.brand, .brand-copy { min-width: 0; }
.brand-mark {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: .68rem;
  background: var(--accent);
  color: var(--ink);
}
.brand-mark::after, .empty-mark span { content: ""; width: 0; height: 0; border-block: .4rem solid transparent; border-left: .65rem solid currentColor; margin-left: .12rem; }
.brand-title { gap: .45rem; line-height: 1.25; }
.brand-title strong { font-size: 1.1rem; white-space: nowrap; }
.brand-name { color: var(--muted); font-size: .72rem; }
.chat-title, .chat .guest-title { display: none; }
.chat .chat-title { display: inline; }
.service { display: flex; align-items: baseline; gap: .4rem; color: var(--muted); font-size: .77rem; margin-top: .2rem; }
.light { width: .42rem; height: .42rem; border-radius: 50%; background: #83938a; flex: none; }
.service[data-state="ready"] .light { background: var(--accent); }
.service[data-state="busy"] .light, .service[data-state="attention"] .light { background: var(--warning); }
.panel, .composer { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; }
.login { max-width: 30rem; margin: clamp(1.5rem, 9vh, 6rem) auto 0; padding: clamp(1.15rem, 6vw, 2rem); }
.login h1 { font-size: clamp(1.37rem, 5.5vw, 1.85rem); letter-spacing: -.035em; line-height: 1.25; }
.login p { color: var(--muted); font-size: .88rem; margin: .6rem 0 .95rem; }
.quiet, .primary, select {
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: .63rem;
  font-size: .86rem;
  font-weight: 650;
  padding: .42rem .72rem;
  white-space: nowrap;
}
.quiet { background: transparent; color: var(--text); }
.secondary, select { border-color: var(--line); background: var(--raised); color: var(--text); }
.primary { display: inline-flex; align-items: center; justify-content: center; color: var(--ink); background: var(--accent); text-decoration: none; }
.login-submit { width: 100%; margin-top: 1.1rem; }
.alert { color: var(--error); font-size: .82rem; }
.alert[data-kind="success"] { color: var(--accent); }
.alert:empty, #result-note:empty { display: none; }
#preferences { flex: none; max-height: 34%; overflow: auto; margin-top: .6rem; padding: .72rem; }
#preferences label { margin-top: 0; font-size: .9rem; }
#account, #preference-note { color: var(--muted); font-size: .75rem; }
#account, .sign-out { margin-left: auto; }
.sign-out { color: var(--muted); }
.queue {
  flex: none;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: .55rem;
  margin-top: .55rem;
  padding: .4rem .66rem;
  background: var(--panel);
  color: var(--muted);
  font-size: .8rem;
}
.queue[data-kind="waiting_customer"], .queue[data-kind="offline"] { border-left-color: var(--warning); }
.queue strong { color: var(--text); font-size: .83rem; }
#queue-hint { display: block; font-size: .74rem; }
#queue-hint:empty { display: none; }
.thread-frame { position: relative; flex: 1 1 0; min-height: 0; }
.thread { position: absolute; inset: 0; min-width: 0; overflow-y: auto; overscroll-behavior-y: contain; scroll-padding-block: .45rem; }
.history-actions { text-align: center; padding: .55rem .5rem .25rem; }
.history-actions button { min-height: 2.4rem; }
#jump-latest { flex: none; align-self: flex-end; min-height: 2.25rem; margin: .2rem .35rem; }
.empty-chat {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 100%;
  text-align: center;
  gap: .6rem;
  padding: .8rem 1rem 1.5rem;
}
.empty-chat h1 { font-size: clamp(1.5rem, 6vw, 2rem); letter-spacing: -.03em; line-height: 1.2; }
.empty-chat p { max-width: 17rem; font-size: .85rem; color: var(--muted); }
.empty-mark {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  margin-bottom: .18rem;
  border: 1px solid #506149;
  border-radius: 1.1rem;
  color: var(--accent);
  background: radial-gradient(circle at 50% 20%, #34432f, #222e25 75%);
}
.empty-chat button { margin-top: .35rem; padding-inline: 1rem; }
.messages { list-style: none; display: flex; flex-direction: column; gap: .8rem; margin: 0; padding: .75rem 0 1rem; }
.messages li { max-width: min(96%, 41rem); border-radius: .88rem; padding: .65rem .8rem; overflow-wrap: anywhere; }
.bubble-text { white-space: pre-wrap; line-height: 1.65; }
.bubble-text code { background: var(--raised); border-radius: .2rem; padding: .05em .2em; }
.reply-collapsed { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }
.reply-toggle { display: block; color: var(--accent); min-height: 2.4rem; padding-inline: 0; }
.messages .user { align-self: flex-end; max-width: min(88%, 40rem); background: #2b3d28; border-bottom-right-radius: .3rem; }
.messages .agent { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: .3rem; }
.messages .preview-open { width: min(96%, 41rem); }
.detail { font-size: .76rem; color: var(--muted); margin-top: .32rem; }
.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .42rem .55rem;
  align-items: center;
  min-width: 0;
  margin-top: .75rem;
  padding: .56rem;
  border: 1px solid #445743;
  border-radius: .72rem;
  background: #213027;
}
.result-title { display: block; font-size: .88rem; }
.result-data { display: block; font-size: .74rem; color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .36rem; }
.result-actions button, .result-actions a { padding-inline: .47rem; }
.result-panel { margin-top: .6rem; padding: .6rem; background: var(--bg); scroll-margin-top: .4rem; }
.result-heading, .result-download-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.result-heading { justify-content: space-between; }
.result-heading h2 { font-size: 1.025rem; }
.result-panel video {
  display: block;
  width: 100%;
  aspect-ratio: 9/16;
  max-height: calc(var(--chat-height, 100vh) * .38);
  margin-top: .55rem;
  border-radius: .6rem;
  background: #080d0a;
}
.result-download-actions a { text-decoration: none; }
.composer { flex: 0 0 auto; max-height: 48%; overflow-y: auto; margin-top: .28rem; padding: .58rem; }
.composer textarea { display: block; border: 0; background: transparent; resize: none; min-height: 2.45rem; max-height: 6.5rem; padding: .4rem .5rem; }
.composer-actions { flex-wrap: nowrap; gap: .4rem; padding-top: .26rem; }
.composer-actions select { min-width: 0; max-width: 52%; text-overflow: ellipsis; }
.composer-actions .primary { margin-left: auto; min-width: 3.3rem; }
.plus { color: var(--accent); font-weight: 400; font-size: 1.16em; }
.file-line { display: flex; align-items: center; justify-content: space-between; gap: .35rem; border-radius: .58rem; background: var(--raised); padding: .15rem .3rem .15rem .6rem; margin-bottom: .26rem; }
.file-copy { min-width: 0; }
.file-copy strong { display: block; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-copy small { display: block; font-size: .7rem; color: var(--muted); }
.upload-state { display: flex; align-items: center; gap: .5rem; padding: .2rem .3rem; font-size: .75rem; color: var(--muted); }
.upload-state progress { width: 100%; height: .55rem; accent-color: var(--accent); }
.composer .alert { margin: .25rem .25rem 0; }
.a11y { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
.compact .masthead { padding-block: max(.26rem, env(safe-area-inset-top)) .25rem; }
.compact .empty-chat { gap: .35rem; padding: .5rem 0; }
.compact .empty-mark { display: none; }
.compact .composer textarea { max-height: 3.2rem; }
@media (max-width: 355px) {
  .shell { padding-inline: max(.55rem, env(safe-area-inset-left)) max(.55rem, env(safe-area-inset-right)); }
  .brand-name { display: none; }
  .composer-actions { gap: .3rem; }
  .composer-actions button, .composer-actions select { padding-inline: .4rem; font-size: .78rem; }
  .result { grid-template-columns: minmax(0, 1fr); }
  .result-actions { justify-content: flex-start; }
}
