/* ==========================================================================
   方寸 · 装修 AI —— 设计系统 v21
   Graphite / bone / pine.  单一来源：tokens → 基础元件 → 业务组件
   1 tokens | 2 reset | 3 type | 4 layout utils | 5 buttons | 6 forms
   7 badges | 8 tables | 9 panels | 10 misc
   ========================================================================== */

/* ---------- 1. tokens ---------- */
:root {
  /* neutrals */
  --coal: #0c0e0d;
  --coal-2: #141816;
  --coal-3: #1d221f;
  --coal-line: #2b312d;

  --bone: #f3f1eb;
  --bone-2: #eae7de;
  --bone-3: #ded9cc;

  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --surface-3: #f6f4ee;

  --ink: #101311;
  --ink-2: #333a35;
  --muted: #6c736c;
  --faint: #969c93;

  --line: #e2dfd5;
  --line-2: #cfcbbd;
  --line-3: #b4afa0;

  /* brand */
  --pine: #1d4a38;
  --pine-600: #163a2c;
  --pine-700: #0f2b20;
  --pine-soft: #e6eee8;
  --pine-line: #c4d6ca;

  --ochre: #9e6f1c;
  --ochre-soft: #f7eeda;
  --ochre-line: #e7d5ac;

  /* semantic */
  --ok: #1d4a38;
  --ok-soft: #e6eee8;
  --ok-line: #c4d6ca;

  --run: #2f5d80;
  --run-soft: #e6eef5;
  --run-line: #c6daea;

  --warn: #95661a;
  --warn-soft: #f7eeda;
  --warn-line: #e7d5ac;

  --danger: #9c3a2c;
  --danger-soft: #f8e6e2;
  --danger-line: #ecc8c1;

  --info: #3a4a5e;
  --info-soft: #eaeef3;
  --info-line: #d0d9e3;

  /* radius */
  --r-2: 2px;
  --r-4: 4px;
  --r-6: 6px;
  --r-10: 10px;
  --r-14: 14px;
  --r-20: 20px;
  --r-pill: 999px;

  /* elevation —— 只用于浮层 */
  --sh-1: 0 1px 1px rgba(16, 19, 17, 0.04);
  --sh-2: 0 2px 6px rgba(16, 19, 17, 0.05), 0 1px 2px rgba(16, 19, 17, 0.04);
  --sh-3: 0 18px 44px -20px rgba(16, 19, 17, 0.28), 0 2px 8px rgba(16, 19, 17, 0.06);
  --sh-4: 0 40px 90px -40px rgba(16, 19, 17, 0.45), 0 4px 14px rgba(16, 19, 17, 0.08);

  /* type */
  --font: "Inter", "HarmonyOS Sans SC", "PingFang SC", "Source Han Sans SC",
    "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, "Cascadia Mono",
    Menlo, Consolas, monospace;

  /* metrics */
  --topbar: 58px;
  --rail: 236px;
  --maxw: 1280px;
}

