/*
 * 两页共用样式。设计语言取自重建前的 `src/console.css`（a44e029 之前）：
 * 冷灰底 + 纯白卡片 + 深藏青侧栏 + 墨绿主按钮 + 金色小标题 + 衬线大标题。
 *
 * 纪律：
 *   * **零新增产物** —— 仍是唯一一份 CSS，`build.entries.json` / Caddyfile / 合同门都不用动；
 *   * **零 class 改名** —— `.doc` / `.msg-*` / `.notice` / `.suggestion` 等由 e2e 逐个断言，
 *     本文件只换外观，不换选择器；
 *   * 后台侧栏在窄屏塌成一条横向导航（纯 CSS）——抽屉式侧栏需要 JS，而本次不动逻辑。
 */

:root {
  --font-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "SimSun", serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #f4f6f8;
  --surface: #fff;
  --border: #e2e6ec;
  --ink: #12233a;
  --ink-2: #2a394f;
  --muted: #5a6a7d;
  --muted-2: #8a94a3;
  --green: #216a4c;
  --green-strong: #15966a;
  --green-ink: #184f39;
  --gold: #d7b26e;
  --sidebar: #0d1a2d;
  --amber: #a9763a;
  --red: #8a3a2c;
  --slate: #7a8794;
  --blue: #2f5c86;

  --radius: 12px;
  --gap: 12px;
  --max: 780px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.75 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* 品牌方章：CSS 绘制，不引入新的图片产物（每多一个文件就多一处要登记的地方）。 */
.brand-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar);
  color: var(--gold);
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
}

/* --------------------------------------------------------------------- */
/* 顶栏（问答页）                                                         */
/* --------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(16px, 4vw, 28px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar-head {
  flex: 1;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 19px;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.topbar-sub {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted-2);
}

.topbar-link {
  flex: 0 0 auto;
  padding: 8px 14px;
  border: 1px solid #d7dde4;
  border-radius: 9px;
  background: var(--surface);
  color: #47566b;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.topbar-link:hover {
  border-color: var(--green);
  color: var(--green);
}

/* --------------------------------------------------------------------- */
/* 聊天页                                                                 */
/* --------------------------------------------------------------------- */
.page-chat {
  /* 底部固定输入区的高度 + 安全区，避免最后一条消息被压住 */
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/*
 * 顶栏与输入区是通栏白条，但**内容**必须落在与消息列同一条 780px 中轴线上：
 * 通栏白条里贴边的标题 / 输入框，与居中的消息列会读成两个不相干的版心。
 */
.page-chat .topbar,
.composer {
  padding-inline: max(clamp(16px, 3vw, 24px), calc((100% - var(--max)) / 2));
}

.chat {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 26px) clamp(16px, 3vw, 24px) 24px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.empty-hint {
  margin: 0 0 2px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.suggestion {
  text-align: left;
  padding: 13px 15px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.suggestion:hover {
  border-color: var(--green);
  border-left-color: var(--green);
  color: var(--ink);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  border-radius: var(--radius);
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--ink-2);
}

.msg-user {
  align-self: flex-end;
  max-width: 88%;
  background: #0f2137;
  border-color: transparent;
  color: #eef2f6;
}

.msg-assistant {
  align-self: flex-start;
  max-width: 100%;
}

.msg-text p {
  margin: 0 0 0.9em;
  white-space: pre-line;
}

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

.msg-text strong {
  font-weight: 700;
  color: var(--ink);
}

.msg-user .msg-text strong {
  color: #fff;
}

.msg-list {
  margin: 0 0 0.9em;
  padding-left: 1.4em;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}

ul.msg-list {
  list-style: disc;
}

ol.msg-list {
  list-style: decimal;
}

/* 「正在查资料…」：与老设计的骨架条同一条低调脉冲。 */
.msg-hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted-2);
  animation: cmSkeleton 1.4s ease-in-out infinite;
}

@keyframes cmSkeleton {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

.msg-sources {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f3f6;
}

.msg-sources summary {
  cursor: pointer;
  min-height: 28px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--amber);
}

.source-list {
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.source-list li {
  border-left: 3px solid var(--gold);
  background: var(--bg);
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--ink-2);
}

.notices {
  margin-top: 14px;
}

.notice {
  margin: 0;
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 12.5px;
  line-height: 1.7;
  background: #eef2f6;
  border: 1px solid #d7dde4;
  border-left-width: 3px;
  color: #47566b;
}

