/* ═══════════ Mobile-First — 真手机适配 ═══════════ */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2d3140;
  --text: #e8eaed;
  --text-muted: #8b919a;
  --accent: #4fc3f7;
  --accent2: #81c784;
  --danger: #e57373;
  --gold: #ffd54f;
  --radius: 12px;
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ═══════════ Top Bar ═══════════ */
.topbar {
  background: var(--surface);
  padding: 14px 16px;
  text-align: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ═══════════ Main Content — Scrollable ═══════════ */
main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(70px + var(--safe-bottom));
}

/* ═══════════ Cards ═══════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 17px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card .desc { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }

/* ═══════════ Bottom Nav ═══════════ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: var(--safe-bottom);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-item .icon { font-size: 22px; }
.nav-item.active { color: var(--accent); font-weight: 600; }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ═══════════ Panels ═══════════ */
.panel { display: none; }
.panel.active { display: block; }

/* ═══════════ Controls ═══════════ */
.ctrl-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ctrl-row label { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.ctrl-row input[type="number"],
.ctrl-row input[type="text"] {
  flex: 1; min-width: 50px;
  padding: 10px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
}
.ctrl-row input[type="text"] { min-width: 70px; }

.btn {
  display: block;
  width: 100%;
  padding: 13px 20px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity .15s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 8px;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: var(--border); color: var(--text); }

.file-label {
  display: block;
  width: 100%;
  padding: 13px 20px;
  background: var(--border);
  color: var(--text);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  margin-bottom: 8px;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ═══════════ Chart / Image Box ═══════════ */
.chart-box, .img-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 12px;
}
.chart-box canvas { width: 100%; height: 160px; display: block; }
.img-box { text-align: center; }
.img-box img { max-width: 100%; max-height: 280px; border-radius: 8px; }

/* ═══════════ Info Table ═══════════ */
.info-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
  background: var(--bg); border-radius: 8px; overflow: hidden;
}
.info-table th, .info-table td { padding: 8px 10px; text-align: left; }
.info-table th { color: var(--text-muted); font-size: 12px; background: var(--surface); }
.info-table td { border-top: 1px solid var(--border); }

.tag {
  display: inline-block; font-size: 10px; padding: 2px 8px;
  border-radius: 10px; background: var(--border); color: var(--text-muted);
  vertical-align: middle; margin-left: 4px;
}
.tag.weather-on {
  background: rgba(129,199,132,0.2); color: var(--accent2);
}

.btn-sm {
  width: auto; display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-sm:active { opacity: 0.7; }
.btn-sm.mode-on {
  background: var(--accent); color: #000; border-color: var(--accent);
  font-weight: 700;
}
pre.code {
  background: var(--bg); padding: 10px; border-radius: 8px;
  font-size: 13px; overflow-x: auto; white-space: pre-wrap;
  margin: 8px 0; border: 1px solid var(--border);
}

/* ═══════════ Capture Zone — 主要占比 ═══════════ */
.capture-zone {
  position: relative;
  min-height: 55vh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.capture-zone video,
.capture-zone img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.overlay-top {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(8px);
  padding: 6px 12px; border-radius: 20px; z-index: 3;
  color: #fff; font-size: 14px;
}
.mode-switch {
  padding: 8px 14px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15); color: #fff; font-size: 14px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  min-height: 40px; min-width: 70px;
  -webkit-tap-highlight-color: transparent;
}
.mode-switch:active { background: rgba(255,255,255,0.25); }
.mode-switch.active { background: var(--accent); color: #000; border-color: var(--accent); }
.overlay-input {
  width: 36px; padding: 3px 4px; background: rgba(255,255,255,0.15);
  border: none; border-radius: 6px; color: #fff; font-size: 16px;
  text-align: center;
}
.overlay-hint {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  text-align: center; color: rgba(255,255,255,0.5);
  pointer-events: none; z-index: 1;
}
.overlay-result {
  position: absolute; bottom: 12px; left: 12px; right: 12px;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(10px);
  padding: 10px 14px; border-radius: 10px; z-index: 3;
  font-size: 14px; max-height: 40%; overflow-y: auto;
}
.overlay-result .found { color: #81c784; font-weight: 600; }
.overlay-result .not-found { color: #e57373; }

/* Bottom capture bar */
.capture-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  background: #000;
  gap: 20px;
  flex-shrink: 0;
}
.cap-btn {
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.cap-btn:active { transform: scale(0.92); }
.cap-btn.secondary {
  width: 46px; height: 46px;
  background: rgba(255,255,255,0.1);
  font-size: 20px; color: #fff;
}
.cap-btn.capture {
  width: 74px; height: 74px;
  background: none;
  border: 4px solid #fff;
}
.cap-inner {
  width: 58px; height: 58px;
  background: #fff;
  border-radius: 50%;
  display: block;
}
.cap-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ═══════════ Status Text ═══════════ */
.status { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.success { color: var(--accent2); font-weight: 600; }
.error { color: var(--danger); }
.warn { color: var(--gold); font-size: 11px; }

/* ═══════════ Focus ═══════════ */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.loading { opacity: 0.4; pointer-events: none; }

/* ═══════════ 视障模式 ═══════════ */
#pnl-a11y { background: #000; min-height: 100%; }
#pnl-a11y #a11y-btn.recording {
  animation: a11y-pulse 1.5s ease-in-out infinite;
}
@keyframes a11y-pulse {
  0%, 100% { box-shadow: 0 0 40px rgba(229,115,115,0.25); }
  50% { box-shadow: 0 0 70px rgba(229,115,115,0.5); }
}