/* ---------- 2. reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--pine-soft); color: var(--pine-700); }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; border-radius: var(--r-4); }

/* ---------- 3. type ---------- */
.display {
  font-size: clamp(40px, 5.2vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.045em;
  font-weight: 600;
}
.d1 { font-size: 40px; line-height: 1.1; letter-spacing: -0.035em; font-weight: 600; }
.d2 { font-size: 30px; line-height: 1.18; letter-spacing: -0.03em; font-weight: 600; }
.d3 { font-size: 22px; line-height: 1.3; letter-spacing: -0.02em; font-weight: 600; }
.h4 { font-size: 16px; line-height: 1.45; letter-spacing: -0.01em; font-weight: 600; }
.h5 { font-size: 14px; line-height: 1.5; font-weight: 600; }
.lead { font-size: 16.5px; line-height: 1.7; color: var(--muted); }
.body { font-size: 14px; line-height: 1.7; }
.sm { font-size: 12.5px; line-height: 1.6; }
.xs { font-size: 11.5px; line-height: 1.5; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ink2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -0.01em; }
.strong { font-weight: 600; }
.medium { font-weight: 500; }

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.eyebrow.on-dark { color: rgba(243, 241, 235, 0.45); }

.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- 4. layout utils ---------- */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.end { justify-content: flex-end; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.top { align-items: flex-start; }
.baseline { align-items: baseline; }
.nowrap { white-space: nowrap; }
.gap-2 { gap: 2px; } .gap-3 { gap: 3px; } .gap-4 { gap: 4px; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.gap-12 { gap: 12px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; }
.gap-20 { gap: 20px; } .gap-24 { gap: 24px; } .gap-32 { gap: 32px; }
.gap-40 { gap: 40px; } .gap-56 { gap: 56px; }

.mt-2 { margin-top: 2px; } .mt-4 { margin-top: 4px; } .mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; } .mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; } .mt-40 { margin-top: 40px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.pad-16 { padding: 16px; } .pad-20 { padding: 20px; } .pad-24 { padding: 24px; }
.tr { text-align: right; } .tc { text-align: center; }
.w-full { width: 100%; }
.hide { display: none !important; }

/* ---------- 5. buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  border-radius: var(--r-6);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.12s ease;
}
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary { background: var(--pine); color: #f6f8f5; }
.btn-primary:hover { background: var(--pine-600); }

.btn-ink { background: var(--ink); color: var(--bone); }
.btn-ink:hover { background: #232a25; }

.btn-light { background: var(--bone); color: var(--ink); }
.btn-light:hover { background: #fff; }

.btn-outline { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-outline:hover { border-color: var(--line-3); background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(16, 19, 17, 0.05); color: var(--ink); }

.btn-quiet { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-3); }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: #f4d9d3; }

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-4); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 14.5px; border-radius: var(--r-6); }
.btn-xl { height: 52px; padding: 0 30px; font-size: 15px; border-radius: var(--r-6); }
.btn-block { width: 100%; }

.btn[disabled], .btn.is-disabled {
  opacity: 0.42;
  pointer-events: none;
}

.btn-icon {
  width: 32px; height: 32px; padding: 0;
  border-radius: var(--r-6);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.btn-icon:hover { background: rgba(16, 19, 17, 0.06); color: var(--ink); }
.btn-icon svg { width: 16px; height: 16px; }

/* 深色区域内的按钮 */
.on-dark .btn-outline { background: transparent; border-color: rgba(243, 241, 235, 0.28); color: var(--bone); }
.on-dark .btn-outline:hover { background: rgba(243, 241, 235, 0.1); border-color: rgba(243, 241, 235, 0.5); }
.on-dark .btn-ghost { color: rgba(243, 241, 235, 0.78); }
.on-dark .btn-ghost:hover { background: rgba(243, 241, 235, 0.1); color: #fff; }
.on-dark .btn-primary { background: var(--bone); color: var(--coal); }
.on-dark .btn-primary:hover { background: #fff; }

/* ---------- 6. forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}
.help { font-size: 11.5px; color: var(--faint); line-height: 1.5; }
.err { font-size: 11.5px; color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-6);
  font-size: 13.5px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(29, 74, 56, 0.1);
}
.textarea {
  height: auto;
  min-height: 86px;
  padding: 9px 11px;
  line-height: 1.65;
  resize: vertical;
}
.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%236c736c' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.input-sm, .select-sm { height: 30px; font-size: 12.5px; border-radius: var(--r-4); }

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--faint);
  pointer-events: none;
}
.search .input { padding-left: 30px; }

.switch {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  width: 34px;
  height: 19px;
  border-radius: var(--r-pill);
  background: var(--line-2);
  flex: none;
  transition: background 0.18s ease;
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform 0.18s ease;
}
.switch[data-on="true"] { background: var(--pine); }
.switch[data-on="true"]::after { transform: translateX(15px); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.check input { width: 15px; height: 15px; accent-color: var(--pine); margin: 0; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r-6);
}
.seg button {
  height: 26px;
  padding: 0 11px;
  border-radius: var(--r-4);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.seg button[data-on="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--sh-1);
}

/* 顶部标签导航 */
.tabs {
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
}
.tabs a, .tabs button {
  position: relative;
  padding: 0 0 11px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs [data-on="true"] { color: var(--ink); font-weight: 500; }
.tabs [data-on="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--ink);
}

/* ---------- 7. badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 7px;
  border-radius: var(--r-4);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
  opacity: 0.9;
}
.badge.no-dot::before { display: none; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.badge-run { background: var(--run-soft); color: var(--run); border-color: var(--run-line); }
.badge-run::before { animation: pulse 1.6s ease-in-out infinite; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge-fail { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge-draft { background: var(--surface-3); color: var(--muted); border-color: var(--line); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--line-3); }
.chip[data-on="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bone);
}
.chip-sm { height: 24px; padding: 0 9px; font-size: 11.5px; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 6px;
  border-radius: var(--r-2);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.tag-pine { background: var(--pine-soft); color: var(--pine); border-color: var(--pine-line); }
.tag-ochre { background: var(--ochre-soft); color: var(--ochre); border-color: var(--ochre-line); }

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: var(--r-2);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  color: var(--muted);
}

/* ---------- 8. tables ---------- */
.table { font-size: 13px; }
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--faint);
  padding: 0 14px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-2);
}
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-strong { color: var(--ink); font-weight: 500; }
.table-compact td { padding: 9px 12px; }

/* ---------- 9. panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-10);
}
.panel-flat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-10);
  box-shadow: none;
}
.panel-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-bd { padding: 18px; }
.panel-ft {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-10) var(--r-10);
}

.note {
  display: flex;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--r-6);
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
}
.note svg { width: 14px; height: 14px; margin-top: 3px; flex: none; color: var(--faint); }
.note-pine { background: var(--pine-soft); border-color: var(--pine-line); color: var(--pine-700); }
.note-pine svg { color: var(--pine); }
.note-warn { background: var(--warn-soft); border-color: var(--warn-line); color: #6f4c12; }
.note-warn svg { color: var(--warn); }

/* 统计块 */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-k { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat-v {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-v small { font-size: 12px; font-weight: 400; color: var(--faint); letter-spacing: 0; margin-left: 3px; }
.stat-d { font-size: 11.5px; color: var(--faint); }

/* 进度 */
.bar { height: 5px; border-radius: var(--r-pill); background: var(--bone-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--pine); }
.bar-thin { height: 3px; }
.bar-lg { height: 8px; }

/* 头像 */
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--pine-soft);
  color: var(--pine);
  font-size: 12px;
  font-weight: 600;
  flex: none;
  border: 1px solid var(--pine-line);
}
.avatar-sm { width: 24px; height: 24px; font-size: 10.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-neutral { background: var(--surface-3); color: var(--muted); border-color: var(--line); }

.stack { display: flex; }
.stack > * + * { margin-left: -8px; }
.stack .avatar { box-shadow: 0 0 0 2px var(--surface); }

/* ---------- 10. misc ---------- */
.divider { height: 1px; background: var(--line); }
.dot-sep { color: var(--line-3); }

.link {
  color: var(--pine);
  border-bottom: 1px solid var(--pine-line);
  padding-bottom: 0.5px;
}
.link:hover { border-color: var(--pine); }

.tooltip-host { position: relative; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 56px 20px;
  color: var(--faint);
  text-align: center;
}
.empty svg { width: 30px; height: 30px; opacity: 0.5; }

/* 闪一下的提示 */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise 0.35s ease both; }
