:root {
  color-scheme: light;
  --paper: #f3efe6;
  --surface: #fcf8ef;
  --ink: #23261f;
  --muted: #5f6256;
  --line: #d9d3c4;
  --forest: #242e26;
  --forest-deep: #1c251e;
  --forest-line: #414e42;
  --forest-text: #eaeade;
  --forest-muted: #bac2b5;
  --accent: #a73c25;
  --accent-mist: #f4dfd5;
  --good: #315844;
  --good-mist: #dfe9db;
  --warn: #775221;
  --warn-mist: #f3e5c8;
  --focus: #9b5b33;
  --body-font: "Aptos", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --display-font: "Noto Serif SC", "Noto Serif CJK SC", "Songti SC", "Source Han Serif SC", "SimSun", serif;
  font-family: var(--body-font);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
button, a, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
button, a { touch-action: manipulation; }
h1, h2, h3, p, ul, ol { margin: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.symbols, .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.button, .icon-button {
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 7px;
  text-decoration: none;
  font-weight: 650;
}
.button.primary { background: var(--accent); color: var(--surface); }
.button.primary:hover:not(:disabled), .send-button:hover:not(:disabled) { background: #852b19; }
.button.quiet { border-color: var(--line); }
.button.quiet:hover:not(:disabled) { background: #eae3d6; }
.icon-button { width: 44px; padding-inline: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #d5a15f;
  color: var(--forest-deep);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-lockup { display: flex; align-items: center; gap: 11px; line-height: 1.25; }
.brand-lockup strong { display: block; font: 750 19px/1.15 var(--display-font); letter-spacing: .11em; }
.brand-lockup div span { display: block; margin-top: 5px; color: var(--forest-muted); font-size: 11px; white-space: nowrap; }

.initial-view { display: grid; min-height: 100svh; place-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; }
.login-view { display: grid; grid-template-columns: .98fr 1.02fr; min-height: 100svh; }
.login-brand {
  background: radial-gradient(ellipse at 19% 100%, #394638, transparent 75%), var(--forest);
  color: var(--forest-text);
  display: flex;
  min-width: 0;
  min-height: 480px;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(22px, 5vw, 72px);
}
.login-cover-title { color: #f3e8d2; font: 700 clamp(42px, 6vw, 92px)/1.18 var(--display-font); letter-spacing: -.05em; }
.film-edge { align-self: stretch; max-width: 248px; height: 10px; opacity: .68; background: repeating-linear-gradient(90deg, #b4946a 0 12px, transparent 12px 24px); }
.login-card { margin: auto; padding: clamp(26px, 5vw, 60px); width: min(100%, 516px); }
.login-card h1, .admin-heading h1 { font: 760 clamp(30px, 3vw, 47px)/1.18 var(--display-font); letter-spacing: -.04em; }
.login-card > p, .admin-heading p { color: var(--muted); margin-top: 9px; }
.login-form { margin-top: 36px; display: grid; gap: 8px; }
.login-form label { font-size: .9rem; font-weight: 700; }
.login-form input { width: 100%; min-height: 47px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 9px 12px; }
.login-form .button { margin-top: 6px; min-height: 48px; }
.inline-error { color: var(--accent); font-size: .88rem; }

.workspace { display: grid; grid-template-columns: 247px minmax(0, 1fr); min-height: 100svh; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 360px;
  padding: 27px 20px 14px;
  color: var(--forest-text);
  background: var(--forest);
  overflow: auto;
  --focus: #e6b578;
}
.sidebar > .brand-lockup { margin-inline: 4px; }
.sidebar-create { width: 100%; justify-content: flex-start; margin-top: 37px; background: #e8dcbd; color: var(--forest-deep); }
.sidebar-create:hover:not(:disabled) { background: #f3e8ce; }
.sidebar-create svg { width: 17px; height: 17px; }
.mobile-history, .mobile-admin, .mobile-library { display: none; }
.history-panel { min-height: 70px; margin-top: 27px; flex: 1 1 auto; overflow-y: auto; scrollbar-width: thin; }
.history-panel h2 { margin: 0 6px 12px; color: var(--forest-muted); font-size: .78rem; font-weight: 650; letter-spacing: .065em; }
.history-state { margin: 0 6px; color: var(--forest-muted); font-size: .82rem; }
.history-list { list-style: none; padding: 0; }
.history-item { display: flex; width: 100%; min-height: 44px; border: 1px solid transparent; border-radius: 6px; background: transparent; text-align: left; align-items: center; gap: 8px; padding: 7px 8px; }
.history-item:hover, .history-item[aria-current] { background: var(--forest-deep); border-color: var(--forest-line); }
.history-item span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-item .history-dot { margin-inline-start: auto; width: 7px; height: 7px; border-radius: 100%; background: #cbbd9b; flex: 0 0 auto; }
.history-item .history-dot.done { background: #a0c3a5; }
.history-item .history-dot.error { background: #efae95; }
.sidebar-footer { border-top: 1px solid var(--forest-line); margin-top: 13px; padding-top: 7px; }
.library-link, .admin-link { min-height: 44px; display: flex; width: 100%; justify-content: space-between; align-items: center; padding: 7px 6px; text-decoration: none; border-radius: 7px; line-height: 1; font-size: .87rem; text-align: left; }
.library-link { color: var(--forest-text); }
.library-link:hover, .admin-link:hover, .logout:hover { background: var(--forest-deep); }
.library-link svg { width: 15px; height: 15px; color: var(--forest-muted); }
.profile { display: flex; gap: 10px; align-items: center; margin-top: 8px; border-top: 1px solid var(--forest-line); padding: 8px 0 0 5px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #53614e; color: var(--forest-text); font-weight: 750; flex: 0 0 auto; }
.account-name { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; font-size: .88rem; }
.logout { color: var(--forest-muted); margin-inline-start: auto; }

.desk { display: flex; min-width: 0; flex-direction: column; min-height: 100svh; }
.desk-header { display: flex; min-height: 73px; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding: 4px clamp(20px, 5vw, 62px); }
.header-label { display: flex; align-items: center; gap: 9px; font-size: .98rem; white-space: nowrap; }
.header-label span { height: 7px; width: 7px; border-radius: 50%; background: var(--accent); }
.chat-view { display: flex; flex: 1; min-height: 0; flex-direction: column; position: relative; padding: 0 clamp(18px, 5vw, 62px); }
.welcome-view, .request-view, .request-form { width: min(100%, 774px); margin-inline: auto; }
.welcome-view { padding: clamp(60px, 18vh, 190px) 0 clamp(36px, 9vh, 88px); flex: 1; }
.welcome-view h1 { font: 760 clamp(36px, 5.5vw, 78px)/1.14 var(--display-font); letter-spacing: -.065em; }
.welcome-view p { margin-top: 15px; max-width: 489px; color: var(--muted); font-size: clamp(.92rem, 1.4vw, 1.07rem); }
.request-view { flex: 1; padding: clamp(27px, 5vw, 64px) 0 40px; }
.request-form { margin-top: auto; padding-block: 11px max(18px, env(safe-area-inset-bottom)); position: sticky; bottom: 0; z-index: 2; background: var(--paper); }
.composer { position: relative; background: var(--surface); border: 1px solid #c8bfac; border-radius: 13px; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { display: block; width: 100%; min-height: 78px; resize: vertical; max-height: 240px; padding: 14px 66px 14px 15px; border-radius: inherit; outline: none; background: transparent; border: 0; }
.composer textarea::placeholder { color: #66665a; }
.send-button { display: grid; place-items: center; position: absolute; bottom: 9px; right: 9px; width: 44px; height: 44px; border: 0; border-radius: 8px; background: var(--accent); color: var(--surface); }
.composer-note { margin-top: 8px; font-size: .81rem; color: var(--muted); }
.request-form .inline-error { margin-top: 8px; }
.service-alert { width: min(100%, 774px); margin: 16px auto 0; background: var(--warn-mist); color: var(--warn); padding: 10px 12px; border-radius: 6px; font-size: .9rem; }
.request-question { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-bottom: 39px; }
.request-question p { max-width: min(90%, 560px); overflow-wrap: anywhere; white-space: pre-wrap; border-radius: 13px 13px 2px 13px; color: var(--surface); background: var(--forest); padding: 12px 17px; }
.request-question time { font-size: .76rem; color: var(--muted); }
.request-answer { min-width: 0; }
.answer-heading { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 9px; }
.answer-heading strong { font-weight: 750; }
.request-reply { overflow-wrap: anywhere; white-space: pre-wrap; }
.status-label { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 9px; border-radius: 999px; font-size: .77rem; font-weight: 675; color: var(--muted); background: #e8e3d6; }
.status-label.done { color: var(--good); background: var(--good-mist); }
.status-label.error { color: var(--accent); background: var(--accent-mist); }
.status-label.pending { color: var(--warn); background: var(--warn-mist); }
.selection, .results { margin-top: 21px; }
.selection h3, .results h3 { font-size: .9rem; }
.selection ul, .results ul { list-style: none; display: grid; padding: 0; margin-top: 8px; }
.result-row, .candidate-row { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.result-row strong, .candidate-row strong { display: block; overflow-wrap: anywhere; }
.result-row p, .candidate-row p { margin-top: 2px; color: var(--muted); font-size: .83rem; overflow-wrap: anywhere; }
.result-row .button, .candidate-row .button { white-space: nowrap; flex: 0 0 auto; font-size: .83rem; }
.process { margin-top: 26px; border: 1px solid var(--line); border-radius: 9px; background: #eee8dc; }
.process summary { cursor: pointer; display: list-item; padding: 12px 15px; color: var(--muted); font-weight: 650; font-size: .91rem; }
.process ol { padding: 3px 15px 9px; list-style: none; }
.process li { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; padding: 0 0 13px; overflow-wrap: anywhere; }
.process li::before { content: ''; display: block; height: 8px; width: 8px; border-radius: 50%; margin-top: 7px; background: #838b76; grid-row: span 2; }
.process li:not(:last-child)::after { content: ''; position: absolute; left: 3px; width: 1px; top: 16px; bottom: 0; background: #c5beae; }
.process .event-heading { display: flex; gap: 7px; align-items: baseline; flex-wrap: wrap; font-size: .84rem; }
.process time, .process .event-message { color: var(--muted); font-size: .79rem; }
.process .event-message { grid-column: 2; }
.process .empty-events { padding: 0 15px 12px; font-size: .86rem; color: var(--muted); }

.admin-view { width: min(100%, 900px); margin-inline: auto; padding: clamp(27px, 5vw, 62px) clamp(18px, 5vw, 56px); }
.admin-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 28px; }
.admin-heading button { flex-shrink: 0; }
.admin-status { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.admin-status.error { color: var(--accent); }
.users-list { list-style: none; padding: 0; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); min-height: 63px; }
.user-row > div { min-width: 0; }
.user-row strong, .user-row small { display: block; overflow-wrap: anywhere; }
.user-row small { color: var(--muted); }
.permission-toggle { display: flex; align-items: center; cursor: pointer; gap: 10px; white-space: nowrap; font-size: .86rem; min-height: 44px; }
.permission-toggle input { appearance: none; width: 42px; height: 24px; border: 1px solid #aaa18e; border-radius: 999px; background: #ded7c7; margin: 0; display: flex; align-items: center; padding: 3px; cursor: pointer; }
.permission-toggle input::before { content: ''; display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 1px solid #aaa18e; transition: transform .17s ease; }
.permission-toggle input:checked { background: var(--good); border-color: var(--good); }
.permission-toggle input:checked::before { transform: translateX(17px); border-color: var(--good); }
.permission-toggle input:disabled { opacity: .6; cursor: not-allowed; }

@media (max-width: 750px) {
  .login-view { grid-template-columns: 1fr; min-height: auto; }
  .login-brand { min-height: 220px; gap: 24px; padding: 24px; }
  .login-cover-title { font-size: clamp(35px, 8vw, 52px); }
  .login-card { padding-bottom: 50px; }
  .workspace { display: block; }
  .sidebar { position: static; height: auto; min-height: 0; padding: 10px 14px; display: grid; grid-template-columns: minmax(80px, 1fr) auto auto auto; gap: 4px 7px; overflow: visible; align-items: center; }
  .sidebar > .brand-lockup { margin: 0; gap: 6px; }
  .sidebar .brand-mark { width: 30px; height: 30px; flex-basis: 30px; border-radius: 6px; }
  .sidebar .brand-mark svg { width: 19px; height: 19px; }
  .sidebar .brand-lockup strong { font-size: 16px; }
  .sidebar .brand-lockup div span { display: none; }
  .sidebar-create { margin: 0; width: 44px; padding: 0; justify-content: center; }
  .sidebar-create span { display: none; }
  .mobile-history { display: inline-flex; width: 44px; padding: 0; color: var(--forest-text); border-color: var(--forest-line); }
  .mobile-history span { display: none; }
  .mobile-history[aria-expanded='true'] { background: var(--forest-deep); }
  .history-panel { display: none; grid-row: 2; grid-column: 1 / -1; margin: 6px 0 0; max-height: min(290px, 45dvh); min-height: 0; padding-top: 9px; border-top: 1px solid var(--forest-line); }
  .history-panel.is-open { display: block; }
  .history-panel h2 { margin-bottom: 4px; }
  .sidebar-footer { display: contents; }
  .sidebar-footer .library-link, .sidebar-footer .admin-link, .profile .avatar, .profile .account-name { display: none; }
  .profile { border: 0; margin: 0; padding: 0; }
  .desk { min-height: calc(100svh - 64px); }
  .desk-header { min-height: 52px; padding-inline: 15px; }
  .header-label { margin-right: auto; font-size: .86rem; }
  .mobile-library { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; font-size: .8rem; text-decoration: none; }
  .mobile-library svg { width: 14px; height: 14px; }
  .mobile-admin { display: inline-flex; font-size: .79rem; padding-inline: 5px; }
  .welcome-view { padding: clamp(40px, 14vh, 160px) 0 40px; }
  .welcome-view p { max-width: 325px; }
  .request-question { margin-bottom: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
