/* ============================================================
   Triangle · Prompt Console
   暖色浅色主题 / 零依赖
   ============================================================ */

:root {
  --bg: #f6f0e7;
  --bg-deep: #efe6d8;
  --surface: #fffdfa;
  --surface-2: #fbf6ef;
  --surface-3: #f3ebdf;
  --line: #e7dccd;
  --line-strong: #d8c8b4;
  --text: #2e2620;
  --text-2: #6f6154;
  --text-3: #9c8b7a;
  --accent: #c1552e;
  --accent-deep: #9d3f1e;
  --accent-soft: #f8e6db;
  --accent-line: #eec3ac;
  --ok: #4f7a5b;
  --ok-soft: #e7f0e7;
  --warn: #a9761c;
  --warn-soft: #f8eed8;
  --danger: #b03b30;
  --danger-soft: #f8e4e0;
  --ink-soft: #7d6a58;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(76, 55, 35, .06), 0 1px 1px rgba(76, 55, 35, .04);
  --shadow-md: 0 6px 24px -12px rgba(76, 55, 35, .28), 0 2px 6px rgba(76, 55, 35, .05);
  --shadow-lg: 0 28px 70px -28px rgba(60, 40, 24, .45);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --nav-w: 268px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 88% -10%, #fbe9d8 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 100%, #f3e6d3 0%, transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button { font: inherit; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: #f3c9b2; color: #42281a; }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================== 登录页 ============================== */

.login-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
}

.login-art {
  position: relative;
  overflow: hidden;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(800px 420px at 15% 10%, #f7d9c0 0%, transparent 58%),
    linear-gradient(150deg, #f2e3d0 0%, #ead6c0 45%, #e6cdb4 100%);
  border-right: 1px solid var(--line);
}

.login-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(150, 110, 78, .10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(150, 110, 78, .10) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(720px 520px at 30% 45%, #000 10%, transparent 78%);
  pointer-events: none;
}

.login-art-inner { position: relative; z-index: 1; max-width: 520px; }
.login-art h2 {
  margin-top: 28px;
  font-size: 40px;
  line-height: 1.18;
  letter-spacing: -.02em;
  font-weight: 680;
  color: #3b2a1d;
}
.login-art h2 em { font-style: normal; color: var(--accent-deep); }
.login-art p { margin-top: 18px; font-size: 15px; color: #6d5443; max-width: 420px; }
.login-art-footer { position: relative; z-index: 1; font-size: 12.5px; color: #8b6d57; letter-spacing: .02em; }

.login-art-triangle {
  position: absolute;
  right: -90px;
  bottom: -70px;
  width: 520px;
  height: 520px;
  opacity: .16;
  transform: rotate(-6deg);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 34px 32px 30px;
}

.login-card .brand { margin-bottom: 22px; }
.login-card h1 { font-size: 22px; letter-spacing: -.01em; }
.login-card .sub { margin-top: 6px; color: var(--text-2); font-size: 13px; }
.login-form { margin-top: 24px; display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.field input {
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: var(--text-3); }
.field input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(193, 85, 46, .14);
}
.login-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.login-hint code { font-family: var(--mono); font-size: 11.5px; color: var(--accent-deep); }

/* ============================== 品牌 ============================== */

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; display: block; flex: none; }
.brand-name { font-weight: 680; letter-spacing: -.01em; font-size: 16.5px; }
.brand-name span { color: var(--text-3); font-weight: 500; font-size: 12px; margin-left: 6px; letter-spacing: .04em; }

/* ============================== 应用骨架 ============================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, #fbf5ec 0%, #f7efe3 100%);
  border-right: 1px solid var(--line);
  padding: 20px 14px 14px;
  gap: 18px;
}

.sidebar .brand { padding: 0 8px; }

.nav-scroll { overflow-y: auto; flex: 1; min-height: 0; margin: 0 -4px; padding: 0 4px; }

.nav-group { margin-bottom: 22px; }
.nav-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.nav-group-head .dot { width: 5px; height: 5px; border-radius: 99px; background: var(--accent-line); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  line-height: 1.3;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: #f2e6d6; color: var(--text); }
.nav-item.is-active {
  background: var(--surface);
  color: var(--accent-deep);
  font-weight: 620;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--accent-line);
  padding: 7px 9px;
}
.nav-item .nav-ico {
  width: 16px;
  height: 16px;
  flex: none;
  color: currentColor;
  opacity: .75;
}
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--surface-3);
  border-radius: 99px;
  padding: 1px 6px;
}
.nav-item.is-active .nav-meta { background: var(--accent-soft); color: var(--accent-deep); }

.do-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--warn); margin-left: auto; flex: none; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 6px 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 99px; flex: none;
  background: linear-gradient(145deg, #e8c6ab, #d9a883);
  color: #5b3a24;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.who { min-width: 0; line-height: 1.25; }
.who b { display: block; font-size: 12.5px; font-weight: 620; }
.who span { display: block; font-size: 11px; color: var(--text-3); }

/* ============================== 主区域 ============================== */

.main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 30px;
  height: 56px;
  background: rgba(250, 245, 237, .82);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); min-width: 0; }
.crumbs .sep { color: var(--text-3); }
.crumbs b { color: var(--text); font-weight: 620; }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--accent); }
.topbar-spacer { flex: 1; }

