:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #dfe3e8;
  --text: #1f2328;
  --muted: #6b7280;
  --blue: #1a73e8;
  --green: #0f9d58;
  --red: #d93025;
  --orange: #e8710a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

/* ---------- 通用 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.topbar a {
  color: var(--blue);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

select {
  font-size: 15px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

/* 语言切换器 */
.lang-sel {
  font-size: 13px;
  padding: 5px 8px;
}

.lang-bar {
  display: flex;
  justify-content: flex-end;
}

.lang-bar .lang-sel {
  font-size: 15px;
  padding: 8px 12px;
}

#map { width: 100%; height: 100%; }

/* ---------- record.html ---------- */

.rec-page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 16px;
  gap: 16px;
  max-width: 520px;
  margin: 0 auto;
}

.rec-head {
  text-align: center;
}

.rec-head .name {
  font-size: 22px;
  font-weight: 700;
}

.rec-head .plate {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.rec-btn-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

#recBtn {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  border: none;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  background: var(--green);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
}

#recBtn.on { background: var(--red); }
#recBtn:disabled { background: #9aa0a6; }
#recBtn:active { filter: brightness(.92); }

.status {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.status .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.status .row:first-child { border-top: none; }
.status .row .k { color: var(--muted); }
.status .row .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.notice {
  background: #fff8e1;
  border: 1px solid #f2d98c;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: #6b5300;
}

.notice b { color: #8a4b00; }

.err {
  background: #fdecea;
  border: 1px solid #f5c2bd;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  color: #8c1d13;
}

.hidden { display: none !important; }

#nosleep {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -10px;
  top: -10px;
}

/* ---------- index.html（全屏地图） ---------- */

.map-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.map-page .fill { flex: 1; min-height: 0; }

/* ---------- history.html ---------- */

.hist-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.hist-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.hist-map { flex: 1; min-width: 0; }

.hist-side {
  width: 340px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 14px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.summary .card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}

.summary .card .label {
  font-size: 12px;
  color: var(--muted);
}

.summary .card .num {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.summary .card .num-sm { font-size: 20px; }

.summary .card .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 2px;
}

.side-title {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
}

.trip {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
}

.trip:hover { background: #f2f6fd; }
.trip.active { border-color: var(--blue); background: #e8f0fe; }

.trip .t1 {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
}

.trip .t2 {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 20px 4px;
  text-align: center;
}

@media (max-width: 760px) {
  .hist-body { flex-direction: column; }
  .hist-map { height: 45vh; flex: none; }
  .hist-side { width: auto; border-left: none; border-top: 1px solid var(--line); flex: 1; }
}
