/* ==================================================================
   写作知识库 · 独立子域前端样式
   设计语言：暖纸、墨色、细线、宋体标题；不依赖任何外部资源。
   ================================================================== */

:root {
  --paper: #f5f1e7;
  --paper-2: #faf7f0;
  --card: #fffdf8;
  --card-2: #fbf8f1;
  --ink: #2b2925;
  --ink-2: #57534b;
  --ink-3: #8b8578;
  --line: #e6dfd1;
  --line-2: #d6cdbc;
  --sakura: #d98c95;
  --sakura-soft: #f7e4e5;
  --sakura-deep: #b96a74;
  --blue: #54677a;
  --blue-soft: #e3e9ee;
  --gold: #b48a4c;
  --gold-soft: #f4ead7;
  --green: #5f7d68;
  --green-soft: #e4eee6;
  --red: #a85050;
  --red-soft: #f6e3e3;
  --shadow: 0 1px 2px rgba(66, 54, 35, 0.04), 0 10px 30px rgba(66, 54, 35, 0.06);
  --shadow-lg: 0 2px 6px rgba(66, 54, 35, 0.06), 0 26px 60px rgba(66, 54, 35, 0.14);
  --serif: "Songti SC", "Noto Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui,
    -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 14px;
  --r-sm: 9px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1100px 680px at 8% -8%, #fffdf6 0%, transparent 58%),
    radial-gradient(900px 600px at 100% 0%, #f8eee9 0%, transparent 55%),
    radial-gradient(760px 520px at 50% 118%, #f1ede0 0%, transparent 62%);
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}

a {
  color: var(--ink-2);
  text-decoration: none;
}

a:hover {
  color: var(--sakura-deep);
}

p {
  margin: 0;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

::selection {
  background: var(--sakura-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid rgba(217, 140, 149, 0.65);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------
   通用按钮
   ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition:
    background 0.16s var(--ease),
    border-color 0.16s var(--ease),
    color 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}

.btn:hover {
  border-color: #c3b8a4;
  background: #fffefb;
}

.btn:active {
  background: var(--card-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper-2);
}

.btn-primary:hover {
  background: #3a3730;
  border-color: #3a3730;
  color: #fffdf8;
}

.btn-primary:active {
  background: #211f1b;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--card);
  color: var(--ink);
}

.btn-danger {
  background: #fffaf8;
  border-color: #e3c9c2;
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red-soft);
  border-color: #d9b3a9;
  color: #8a3b3b;
}

.btn-danger-solid {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn-danger-solid:hover {
  background: #934343;
  border-color: #934343;
  color: #fff;
}

.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  height: 42px;
  font-size: 13.5px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--ink-3);
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.icon-btn:hover {
  background: rgba(43, 41, 37, 0.06);
  color: var(--ink);
}

/* ------------------------------------------------------------------
   表单
   ------------------------------------------------------------------ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.field-label i {
  font-style: normal;
  color: var(--sakura-deep);
}

.field-hint {
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.field-hint.is-over {
  color: var(--red);
  font-weight: 600;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card-2);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  transition:
    border-color 0.16s var(--ease),
    background 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: #a8a193;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-2);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--sakura);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(217, 140, 149, 0.13);
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8578' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 14px;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.8;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.input-with-icon {
  position: relative;
  display: block;
}

.input-with-icon > svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}

.input-with-icon > input {
  padding-left: 33px;
}

.form-error {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid #e3c9c2;
  border-radius: var(--r-sm);
  background: #fdf5f2;
  color: #8c3b2b;
  font-size: 12.5px;
  line-height: 1.6;
}

/* ------------------------------------------------------------------
   启动占位
   ------------------------------------------------------------------ */

.boot-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ink-3);
  font-size: 12.5px;
}

.boot-view p {
  letter-spacing: 0.06em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper-2);
  box-shadow: 0 2px 6px rgba(43, 41, 37, 0.18);
}

.brand-mark-lg {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid var(--line-2);
  border-top-color: var(--sakura-deep);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------------
   登录
   ------------------------------------------------------------------ */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 20px 56px;
  position: relative;
}

.auth-top {
  position: absolute;
  top: 26px;
  left: 30px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.auth-brand {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.auth-card {
  position: relative;
  width: min(432px, 100%);
  padding: 34px 34px 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
}

.auth-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 34px;
  right: 34px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--sakura) 22%,
    var(--sakura) 78%,
    transparent
  );
  opacity: 0.7;
}