.page { padding: 28px 30px 64px; max-width: 1240px; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 25px; letter-spacing: -.02em; font-weight: 680; line-height: 1.2; }
.page-head .lede { margin-top: 6px; color: var(--text-2); font-size: 13.5px; max-width: 680px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex: none; padding-top: 4px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-deep);
}
.eyebrow::before { content: ""; width: 14px; height: 1.5px; background: var(--accent); border-radius: 2px; }

/* ============================== 通用控件 ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, box-shadow .14s, transform .06s, color .14s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(180deg, #cb613a, #b84f27);
  border-color: #a5461f;
  color: #fff8f2;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 2px 8px -3px rgba(150, 60, 25, .5);
}
.btn-primary:hover { background: linear-gradient(180deg, #d06a42, #bb5229); border-color: #9b3f1a; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #e5c6c0; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: #d8a9a0; }
.btn-sm { height: 29px; padding: 0 10px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-block { width: 100%; }
.btn .ico { width: 15px; height: 15px; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  border-radius: 99px;
  font-size: 11.5px; font-weight: 620; letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 99px; background: currentColor; }
.badge-active { color: var(--ok); background: var(--ok-soft); border-color: #cfe0d0; }
.badge-pending { color: var(--warn); background: var(--warn-soft); border-color: #ecdcb8; }
.badge-historical { color: var(--text-3); background: var(--surface-3); border-color: var(--line); }
.badge-archived { color: #8a7a6a; background: #f1ece4; border-color: #e2d9cd; }

.tag {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px;
  border-radius: 5px;
  font-family: var(--mono); font-size: 11px;
  color: var(--accent-deep); background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.tag-muted { color: var(--text-2); background: var(--surface-3); border-color: var(--line); }

/* ============================== 卡片 ============================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 15px; font-weight: 640; letter-spacing: -.01em; }
.card-head .muted { color: var(--text-3); font-size: 12px; }
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px 20px; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat .k { font-size: 11.5px; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; font-weight: 620; }
.stat .v { margin-top: 6px; font-size: 24px; font-weight: 660; letter-spacing: -.02em; font-family: var(--mono); }
.stat .v small { font-size: 12px; color: var(--text-3); font-weight: 500; margin-left: 4px; font-family: var(--font); }
.stat.accent .v { color: var(--accent-deep); }

/* ============================== 表格 ============================== */

.table-wrap { overflow-x: auto; }
table.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table thead th {
  position: sticky; top: 0;
  text-align: left;
  font-size: 11px;
  font-weight: 680;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fdf8f1; }