.notice[data-notice-kind="error"] {
  background: #f7ece9;
  border-color: #e0c4bc;
  color: var(--red);
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px clamp(16px, 3vw, 24px) calc(12px + env(safe-area-inset-bottom));
  /* 与上面同一条中轴线（本行必须在 padding 简写之后，否则被简写覆盖） */
  padding-inline: max(clamp(16px, 3vw, 24px), calc((100% - var(--max)) / 2));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.composer-input {
  flex: 1;
  min-height: 44px;
  max-height: 30vh;
  padding: 11px 13px;
  border: 1px solid #d7dde4;
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--surface);
  resize: vertical;
}

.composer-input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.composer-send {
  min-height: 44px;
  min-width: 84px;
  padding: 0 22px;
  border: 0;
  border-radius: 9px;
  background: var(--green);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.composer-send:disabled {
  background: var(--slate);
  cursor: default;
}

/* --------------------------------------------------------------------- */
/* 后台页：侧栏骨架                                                       */
/* --------------------------------------------------------------------- */
.page-admin {
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  flex: 0 0 244px;
  width: 244px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .brand-mark {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(215, 178, 110, 0.35);
}

.brand-name {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 18px;
  color: #fff;
  line-height: 1.1;
}

.brand-sub {
  font-size: 10.5px;
  letter-spacing: 1.4px;
  color: #8a99ab;
  margin-top: 3px;
}

.nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
}

.nav-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #5c6b7d;
  padding: 4px 8px 8px;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 14px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: 9px;
  border-left: 2px solid transparent;
  color: #aab6c4;
  font-size: 13.5px;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item--active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-left-color: var(--gold);
}

.nav-item-icon {
  flex: 0 0 20px;
  text-align: center;
  font-size: 13px;
  color: #6b7891;
}

.nav-item--active .nav-item-icon {
  color: var(--gold);
}

.nav-item-label {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.nav-item--active .nav-item-label {
  font-weight: 700;
}

.sidebar-foot {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  line-height: 1.6;
  color: #5c6b7d;
}

.dot-conn {
  font-weight: 700;
  color: #6fdcaa;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-admin .topbar {
  flex: 0 0 auto;
  position: static;
  height: 60px;
  padding: 0 clamp(16px, 3vw, 28px);
  gap: 16px;
}

.crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.crumb-org {
  font-size: 12.5px;
  color: var(--muted-2);
}

.crumb-sep {
  color: #cfd6dd;
}

.crumb-page {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sys-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sys-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-strong);
  box-shadow: 0 0 0 3px rgba(21, 150, 106, 0.18);
}

.sys-text {
  font-size: 12.5px;
  color: #47566b;
}

.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* --------------------------------------------------------------------- */
/* 后台页：内容区                                                         */
/* --------------------------------------------------------------------- */
.admin {
  max-width: 1000px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 30px) clamp(16px, 3vw, 30px) 60px;
  container-type: inline-size;
}

.page-head {
  margin-bottom: 20px;
}

.page-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: clamp(22px, 3vw, 28px);
  letter-spacing: -0.3px;
  color: var(--ink);
}

.page-sub {
  margin: 0;
  max-width: 640px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--muted);
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 24px;
}

.section-card--sensitive {
  border-left: 3px solid var(--gold);
}

.section-card--split {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 460px);
  gap: clamp(20px, 4cqi, 44px);
  align-items: start;
  max-width: 820px;
}

.section-card-rail {
  min-width: 0;
}

.admin h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

/* 上传卡：老设计的虚线投递区 + 双 picker 版式 */
.dropzone {
  border: 1px dashed #cfd8e0;
  text-align: center;
  padding: 26px 18px;
}

.dropzone[data-active="yes"] {
  border-color: var(--green);
  background: #e8f1ec;
}

.dropzone-text {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.dropzone-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 5px 6px;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 9px;
  background: var(--green);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.dropzone-pick:last-of-type {
  background: var(--surface);
  color: #47566b;
  border: 1px solid #d7dde4;
  font-weight: 600;
}

.dropzone-pick input {
  display: none;
}

.dropzone-note {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--muted-2);
}

.page-admin .notices:not(:empty) {
  margin: 0 0 24px;
}

.page-admin .notices:empty {
  margin: 0;
}

/* 批次条：只讲「这批」的会话内进度。金色 3px 左规 = 本系统「需要留意」的固定信号，
   只挂在批次条本体；未受理清单浅底无左规，失败原因保留红左规——三条左规不叠在同一列。 */
.batch-host:not(:empty) {
  margin: 0 0 24px;
}

