/* ===== 主题系统 =====
 * 默认主题: Blaze
 * 切换方法: 修改 <html data-theme="xxx"> 的值
 * 可选: dark-roast / frost / obsidian / blaze
 * 自定义: 复制任意一套，改 data-theme 名称和色值即可
 */

/* --- Blaze: 深色玫红/激励感 --- */
[data-theme="blaze"] {
  --bg: #1a0a14; --surface: #261520; --surface2: #321e2c; --surface3: #3e2838;
  --border: #4a3344; --border-light: #5c4055;
  --text: #f5e8f0; --text-muted: #b89aad; --text-dim: #8a6e80;
  --accent: #f43f7a; --accent-glow: #ff6b9d;
  --green: #4ade80; --blue: #60a5fa; --purple: #c084fc;
  --red: #f87171; --orange: #fb923c; --yellow: #fbbf24;
  --font-display: 'Bebas Neue', Impact, sans-serif;
  --font-body: 'Noto Sans SC', -apple-system, sans-serif;
}
/* --- Dark Roast: 深色暖褐/品质感 --- */
[data-theme="dark-roast"] {
  --bg: #1a1412; --surface: #231e1a; --surface2: #2c2520; --surface3: #362e28;
  --border: #3d3430; --border-light: #4a3f39;
  --text: #f0e8e0; --text-muted: #a89888; --text-dim: #7a6b5e;
  --accent: #d4a574; --accent-glow: #e8b888;
  --green: #6db87a; --blue: #7aa3c8; --purple: #9b82c4;
  --red: #c47a6d; --orange: #d4956a; --yellow: #d4b86a;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Noto Sans SC', -apple-system, sans-serif;
}
/* --- Frost: 浅色简约/清爽效率 --- */
[data-theme="frost"] {
  --bg: #f5f6f8; --surface: #ffffff; --surface2: #eef0f4; --surface3: #e4e7ed;
  --border: #d8dce6; --border-light: #c8cdd8;
  --text: #1c1f26; --text-muted: #5c6070; --text-dim: #8b90a0;
  --accent: #2d6be6; --accent-glow: #5b8ff7;
  --green: #16a34a; --blue: #2563eb; --purple: #7c3aed;
  --red: #dc2626; --orange: #ea580c; --yellow: #ca8a04;
  --font-display: 'Inter Tight', -apple-system, sans-serif;
  --font-body: 'Noto Sans SC', -apple-system, sans-serif;
}
/* --- Obsidian: 深蓝灰/极客科技 --- */
[data-theme="obsidian"] {
  --bg: #0f1117; --surface: #1a1d27; --surface2: #242833; --surface3: #2e323f;
  --border: #363b4a; --border-light: #434959;
  --text: #e4e6ed; --text-muted: #8b90a0; --text-dim: #5c6173;
  --accent: #818cf8; --accent-glow: #a5b4fc;
  --green: #4ade80; --blue: #60a5fa; --purple: #c084fc;
  --red: #f87171; --orange: #fb923c; --yellow: #fbbf24;
  --font-display: 'JetBrains Mono', 'SF Mono', monospace;
  --font-body: 'Noto Sans SC', -apple-system, sans-serif;
}

:root {
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-body);
  font-weight: 300;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Top Bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--bg) 60%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; }
.topbar h1 {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 400;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.count { font-size: 13px; color: var(--text-dim); }
.icon-btn {
  background: none; border: none;
  color: var(--text-muted); font-size: 20px;
  cursor: pointer; padding: 4px 8px;
  border-radius: 6px; transition: all .15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

/* Menu */
.menu-dropdown {
  position: fixed; top: 52px; right: 16px; z-index: 50;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  padding: 6px 0; display: none; min-width: 180px;
}
.menu-dropdown.open { display: block; }
.menu-dropdown button, .menu-dropdown .menu-item {
  display: block; width: 100%; padding: 10px 16px;
  background: none; border: none; color: var(--text);
  font-size: 14px; font-family: var(--font-body);
  text-align: left; cursor: pointer; transition: background .15s;
}
.menu-dropdown button:hover, .menu-dropdown .menu-item:hover { background: var(--surface3); }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 20px; z-index: 20;
  display: grid; place-items: center;
  width: 56px; height: 56px;
  background: var(--accent); border: none; border-radius: 50%;
  color: #fff; cursor: pointer;
  box-shadow: 0 4px 24px rgba(244,63,122,.4);
  transition: all .2s;
}
.fab:hover { background: var(--accent-glow); transform: scale(1.05); }
.fab:active { transform: scale(.95); }

/* ===== Filters ===== */
.filters {
  position: sticky; top: 54px; z-index: 9;
  padding: 8px 20px 12px; background: var(--bg);
  display: flex; flex-direction: column; gap: 10px;
}
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
}
.filters input {
  width: 100%; padding: 10px 12px 10px 36px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
  font-family: var(--font-body); transition: border-color .2s;
}
.filters input:focus { outline: none; border-color: var(--accent); }
.filters input::placeholder { color: var(--text-dim); }

.chips {
  display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: none; padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 5px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; color: var(--text-muted);
  font-size: 13px; font-family: var(--font-body); font-weight: 400;
  cursor: pointer; transition: all .2s; white-space: nowrap;
}
.chip:hover { border-color: var(--border-light); color: var(--text); }
.chip.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 500;
}

/* ===== Sort Bar ===== */
.sort-bar {
  display: flex; gap: 8px; padding: 4px 16px 8px; background: var(--bg);
}
.sort-btn {
  font-size: 13px; padding: 5px 14px; border-radius: 14px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-family: inherit; cursor: pointer;
  transition: all 0.2s;
}
.sort-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* ===== Cards ===== */
.cards {
  padding: 6px 16px 120px;
  display: flex; flex-direction: column; gap: 10px;
}

