:root {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #202d29;
  background: #f8f9f5;
  --paper: #fcfdf9;
  --green: #275448;
  --deep: #1b3e35;
  --muted: #55655f;
  --line: #dbe3da;
  --soft: #e9f0e8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid #4b8474; outline-offset: 3px; }
h1, h2, p { margin: 0; }
small { color: var(--muted); }
button { border: 1px solid transparent; border-radius: 9px; color: inherit; background: none; }
.primary, .outline, .quiet { padding: .61rem .9rem; font-weight: 650; }
.primary { background: var(--green); color: white; }
.primary:hover:not(:disabled) { background: var(--deep); }
.outline { border-color: var(--line); background: var(--paper); }
.outline:hover:not(:disabled), .quiet:hover:not(:disabled) { background: var(--soft); }
.quiet { color: var(--green); }
.danger { color: #953626; }
.eyebrow { color: var(--green); font-size: .75rem; letter-spacing: .11em; font-weight: 700; }
.muted { color: var(--muted); line-height: 1.55; }
.notice { color: var(--muted); font-size: .85rem; line-height: 1.5; }
.notice:empty { display: none; }
.notice.error { color: #962f24; }
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 750; letter-spacing: .03em; }
.mark, .welcome-mark { display: grid; place-items: center; background: var(--green); color: #fff; border-radius: 11px; width: 36px; height: 36px; }
.auth-screen { min-height: 100dvh; padding: clamp(1rem, 5vw, 3.5rem); display: grid; grid-template-rows: auto 1fr; background: radial-gradient(ellipse at 70% 35%, #e8f1e5, transparent 64%), #f8f9f5; }
.auth-card { align-self: center; justify-self: center; width: min(100%, 440px); margin-block: 2rem; border-radius: 22px; border: 1px solid var(--line); background: var(--paper); padding: clamp(1.5rem, 5vw, 2.6rem); box-shadow: 0 18px 55px #263d2920; }
.auth-card h1 { font-size: clamp(1.6rem, 5vw, 2.05rem); margin-block: .45rem .65rem; }
.auth-card form { margin-top: 1.35rem; }
.auth-card .notice { margin-top: .75rem; }
form:not(.composer), .form-grid { display: grid; gap: .85rem; }
form label:not(.check) { display: grid; gap: .4rem; font-size: .88rem; font-weight: 650; }
form label small { font-weight: 400; }
input:not([type=checkbox]), textarea, select { width: 100%; min-width: 0; color: inherit; background: white; border: 1px solid #bdcbbf; border-radius: 9px; padding: .66rem .72rem; }
textarea { resize: vertical; }
.workspace { min-height: 100dvh; display: grid; grid-template-columns: minmax(205px, 258px) minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; background: #eef2e9; border-right: 1px solid var(--line); height: 100dvh; padding: 1.3rem 1rem .9rem; gap: 1rem; }
.sidebar .brand { padding: .2rem .45rem .55rem; font-size: 1.13rem; }
.sections { display: grid; gap: .28rem; }
.nav-button, .chat-link { width: 100%; text-align: left; padding: .65rem .75rem; }
.nav-button { display: flex; align-items: center; gap: .6rem; font-weight: 650; }
.nav-button span { min-width: 1.1rem; color: var(--green); }
.nav-button[aria-current], .chat-link[aria-current], .nav-button:hover, .chat-link:hover { background: #dce8dc; }
.history-label { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.history-label h2 { font-size: .79rem; padding-left: .45rem; color: var(--muted); }
.history-label .outline { font-size: .78rem; padding: .37rem .55rem; }
.chat-list, .message-list, .item-list { list-style: none; padding: 0; margin: 0; }
.chat-list { flex: 1 1 auto; min-height: 0; overflow: auto; }
.chat-list .muted { padding: .45rem; font-size: .83rem; }
.chat-link { font-size: .87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-button { width: 100%; padding: .65rem .45rem; border-top: 1px solid var(--line); border-radius: 0; text-align: left; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: .55rem; }
.profile-button:hover { background: var(--soft); }
.profile-button strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.profile-button small { display: block; font-size: .73rem; margin-top: .2rem; }
.avatar, .welcome-mark { border-radius: 50%; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; background: #d8e7da; color: var(--deep); font-weight: 750; }
.profile-arrow { color: var(--muted); font-size: 1.2rem; }
.main { min-width: 0; display: grid; grid-template-rows: auto minmax(0,1fr); height: 100dvh; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: 1rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar h1 { font-size: clamp(1.15rem, 3.2vw, 1.55rem); margin-top: .18rem; overflow-wrap: anywhere; }
.view-heading { min-width: 0; }
.conversation-id { display: flex; flex-wrap: wrap; align-items: center; gap: .18rem .5rem; margin-top: .28rem; color: var(--muted); font-size: .75rem; }
.conversation-id code { overflow-wrap: anywhere; user-select: all; }
.conversation-id button { padding: .18rem .4rem; font-size: inherit; }
.conversation-id [role=status]:empty { display: none; }
.status-pill { border-radius: 999px; padding: .42rem .65rem; background: #e3eee4; color: var(--deep); white-space: nowrap; font-size: .74rem; font-weight: 650; }
.status-pill.offline { background: #f3ece0; color: #71552a; }
.chat-panel { display: grid; grid-template-rows: auto minmax(0,1fr) auto; min-height: 0; }
.due-reminders { grid-row: 1; width: min(calc(100% - 2rem), 760px); margin: .65rem auto 0; padding: .5rem .7rem; border: 1px solid #ddd9be; border-radius: 12px; background: #f8f4e5; }
.reminder-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.reminder-heading h2 { font-size: .85rem; color: #655128; }
.reminder-heading .quiet { padding: .3rem .5rem; font-size: .78rem; }
.reminder-list { display: grid; gap: .35rem; max-height: 24dvh; overflow: auto; }
.reminder-list .item { padding: .4rem .5rem; font-size: .86rem; }
.reminder-list .actions button { padding: .32rem .46rem; font-size: .75rem; }
.reminder-list .item small { margin-top: .1rem; }
.reminder-list .item-text, .item-list .item-text { min-width: 0; }
.messages { grid-row: 2; }
.composer { grid-row: 3; }
.messages { overflow-y: auto; padding: 1rem clamp(.9rem, 4vw, 2.5rem); }
.welcome { margin: clamp(2rem, 10vh, 6rem) auto 2rem; text-align: center; max-width: 32rem; }
.welcome h2 { font-size: clamp(1.55rem, 4vw, 2.5rem); letter-spacing: -.03em; }
.welcome p { margin-top: .65rem; color: var(--muted); line-height: 1.6; }
.welcome-mark { margin: 0 auto 1.05rem; width: 49px; height: 49px; font-size: 1.45rem; }
.message-list { max-width: 760px; margin: auto; display: grid; gap: 1rem; }
.message { justify-self: start; max-width: min(88%, 660px); }
.message.user { justify-self: end; }
.message small { display: block; margin-bottom: .28rem; font-size: .73rem; }
.message.user small { text-align: right; }
.correction-button { display: block; margin-left: auto; font-size: .72rem; padding: .25rem .1rem; color: var(--muted); }
.bubble { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; border-radius: 14px; padding: .7rem .9rem; background: white; border: 1px solid var(--line); }
.message.user .bubble { background: #e5efe3; }
.composer { width: min(100%, 812px); margin: 0 auto; padding: .65rem clamp(.9rem, 3vw, 1.5rem) .85rem; }
.composer textarea { display: block; max-height: 26dvh; min-height: 3.25rem; }
.composer-bar, .actions { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.composer-bar { justify-content: space-between; margin-top: .55rem; }
.check { display: flex; align-items: center; gap: .36rem; font-size: .82rem; color: var(--muted); }
.check input { accent-color: var(--green); }
.fineprint { margin-top: .4rem; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.composer .notice { margin-top: .45rem; }
.voice-preview { max-height: 5rem; overflow: auto; margin-top: .4rem; font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.voice-preview:empty { display: none; }
#voice-controls { margin-top: .4rem; display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.voice-option { display: flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--muted); }
.voice-option select { width: auto; max-width: 13rem; padding: .35rem .45rem; }
#voice-audition { padding: .4rem .6rem; font-size: .82rem; }
#voice-history { margin-top: .5rem; }
#voice-history-list { max-height: 18rem; overflow: auto; }
.voice-record { border-top: 1px solid var(--line); padding: .5rem 0; font-size: .85rem; }
.voice-record p { margin: .35rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.voice-record audio { display: block; max-width: 100%; height: 36px; margin: .35rem 0; }
.voice-record a { color: var(--green); }
.scroll-panel { overflow-y: auto; padding: clamp(1rem, 4vw, 2.5rem); }
.section-intro, .card, .item-list, .section-actions, .scroll-panel > .notice { max-width: 760px; margin-inline: auto; }
.section-intro h2 { font-size: 1.35rem; }
.admin-memory-heading { margin-top: 1.75rem; }
.memory-audit-group { display: grid; gap: .5rem; margin-top: .8rem; }
.memory-audit-group h3 { margin: 0; font-size: .94rem; }
.memory-audit-group .item-text { font-size: .86rem; }
.memory-audit-group details .item { margin-top: .5rem; }
.memory-preferences { margin-bottom: .75rem; }
.memory-preferences h3 { margin: 0; font-size: 1rem; }
.section-intro p { color: var(--muted); margin-block: .4rem 1.15rem; line-height: 1.6; }
.card, .item { background: var(--paper); border: 1px solid var(--line); border-radius: 13px; padding: .9rem 1.1rem; }
.item-list { display: grid; gap: .6rem; margin-top: 1rem; }
.item { display: flex; gap: .75rem; align-items: center; justify-content: space-between; }
.item .item-text { overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.55; }
.item small { display: block; margin-top: .25rem; }
.item button { flex-shrink: 0; }
dialog { width: min(460px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); color: inherit; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; padding: 1.3rem; }
dialog::backdrop { background: #172b23a0; }
details summary { font-size: .88rem; cursor: pointer; color: var(--green); }
details label { margin-top: .7rem; }
#logout { margin-right: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 650px) {
  .workspace { display: block; }
  .sidebar { height: auto; padding: .7rem .85rem .4rem; gap: .4rem; border-right: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .sidebar .brand { padding: 0; }
  .profile-button { grid-column: 2; grid-row: 1; justify-self: end; width: auto; border-top: 0; padding: .3rem; }
  .sections, .history-label, .chat-list, #older-chats { grid-column: 1 / -1; }
  .sections { display: flex; overflow-x: auto; }
  .sections .nav-button { flex: 0 0 auto; width: auto; white-space: nowrap; }
  .nav-button { padding: .46rem .45rem; font-size: .78rem; }
  .history-label { padding-right: .2rem; }
  .chat-list { display: flex; gap: .3rem; overflow-x: auto; }
  .chat-link { width: max-content; max-width: 11rem; }
  .main { height: auto; min-height: calc(100dvh - 181px); }
  .chat-panel { min-height: 58dvh; grid-template-rows: auto minmax(15rem, 1fr) auto; }
  .reminder-list .item, #reminder-list .item { flex-wrap: wrap; }
  .topbar { padding-block: .6rem; }
  .welcome { margin-block: 1.4rem; }
}

#timings-dialog { width: min(720px, calc(100% - 2rem)); overflow-wrap: anywhere; }
#timings-dialog summary { cursor: pointer; font-weight: 600; }
#timings-dialog details p { margin: .45rem 0; font-variant-numeric: tabular-nums; }
