:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6d7686;
  --line: #e6eaf1;
  --accent: #2f6fed;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --free: #2fa36b;
  --normal: #e0a23c;
  --busy: #e2734b;
  --crowded: #d64545;
}

html[data-theme="dark"] {
  --bg: #0e1116;
  --card: #171b22;
  --text: #e9edf3;
  --muted: #97a1b2;
  --line: #242b34;
  --accent: #5b8cff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 12px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 4px 2px; }
.top h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
.tools { display: flex; gap: 8px; align-items: center; }
.inline { margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px 16px;
  box-shadow: var(--shadow);
}

h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
h3 { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.note { font-size: 12px; margin: 10px 0 0; padding: 8px 10px; border-radius: 10px;
        border: 1px dashed var(--busy); }
.hidden { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
.icon-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 13px;
}
.icon-btn:active { transform: scale(.97); }

/* --- 当前状态 --- */
.hero-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.big { font-size: 52px; font-weight: 700; line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.unit { font-size: 14px; color: var(--muted); margin-left: 4px; }
.badge {
  display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--line); color: var(--text);
}
.badge.free { background: var(--free); color: #fff; }
.badge.normal { background: var(--normal); color: #fff; }
.badge.busy { background: var(--busy); color: #fff; }
.badge.crowded { background: var(--crowded); color: #fff; }
.badge.unknown { background: var(--line); color: var(--muted); }

.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 12px 0 14px; }
.bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .4s ease, background .4s ease; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 6px; }
.metrics > div { display: flex; flex-direction: column; gap: 2px; }
.metrics b { font-size: 17px; font-variant-numeric: tabular-nums; }

/* --- 推荐 --- */
.rec .verdict { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.slots { display: flex; flex-direction: column; gap: 8px; }
.slot { border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
.slot .head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.slot .time { font-weight: 700; font-size: 15px; }
.slot .exp { font-size: 13px; color: var(--accent); }
.slot .why { font-size: 12px; color: var(--muted); margin-top: 3px; }
.week { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.day { flex: 0 0 auto; min-width: 108px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.day .d { font-size: 12px; color: var(--muted); }
.day .t { font-weight: 600; font-size: 14px; }
.day .e { font-size: 12px; color: var(--accent); }
.day.na .t { color: var(--muted); font-weight: 500; }

/* --- 图表 --- */
.chart { width: 100%; height: 220px; }
.chart.tall { height: 260px; }
.chart.heat { height: 300px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.tabs button {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 13px;
}
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- 快照 --- */
details summary { cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }
.cams { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 12px 0 4px; }
.cams img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: var(--line); cursor: zoom-in; display: block; }
.cams .cam-fallback { font-size: 12px; color: var(--muted); margin: 0; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .86); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 12px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox.hidden { display: none; }

/* --- 登录 --- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0; font-size: 18px; }
.login input {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 16px;
}
.login button {
  padding: 12px; border: 0; border-radius: 12px; background: var(--accent);
  color: #fff; font-size: 15px; font-weight: 600;
}
.login .error { margin: 0; min-height: 18px; font-size: 13px; color: var(--crowded); }

.foot { text-align: center; padding: 6px 0 0; }

@media (max-width: 360px) {
  .big { font-size: 44px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
