:root {
  --bg: #05070d;
  --ink: #e8eef8;
  --dim: #8ea3bf;
  --line: rgba(126, 180, 255, 0.14);
  --panel: rgba(12, 19, 31, 0.74);
  --panel-solid: #0c1320;
  --teal: #5eead4;
  --amber: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --green: #34d399;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#globe {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#globe.dragging { cursor: grabbing; }

#labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ---------------------------------------------------------------- topbar */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.92), rgba(5, 7, 13, 0));
  z-index: 20;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brandtext h1 { margin: 0; font-size: 15px; letter-spacing: 0.4px; font-weight: 650; }
.brandtext p { margin: 2px 0 0; font-size: 11px; color: var(--dim); white-space: nowrap; }

#tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(14, 22, 36, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.tab {
  border: 0;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  padding: 7px 15px;
  border-radius: 9px;
  cursor: pointer;
  transition: 0.16s;
}
.tab:hover { color: var(--ink); background: rgba(255, 255, 255, 0.04); }
.tab.active {
  color: #04231d;
  background: linear-gradient(180deg, #7ff2df, #46cbb8);
  font-weight: 650;
  box-shadow: 0 3px 14px rgba(94, 234, 212, 0.28);
}

.topright { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.clocks { display: flex; gap: 14px; }
.clk { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.clk span { font-size: 10px; color: var(--dim); letter-spacing: 0.6px; }
.clk b { font-size: 17px; font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0.5px; }

button.ghost {
  border: 1px solid var(--line);
  background: rgba(14, 22, 36, 0.7);
  color: var(--ink);
  border-radius: 10px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: 0.16s;
}
button.ghost:hover { border-color: rgba(94, 234, 212, 0.5); color: var(--teal); }
button.ghost.tiny { font-size: 11px; padding: 6px 10px; color: var(--teal); }
button.ghost.small { padding: 5px 10px; font-size: 11px; }

/* ---------------------------------------------------------------- panels */
.panel {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  z-index: 12;
}

#citypanel {
  left: 18px;
  top: 78px;
  width: 232px;
  max-height: calc(100vh - 210px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#sidepanel {
  right: 18px;
  top: 78px;
  width: 356px;
  max-height: calc(100vh - 176px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
}
#sidepanel::-webkit-scrollbar, .citylist::-webkit-scrollbar { width: 6px; }
#sidepanel::-webkit-scrollbar-thumb, .citylist::-webkit-scrollbar-thumb {
  background: rgba(126, 180, 255, 0.2);
  border-radius: 3px;
}

.phead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--line);
}
.phead h2 { flex: 0 0 auto; white-space: nowrap; margin: 0; font-size: 12px; letter-spacing: 0.6px; color: var(--dim); font-weight: 600; }

.chips { display: flex; gap: 4px; }
.chip {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--dim);
  font: inherit;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.chip.active { color: var(--teal); border-color: rgba(94, 234, 212, 0.4); background: rgba(94, 234, 212, 0.1); }

.citylist { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.citylist li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.14s;
  border: 1px solid transparent;
}
.citylist li:hover { background: rgba(255, 255, 255, 0.045); }
.citylist li.sel { background: rgba(94, 234, 212, 0.1); border-color: rgba(94, 234, 212, 0.35); }
.citylist .nm { font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citylist .tm { font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 600; letter-spacing: 0.2px; white-space: nowrap; }
.citylist .off { display: flex; flex-direction: column; align-items: flex-end; min-width: 52px; line-height: 1.2; }
.citylist .off .ab { font-size: 9.5px; color: #9fb3cc; font-weight: 600; letter-spacing: 0.3px; }
.citylist .off .of { font-size: 8.5px; color: var(--dim); font-style: normal; font-variant-numeric: tabular-nums; }
.citylist .ico { font-size: 11px; width: 13px; text-align: center; }
.citylist .dst {
  font-size: 8.5px;
  color: #0b1b12;
  background: var(--amber);
  border-radius: 4px;
  padding: 1px 3px;
  font-weight: 700;
}

/* ---------------------------------------------------------------- cards */
.card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.022);
  margin-bottom: 8px;
}
.card:last-child { margin-bottom: 0; }
.card h3 { margin: 0 0 8px; font-size: 12px; color: var(--dim); letter-spacing: 0.5px; font-weight: 600; }
.card .big { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }

.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 4px 0; align-items: baseline; }
.kv span { color: var(--dim); white-space: nowrap; flex: 0 0 auto; }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 0; word-break: break-word; }
.kv b.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; }

.tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
}
.tag.na { color: var(--teal); border-color: rgba(94, 234, 212, 0.4); }
.tag.warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.4); }
.tag.bad { color: var(--red); border-color: rgba(248, 113, 113, 0.4); }

.note { font-size: 11px; color: var(--dim); line-height: 1.6; }
.note .ctry { color: #a9c4e4; }
.hint { font-size: 11.5px; color: var(--dim); line-height: 1.65; }

/* ---------------------------------------------------------------- errors */
#errbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-100%);
  background: linear-gradient(180deg, #7f1d1d, #450a0a);
  color: #fee2e2;
  font-size: 12px;
  padding: 9px 16px;
  z-index: 90;
  transition: transform 0.25s;
  display: flex;
  gap: 10px;
}
#errbar.show { transform: translateY(0); }
#errbar b { color: #fca5a5; }

/* ---------------------------------------------------------------- loader */
#loader {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 45%, #0a1420, #03050a 70%);
  transition: opacity 0.5s;
}
#loader.done { opacity: 0; pointer-events: none; }
.loadcard { text-align: center; width: 260px; }
.loadcard p { font-size: 13px; color: var(--ink); margin: 16px 0 10px; }
.loadcard small { display: block; margin-top: 12px; font-size: 10.5px; color: var(--dim); }
.spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(94, 234, 212, 0.16);
  border-top-color: var(--teal);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2dd4bf, #5eead4); transition: width 0.3s; }

/* ---------------------------------------------------------------- fatal */
#fatal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #05070d;
}
.fatalcard { text-align: center; max-width: 380px; padding: 24px; }
.fatalcard h2 { font-size: 18px; margin: 0 0 8px; }
.fatalcard p { color: var(--dim); font-size: 13px; line-height: 1.7; }
.fatalcard small { color: #52627a; font-size: 11px; }

/* ---------------------------------------------------------------- timebar */
#timebar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(980px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  z-index: 15;
  flex-wrap: wrap;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; }
.tb-sliders { flex: 1; display: flex; gap: 16px; min-width: 280px; }
.tb-sliders label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
}
.tb-sliders output { font-size: 11px; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 42px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: rgba(126, 180, 255, 0.22);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.18);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
  cursor: pointer;
}

.iconbtn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
}
.iconbtn:hover { border-color: var(--teal); color: var(--teal); }
.iconbtn.on { background: rgba(94, 234, 212, 0.16); color: var(--teal); border-color: rgba(94, 234, 212, 0.5); }

.sw { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--dim); cursor: pointer; }
.sw input { accent-color: #2dd4bf; width: 13px; height: 13px; }
.simflag {
  font-size: 10px;
  color: #1a1206;
  background: var(--amber);
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
}

/* ---------------------------------------------------------------- labels */
.citylabel {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  font-size: 10.5px;
  color: #dbe9ff;
  background: rgba(8, 14, 24, 0.6);
  border: 1px solid rgba(126, 180, 255, 0.16);
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.2s, background 0.15s;
  backdrop-filter: blur(6px);
}
.citylabel:hover { background: rgba(94, 234, 212, 0.18); border-color: rgba(94, 234, 212, 0.5); }
.citylabel .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 6px var(--teal);
}
.citylabel .t { font-variant-numeric: tabular-nums; color: #9fd8ff; font-size: 10px; }
.citylabel.sel { background: rgba(94, 234, 212, 0.22); border-color: var(--teal); color: #eafffb; }

/* ---------------------------------------------------------------- quiz / lesson */
.lvlrow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-bottom: 10px; }
.lvl {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 6px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.025);
  transition: 0.15s;
}
.lvl:hover { border-color: rgba(94, 234, 212, 0.4); }
.lvl.on { border-color: var(--teal); background: rgba(94, 234, 212, 0.1); }
.lvl b { display: block; font-size: 12.5px; margin-bottom: 3px; }
.lvl small { font-size: 10px; color: var(--dim); }
.lvl.basic b { color: var(--teal); }
.lvl.advanced b { color: var(--amber); }
.lvl.expert b { color: var(--red); }

