:root {
  color-scheme: light;
  --forest: #102d25;
  --forest-hover: #1c4235;
  --forest-text: #fcfbf5;
  --mint: #b9d9c6;
  --mast-line: #537469;
  --paper: #faf7ef;
  --field: #f1eee5;
  --ink: #122c23;
  --muted: #586258;
  --line: #a5ab9e;
  --soft-line: #dedfd4;
  --bubble: #e3ebdf;
  --error: #8b352a;
  --serif: "Noto Serif CJK SC", "Songti SC", "Source Han Serif SC", STSong, SimSun, Georgia, serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --page-width: 788px;
  --auth-width: 454px;
  --gutter: 24px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 280px; }
body { margin: 0; background: var(--forest); color: var(--ink); font: 16px/1.6 var(--sans); }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid #447858; outline-offset: 3px; }
h1, p { margin: 0; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.screen-reader {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.content-width {
  --content-width: var(--page-width);
  width: min(
    var(--content-width),
    calc(100% - max(var(--gutter), env(safe-area-inset-left)) - max(var(--gutter), env(safe-area-inset-right)))
  );
  margin: 0 auto;
}
.auth-width { --content-width: var(--auth-width); }
.auth-masthead, .chat-masthead { color: var(--forest-text); }
.auth-masthead :focus-visible, .chat-masthead :focus-visible { outline-color: var(--mint); }
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) 0 0;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 700 26px/1.15 var(--serif);
  letter-spacing: .015em;
}
.wordmark svg {
  width: 36px;
  height: 36px;
  flex: none;
  fill: none;
  stroke: var(--mint);
  stroke-width: 1.55;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}