.table tbody tr.is-current { background: #fdf5ee; }
.table tbody tr.is-current:hover { background: #fbf0e6; }
.table .num { font-family: var(--mono); font-size: 12.5px; }
.table .dim { color: var(--text-3); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 6px; }
.table .row-title { font-weight: 600; color: var(--text); }
.table .row-sub { color: var(--text-3); font-size: 11.5px; margin-top: 2px; }
.clickable { cursor: pointer; }

/* ============================== 空态 ============================== */

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty svg { width: 46px; height: 46px; color: var(--line-strong); margin-bottom: 10px; }
.empty p { font-size: 13.5px; }

/* ============================== 提示词详情 ============================== */

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

.editor-card { position: sticky; top: 74px; }

.editor-tabs {
  display: flex; gap: 2px;
  background: var(--surface-3);
  padding: 3px;
  border-radius: 9px;
}
.editor-tab {
  border: 0; background: transparent; color: var(--text-2);
  padding: 5px 11px; border-radius: 7px; font-size: 12.5px; cursor: pointer; font-weight: 560;
}
.editor-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.editor-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 460px;
}
.editor-panes.mode-edit { grid-template-columns: 1fr; }
.editor-panes.mode-preview { grid-template-columns: 1fr; }
.editor-panes.mode-edit .pane-preview,
.editor-panes.mode-preview .pane-edit { display: none; }

.pane { min-width: 0; display: flex; flex-direction: column; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-size: 11px; font-weight: 680; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.pane-head .spacer { flex: 1; }

.prompt-textarea {
  flex: 1;
  width: 100%;
  min-height: 430px;
  resize: vertical;
  border: 0;
  outline: none;
  background: var(--surface);
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12.6px;
  line-height: 1.72;
  color: #3b322b;
  tab-size: 2;
}

.markdown-body {
  padding: 18px 22px 26px;
  font-size: 13.6px;
  line-height: 1.75;
  color: #3a3129;
  overflow-wrap: anywhere;
}
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin: 1.3em 0 .5em; line-height: 1.35; letter-spacing: -.01em; font-weight: 660;
}
.markdown-body h1 { font-size: 21px; }
.markdown-body h2 { font-size: 17px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.markdown-body h3 { font-size: 15px; }
.markdown-body h4 { font-size: 13.5px; color: var(--text-2); }
.markdown-body p { margin: .7em 0; }
.markdown-body ul, .markdown-body ol { margin: .6em 0; padding-left: 1.5em; }
.markdown-body li { margin: .25em 0; }
.markdown-body li::marker { color: var(--accent); }
.markdown-body code {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-3); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 5px; color: #8a3f20;
}
.markdown-body pre {
  background: #2f2a25; color: #f0e6da;
  padding: 14px 16px; border-radius: 10px; overflow-x: auto; margin: 1em 0;
}
.markdown-body pre code { background: transparent; border: 0; padding: 0; color: inherit; font-size: 12px; }
.markdown-body blockquote {
  margin: 1em 0; padding: 6px 16px;
  border-left: 3px solid var(--accent-line);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 0 8px 8px 0;
}
.markdown-body hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 12.8px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.markdown-body th { background: var(--surface-2); font-weight: 640; }
.markdown-body a { border-bottom: 1px solid var(--accent-line); }
.markdown-body strong { font-weight: 660; color: #2c231c; }

/* 元信息栅格 */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
.meta-cell { background: var(--surface); padding: 11px 14px; }
.meta-cell .k { font-size: 11px; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; font-weight: 620; }
.meta-cell .v { margin-top: 3px; font-size: 13px; font-weight: 560; }
.meta-cell .v.mono { font-family: var(--mono); font-size: 12.5px; }

/* ============================== 数据源勾选 ============================== */

.ds-toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ds-toolbar .search { flex: 1; }

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search svg { position: absolute; left: 10px; width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 31px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(193, 85, 46, .12); }

.ds-groups { max-height: 520px; overflow-y: auto; }
.ds-group { border-bottom: 1px solid var(--line); }
.ds-group:last-child { border-bottom: 0; }
.ds-group-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 9px 16px;
  background: var(--surface-2);
  border: 0; border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 680; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-2); cursor: pointer; text-align: left;
}
.ds-group-head .count { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); font-weight: 500; }
.ds-group-head .chev { width: 13px; height: 13px; transition: transform .18s; color: var(--text-3); }
.ds-group.is-collapsed .ds-group-head .chev { transform: rotate(-90deg); }
.ds-group.is-collapsed .ds-group-body { display: none; }