.eyebrow {
  margin: 0 0 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.auth-card h1 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.32;
  letter-spacing: 0.02em;
}

.auth-lead {
  margin: 0 0 24px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-3);
}

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

.auth-note {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--ink-3);
}

.auth-foot {
  position: absolute;
  bottom: 20px;
  font-size: 11px;
  color: var(--ink-3);
}

.auth-foot a {
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-2);
}

/* ------------------------------------------------------------------
   顶栏与骨架
   ------------------------------------------------------------------ */

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 241, 231, 0.88);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: var(--ink);
}

.brand:hover {
  color: var(--ink);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.brand-text strong {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.brand-text small {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  white-space: nowrap;
}

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

.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.65);
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}

.health-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-2);
  flex: 0 0 auto;
}

.health-chip.ok .dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(95, 125, 104, 0.12);
}

.health-chip.err .dot {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(168, 80, 80, 0.12);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid #efd3d6;
  background: var(--sakura-soft);
  color: var(--sakura-deep);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 600;
}

.user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--ink-2);
}

.layout {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 26px;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 24px 64px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 253, 248, 0.58);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: left;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.nav-item svg {
  color: var(--ink-3);
  transition: color 0.16s var(--ease);
}

.nav-item:hover {
  background: var(--card);
  color: var(--ink);
}

.nav-item.is-active {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(66, 54, 35, 0.06);
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sakura);
}

.nav-item.is-active svg {
  color: var(--sakura-deep);
}

.nav-count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--paper);
  font-style: normal;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.side-card {
  padding: 15px 15px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 253, 248, 0.58);
}

.side-title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

.meter {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-3);
}

.meter b {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.meter-track {
  height: 4px;
  margin: 6px 0 11px;
  border-radius: 999px;
  background: #ece6d9;
  overflow: hidden;
}

.meter-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sakura), var(--sakura-deep));
  transition: width 0.4s var(--ease);
}

.meter-track > span.is-warn {
  background: linear-gradient(90deg, #d8a05f, #b9764c);
}

.side-hint {
  margin: 2px 0 0;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--ink-3);
}

.side-foot {
  padding-left: 3px;
  font-family: var(--serif);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: #aaa294;
}

.main {
  min-width: 0;
}

.view {
  animation: viewIn 0.24s var(--ease);
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.22;
  letter-spacing: 0.02em;
}

.page-sub {
  margin-top: 8px;
  max-width: 640px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-3);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------
   卡片与通用态
   ------------------------------------------------------------------ */

.card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: 0 1px 0 rgba(66, 54, 35, 0.02);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.card-title small {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  background: rgba(255, 253, 248, 0.5);
  text-align: center;
}

.state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-3);
}

.state-box h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.state-box p {
  max-width: 440px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-3);
}

.state-box .state-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.state-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 26px 16px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.state-inline.is-error {
  color: var(--red);
}

