/* 陈书记 — 纸面、朱印、红头。 */

:root {
  --paper: #fbfbf6;
  --paper-2: #f3f2e9;
  --paper-3: #ecebe0;
  --ink: #1b1a17;
  --ink-2: #45413a;
  --ink-3: #8b8577;
  --rule: #dcd8c9;
  --rule-2: #eae7da;
  --red: #b32d1e;
  --red-deep: #8d2317;
  --red-wash: rgba(179, 45, 30, 0.055);
  --danger: #a12b1f;
  --ok: #3f6b4a;
  --serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
  --shadow: 0 1px 0 rgba(27, 26, 23, 0.03), 0 14px 34px -28px rgba(27, 26, 23, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.72 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.chat {
  overflow: hidden;
}

body.chat .login {
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--ink-3);
  font-size: 13px;
}

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 0;
}

a {
  color: var(--red-deep);
  text-decoration: none;
  border-bottom: 1px solid rgba(141, 35, 23, 0.28);
}

a:hover {
  border-bottom-color: var(--red-deep);
}

button {
  font-family: inherit;
}

button.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--red-deep);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}

button.link:hover {
  border-bottom-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* ---------------- 印章与红头 ---------------- */

.seal {
  display: block;
  width: 26px;
  height: 26px;
}

.scrim {
  display: none;
}

.rule-double {
  height: 7px;
  border-top: 2px solid var(--red);
  border-bottom: 1px solid var(--red);
  opacity: 0.9;
}

/* ---------------- 登录 / 注册 ---------------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--paper-2);
}

.login-card {
  width: min(430px, 100%);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  box-shadow: var(--shadow);
  padding: 34px 38px 30px;
}

.login-card .rule-double {
  margin: 18px 0 26px;
}

.masthead-mark {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.masthead-mark .seal {
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
}

.wordmark {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.14em;
  margin: 0;
  color: var(--ink);
}

.masthead-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  margin: 8px 0 0;
}

.field {
  display: block;
  margin-bottom: 20px;
}

.field span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding: 6px 0;
  font: 15px/1.6 var(--sans);
  color: var(--ink);
  outline: none;
  border-radius: 0;
}

.field input:focus {
  border-bottom-color: var(--red);
}

.btn-primary {
  width: 100%;
  margin-top: 8px;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 2px;
  padding: 11px 16px;
  font-size: 15px;
  letter-spacing: 0.22em;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-primary:hover {
  background: var(--red-deep);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.login-alt {
  text-align: center;
  margin: 22px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.login-note {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule-2);
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.7;
}

/* ---------------- 外壳 ---------------- */

.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 18px 12px;
}

.sidebar-title {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--ink-2);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 2px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 16px;
  scrollbar-width: thin;
}

.session-group {
  padding: 16px 18px 6px;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 16px;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.session-item:hover {
  background: rgba(27, 26, 23, 0.028);
}

.session-item.active {
  border-left-color: var(--red);
  background: var(--red-wash);
}

.session-item .title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item.active .title {
  color: var(--ink);
}

.session-item .del {
  opacity: 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  transition: color 0.12s ease, opacity 0.12s ease;
}

.session-item:hover .del,
.session-item.active .del {
  opacity: 1;
}

.session-item .del:hover {
  color: var(--danger);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--rule);
}

.sidebar-foot .who {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px 10px;
}

.masthead-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.wordmark-sm {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--ink);
  white-space: nowrap;
}

.masthead-left .seal {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
}

.masthead-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

.masthead-right .route + .route,
.masthead-right .route + .quota {
  border-left: 1px solid var(--rule);
  padding-left: 10px;
}

.menu {
  display: none;
}

.main > .rule-double {
  margin: 0 32px;
}

/* ---------------- 正文 ---------------- */

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.messages-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 30px 32px 44px 26px;
  border-left: 1px solid rgba(179, 45, 30, 0.2);
  margin-left: auto;
  margin-right: auto;
}

.msg {
  padding-bottom: 26px;
}

.msg + .msg {
  border-top: 1px solid var(--rule-2);
  padding-top: 22px;
}

.msg .role {
  font-family: var(--serif);
  font-size: 12.5px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.msg.user .role {
  color: var(--red);
}

.msg .body {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.msg.user .body {
  white-space: pre-wrap;
}

.msg .meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.msg .body.cursor::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--red);
  opacity: 0.55;
  animation: caret 1.05s steps(2, start) infinite;
}

@keyframes caret {
  50% {
    opacity: 0;
  }
}