.ds-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #f1e9dd;
  cursor: pointer;
  transition: background .12s;
}
.ds-row:last-child { border-bottom: 0; }
.ds-row:hover { background: #fdf9f3; }
.ds-row input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px; margin: 2px 0 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  flex: none;
  cursor: pointer;
  position: relative;
  transition: background .12s, border-color .12s;
}
.ds-row input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent-deep); }
.ds-row input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4.5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.ds-row input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ds-main { min-width: 0; flex: 1; }
.ds-name { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ds-name code { font-family: var(--mono); font-size: 12px; font-weight: 620; color: var(--text); }
.ds-name .cn { font-size: 12.5px; color: var(--text-2); }
.ds-desc { margin-top: 2px; font-size: 12px; color: var(--text-3); line-height: 1.5; }
.ds-usage { margin-top: 3px; font-size: 11.5px; color: var(--text-2); }
.ds-usage b { color: var(--text-3); font-weight: 600; }

.ds-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px; color: var(--text-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.ds-summary .mono { font-family: var(--mono); color: var(--accent-deep); font-weight: 620; }

/* ============================== 数据源字典页 ============================== */

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

.ds-cat-nav { padding: 8px; position: sticky; top: 74px; }
.ds-cat-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: transparent; text-align: left;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text-2); cursor: pointer;
}
.ds-cat-btn:hover { background: var(--surface-3); color: var(--text); }
.ds-cat-btn.is-active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 620; }
.ds-cat-btn .count { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.ds-cat-btn.is-active .count { color: var(--accent-deep); }

.ds-table td { vertical-align: top; }
.ds-table .ds-id { font-family: var(--mono); font-size: 12px; font-weight: 620; }
.ds-table .ds-cn { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.ds-table .desc { color: var(--text-2); font-size: 12.5px; max-width: 380px; }
.ds-table .usage { color: var(--text-3); font-size: 12px; max-width: 220px; }

/* ============================== 弹窗 ============================== */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(58, 40, 26, .32);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fadeIn .16s ease;
}
.modal {
  width: 100%; max-width: 452px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px 24px 20px;
  animation: popIn .18s cubic-bezier(.2, .9, .3, 1.2);
}
.modal h3 { font-size: 17px; letter-spacing: -.01em; }
.modal .modal-body { margin-top: 10px; color: var(--text-2); font-size: 13.5px; line-height: 1.65; }
.modal .modal-body strong { color: var(--text); }
.modal-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 8px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================== Toast ============================== */

.toast-root {
  position: fixed; right: 24px; bottom: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #33291f; color: #fdf3e7;
  padding: 10px 15px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
  max-width: 420px;
}
.toast .tick { width: 15px; height: 15px; color: #a8d5a8; flex: none; }
.toast.is-error .tick { color: #f0a49a; }

/* ============================== 提示条 ============================== */

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  margin-bottom: 16px;
}
.notice.is-warn { background: var(--warn-soft); border-color: #ecdcb8; color: #7d5a16; }
.notice svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.notice b { color: var(--text); }

/* ============================== 响应式 ============================== */

@media (max-width: 1180px) {
  .detail-grid { grid-template-columns: 1fr; }
  .editor-card { position: static; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  :root { --nav-w: 232px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .ds-page-grid { grid-template-columns: 1fr; }
  .ds-cat-nav { position: static; display: flex; gap: 6px; overflow-x: auto; }
  .page { padding: 20px 18px 48px; }
  .topbar { padding: 0 18px; }
  .editor-panes { grid-template-columns: 1fr; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
}

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

/* ============================== 补充组件 ============================== */

/* 长内容下 sticky 会让编辑卡片超出视口，这里统一改为静态 */
.editor-card { position: static; }

.muted { color: var(--text-3); font-size: 12px; }
.dim { color: var(--text-3); }

.page-head .lede .badge { vertical-align: 1px; margin-right: 2px; }

.editor-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.note-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.note-input::placeholder { color: var(--text-3); }
.note-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(193, 85, 46, .12); }

.pane-preview .markdown-body { max-height: 640px; overflow-y: auto; }

.markdown-body .task { list-style: none; margin-left: -1.25em; }
.markdown-body .task input { margin-right: 6px; accent-color: var(--accent); vertical-align: -1px; }
.markdown-body .task.is-done span { color: var(--text-3); text-decoration: line-through; }
.markdown-body .task.is-done input { opacity: .85; }

@media (max-width: 900px) {
  .editor-foot { flex-wrap: wrap; }
  .note-input { min-width: 100%; }
}