/* ------------------------------------------------------------------
   概览
   ------------------------------------------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  position: relative;
  min-width: 0;
  padding: 18px 19px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -32px;
  top: -32px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 140, 149, 0.1), transparent 68%);
  pointer-events: none;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-3);
}

.stat-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--serif);
  font-size: 29px;
  line-height: 1.1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-3);
}

.stat-foot {
  margin-top: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  color: var(--ink-3);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.overview-grid + .overview-grid {
  margin-top: 16px;
}

.dist-card {
  padding: 19px 20px 20px;
}

.dist-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
}

.dist-sub {
  margin: 0 0 12px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

.dist-row {
  margin-bottom: 13px;
}

.dist-row:last-child {
  margin-bottom: 0;
}

.dist-row-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--ink-2);
}

.dist-row-top b {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.dist-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--ink-3);
}

.dist-dot.tone-rose {
  background: var(--sakura);
}

.dist-dot.tone-gold {
  background: var(--gold);
}

.dist-dot.tone-blue {
  background: var(--blue);
}

.dist-dot.tone-green {
  background: var(--green);
}

.dist-dot.tone-slate {
  background: var(--ink-3);
}

.dist-dot.tone-gray {
  background: var(--line-2);
}

.dist-track {
  height: 5px;
  border-radius: 999px;
  background: #eee8dc;
  overflow: hidden;
}

.dist-track > span {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--ink-3);
  transition: width 0.45s var(--ease);
}

.dist-track > span.tone-rose {
  background: linear-gradient(90deg, #e4a6ac, var(--sakura-deep));
}

.dist-track > span.tone-gold {
  background: linear-gradient(90deg, #d8b67a, var(--gold));
}

.dist-track > span.tone-blue {
  background: linear-gradient(90deg, #8fa2b3, var(--blue));
}

.dist-track > span.tone-green {
  background: linear-gradient(90deg, #97b09f, var(--green));
}

.dist-track > span.tone-slate {
  background: linear-gradient(90deg, #b3ac9e, var(--ink-3));
}

.dist-track > span.tone-gray {
  background: var(--line-2);
}

.recent-card {
  padding: 19px 20px 8px;
}

.recent-list {
  display: flex;
  flex-direction: column;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 4px;
  border-top: 1px solid #efe9dd;
  text-align: left;
  transition: background 0.15s var(--ease);
}

.recent-item:first-child {
  border-top: none;
}

.recent-item:hover {
  background: var(--card-2);
}

.recent-main {
  min-width: 0;
  flex: 1 1 auto;
}

.recent-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}

.recent-meta {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  color: var(--ink-3);
}

.recent-time {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

.genre-card {
  padding: 19px 20px 20px;
}

.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-2);
  font-size: 12px;
  color: var(--ink-2);
}

.genre-chip b {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.capacity-card {
  padding: 19px 20px 18px;
}

.capacity-row {
  margin-bottom: 14px;
}

.capacity-row:last-child {
  margin-bottom: 0;
}

.capacity-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
}

.capacity-top b {
  font-weight: 500;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.capacity-track {
  height: 6px;
  border-radius: 999px;
  background: #ece6d9;
  overflow: hidden;
}

.capacity-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sakura), var(--sakura-deep));
  transition: width 0.45s var(--ease);
}

.capacity-track > span.is-warn {
  background: linear-gradient(90deg, #d8a05f, #b9764c);
}

.capacity-hint {
  margin-top: 9px;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--ink-3);
}

.welcome-card {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 24px 26px;
  margin-bottom: 16px;
  border: 1px solid #ead9db;
  border-radius: var(--r);
  background:
    radial-gradient(420px 200px at 100% 0%, rgba(217, 140, 149, 0.12), transparent 70%),
    var(--card);
}

.welcome-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 15px;
  background: var(--sakura-soft);
  color: var(--sakura-deep);
}

.welcome-main {
  min-width: 0;
  flex: 1 1 auto;
}

.welcome-main h2 {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.03em;
}

.welcome-main p {
  margin-top: 5px;
  max-width: 520px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-3);
}

.welcome-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------
   徽标
   ------------------------------------------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10.5px;
  font-style: normal;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge.scope-global {
  border-color: #e2dbcd;
  background: #f1ede4;
  color: #6f6a5f;
}

.badge.scope-genre {
  border-color: #ead9b8;
  background: var(--gold-soft);
  color: #8a652f;
}

.badge.scope-project {
  border-color: #efd0d3;
  background: var(--sakura-soft);
  color: var(--sakura-deep);
}

.badge.off {
  border-color: var(--line);
  background: transparent;
  color: var(--ink-3);
  border-style: dashed;
}

.badge.rose {
  background: var(--sakura-soft);
  color: var(--sakura-deep);
}

.badge.gold {
  background: var(--gold-soft);
  color: #8a652f;
}

.badge.blue {
  background: var(--blue-soft);
  color: #465b6d;
}

.badge.green {
  background: var(--green-soft);
  color: #4e6b57;
}

.badge.slate {
  background: #f1ede4;
  color: #6f6a5f;
}

.badge.gray {
  background: #f2efe8;
  color: #8b8578;
}

.badge.score {
  border-color: #ead9b8;
  background: var(--gold-soft);
  color: #8a652f;
  font-variant-numeric: tabular-nums;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f2eee5;
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ------------------------------------------------------------------
   资料库
   ------------------------------------------------------------------ */

.filter-card {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 253, 248, 0.72);
}

.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-field {
  flex: 0 1 132px;
  min-width: 0;
}

.filter-field.grow {
  flex: 1 1 220px;
}

.filter-field .field-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.filter-field input,
.filter-field select {
  height: 35px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 12.5px;
  background-color: var(--card);
}

.filter-reset {
  height: 35px;
  font-size: 12px;
}