.auth-prompt {
  margin-top: clamp(61px, 12.3vh, 114px);
  padding-bottom: clamp(30px, 4.6vh, 43px);
}
h1 { font: 800 clamp(44px, 12vw, 62px)/1.12 var(--serif); letter-spacing: -.035em; }
.auth-intro { color: var(--mint); margin-top: 13px; font-size: 15px; }
.paper { background: var(--paper); border-radius: 13px 13px 0 0; }
.auth-sheet {
  padding: clamp(29px, 5.2vh, 53px) 0 max(32px, env(safe-area-inset-bottom));
}
.auth-sheet label {
  display: block;
  margin-bottom: 7px;
  font: 700 19px/1.35 var(--serif);
}
.auth-sheet input, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font-size: 16px;
}
.auth-sheet input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.auth-sheet input { min-height: 52px; padding: 11px 14px; margin-bottom: 22px; }
.auth-sheet input:focus, textarea:focus { border-color: #3c604e; outline: 2px solid #7eaa8e; outline-offset: 1px; }
.button {
  display: inline-flex;
  min-height: 47px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 650;
  line-height: 1.3;
}
.button:not(:disabled):active { transform: translateY(1px); }
.button-primary { background: var(--forest); color: var(--forest-text); }
.button-primary:disabled { background: #597269; color: #fff; }
.button-outline { border-color: var(--forest); background: var(--paper); color: var(--forest); }
.button-outline:disabled { border-color: var(--line); color: var(--muted); }
@media (hover: hover) {
  .button-primary:not(:disabled):hover { background: var(--forest-hover); }
  .button-outline:not(:disabled):hover { background: var(--bubble); }
}
.button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.auth-submit { width: 100%; min-height: 54px; margin-top: 13px; font: 700 21px/1.2 var(--serif); }
.auth-switch { margin-top: 15px; text-align: center; font-size: 15px; }
.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 5px 3px;
  background: transparent;
  border: 0;
  border-radius: 2px;
  text-underline-offset: 3px;
  text-decoration: underline;
  font-weight: 670;
}
.button-link:disabled { opacity: .65; }
.feedback { color: var(--error); font-size: 14px; overflow-wrap: anywhere; }
.chat-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; }
.chat-header { padding-bottom: 11px; }
.logout { padding-inline: 6px; font-size: 15px; text-decoration: none; }
.logout:hover { text-decoration: underline; }
.quota {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--mast-line);
  padding: 11px 0 19px;
  font-variant-numeric: tabular-nums;
}
.quota-item { display: flex; flex-direction: column; padding: 0 16px 0 13px; }
.quota-item + .quota-item { border-left: 1px solid var(--mast-line); padding-left: clamp(22px, 8vw, 62px); }
.quota-label { color: var(--mint); font-size: 12px; letter-spacing: .065em; }
.quota-value { font: 500 clamp(23px, 5.4vw, 27px)/1.22 Georgia, var(--serif); letter-spacing: .005em; }
.quota-value strong { font-weight: 700; }
.quota-value > span { margin-left: 2px; font-size: .72em; }
.chat-paper {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.conversation {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 16px 2px;
}
.conversation:focus-visible { outline-offset: -3px; }
.empty-chat {
  display: grid;
  place-content: center;
  gap: 13px;
  min-height: 100%;
  padding: 4px 0 70px;
  text-align: center;
}
.empty-chat h1 { font-size: clamp(38px, 10vw, 55px); }
.empty-chat p { color: var(--muted); font-size: 15px; }
.empty-chat .models { color: var(--ink); font: 500 clamp(17px, 4.7vw, 23px)/1.38 Georgia, var(--serif); }
.message-list { display: grid; gap: 18px; padding: 1px 0 4px; }
.message-list:empty { display: none; }
.message-item { min-width: 0; width: min(100%, 41rem); }
.message-item.user { justify-self: end; width: fit-content; max-width: min(88%, 33rem); }
.message-author { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 670; }
.message-item.user .message-author { text-align: right; }
.message-body { overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.65; }
.message-item.user .message-body { background: var(--bubble); padding: 9px 13px; border-radius: 12px 12px 3px 12px; }
.message-item.pending .message-body { color: var(--muted); }
.composer { --gutter: 17px; padding: 10px; border: 1px solid var(--soft-line); border-radius: 15px; background: #fdfaf3; box-shadow: 0 2px 6px #122c230b; }
.composer textarea { height: 58px; min-height: 58px; max-height: 145px; resize: none; padding: 12px; line-height: 1.45; }
.composer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 9px; }
.composer-feedback { margin: 0 2px 8px; }
.call-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  margin-bottom: 7px;
  padding: 5px 11px;
  border-radius: 9px;
  background: #e9eee3;
  color: var(--ink);
  font-size: 14px;
}
.voice-meter { width: 23px; height: 18px; flex: none; stroke: #668673; stroke-width: 2.3; stroke-linecap: round; }
.call-banner:has(button:not([hidden])) .button-link { margin-left: auto; }
.call-banner .button-link { flex: none; min-height: 34px; font-size: 13px; }
.chat-shell:has(#voice-icon[href="#end-icon"]) .call-banner { background: #315242; color: var(--forest-text); }
.chat-shell:has(#voice-icon[href="#end-icon"]) .voice-meter { stroke: var(--mint); }
@media (min-width: 600px) {
  .quota-item { padding-left: 20px; }
  .quota-item + .quota-item { padding-left: 44px; }
  .composer { padding: 11px; }
  .composer-actions { grid-template-columns: minmax(128px, max-content) minmax(98px, max-content); justify-content: end; }
}
@media (max-height: 515px) {
  .chat-header { padding-top: max(5px, env(safe-area-inset-top)); padding-bottom: 1px; }
  .chat-header .wordmark { font-size: 22px; }
  .chat-header .wordmark svg { width: 29px; height: 29px; }
  .quota { padding: 4px 0 7px; }
  .quota-item { flex-direction: row; align-items: center; gap: 6px; }
  .quota-item + .quota-item { padding-left: 8px; }
  .quota-value { font-size: 18px; }
  .conversation { padding: 7px 2px; }
  .composer { padding: 6px; }
  .composer textarea { height: 40px; min-height: 40px; padding: 7px 10px; }
  .composer-actions { margin-top: 5px; }
  .composer .button { min-height: 43px; }
  .empty-chat { gap: 6px; padding-bottom: 0; }
  .empty-chat h1 { font-size: 30px; }
}
@media (max-width: 350px) {
  :root { --gutter: 18px; }
  .auth-intro { font-size: 14px; }
  .quota-item { padding-left: 9px; }
  .composer { --gutter: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