/* 正文排版 */

.msg.assistant .body p {
  margin: 0 0 12px;
}

.msg.assistant .body p:last-child {
  margin-bottom: 0;
}

.msg.assistant .body h1,
.msg.assistant .body h2,
.msg.assistant .body h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.45;
  margin: 22px 0 10px;
}

.msg.assistant .body h1 {
  font-size: 20px;
  letter-spacing: 0.04em;
}

.msg.assistant .body h2 {
  font-size: 17px;
  letter-spacing: 0.04em;
}

.msg.assistant .body h3 {
  font-size: 15.5px;
  letter-spacing: 0.04em;
}

.msg.assistant .body h1:first-child,
.msg.assistant .body h2:first-child,
.msg.assistant .body h3:first-child {
  margin-top: 0;
}

.msg.assistant .body ul,
.msg.assistant .body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.msg.assistant .body li {
  margin: 4px 0;
}

.msg.assistant .body li > ul,
.msg.assistant .body li > ol {
  margin: 4px 0 2px;
}

.msg.assistant .body .task {
  list-style: none;
  margin-left: -18px;
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.msg.assistant .body .task input {
  accent-color: var(--red);
  margin: 0;
}

.msg.assistant .body blockquote {
  margin: 12px 0;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--rule);
  color: var(--ink-2);
}

.msg.assistant .body blockquote p {
  margin: 0 0 8px;
}

.msg.assistant .body blockquote p:last-child {
  margin: 0;
}

.msg.assistant .body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 20px 0;
}

.msg.assistant .body a {
  border-bottom: 1px solid rgba(141, 35, 23, 0.3);
}

.msg.assistant .body strong {
  font-weight: 600;
}

.msg.assistant .body del {
  color: var(--ink-3);
}

.msg.assistant .body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--paper-3);
  border: 1px solid var(--rule-2);
  border-radius: 2px;
  padding: 1px 5px;
}

.table-wrap {
  margin: 14px 0;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.msg.assistant .body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
}

.msg.assistant .body th,
.msg.assistant .body td {
  border-bottom: 1px solid var(--rule-2);
  border-right: 1px solid var(--rule-2);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.msg.assistant .body th:last-child,
.msg.assistant .body td:last-child {
  border-right: 0;
}

.msg.assistant .body tr:last-child td {
  border-bottom: 0;
}

.msg.assistant .body thead th {
  background: var(--paper-2);
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.code-block {
  margin: 14px 0;
  border-radius: 2px;
  overflow: hidden;
  background: #201f1b;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.045);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-lang {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(243, 241, 232, 0.55);
}

.code-copy {
  border: 0;
  background: none;
  color: rgba(243, 241, 232, 0.6);
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 0;
}

.code-copy:hover {
  color: #f3f1e8;
}

.code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
}

.code-block code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #f3f1e8;
  background: none;
  border: 0;
  padding: 0;
}

.thinking {
  margin: 0 0 14px;
  border-left: 2px solid var(--rule);
  padding-left: 12px;
}

.thinking summary {
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  letter-spacing: 0.06em;
  list-style: none;
}

.thinking summary::-webkit-details-marker {
  display: none;
}

.thinking summary::before {
  content: "▸ ";
  color: var(--ink-3);
}

.thinking[open] summary::before {
  content: "▾ ";
}

.thinking pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font: 13px/1.7 var(--sans);
  color: var(--ink-3);
}

.tool-chip {
  display: inline-block;
  margin: 0 8px 8px 0;
  font-size: 11.5px;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 2px 7px;
  font-variant-numeric: tabular-nums;
}

/* 落印 */

.seal-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.seal-line .seal {
  width: 24px;
  height: 24px;
  opacity: 0.92;
  animation: stamp 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.seal-line .meta {
  margin: 0;
}

@keyframes stamp {
  from {
    opacity: 0;
    transform: scale(1.35) rotate(-4deg);
  }
  to {
    opacity: 0.92;
    transform: none;
  }
}

/* 等待 */

.wait {
  margin: 2px 0 4px;
  padding: 10px 0 10px 14px;
  border-left: 2px solid var(--red);
}

.wait-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.wait-dots {
  display: inline-flex;
  gap: 3px;
}

.wait-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.25;
  animation: wait-bounce 1.2s infinite;
}