/* Date group header */
.date-header {
  font-family: var(--font-display);
  font-size: 16px; letter-spacing: 0.08em;
  color: var(--text-dim); padding: 12px 0 4px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; transition: all .25s ease;
  position: relative; overflow: hidden;
}
.card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; border-radius: 3px 0 0 3px;
}
/* Category colors */
.card.cat-推::before { background: var(--green); }
.card.cat-拉::before { background: var(--purple); }
.card.cat-腿::before { background: var(--blue); }
.card.cat-核心::before { background: var(--orange); }

.card:active { transform: scale(.985); }
@media (hover: hover) {
  .card:hover { border-color: var(--border-light); background: var(--surface2); }
}

.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-exercise {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 400;
  color: var(--accent-glow); letter-spacing: 0.04em;
  line-height: 1.2;
}
.card-status {
  flex-shrink: 0; font-size: 11px; padding: 3px 10px;
  border-radius: 999px; font-weight: 500; white-space: nowrap;
}
.card-status.正常 { background: rgba(184,154,173,.12); color: var(--text-muted); }
.card-status.PR { background: rgba(244,63,122,.18); color: var(--accent); font-weight: 700; }
.card-status.试重 { background: rgba(251,191,36,.15); color: var(--yellow); }
.card-status.降载 { background: rgba(96,165,250,.12); color: var(--blue); }

.card-metrics {
  margin-top: 8px; font-size: 14px; color: var(--text);
  display: flex; gap: 12px; align-items: center;
}
.card-metrics .metric-val {
  font-weight: 500;
}
.card-metrics .metric-sep {
  color: var(--text-dim); opacity: .4;
}
.card-metrics .rpe-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface3); color: var(--text-muted);
}

.card-notes {
  margin-top: 8px; font-size: 13px; line-height: 1.5;
  color: var(--text-muted); font-style: italic;
}

.card-footer {
  margin-top: 8px; display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-dim);
}
.card-cat-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface3); color: var(--text-muted);
}

/* ===== Empty State ===== */
.empty { text-align: center; padding: 80px 20px; color: var(--text-dim); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== Editor Dialog ===== */
dialog {
  border: none; border-radius: 16px;
  max-width: 520px; width: 94vw;
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  padding: 0; margin: auto; inset: 0;
  max-height: 90vh; overflow-y: auto;
}
dialog::backdrop { background: rgba(0,0,0,.65); }

.editor-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px 0;
}
.editor-header h3 {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 400; color: var(--accent);
  letter-spacing: 0.04em;
}
.close-btn {
  background: none; border: none;
  color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 4px 8px;
}

.editor-body {
  padding: 16px 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  max-height: 60vh; overflow-y: auto;
}
.editor-body label { display: flex; flex-direction: column; gap: 4px; }
.editor-body label.full { grid-column: 1 / -1; }
.editor-body span { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.editor-body input, .editor-body select, .editor-body textarea {
  padding: 9px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: var(--font-body);
  transition: border-color .2s;
}
.editor-body input:focus, .editor-body select:focus, .editor-body textarea:focus {
  outline: none; border-color: var(--accent);
}
.editor-body textarea { resize: vertical; }

.editor-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px 18px; border-top: 1px solid var(--border);
}
.spacer { flex: 1; }
.ghost-btn {
  padding: 8px 18px; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted); font-size: 14px;
  cursor: pointer; transition: all .2s;
}
.ghost-btn:hover { border-color: var(--text-muted); color: var(--text); }
.primary-btn {
  padding: 8px 22px; background: var(--accent);
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .2s;
}
.primary-btn:hover { background: var(--accent-glow); }
.danger-btn {
  padding: 8px 16px; background: none; border: 1px solid var(--red);
  border-radius: var(--radius-sm); color: var(--red); font-size: 13px;
  cursor: pointer; transition: all .2s;
}
.danger-btn:hover { background: rgba(248,113,113,.12); }

/* Smart Select */
.smart-select-wrap { display: flex; gap: 6px; align-items: center; }
.smart-select-wrap select { flex: 1; min-width: 0; }
.smart-manage-btn {
  flex-shrink: 0; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text-dim);
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.smart-manage-btn:hover { background: var(--surface3); color: var(--text); }

.smart-manager-body { padding: 12px 16px; max-height: 50vh; overflow-y: auto; }
.smart-manager-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.smart-manager-item:last-child { border-bottom: none; }
.smart-manager-name {
  flex: 1; font-size: 15px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.smart-manager-count { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.smart-manager-actions { display: flex; gap: 4px; flex-shrink: 0; }
.smart-manager-action {
  width: 32px; height: 32px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: all .15s; color: var(--text-muted);
}
.smart-manager-action:hover { background: var(--surface2); }
.smart-manager-action.danger:hover { background: rgba(248,113,113,.12); color: var(--red); border-color: var(--red); }
.smart-manager-empty { text-align: center; color: var(--text-dim); padding: 24px 0; font-size: 14px; }
.smart-input {
  margin-top: 6px; padding: 9px 12px; background: var(--surface2);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: var(--font-body); width: 100%;
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeUp .3s ease both; }
.cards .card:nth-child(1) { animation-delay: 0s; }
.cards .card:nth-child(2) { animation-delay: .03s; }
.cards .card:nth-child(3) { animation-delay: .06s; }
.cards .card:nth-child(4) { animation-delay: .09s; }
.cards .card:nth-child(5) { animation-delay: .12s; }

/* Responsive */
@media (max-width: 520px) {
  .editor-body { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .filters { padding: 6px 16px 10px; }
  .topbar h1 { font-size: 26px; }
}
@media (display-mode: standalone) {
  .topbar { padding-top: 56px; }
  .editor-header { padding-top: 56px; }
}