.progressline { height: 3px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; overflow: hidden; margin: 8px 0 12px; }
.progressline i { display: block; height: 100%; background: linear-gradient(90deg, #2dd4bf, #5eead4); }

.qstem { font-size: 13.5px; line-height: 1.75; margin: 4px 0 12px; }
.qstem code, .opt code, .explain code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  background: rgba(96, 165, 250, 0.13);
  border: 1px solid rgba(96, 165, 250, 0.18);
  border-radius: 5px;
  padding: 1px 5px;
}
pre.code {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #060c15;
  border: 1px solid rgba(96, 165, 250, 0.16);
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.6;
}
pre.code code { background: none; border: 0; padding: 0; color: #cfe6ff; }

.opts { display: flex; flex-direction: column; gap: 7px; }
.opt {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  cursor: pointer;
  transition: 0.14s;
}
.opt:hover { border-color: rgba(94, 234, 212, 0.45); background: rgba(94, 234, 212, 0.05); }
.opt .key {
  flex: 0 0 18px;
  height: 18px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  display: grid;
  place-items: center;
  font-size: 10px;
  color: var(--dim);
}
.opt.on { border-color: var(--teal); background: rgba(94, 234, 212, 0.1); }
.opt.on .key { background: var(--teal); color: #04231d; }
.opt.correct { border-color: var(--green); background: rgba(52, 211, 153, 0.12); }
.opt.correct .key { background: var(--green); color: #04231d; }
.opt.wrong { border-color: var(--red); background: rgba(248, 113, 113, 0.1); }
.opt.wrong .key { background: var(--red); color: #2a0808; }
.opt[disabled] { cursor: default; }

.explain {
  margin-top: 10px;
  border-left: 2px solid var(--teal);
  padding: 2px 0 2px 11px;
  font-size: 12px;
  line-height: 1.75;
  color: #c3d3e8;
}
.explain b { color: var(--teal); }
.explain .src { display: block; margin-top: 6px; font-size: 10.5px; color: var(--dim); }

.verdict { font-size: 13px; font-weight: 650; margin-bottom: 6px; }
.verdict.ok { color: var(--green); }
.verdict.no { color: var(--red); }

.btnrow { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  border: 0;
  border-radius: 9px;
  padding: 8px 13px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  background: linear-gradient(180deg, #7ff2df, #46cbb8);
  color: #04231d;
  font-weight: 650;
}
.btn:hover { filter: brightness(1.06); }
.btn.alt { background: rgba(255, 255, 255, 0.06); color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.alt:hover { border-color: var(--teal); color: var(--teal); }
.btn:disabled { opacity: 0.45; cursor: default; }

.steps { display: flex; gap: 4px; margin: 8px 0 0; }
.steps i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); }
.steps i.done { background: rgba(94, 234, 212, 0.55); }
.steps i.cur { background: var(--teal); }

.lessonbody { font-size: 12.5px; line-height: 1.8; color: #c9d7ea; }
.lessonbody p { margin: 0 0 9px; }
.lessonbody em { color: var(--teal); font-style: normal; }
.lessonbody .callout {
  background: rgba(94, 234, 212, 0.07);
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: #a9e8dd;
}

/* ---------------------------------------------------------------- tools */
.tooltabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.tooltabs button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--dim);
  font: inherit;
  font-size: 10.5px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.tooltabs button.on { color: var(--teal); border-color: rgba(94, 234, 212, 0.45); background: rgba(94, 234, 212, 0.09); }

input.txt, select.txt {
  width: 100%;
  background: #060c15;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  font-size: 12px;
  outline: none;
}
input.txt:focus, select.txt:focus { border-color: rgba(94, 234, 212, 0.6); }
.field { margin-bottom: 8px; }
.field label { display: block; font-size: 10.5px; color: var(--dim); margin-bottom: 4px; }
.inline2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }

.planner { font-size: 10px; }
.prow { display: flex; align-items: center; gap: 4px; }
.prow .pname { width: 52px; text-align: right; color: var(--dim); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcells { display: flex; flex: 1; gap: 1px; }
.pcell { flex: 1; height: 14px; border-radius: 2px; background: rgba(255, 255, 255, 0.05); }
.pcell.work { background: rgba(52, 211, 153, 0.72); }
.pcell.edge { background: rgba(251, 191, 36, 0.55); }
.pcell.best { outline: 1px solid #eafffb; }
.paxis { display: flex; gap: 1px; margin-left: 56px; margin-top: 3px; }
.paxis span { flex: 1; font-size: 8px; color: #5b6b82; text-align: center; }

/* ---------------------------------------------------------------- modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(2, 5, 10, 0.66);
  backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modalcard {
  position: relative;
  width: min(520px, calc(100vw - 40px));
  max-height: 82vh;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modalx {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.modalx:hover { color: var(--ink); }
.modalcard h2 { margin: 0 0 14px; font-size: 15px; }

.srclist { display: flex; flex-direction: column; gap: 8px; }
.srcrow { border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; }
.srcrow .t { font-size: 12.5px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.srcrow .d { font-size: 11px; color: var(--dim); margin-top: 4px; line-height: 1.6; }

/* ---------------------------------------------------------------- misc */
[hidden] { display: none !important; }

@media (max-width: 1180px) {
  #citypanel { display: none; }
}
@media (max-width: 860px) {
  #topbar { height: 54px; gap: 8px; padding: 0 10px; }
  .brandtext h1 { font-size: 12.5px; white-space: nowrap; }
  .brandtext p { display: none; }
  .clocks { display: none; }
  #tabs { flex: 0 0 auto; padding: 3px; gap: 2px; }
  .tab { padding: 6px 8px; font-size: 11.5px; white-space: nowrap; }
  #btn-source { font-size: 9.5px; padding: 5px 6px; white-space: nowrap; }
  #sidepanel {
    top: auto;
    bottom: calc(var(--tbh, 90px) + 12px + env(safe-area-inset-bottom));
    right: 8px;
    left: 8px;
    width: auto;
    max-height: 38vh;
    padding: 10px;
  }
  #timebar {
    gap: 6px;
    padding: 8px 10px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }
  .tb-left { order: 1; }
  .tb-right { order: 2; margin-left: auto; gap: 7px; }
  .tb-sliders { order: 3; flex: 1 1 100%; min-width: 0; gap: 10px; }
  .sw { font-size: 10px; }
  .lvlrow { gap: 5px; }
  .lvl b { font-size: 11.5px; }
  .lvl small { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------- language */
.langswitch {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(14, 22, 36, 0.7);
}
.langswitch button {
  border: 0;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 10.5px;
  padding: 4px 7px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.langswitch button:hover { color: var(--ink); }
.langswitch button.on { background: rgba(94, 234, 212, 0.16); color: var(--teal); font-weight: 650; }

em.en {
  font-style: normal;
  font-size: 0.88em;
  opacity: 0.62;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.citylabel .nm em.en { font-size: 0.86em; }

/* ---------------------------------------------------------------- readout */
.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  font-size: 10.5px;
  color: var(--dim);
  background: rgba(94, 234, 212, 0.06);
  border: 1px solid rgba(94, 234, 212, 0.16);
  border-radius: 9px;
  padding: 6px 9px;
  margin-bottom: 10px;
  line-height: 1.5;
}
.readout b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.readout .zone { color: var(--teal); }
.readout.empty { color: #6d8099; background: rgba(255, 255, 255, 0.02); border-color: var(--line); }

/* ---------------------------------------------------------------- align */
.alignrow {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 5px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(126, 180, 255, 0.12);
  font-size: 11.5px;
}
.alignrow:last-child { border-bottom: 0; }
.alignrow select { max-width: 152px; padding: 4px 3px; font-size: 10px; }
.alignrow .who { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alignrow .when { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; font-size: 11px; }
.alignrow .when em { font-style: normal; font-size: 9.5px; color: #9fb3cc; margin-left: 2px; letter-spacing: 0.3px; }
.alignrow .wk { color: var(--dim); font-size: 10px; text-align: right; white-space: nowrap; }
.alignrow .st { font-size: 9.5px; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
.st.work { background: rgba(52, 211, 153, 0.16); color: #6ee7b7; }
.st.awake { background: rgba(251, 191, 36, 0.14); color: var(--amber); }
.st.rest { background: rgba(148, 163, 184, 0.14); color: #94a3b8; }
.alignhead { font-size: 10px; color: var(--dim); display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding-bottom: 4px; }
.warnline { font-size: 10.5px; color: var(--amber); margin-top: 8px; }

@media (max-width: 860px) {
  .langswitch button { padding: 4px 5px; font-size: 10px; }
  .topright { gap: 6px; }
}

/* bilingual: wider city panel, compact secondary lines */
html[data-lang="both"] #citypanel { width: 300px; }
html[data-lang="both"] .citylist .nm em.en { font-size: 0.78em; }
html[data-lang="both"] .citylist .off { min-width: 46px; }
html[data-lang="both"] .chips .chip { font-size: 10px; padding: 3px 7px; }

/* ---------------------------------------------------------------- tzdb switch */
.tzdb-sel {
  color-scheme: dark;
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 18px 6px 8px;
  max-width: 132px;
  background-image: linear-gradient(45deg, transparent 50%, #5eead4 50%),
    linear-gradient(135deg, #5eead4 50%, transparent 50%);
  background-position: calc(100% - 10px) 55%, calc(100% - 6px) 55%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  font-size: 10.5px;
  color: var(--teal);
  background-color: rgba(14, 22, 36, 0.7);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.tzdb-sel:hover { border-color: rgba(94, 234, 212, 0.5); }
.tzdb-sel option { background: #0c1320; color: var(--ink); }
.tzdb-sel:disabled { opacity: 0.55; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translate(-50%, 12px);
  background: rgba(12, 19, 31, 0.94);
  border: 1px solid rgba(94, 234, 212, 0.35);
  color: var(--ink);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
  max-width: 80vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }

@media (max-width: 860px) {
  .tzdb-sel { max-width: 74px; font-size: 9.5px; padding: 5px 16px 5px 6px; }
}

/* ---------------------------------------------------------------- anchors */
.citylabel.anchorlabel {
  background: rgba(46, 12, 38, 0.78);
  border-color: rgba(255, 107, 214, 0.6);
  color: #ffe2f7;
  font-weight: 600;
}
.citylabel.anchorlabel .dot {
  background: #ff6bd6;
  box-shadow: 0 0 8px #ff6bd6;
}
.citylabel.anchorlabel:hover {
  background: rgba(255, 107, 214, 0.26);
  border-color: #ff6bd6;
}

.citylabel.anchorlabel { padding: 3px 9px 3px 6px; font-size: 11px; }
@keyframes anchorPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 107, 214, 0); }
  50% { box-shadow: 0 0 22px rgba(255, 107, 214, 0.95); }
}
.citylabel.anchorlabel.pulse { animation: anchorPulse 0.9s ease-in-out 3; }
#anchors-card h3 { color: #ff9fe6; }

/* screen-space anchor pin */
.anchorpin {
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  pointer-events: none;
  display: none;
  z-index: 3;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.6));
}
.anchorpin i {
  display: block;
  width: 18px;
  height: 18px;
  background: #ff5ccf;
  border: 2px solid #ffe6f9;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 0 14px rgba(255, 92, 207, 0.9);
}
.anchorpin.pulse i { animation: anchorPulse 0.75s ease-in-out 4; }
@keyframes anchorPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 92, 207, 0.75); transform: rotate(-45deg) scale(1); }
  50% { box-shadow: 0 0 26px rgba(255, 92, 207, 1); transform: rotate(-45deg) scale(1.35); }
}
.citylabel.anchorlabel.pulse { animation: anchorLabelPulse 0.75s ease-in-out 4; }
@keyframes anchorLabelPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 92, 207, 0); }
  50% { box-shadow: 0 0 18px rgba(255, 92, 207, 0.85); }
}

.btn.mini { padding: 5px 9px; font-size: 11px; border-radius: 8px; }

.basepick {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 92, 207, 0.55);
  background: transparent;
  color: #ff9fe6;
  font-size: 8px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.basepick:hover { border-color: #ff5ccf; background: rgba(255, 92, 207, 0.18); }
.basepick.on { background: #ff5ccf; border-color: #ff5ccf; color: #fff; }
.alignrow.is-base { background: rgba(255, 92, 207, 0.07); border-radius: 8px; }
.alignrow { grid-template-columns: auto auto 1fr auto auto; gap: 5px; }
.alignhead { grid-template-columns: 16px auto 1fr auto; }

.searchrow { padding: 8px 10px 4px; }
.searchrow .txt { font-size: 11px; padding: 5px 8px; }
.citylist .pinbtn {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #7286a0;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.65;
  transition: color 0.15s, opacity 0.15s, transform 0.15s;
}
.citylist .pinbtn svg { width: 12px; height: 12px; display: block; }
.citylist li:hover .pinbtn { opacity: 1; }
.citylist .pinbtn:hover { color: #ff5ccf; transform: translateY(-1px); }

/* ---------------------------------------------------------------- facts */
.facthead { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.facthead h3 { margin: 0 0 6px; font-size: 13px; color: var(--ink); letter-spacing: 0; }
.factbody { font-size: 12px; line-height: 1.75; color: #c3d3e8; margin: 0 0 8px; }
.factfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.factsrc { font-size: 9.5px; color: #5f7089; }
.factbar { display: flex; align-items: center; justify-content: space-between; font-size: 10.5px; color: var(--dim); margin: 0 0 8px; }
.factcard { cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.factcard:hover { border-color: rgba(94, 234, 212, 0.35); }
.factcard.read { border-color: rgba(94, 234, 212, 0.18); }
.factcard.read .facthead h3 { color: #9fb3cc; }
.factcard.flash { border-color: var(--teal); background: rgba(94, 234, 212, 0.08); }

@media (max-width: 860px) {
  #tabs { overflow-x: auto; max-width: 46vw; scrollbar-width: none; }
  #tabs::-webkit-scrollbar { display: none; }
  .brandtext { display: none; }
}

.pgcode {
  width: 100%;
  height: 220px;
  background: #060c15;
  color: #cfe6ff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: 12px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
  resize: vertical;
  outline: none;
  margin-bottom: 8px;
}
.pgcode:focus { border-color: rgba(94, 234, 212, 0.5); }
.pgout {
  background: #060c15;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: 11.5px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
  color: #bfe3ff;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 8px 0 0;
}

.citylist li.kbd { background: rgba(94, 234, 212, 0.12); border-color: rgba(94, 234, 212, 0.4); }

.factcard.kbd { border-color: var(--teal); background: rgba(94, 234, 212, 0.10); }
.factkeys { font-size: 10px; color: #6d8099; }

/* ---------------------------------------------------------------- align timeline */
.alignaxis { margin: 0 0 4px; }
.alignaxis input[type="range"] { width: 100%; }
.alignstrip {
  display: grid;
  grid-template-columns: repeat(96, 1fr);
  gap: 1px;
  height: 12px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 6px;
}
.alignstrip i { display: block; height: 100%; background: rgba(148, 163, 184, 0.16); }
.alignstrip i.w { background: rgba(52, 211, 153, 0.88); }
.alignstrip i.a { background: rgba(251, 191, 36, 0.7); }
.alignstrip i.r { background: rgba(148, 163, 184, 0.24); }
.alignstrip i.gap {
  background: repeating-linear-gradient(45deg, rgba(148, 163, 184, 0.28) 0 2px, transparent 2px 4px);
}
.alignstrip i.cur { outline: 1px solid #eafffb; outline-offset: -1px; }
.alignrecs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
  font-size: 10.5px;
}
.reclabel { color: var(--dim); font-size: 10px; }
.recchip {
  border: 1px solid rgba(94, 234, 212, 0.35);
  background: rgba(94, 234, 212, 0.08);
  color: var(--teal);
  border-radius: 999px;
  padding: 3px 8px;
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
}
.recchip:hover { background: rgba(94, 234, 212, 0.18); }

/* ================================================================ mobile */
#btn-city, #btn-layers, #grabber { display: none; }

@media (max-width: 1180px) {
  #citypanel { display: none; }
  html #citypanel.open {
    display: flex;
    background: #0a101b;
    backdrop-filter: none;
    left: 8px;
    right: 8px;
    top: calc(var(--tbtop, 96px) + 6px);
    bottom: calc(var(--tbh, 90px) + 84px);
    width: auto;
    max-height: 62vh;
    z-index: 30;
  }
  #btn-city { display: inline-flex; align-items: center; }
}

@media (max-width: 860px) {
  #grabber {
    display: block;
    position: sticky;
    top: -7px;
    width: 40px;
    height: 4px;
    margin: -7px auto 10px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.24);
    z-index: 3;
  }
  #sidepanel { padding: 12px 12px 16px; max-height: 38vh; }
  #sidepanel.wide { max-height: 58vh; }
  #sidepanel.expanded { max-height: 74vh; }
  #sidepanel { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

  .tab { min-height: 38px; }
  .citylist li { min-height: 44px; }
  .tooltabs button { min-height: 34px; }
  .btn, .btn.alt, .ghost.small { min-height: 38px; }
}

/* two-row topbar on phones */
@media (max-width: 560px) {
  #topbar {
    height: auto;
    min-height: 0;
    padding: 6px 8px 8px;
    flex-wrap: wrap;
    row-gap: 6px;
    align-items: center;
  }
  .brand { display: none; }
  #tabs {
    order: 1;
    flex: 1 1 100%;
    max-width: none;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 8px 12px; font-size: 12px; }
  .topright {
    order: 2;
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: wrap;
  }
  .topright .clocks { display: none; }
  .langswitch button { min-height: 32px; min-width: 34px; padding: 4px 6px; }
  .ghost.tiny { min-height: 32px; }
  #btn-layers { display: inline-flex; align-items: center; }
  #timebar {
    left: 8px;
    right: 8px;
    width: auto;
    transform: none;
    padding: 6px 10px;
    gap: 4px;
    z-index: 45;
  }
  #timebar .tb-sliders { order: 3; flex: 1 1 100%; gap: 8px; }
  #timebar .tb-right { display: none; }
  #timebar.layers-open .tb-right {
    display: flex;
    background: rgba(10, 16, 27, 0.98);
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--tbh, 90px) + 12px);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 6px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #0a101b;
    backdrop-filter: none;
    box-shadow: var(--shadow);
    z-index: 40;
  }
  #timebar.layers-open .tb-right .sw {
    height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
  }
  #timebar.layers-open .tb-right .sw input { width: 18px; height: 18px; }
}

/* landscape phones: side sheet instead of a full-width bottom bar */
@media (orientation: landscape) and (max-height: 520px) {
  #sidepanel {
    top: 58px;
    bottom: 8px;
    left: auto;
    right: 8px;
    width: 372px;
    max-height: none;
  }
  #grabber { display: none; }
  #timebar {
    left: 8px;
    right: 388px;
    width: auto;
    transform: none;
    padding: 5px 10px;
  }
  #timebar .tb-sliders { order: 3; flex: 1 1 100%; }
  #citypanel.open { top: 58px; bottom: 80px; max-height: none; right: 388px; }
}