.wait-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.wait-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes wait-bounce {
  0%,
  60%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.wait-note {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  animation: wait-fade 0.35s ease;
}

.wait.streaming {
  border-left-color: transparent;
  padding-left: 0;
  margin-bottom: 6px;
}

.wait.streaming .wait-note {
  color: var(--ink-3);
}

@keyframes wait-fade {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 空态 */

.empty {
  max-width: 780px;
  margin: 0 auto;
  padding: 56px 32px 40px 26px;
  border-left: 1px solid rgba(179, 45, 30, 0.2);
}

.empty .seal {
  width: 84px;
  height: 84px;
  opacity: 0.12;
}

.empty h2 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 22px 0 8px;
}

.empty p {
  margin: 0 0 26px;
  font-size: 14px;
  color: var(--ink-3);
  max-width: 46ch;
}

.empty-prompts {
  border-top: 1px solid var(--rule);
  max-width: 520px;
}

.empty-prompts button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  padding: 11px 2px;
  font: 14px/1.5 var(--sans);
  color: var(--ink-2);
  cursor: pointer;
  transition: color 0.12s ease, padding-left 0.12s ease;
}

.empty-prompts button:hover {
  color: var(--red);
  padding-left: 6px;
}

/* ---------------- 输入 ---------------- */

.composer {
  border-top: 1px solid var(--rule);
  background: var(--paper);
  padding: 14px 32px 18px;
}

.composer-inner {
  max-width: 780px;
  margin: 0 auto;
  padding-left: 26px;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 8px 0;
  border-bottom: 1px dashed var(--rule);
}

.attachment-preview {
  border-bottom: 1px solid var(--rule-2);
  padding: 8px 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.attachment-preview summary {
  cursor: pointer;
  list-style: none;
  letter-spacing: 0.04em;
}

.attachment-preview summary::-webkit-details-marker {
  display: none;
}

.attachment-preview summary::before {
  content: "▸ ";
}

.attachment-preview[open] summary::before {
  content: "▾ ";
}

.attachment-preview pre {
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  font: 12.5px/1.7 var(--sans);
  color: var(--ink-2);
  background: var(--paper-2);
  padding: 10px 12px;
  border-radius: 2px;
}

#input {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding: 10px 0;
  font: 15px/1.7 var(--sans);
  color: var(--ink);
  resize: none;
  outline: none;
  max-height: 40vh;
}

#input::placeholder {
  color: var(--ink-3);
}

#input:focus {
  border-bottom-color: var(--red);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 2px;
  transition: color 0.12s ease;
}

.attach:hover {
  color: var(--red);
}

#status {
  flex: 1;
  font-size: 12.5px;
  color: var(--ink-3);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#send {
  border: 0;
  border-radius: 2px;
  background: var(--red);
  color: #fff;
  padding: 8px 20px;
  font-size: 14px;
  letter-spacing: 0.18em;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#send:hover {
  background: var(--red-deep);
}

#send:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------------- 管理台 ---------------- */

.admin-page {
  min-height: 100dvh;
  background: var(--paper-2);
  padding: 0 0 64px;
}

.admin-head {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 22px 0 0;
}

.admin-head-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px;
}

.admin-head .masthead-mark .seal {
  width: 30px;
  height: 30px;
}

.admin-head .wordmark {
  font-size: 22px;
}

.admin-head .masthead-sub {
  margin-top: 6px;
}

.admin-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.admin-body {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 32px 0;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 22px 24px 24px;
  margin-bottom: 22px;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink);
  margin: 0 0 4px;
}

.panel-title .muted {
  font-family: var(--sans);
  font-weight: 400;
  letter-spacing: 0;
}

.panel-note {
  margin: 0 0 16px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-3);
  max-width: 78ch;
}

.field-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.field-row > label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
}

.field-row input,
.field-row select {
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper);
  padding: 7px 10px;
  font: 14px/1.4 var(--sans);
  color: var(--ink);
  min-width: 140px;
}

.field-row input:focus,
.field-row select:focus {
  outline: none;
  border-color: var(--red);
}

.btn {
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
  border-radius: 2px;
  padding: 8px 16px;
  font-size: 14px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn:hover {
  background: var(--red-deep);
}

.btn-quiet {
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-2);
  border-radius: 2px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

.btn-quiet:hover {
  border-color: var(--red);
  color: var(--red);
}

.table-wrap {
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  background: var(--paper-2);
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  color: var(--ink-2);
}

.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule-2);
  vertical-align: middle;
  color: var(--ink-2);
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: rgba(27, 26, 23, 0.02);
}

.table input[type="number"] {
  width: 110px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 4px 8px;
  font: 13px/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--paper);
}