.batch {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.batch--attention {
  background: #fffdf8;
}

.batch-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.batch-phase {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.4px;
}

.batch-line {
  flex: 1 1 auto;
  margin: 0;
  min-width: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.batch-line b {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink);
}

.batch-dismiss {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #d7dde4;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
}

.batch-dismiss:hover {
  background: #f2f5f8;
}

.ticks {
  display: flex;
  gap: 2px;
  margin: 10px 0 0;
  height: 8px;
}

.ticks .tick {
  flex: 1 1 0;
  min-width: 6px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: #e6eaef;
}

.ticks .tick[data-state="queued"],
.ticks .tick[data-state="sending"] {
  background: #ded2b6;
}

.ticks .tick[data-state="processing"] {
  background: var(--gold);
  animation: tick-pulse 1.4s ease-in-out infinite;
}

.ticks .tick[data-state="ready"] {
  background: var(--green-strong);
}

.ticks .tick[data-state="failed"],
.ticks .tick[data-state="sendFailed"] {
  background: var(--red);
  cursor: pointer;
}

.ticks .tick[data-state="rejected"] {
  background: var(--slate);
  cursor: pointer;
}

/* 已在库里 = 中性灰：跳过不是告警，必须与 rejected 的 slate 明确区分。 */
.ticks .tick[data-state="duplicate"] {
  background: var(--muted-2);
}

.ticks button.tick:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.ticks .tick-part {
  border-radius: 2px;
  background: #e6eaef;
}

.ticks .tick-part[data-kind="ready"] {
  background: var(--green-strong);
}

.ticks .tick-part[data-kind="bad"] {
  background: var(--red);
}

@keyframes tick-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.batch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #e6eaef;
}

.legend-item[data-kind="ready"] .legend-dot {
  background: var(--green-strong);
}

.legend-item[data-kind="processing"] .legend-dot {
  background: var(--gold);
}

.legend-item[data-kind="failed"] .legend-dot,
.legend-item[data-kind="sendFailed"] .legend-dot {
  background: var(--red);
}

.legend-item[data-kind="rejected"] .legend-dot {
  background: var(--slate);
}

.legend-item[data-kind="duplicate"] .legend-dot {
  background: var(--muted-2);
}

.legend-n {
  font-family: var(--font-mono);
  color: var(--ink-2);
}

.batch-foot {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--muted);
}

.batch-foot-line {
  display: block;
}

.batch-action {
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--green);
  background: transparent;
  color: var(--green);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.batch-action:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.skipped {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f6f8;
  font-size: 12.5px;
  color: var(--muted);
}

.skipped summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink-2);
}

.skipped-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.skipped-name {
  font-weight: 600;
  color: var(--ink-2);
}

.skipped-why::before {
  content: " · ";
}

/* 卡头：标题 ↔ 筛选（筛选计数按全库） */
.documents-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

.doc-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 12px;
}

.doc-filter {
  padding: 2px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.doc-filter[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--gold);
}

.doc-filter:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.doc-filter-n {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-2);
}

/* 常驻处理中横幅：刷新页面后唯一的进度来源（纯由列表派生） */
.processing-banner {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #faf4e9;
  border: 1px solid #e4d8bf;
  font-size: 12.5px;
  color: var(--amber);
}

/* 资料列表：老设计的表格行语汇（斑马纹 + 状态徽章 + 弱化的删除键） */
.document-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.document-list:empty::after {
  content: "还没有资料。把文件拖到上面的投递区，或点「选择文件」。";
  display: block;
  padding: 40px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted-2);
}

.doc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  grid-template-areas:
    "title status reupload delete"
    "meta meta meta meta"
    "error error error error"
    "notice notice notice notice"
    "progress progress progress progress";
  gap: 6px 12px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid #f1f3f6;
}

/* 筛选把行隐藏起来：`display:grid` 会盖住 UA 的 [hidden]{display:none}，必须显式重申。 */
.doc[hidden] {
  display: none;
}

.doc:first-child {
  border-top: none;
}

.doc:nth-child(even) {
  background: #fcfcfd;
}

.doc-title {
  grid-area: title;
  min-width: 0;
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
}

.doc-title:hover {
  border-color: #e6e9ee;
}

.doc-title:focus {
  border-color: var(--blue);
  background: #fff;
  outline: none;
}

.doc-status {
  grid-area: status;
  justify-self: end;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid #d7dde4;
  background: #eef2f6;
  color: var(--muted);
  white-space: nowrap;
}

.doc-status[data-status="ready"] {
  color: var(--green-ink);
  background: #e8f1ec;
  border-color: #bcdcca;
}