.list-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 15px 2px 10px;
  font-size: 11.5px;
  color: var(--ink-3);
}

.list-summary b {
  font-weight: 600;
  color: var(--ink-2);
}

.list-summary .sep {
  color: var(--line-2);
}

.list-summary .filter-clear {
  margin-left: auto;
  font-size: 11px;
  color: var(--sakura-deep);
  border-bottom: 1px solid rgba(185, 106, 116, 0.35);
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  transition:
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    background 0.16s var(--ease);
}

.doc-card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow);
}

.doc-card.is-disabled {
  background: #fbf8f1;
}

.doc-card.is-disabled .doc-title {
  color: var(--ink-3);
}

.doc-main {
  min-width: 0;
  flex: 1 1 auto;
}

.doc-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}

.doc-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  border-bottom: 1px solid transparent;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.doc-title:hover {
  color: var(--sakura-deep);
  border-bottom-color: rgba(185, 106, 116, 0.3);
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-3);
}

.doc-meta .dot-sep {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--line-2);
}

.doc-meta .source {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.doc-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quiet-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 29px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 11.5px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.quiet-btn:hover {
  background: var(--paper);
  color: var(--ink);
}

.quiet-btn.is-danger:hover {
  background: var(--red-soft);
  color: var(--red);
}

.quiet-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.load-more-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 0 4px;
}

.list-end {
  min-height: 17px;
  font-size: 11px;
  color: #a8a193;
}

/* ------------------------------------------------------------------
   编辑器
   ------------------------------------------------------------------ */

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 278px;
  gap: 18px;
  align-items: start;
}

.editor.is-loading .editor-main {
  opacity: 0.55;
  pointer-events: none;
}

.editor-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  min-width: 0;
  transition: opacity 0.2s var(--ease);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-full {
  grid-column: 1 / -1;
}

#kb-text {
  min-height: 310px;
  padding: 14px 15px;
  background: #fffdf9;
  font-size: 14px;
  line-height: 1.9;
}

.scope-note {
  margin: -4px 0 0;
  padding: 9px 12px;
  border-left: 2px solid var(--line-2);
  background: var(--paper-2);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--ink-3);
}

.text-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.file-btn {
  cursor: pointer;
}

.toolbar-hint {
  margin-left: auto;
  font-size: 10.5px;
  color: #a8a193;
}

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.editor-actions-right {
  display: flex;
  gap: 8px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  position: relative;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--line-2);
  transition: background 0.18s var(--ease);
}

.switch-track > span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(43, 41, 37, 0.18);
  transition: transform 0.18s var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--green);
}

.switch input:checked + .switch-track > span {
  transform: translateX(14px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid rgba(217, 140, 149, 0.65);
  outline-offset: 2px;
}

.chunk-panel {
  padding: 15px 16px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  background: var(--paper-2);
}

.chunk-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 11px;
}

.chunk-head h3 {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.03em;
}

.chunk-head span {
  font-size: 11px;
  color: var(--ink-3);
}

.chunk-row {
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  overflow: hidden;
}

.chunk-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #efe9dd;
  font-size: 10px;
  color: var(--ink-3);
  background: var(--card-2);
}

.chunk-row pre {
  margin: 0;
  padding: 9px 11px;
  max-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.75;
  color: var(--ink-2);
}

.chunk-empty {
  padding: 10px 0 2px;
  font-size: 12px;
  color: var(--ink-3);
}

.editor-aside {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.aside-card {
  padding: 16px 17px;
}

.aside-title {
  margin-bottom: 11px;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.scope-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scope-list li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.scope-list p {
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--ink-3);
}

.tip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tip-list li {
  position: relative;
  padding-left: 13px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--ink-3);
}

.tip-list li::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--sakura);
}

/* ------------------------------------------------------------------
   检索测试
   ------------------------------------------------------------------ */

.search-grid {
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.search-form {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 19px;
}

.search-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.search-submit-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.topk-field {
  flex: 0 0 74px;
}

.search-submit {
  flex: 1 1 auto;
  height: 42px;
  font-size: 13.5px;
}

#search-query {
  min-height: 104px;
  font-size: 13px;
}

.check-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.check-chip {
  position: relative;
  display: inline-flex;
}

.check-chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.check-chip span {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--card);
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  transition:
    background 0.15s var(--ease),
    border-color 0.15s var(--ease),
    color 0.15s var(--ease);
}

