/* =========================================================================
   tokens.css —— 设计令牌 / 字体 / 基础重置
   两个页面（门户 + 控制台）共用

   主题：暖白纸张 + 石墨字 + 黄铜强调（亮色主调）
   变量名沿用 ink-* 历史命名，语义已重映射为「层次」而不是「暗度」：
     ink-900 = 页面底色    ink-800 = 面板/卡片    ink-700 = 面板次级
     ink-600 = 凹陷/轨道   ink-500 = 分隔
   ========================================================================= */

@font-face {
  font-family: 'Chakra Petch';
  src: url('/assets/fonts/chakra-petch-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Chakra Petch';
  src: url('/assets/fonts/chakra-petch-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* 底色：暖白纸感，比纯白柔和，投影仪上不刺眼 */
  --ink-900: #f7f5ef;
  --ink-800: #ffffff;
  --ink-700: #fdfbf6;
  --ink-600: #f1ede3;
  --ink-500: #e7e2d6;

  --text: #14201b;
  --text-soft: #38443d;
  --muted: #5c6862;
  --muted-dim: #7b867e;

  /* 主强调：黄铜 —— 浅底上压深一点，白字/描边都够对比 */
  --brass: #a2701a;
  --brass-bright: #c08a2a;
  --brass-wash: rgba(162, 112, 26, 0.10);

  --live: #1e7a4d;
  --live-wash: rgba(30, 122, 77, 0.12);
  --off: #9aa39b;
  --danger: #b2412c;
  --danger-wash: rgba(178, 65, 44, 0.10);

  --line: rgba(20, 32, 26, 0.10);
  --line-mid: rgba(20, 32, 26, 0.16);
  --line-hard: rgba(20, 32, 26, 0.26);

  --font-display: 'Chakra Petch', 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC',
               'Noto Sans SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  --font-mono: 'SFMono-Regular', ui-monospace, Menlo, Consolas, 'Liberation Mono', monospace;

  --r-sm: 2px;
  --r-md: 4px;
  --shell: min(1240px, calc(100vw - 4rem));

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--ink-900);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, dl, dd, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

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

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

/* ---------- 通用零件 ---------- */

.shell {
  width: var(--shell);
  margin-inline: auto;
}

.label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--off);
  flex: none;
}
.led--live {
  background: var(--live);
  box-shadow: 0 0 0 3px var(--live-wash), 0 0 0 1px rgba(30, 122, 77, 0.25);
  animation: led-pulse 2.6s var(--ease) infinite;
}
.led--idle { background: var(--brass); box-shadow: 0 0 0 3px var(--brass-wash); }
.led--err { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-wash); }

@keyframes led-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--live-wash), 0 0 0 1px rgba(30, 122, 77, 0.3); }
  50%      { box-shadow: 0 0 0 6px rgba(30, 122, 77, 0.07), 0 0 0 1px rgba(30, 122, 77, 0.45); }
}

/* 按钮 */
.btn {
  --btn-line: var(--line-mid);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--btn-line);
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.65);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
              background-color 0.2s var(--ease), transform 0.12s var(--ease);
  white-space: nowrap;
}
.btn:hover {
  color: #fff;
  background: var(--brass);
  border-color: var(--brass);
}
.btn:active { transform: translateY(1px); }
.btn--ghost:hover { color: var(--text); background: rgba(20, 32, 26, 0.06); border-color: var(--line-hard); }
.btn--danger { --btn-line: rgba(178, 65, 44, 0.35); color: var(--danger); }
.btn--danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--sm { padding: 0.35rem 0.6rem; font-size: 0.6875rem; letter-spacing: 0.1em; }
.btn[disabled], .btn[aria-busy='true'] {
  opacity: 0.45;
  pointer-events: none;
}
.btn[aria-busy='true']::after {
  content: '';
  width: 10px; height: 10px;
  border: 1px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 过滤 chip */
.chip {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--line-hard); }
.chip[aria-pressed='true'] {
  color: #fff;
  background: var(--brass);
  border-color: var(--brass);
}

/* [hidden] 必须压过组件自身的 display，否则 hidden 形同虚设 */
[hidden] { display: none !important; }

/* 视觉隐藏但可读 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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