/* 设计令牌与基础排版。字体全部使用系统内置，离线可用、无网络请求。 */

:root {
  color-scheme: light;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #eef0f3;
  --border: #dfe2e7;
  --border-strong: #c6cbd3;

  --text: #1b1f24;
  --text-soft: #5a626d;
  --text-faint: #8b939f;

  --accent: #2f6df6;
  --accent-soft: #e6eeff;
  --accent-text: #1b4fd0;
  --ok: #158b4e;
  --ok-soft: #e3f6ea;
  --bad: #cf3b3b;
  --bad-soft: #fdecec;
  --warn: #a86400;
  --warn-soft: #fff4e0;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-2: 0 4px 12px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, .16);

  --font: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-en: "Segoe UI", Georgia, "Times New Roman", serif;
  --font-mono: "Cascadia Mono", Consolas, "Courier New", monospace;

  --topbar-h: 56px;
  --ratebar-h: 44px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #14171b;
  --surface: #1c2026;
  --surface-2: #21262d;
  --surface-3: #2a3038;
  --border: #313841;
  --border-strong: #444c57;

  --text: #e8ecf1;
  --text-soft: #aab3bf;
  --text-faint: #7d8794;

  --accent: #6a9bff;
  --accent-soft: #1e2b48;
  --accent-text: #9ab8ff;
  --ok: #4ec98a;
  --ok-soft: #16301f;
  --bad: #f07171;
  --bad-soft: #3a1e1e;
  --warn: #e2b25c;
  --warn-soft: #352a15;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .45);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .6);
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; font-weight: 650; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 .8em; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 var(--radius) 0; z-index: 100;
}
.skip:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

::selection { background: var(--accent-soft); }

/* ---- 顶栏 ---- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brand-mark {
  font-family: var(--font-mono); font-weight: 700; font-size: 13px; letter-spacing: .5px;
  background: var(--accent); color: #fff; border-radius: var(--radius-sm);
  padding: 3px 7px;
}
.brand-mark span { opacity: .75; }
.brand-text { font-size: 15px; }

.tabs { display: flex; gap: 4px; margin-left: 6px; }
.tab {
  padding: 6px 14px; border-radius: 999px; color: var(--text-soft);
  font-weight: 550; font-size: 14px; white-space: nowrap;
}
.tab:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent-text); }

/* ---- 配速条 ---- */
/* hidden 属性会被下面的 display:flex 压掉，必须显式声明：配速条只该在精听模式出现 */
.rate-bar[hidden] { display: none; }
.rate-bar {
  position: sticky; top: var(--topbar-h); z-index: 35;
  display: flex; align-items: center; gap: 12px;
  height: var(--ratebar-h); padding: 0 18px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-soft);
}
.rate-bar label { font-weight: 600; color: var(--text); }
.rate-bar input[type="range"] { width: 190px; accent-color: var(--accent); }
.rate-bar output { font-family: var(--font-mono); font-size: 15px; font-weight: 650; color: var(--text); min-width: 62px; }

/* ---- 回到顶部悬浮按钮 ---- */
.to-top {
  position: fixed; right: 26px; bottom: 34px; z-index: 80;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px;
  background: var(--accent); border: 1px solid var(--accent);
  color: #fff; font-size: 14px; font-weight: 650;
  box-shadow: var(--shadow-1);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.to-top:hover { filter: brightness(1.08); transform: translateY(-2px); }
.to-top svg { transform: rotate(-90deg); }
.to-top[hidden] { display: none; }
.rate-warn { color: var(--warn); font-size: 12px; }

/* ---- 布局 ---- */
.view { padding: 22px 22px 60px; max-width: 1280px; margin: 0 auto; }
/* 顶栏与配速条是 sticky 的，而 setView 里的 scrollIntoView 会把视图顶部对到视口顶部，
   那样第一屏内容会被这两条压住。留出它们的高度，滚动就停在「内容完整可见」的位置。 */
.view { scroll-margin-top: calc(var(--topbar-h) + var(--ratebar-h) + 8px); }
.view:focus { outline: none; }

.grid { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.en { font-family: var(--font-en); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

/* ---- 卡片与控件 ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-1);
}
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }

.paper-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.paper-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-1); cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s;
  text-align: left; font: inherit; color: inherit; width: 100%;
}
.paper-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.paper-card h3 { font-size: 16px; margin-bottom: 6px; }
.paper-card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-3); color: var(--text-soft);
  border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 550; white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }

button, .btn {
  font: inherit; font-size: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover:not(:disabled), .btn:hover { background: var(--surface-3); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
button.ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
button.small { padding: 3px 8px; font-size: 12.5px; }
button.danger { color: var(--bad); border-color: var(--bad-soft); }

input[type="text"], input[type="number"], textarea, select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 9px;
}
textarea { width: 100%; min-height: 120px; resize: vertical; line-height: 1.65; }
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 4px; }

.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: var(--text-soft); user-select: none; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---- 提示条 ---- */
.notice {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; color: var(--text-soft);
}
.notice.warn { border-left-color: var(--warn); }
.notice.bad { border-left-color: var(--bad); }
.notice.ok { border-left-color: var(--ok); }
.notice strong { color: var(--text); }

.empty { text-align: center; padding: 48px 20px; color: var(--text-soft); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---- 表格 ---- */
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 12.5px; text-transform: none; color: var(--text-faint); font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--font-mono); }

/* ---- 进度条 ---- */
.bar { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---- toast ---- */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
  padding: 9px 14px; font-size: 13.5px; max-width: 380px;
  animation: toast-in .16s ease-out;
}
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- 骨架 ---- */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--radius-sm); height: 14px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