.check-chip span:hover {
  border-color: #c3b8a4;
}

.check-chip input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper-2);
}

.check-chip input:focus-visible + span {
  outline: 2px solid rgba(217, 140, 149, 0.65);
  outline-offset: 2px;
}

.search-result {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.search-placeholder {
  padding: 46px 34px;
  text-align: center;
  border-style: dashed;
  background: rgba(255, 253, 248, 0.5);
}

.placeholder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
}

.search-placeholder h2 {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.03em;
}

.search-placeholder p {
  max-width: 440px;
  margin: 8px auto 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-3);
}

.search-placeholder .hint-line {
  margin-top: 14px;
  font-size: 11px;
  color: #a8a193;
}

.search-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 2px;
  font-size: 11px;
  color: var(--ink-3);
}

.search-stats b {
  font-weight: 600;
  color: var(--ink-2);
}

.digest-card {
  padding: 17px 18px 18px;
  border-color: #2f2c27;
  background: #2f2c27;
  color: var(--paper-2);
  box-shadow: 0 10px 28px rgba(47, 44, 39, 0.18);
}

.digest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 11px;
}

.digest-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 14.5px;
  letter-spacing: 0.04em;
  color: #f7f2e7;
}

.digest-title svg {
  color: #d9b98c;
}

.digest-meta {
  font-size: 10.5px;
  color: #a8a094;
}

.digest-card .btn {
  border-color: rgba(245, 241, 231, 0.24);
  background: rgba(245, 241, 231, 0.08);
  color: #f2ecdf;
}

.digest-card .btn:hover {
  background: rgba(245, 241, 231, 0.16);
  border-color: rgba(245, 241, 231, 0.4);
  color: #fffdf8;
}

.digest-text {
  margin: 0;
  padding: 13px 14px;
  max-height: 300px;
  overflow: auto;
  border: 1px solid rgba(245, 241, 231, 0.1);
  border-radius: 8px;
  background: rgba(18, 17, 15, 0.35);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.9;
  color: #ece5d8;
}

.digest-note {
  margin-top: 10px;
  font-size: 10.5px;
  line-height: 1.7;
  color: #a8a094;
}

.digest-empty {
  padding: 13px 14px;
  border: 1px dashed rgba(245, 241, 231, 0.24);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.8;
  color: #c9c1b3;
}

.hits-card {
  padding: 17px 18px 8px;
}

.hits-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.hits-head h2 {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.03em;
}

.hits-head span {
  font-size: 10.5px;
  color: var(--ink-3);
}

.hit {
  padding: 14px 2px 15px;
  border-top: 1px solid #efe9dd;
}

.hit:first-of-type {
  border-top: none;
}

.hit-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.hit-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink-3);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.hit-citation {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
}

.hit-citation {
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink);
  text-align: left;
  border-bottom: 1px solid transparent;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.hit-citation:hover {
  color: var(--sakura-deep);
  border-bottom-color: rgba(185, 106, 116, 0.3);
}

.hit-head .badge.score {
  margin-left: auto;
}

.hit-text {
  margin: 9px 0 0;
  padding: 0;
  max-height: 158px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.82;
  color: var(--ink-2);
}

.hit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

/* ------------------------------------------------------------------
   弹层
   ------------------------------------------------------------------ */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 41, 37, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.18s var(--ease);
}

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(660px, 100%);
  max-height: 86vh;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--paper-2);
  box-shadow: var(--shadow-lg);
  animation: popIn 0.2s var(--ease);
  outline: none;
}

.modal-wide {
  width: min(900px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 13px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.modal-body {
  padding: 17px 20px;
  overflow: auto;
  font-size: 13px;
  color: var(--ink-2);
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 13px 20px 17px;
  border-top: 1px solid var(--line);
}

.modal-text {
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-2);
}

.modal-text b {
  color: var(--ink);
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.preview-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px 16px;
  margin-bottom: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
}

.preview-info dt {
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.preview-info dd {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.preview-note {
  margin-bottom: 12px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-3);
}

.preview-text {
  margin: 0;
  padding: 15px 16px;
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink-2);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

/* ------------------------------------------------------------------
   轻提示
   ------------------------------------------------------------------ */

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--line-2);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.6;
  text-align: left;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: auto;
  cursor: pointer;
}

.toast.in {
  opacity: 1;
  transform: none;
}

.toast svg {
  margin-top: 2px;
}

