:root {
  --ink: #2c2a26;
  --muted: #7a746a;
  --line: #e3ddd2;
  --paper: #faf7f1;
  --accent: #a0392b;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- topbar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(120deg, #4a3423, #6b4a2f);
  color: #f5ead8;
  box-shadow: 0 1px 6px rgba(0,0,0,.25);
  z-index: 1000;
}
#topbar h1 { margin: 0; font-size: 19px; letter-spacing: 2px; font-weight: 700; }
#topbar p { margin: 3px 0 0; font-size: 12px; opacity: .82; letter-spacing: .5px; }
.badge {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  white-space: nowrap;
}
.lang-btn {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
  color: #6b4a2f; background: #f5ead8; border: 1px solid rgba(255,255,255,.35);
  white-space: nowrap;
}
.lang-btn:hover { background: #fff7e8; }

/* ---------- main ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#sidebar {
  width: 322px; flex: 0 0 322px; overflow-y: auto;
  background: var(--paper); border-right: 1px solid var(--line);
  padding: 12px; z-index: 500;
}
#map { flex: 1; min-width: 0; background: #dfe7ea; }

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(60,40,10,.05);
}
.panel h2 {
  margin: 0 0 8px; font-size: 13px; color: var(--accent);
  letter-spacing: 1.5px; border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.btnrow { display: flex; gap: 6px; margin-bottom: 8px; }
button {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid #c9c1b2; background: #fff; color: var(--ink); cursor: pointer;
}
button:hover { background: #f3ede2; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #8c2f22; }
button.on { background: #7d9a4f; border-color: #7d9a4f; color: #fff; }

.row { margin: 6px 0; }
.lbl { font-size: 13px; color: var(--muted); }
.lbl select {
  font: inherit; margin-left: 6px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid #c9c1b2; background: #fff;
}

input[type="range"] { width: 100%; margin: 4px 0 8px; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.checks label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

.ds-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 13px; padding: 6px 2px; border-bottom: 1px dashed var(--line);
}
.ds-row:last-child { border-bottom: none; }
.ds-row label { display: flex; align-items: center; gap: 3px; cursor: pointer; margin-left: 2px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: 0 0 11px; }
.dim { color: var(--muted); font-size: 12px; }

#catFilter { display: flex; flex-direction: column; gap: 2px; }
#catFilter label {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer;
  padding: 3px 0; color: #444; min-width: 0;
}
#catFilter label input { flex: 0 0 auto; }
.cat-count {
  color: var(--muted); font-size: 11px; margin-left: auto;
  flex: 0 0 auto; padding-left: 6px;
}

#basemapSel { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
#basemapSel label { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 3px 0; }

.notes { margin: 0; padding-left: 18px; font-size: 12px; color: #5c564c; line-height: 1.7; }

/* ---------- infobar ---------- */
#infobar {
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap;
  padding: 7px 14px; background: #2f2b26; color: #f0e8da;
  font-size: 12.5px; z-index: 1000;
  box-shadow: 0 -1px 6px rgba(0,0,0,.25);
}
#infobar .item { white-space: nowrap; }
#infobar .item.grow { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#infobar b { color: #f2c879; }
#infoChips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; white-space: nowrap;
}
.chip .chip-date { color: #e6d9bd; }
.chip .chip-mile { color: #b9ad97; }
.chip .chip-cur { color: #f0e8da; }
.chip .chip-next { color: #b9ad97; }
.chip b { color: #f2c879; }
.mini { width: 140px; height: 8px; background: rgba(255,255,255,.18); border-radius: 4px; overflow: hidden; }
.mini #miniBar { height: 100%; width: 0; background: #e0a75c; }

/* ---------- popup ---------- */
.pop { font-size: 12.5px; line-height: 1.55; max-width: 280px; }
.pop-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.pop-sub { color: #7a746a; font-size: 12px; margin: 2px 0 6px; }
.pop table { width: 100%; border-collapse: collapse; }
.pop th {
  text-align: left; vertical-align: top; color: var(--muted); font-weight: 500;
  padding: 3px 8px 3px 0; white-space: nowrap; width: 64px;
}
.pop td { padding: 3px 0; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  #main { flex-direction: column; }
  #sidebar { width: 100%; flex: 0 0 auto; max-height: 42vh; }
  #map { min-height: 50vh; }
  #topbar p { display: none; }
  .badge { display: none; }
  #infobar { flex-wrap: wrap; gap: 6px 14px; }
  .mini { display: none; }
}
