/* ============================================================
   BUDDY — 设计系统（tokens + reset + 通用组件）
   配色取自 buddy.png 实拍主色：橙 #FC5D05 / 海蓝 #0176DA / 墨 #18120F
   ============================================================ */

:root {
  /* 纸面层 */
  --paper: #FBF7F1;
  --paper-2: #F5EEE5;
  --paper-3: #EDE3D6;
  --paper-4: #E3D6C5;
  --white: #FFFFFF;

  /* 墨色三级 */
  --ink: #18120F;
  --ink-2: #4E453E;
  --ink-3: #8B8079;
  --ink-4: #B0A69D;

  /* 主橙 */
  --orange: #FC5D05;
  --orange-d: #D94B00;
  --orange-l: #FF8A3D;
  --orange-soft: rgba(252, 93, 5, .10);
  --orange-line: rgba(252, 93, 5, .28);

  /* 海蓝 */
  --sea: #0176DA;
  --sea-d: #0B5AA8;
  --sea-soft: rgba(1, 118, 218, .10);

  /* 琥珀（点缀） */
  --amber: #FDA13B;
  --amber-soft: rgba(253, 161, 59, .16);

  /* 深色块 */
  --dark: #1B1512;
  --dark-2: #241C18;
  --dark-ink: rgba(251, 247, 241, .80);
  --dark-ink-2: rgba(251, 247, 241, .56);

  /* 线与阴影 */
  --line: rgba(24, 18, 15, .10);
  --line-2: rgba(24, 18, 15, .18);
  --sh-1: 0 1px 2px rgba(24, 18, 15, .05), 0 4px 14px rgba(24, 18, 15, .05);
  --sh-2: 0 2px 6px rgba(24, 18, 15, .06), 0 16px 40px rgba(24, 18, 15, .09);
  --sh-3: 0 24px 70px rgba(24, 18, 15, .16);

  /* 字体：全部走系统栈。国内访问 Google Fonts 不稳，不引第三方字体。 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
          "Noto Sans CJK SC", sans-serif;
  --font-d: "Segoe UI Variable Display", "Segoe UI", -apple-system,
            "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-m: "Cascadia Code", "JetBrains Mono", ui-monospace, Consolas,
            "SF Mono", Menlo, monospace;

  /* 圆角 */
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --r-xl: 26px;
  --r-f: 999px;

  /* 版心 */
  --wrap: 1180px;
  --nav-h: 68px;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
figure { margin: 0; }
h1, h2, h3, h4, p, ul, ol, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }

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

::selection { background: var(--orange); color: #fff; }

/* 滚动条（Webkit） */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(24, 18, 15, .16);
  border-radius: 99px;
  border: 2px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: rgba(24, 18, 15, .28); }