.toast-success {
  border-left-color: var(--green);
}

.toast-success svg {
  color: var(--green);
}

.toast-error {
  border-left-color: var(--red);
}

.toast-error svg {
  color: var(--red);
}

.toast-info {
  border-left-color: var(--gold);
}

.toast-info svg {
  color: var(--gold);
}

.toast-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------
   响应式
   ------------------------------------------------------------------ */

@media (max-width: 1160px) {
  .search-grid {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .editor {
    grid-template-columns: minmax(0, 1fr) 250px;
  }

  .dist-cols {
    gap: 18px;
  }
}

@media (max-width: 1040px) {
  .overview-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-aside {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-form {
    position: static;
  }
}

@media (max-width: 900px) {
  .topbar {
    padding: 0 16px;
  }

  .layout {
    display: block;
    padding: 18px 16px 52px;
  }

  .sidebar {
    position: static;
    display: block;
    margin-bottom: 16px;
  }

  .nav {
    flex-direction: row;
    gap: 2px;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    height: 37px;
    padding: 0 12px;
    font-size: 12.5px;
  }

  .nav-item.is-active::before {
    top: auto;
    right: 12px;
    bottom: 0;
    left: 12px;
    width: auto;
    height: 2px;
    border-radius: 2px 2px 0 0;
  }

  .side-card,
  .side-foot {
    display: none;
  }

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

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .brand-text small {
    display: none;
  }

  .health-chip {
    padding: 0 7px;
  }

  .health-chip #health-text {
    display: none;
  }

  .user-name {
    display: none;
  }

  /* 顶部导航：窄屏隐藏图标与计数，让四个入口都能放下 */
  .nav-item {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    gap: 0;
    padding: 0 4px;
    font-size: 12px;
  }

  .nav-item svg,
  .nav-count {
    display: none;
  }

  .nav-item.is-active::before {
    left: 8px;
    right: 8px;
  }

  /* 筛选区改两列，避免把列表推到很下面 */
  .filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 8px;
  }

  .filter-field,
  .filter-field.grow {
    flex: none;
    width: auto;
    grid-column: auto;
  }

  .filter-field.grow,
  .filter-reset {
    grid-column: 1 / -1;
  }

  .filter-reset {
    width: auto;
  }

  .page-head {
    align-items: flex-start;
  }

  .page-head h1 {
    font-size: 25px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1 1 auto;
  }

  .stat-grid {
    gap: 10px;
  }

  .stat-card {
    padding: 14px 14px 13px;
  }

  .stat-value {
    font-size: 24px;
  }

  .welcome-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 20px;
  }

  .welcome-actions {
    width: 100%;
  }

  .welcome-actions .btn {
    flex: 1 1 auto;
  }

  .dist-cols {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .dist-sub {
    margin-top: 10px;
  }

  .doc-card {
    flex-direction: column;
    gap: 10px;
    padding: 13px 14px;
  }

  .doc-actions {
    width: 100%;
    justify-content: flex-start;
    padding-top: 9px;
    border-top: 1px dashed var(--line);
  }

  .doc-title {
    white-space: normal;
  }

  .field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-main {
    padding: 16px;
  }

  #kb-text {
    min-height: 240px;
  }

  .toolbar-hint {
    display: none;
  }

  .editor-aside {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .editor-actions-right {
    width: 100%;
  }

  .editor-actions-right .btn {
    flex: 1 1 auto;
  }

  .search-form {
    padding: 15px;
  }

  .search-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-placeholder {
    padding: 30px 20px;
  }

  .modal-root {
    padding: 10px;
  }

  .modal {
    max-height: 92vh;
  }

  .modal-head {
    padding: 15px 16px 11px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  .modal-foot {
    padding: 11px 16px 14px;
  }

  .modal-foot .btn {
    flex: 1 1 auto;
  }

  .toast-root {
    right: 16px;
    bottom: 16px;
    left: 16px;
    width: auto;
    align-items: stretch;
  }

  .auth-page {
    padding: 66px 14px 48px;
  }

  .auth-top {
    top: 20px;
    left: 20px;
  }

  .auth-card {
    padding: 26px 22px 22px;
  }

  .auth-card::before {
    left: 22px;
    right: 22px;
  }

  .auth-card h1 {
    font-size: 26px;
  }

  .auth-foot {
    position: static;
    margin-top: 22px;
  }
}

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