.table select {
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 4px 8px;
  font: 13px/1.4 var(--sans);
  background: var(--paper);
  color: var(--ink);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-right: 12px;
  white-space: nowrap;
}

.check input {
  accent-color: var(--red);
}

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(27, 26, 23, 0.42);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}

.viewer-panel {
  width: min(760px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  box-shadow: var(--shadow);
}

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.08em;
}

.viewer-body {
  overflow: auto;
  padding: 18px 20px 22px;
  font-size: 14px;
}

.viewer-body .turn {
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-2);
}

.viewer-body .turn:last-child {
  border-bottom: 0;
}

.viewer-body .turn .who {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.viewer-body .turn.user .who {
  color: var(--red);
}

/* ---------------- 滚动条 ---------------- */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(27, 26, 23, 0.16);
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(27, 26, 23, 0.28);
  background-clip: content-box;
}

/* ---------------- 移动端 ---------------- */

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 84vw);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
    box-shadow: 0 0 0 1px var(--rule);
  }

  .app.nav-open .sidebar {
    transform: none;
  }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(27, 26, 23, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 20;
  }

  .app.nav-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .menu {
    display: inline-grid;
  }

  .masthead {
    align-items: center;
    padding: 14px 16px 10px;
  }

  .main > .rule-double {
    margin: 0 16px;
  }

  .masthead-right {
    gap: 8px;
    font-size: 11px;
  }

  .masthead-right .quota {
    display: none;
  }

  .messages-inner,
  .empty {
    padding: 22px 18px 34px 18px;
    border-left: 0;
  }

  .composer {
    padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  }

  .composer-inner {
    padding-left: 0;
  }

  #input {
    font-size: 16px;
  }

  .login-card {
    padding: 28px 24px 24px;
  }

  .admin-body,
  .admin-head-inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  .panel {
    padding: 18px 16px 20px;
  }

  .msg + .msg {
    padding-top: 18px;
  }

  /* 管理台：表单与元信息在窄屏折行，避免撑出横向滚动 */
  .efforts {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 2px 10px;
  }

  .field-row > label {
    min-width: 0;
    flex: 1 1 140px;
  }

  .field-row input,
  .field-row select {
    min-width: 0;
    width: 100%;
  }

  .msg.assistant .body table {
    min-width: 420px;
  }

  .admin-meta,
  .panel-title {
    flex-wrap: wrap;
    gap: 6px 14px;
  }

  .invite-code {
    flex-wrap: wrap;
  }

  .viewer-panel {
    width: 100%;
    max-height: 90vh;
  }

  .table {
    font-size: 13px;
    min-width: 560px;
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }

  /* 访客端：顶栏模型名过长时省略，输入区不撑宽 */
  .masthead-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .masthead-right .route {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .attachment-bar,
  .composer-inner {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------- 管理台补充 ---------------- */

.admin-head {
  padding: 24px 0 0;
}

.admin-head-inner {
  padding-bottom: 16px;
}

.admin-head .rule-double {
  margin: 0;
}

.admin-meta {
  border-top: 1px solid var(--rule-2);
  margin-top: 16px;
}

.grow {
  flex: 1 1 220px;
  min-width: 200px;
}

.grow input {
  width: 100%;
}

.efforts {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 2px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-2);
}

.efforts .check {
  margin-right: 8px;
}

.efforts .check:last-child {
  margin-right: 0;
}

.add-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-2);
}

.add-form .field-row + .field-row {
  margin-top: 12px;
}

.add-form textarea {
  display: block;
  width: 100%;
  min-height: 220px;
  margin: 12px 0;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  resize: vertical;
  -webkit-text-size-adjust: 100%;
}

.add-form textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 1px rgba(179, 45, 30, 0.18);
}

.invite-code {
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.2em;
  padding: 7px 14px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink);
}

.model-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.tag {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--red);
  border: 1px solid rgba(179, 45, 30, 0.3);
  border-radius: 2px;
  padding: 1px 6px;
}

.link.danger {
  color: var(--danger);
}

.viewer-body .turn .text {
  white-space: pre-wrap;
  color: var(--ink-2);
}

.load-more {
  display: block;
  width: 100%;
  margin: 0 0 18px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--rule-2);
  background: none;
  color: var(--ink-3);
  font: 12.5px/1.4 var(--sans);
  letter-spacing: 0.08em;
  cursor: pointer;
}

.load-more:hover {
  color: var(--red);
}