/* ---------- 版心 ---------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 24px;
}
.wrap-narrow { max-width: 820px; }

/* ---------- 文字 ---------- */
.h1 {
  font-family: var(--font-d);
  font-size: clamp(38px, 6.4vw, 76px);
  line-height: 1.06;
  letter-spacing: -.03em;
  font-weight: 800;
}
.h2 {
  font-family: var(--font-d);
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.14;
  letter-spacing: -.025em;
  font-weight: 800;
}
.h3 {
  font-family: var(--font-d);
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 700;
}
.lead {
  font-size: clamp(16px, 1.5vw, 18.5px);
  line-height: 1.78;
  color: var(--ink-2);
}
.muted { color: var(--ink-3); }
.mono { font-family: var(--font-m); font-variant-ligatures: none; }
.grad-warm {
  background: linear-gradient(100deg, var(--orange) 0%, var(--amber) 62%, var(--orange-d) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.grad-sea {
  background: linear-gradient(100deg, var(--sea) 0%, #4FA3E8 60%, var(--sea-d) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* 小标签 */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--orange-d);
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--orange);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  border-radius: var(--r-f);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .01em;
  white-space: nowrap;
  border: 1.5px solid transparent;
  transition: transform .18s var(--ease), background .18s, border-color .18s,
              color .18s, box-shadow .18s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 6px 18px rgba(252, 93, 5, .26);
}
.btn-primary:hover {
  background: var(--orange-d);
  box-shadow: 0 10px 26px rgba(252, 93, 5, .34);
  transform: translateY(-1px);
}
.btn-ghost {
  border-color: var(--line-2);
  color: var(--ink);
  background: rgba(255, 255, 255, .6);
}
.btn-ghost:hover { border-color: var(--ink); background: #fff; }
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: #000; transform: translateY(-1px); }
.btn-sea { background: var(--sea); color: #fff; }
.btn-sea:hover { background: var(--sea-d); transform: translateY(-1px); }
.btn-sm { height: 38px; padding: 0 16px; font-size: 13.5px; }
.btn-lg { height: 54px; padding: 0 30px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-danger {
  border-color: rgba(214, 45, 32, .3);
  color: #C4281B;
  background: rgba(214, 45, 32, .06);
}
.btn-danger:hover { background: rgba(214, 45, 32, .12); border-color: #C4281B; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--sh-1);
}
.card-pad { padding: 26px; }

/* ---------- 徽章 ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-f);
  font-size: 12px;
  font-weight: 650;
  background: var(--paper-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip-orange { background: var(--orange-soft); color: var(--orange-d); }
.chip-sea { background: var(--sea-soft); color: var(--sea-d); }
.chip-amber { background: var(--amber-soft); color: #9A6412; }
.chip-ok { background: rgba(22, 138, 74, .12); color: #0F7A42; }
.chip-off { background: rgba(24, 18, 15, .08); color: var(--ink-3); }
.chip-bad { background: rgba(214, 45, 32, .1); color: #C4281B; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.input, .textarea, .select {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: var(--r-m);
  border: 1.5px solid var(--line-2);
  background: #fff;
  font-size: 15px;
  line-height: 1.5;
  transition: border-color .16s, box-shadow .16s;
}
.textarea { min-height: 96px; resize: vertical; font-size: 14.5px; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3.5px var(--orange-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.select { appearance: none; padding-right: 36px; cursor: pointer; }
.field-hint { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.field-err { font-size: 12.5px; color: #C4281B; margin-top: 6px; }
code {
  font-family: var(--font-m);
  font-size: .92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--paper-3);
  color: var(--ink-2);
}

/* 复选框 */
.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.check input { width: 17px; height: 17px; accent-color: var(--orange); cursor: pointer; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: var(--paper-4);
  transition: background .2s;
  pointer-events: none;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .2s var(--ease);
}
.switch input:checked + i { background: var(--orange); }
.switch input:checked + i::after { transform: translateX(19px); }

/* ---------- 提示条 ---------- */
.alert {
  display: flex;
  gap: 10px;
  padding: 12px 15px;
  border-radius: var(--r-m);
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid transparent;
}
.alert-err { background: rgba(214, 45, 32, .07); border-color: rgba(214, 45, 32, .22); color: #A31F13; }
.alert-ok { background: rgba(22, 138, 74, .08); border-color: rgba(22, 138, 74, .22); color: #0F6B3B; }
.alert-info { background: var(--sea-soft); border-color: rgba(1, 118, 218, .22); color: var(--sea-d); }
.alert-warn { background: var(--amber-soft); border-color: rgba(253, 161, 59, .34); color: #8A5A10; }

/* ---------- 空态 ---------- */
.empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 54px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty-ico {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--paper-3);
  font-size: 24px;
}

/* ---------- 骨架 ---------- */
.skel {
  background: linear-gradient(90deg, var(--paper-2) 25%, var(--paper-3) 37%, var(--paper-2) 63%);
  background-size: 400% 100%;
  animation: skel 1.4s ease infinite;
  border-radius: var(--r-s);
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- 加载圈 ---------- */
.spin {
  width: 17px; height: 17px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
.spin-dark { border-color: var(--line-2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 滚动揭示 ---------- */
.rv { opacity: 0; transform: translateY(22px); }
.rv.in {
  opacity: 1;
  transform: none;
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 16px;
  border-radius: var(--r-m);
  background: var(--dark);
  color: var(--dark-ink);
  font-size: 14px;
  line-height: 1.5;
  box-shadow: var(--sh-3);
  animation: toastIn .28s var(--ease);
}
.toast.ok { background: #0F6B3B; color: #fff; }
.toast.err { background: #A31F13; color: #fff; }
.toast.out { animation: toastOut .24s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- 对话框 ---------- */
.dlg {
  border: 0;
  padding: 0;
  border-radius: var(--r-xl);
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--sh-3);
  max-width: min(520px, calc(100vw - 32px));
  width: 100%;
}
.dlg::backdrop { background: rgba(24, 18, 15, .48); backdrop-filter: blur(3px); }
.dlg[open] { animation: dlgIn .24s var(--ease); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 24px 0;
}
.dlg-head h3 { font-size: 18px; font-weight: 750; letter-spacing: -.01em; }
.dlg-x {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-3);
  font-size: 19px;
  line-height: 1;
  flex: none;
}
.dlg-x:hover { background: var(--paper-2); color: var(--ink); }
.dlg-body { padding: 16px 24px; }
.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 22px;
}
.dlg-foot .btn { min-width: 92px; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--r-l); border: 1px solid var(--line); background: #fff; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
.tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 13px 16px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--paper); }

/* ---------- 分段控件 ---------- */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-f);
  background: var(--paper-3);
}
.seg button {
  height: 32px;
  padding: 0 15px;
  border-radius: var(--r-f);
  font-size: 13.5px;
  font-weight: 620;
  color: var(--ink-2);
  transition: background .18s, color .18s;
}
.seg button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: var(--sh-1); }

/* ---------- 工具类 ---------- */
.sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }

/* ---------- 降低动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .rv { opacity: 1; transform: none; }
}