.doc-status[data-status="processing"] {
  color: var(--amber);
  background: #faf4e9;
  border-color: #e4d8bf;
}

.doc-status[data-status="failed"] {
  color: var(--red);
  background: #f7ece9;
  border-color: #e0c4bc;
}

.doc-meta {
  grid-area: meta;
  margin: 0;
  padding-left: 9px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-2);
}

.doc-error {
  grid-area: error;
  margin: 2px 0 0;
  padding: 9px 12px;
  border-left: 3px solid #e0c4bc;
  border-radius: 0 8px 8px 0;
  background: #f7ece9;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--red);
}

/* 删除是这一行里最弱的动作：透明底 + 深危险字色（不与主动作抢注意力）。 */
.doc-delete {
  grid-area: delete;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #dcc6c0;
  border-radius: 7px;
  background: transparent;
  color: #8c2f22;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.doc-delete:hover {
  background: #f7ece9;
}

/* 「重新上传（替换这一份）」：失败行唯一能做的事——服务器不留原始字节，重试在技术上不可能。 */
.doc-reupload {
  grid-area: reupload;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #d7dde4;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.doc-reupload:hover {
  background: #f2f5f8;
}

.doc-error-what {
  display: block;
}

.doc-error-how {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

/* 重新上传就地报错：不弹 modal、不飘 toast。 */
.doc-notice {
  grid-area: notice;
  margin: 2px 0 0;
  padding: 7px 10px;
  border-radius: 8px;
  background: #f7ece9;
  font-size: 12.5px;
  color: var(--red);
}

/* 队列第 1 位的推进线（纯装饰，真值在徽章与横幅里）。 */
.doc-progress {
  grid-area: progress;
  height: 2px;
  margin-top: 4px;
  border-radius: 2px;
  background: #f0e6d2;
  overflow: hidden;
}

.doc-progress::after {
  content: "";
  display: block;
  width: 34%;
  height: 100%;
  border-radius: 2px;
  background: var(--gold);
  animation: doc-progress-slide 1.6s ease-in-out infinite;
}

@keyframes doc-progress-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(295%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ticks .tick[data-state="processing"] {
    animation: none;
    background: var(--gold);
  }

  .doc-progress {
    display: none;
  }
}

/* 人设卡：左说明 ↔ 右控件 */
.persona-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}

.persona-input {
  width: 100%;
  min-height: 140px;
  padding: 11px 13px;
  border: 1px solid #d7dde4;
  border-radius: 9px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--surface);
  resize: vertical;
}

.persona-input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* 保存的回执必须挨着按钮：页面顶部那条 .notices 在滚到人设这一节时早已不在视区，
   写在那里等于没有反馈。 */
.persona-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.persona-notices:not(:empty) {
  flex: 1 1 260px;
}

.persona-notices .notice {
  padding: 9px 13px;
}

.persona-save {
  min-height: 44px;
  padding: 10px 26px;
  border: 0;
  border-radius: 9px;
  background: var(--green);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.persona-save:disabled {
  background: var(--slate);
  cursor: default;
}

@container (max-width: 700px) {
  .section-card--split {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* --------------------------------------------------------------------- */
/* 窄屏：侧栏塌成一条横向导航（纯 CSS，不引入抽屉所需的 JS）              */
/* --------------------------------------------------------------------- */
@media (max-width: 820px) {
  /* 格宽不足 6px 时逐格件次条读不出来，退化成一条连续的比例条。 */
  .ticks[data-mode="per-file"] {
    gap: 0;
  }

  .ticks[data-mode="per-file"] .tick {
    min-width: 0;
    border-radius: 0;
  }

  .documents-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-admin,
  .app {
    height: auto;
    overflow: visible;
  }

  .app {
    flex-direction: column;
  }

  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .brand {
    flex: 0 0 auto;
    padding: 0 12px 0 4px;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }

  /* 横向导航条里字标不许折行——竖排的「企业知识库」会把整条导航撑高一倍。 */
  .brand-name {
    white-space: nowrap;
    font-size: 16px;
  }

  .brand-sub,
  .nav-label,
  .nav-divider,
  .sidebar-foot {
    display: none;
  }

  .nav-scroll {
    flex: 1;
    display: flex;
    gap: 6px;
    padding: 0;
    overflow: visible;
  }

  .nav-item {
    margin-bottom: 0;
    white-space: nowrap;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 8px;
  }

  .nav-item--active {
    border-bottom-color: var(--gold);
  }

  .main,
  .scroll {
    overflow: visible;
  }
}
