/* HAM SPOT —— 墨水屏主题
 *
 * 设计约束（不是纯粹换色，是按电子墨水设备的物理特性来的）：
 *   1. 纯纸底 + 纯墨字，靠字重、线宽、边框、反白区分层级，不用发光和渐变
 *   2. 全场零阴影、零模糊（e-ink 刷新时模糊和阴影会拖影、残影）
 *   3. 不用色彩表达状态：CQ 反白实底、QRV 描边、QSO 灰底，灰度屏上也分得清
 *   4. 圆角收敛、边线清晰，接近印刷品的锐利感
 *   5. 最小字号提到 10.5px，e-ink 的灰阶下小字容易糊
 */

:root {
  /* 变量名沿用旧主题，app.js 里有内联 var(--cyan)/var(--dim) 引用 */
  --bg: #f7f5ef;
  --panel: #fbfaf5;
  --panel2: #e9e5d9;
  --line: #cfc9ba;
  --text: #17160f;
  --dim: #565347;
  --dim2: #837e6f;
  --green: #17160f;
  --amber: #17160f;
  --cyan: #3a382e;
  --violet: #6b6759;
  --red: #8f2f22;
  --rule-soft: #e2ded1;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 2px solid var(--text);
}

.brand { display: flex; align-items: center; gap: 9px; }

/* 墨水屏不做呼吸动画：残影会一直挂着 */
.pulse {
  width: 9px; height: 9px;
  background: var(--text);
}

.brand-name {
  font-size: 15px; font-weight: 700; letter-spacing: 2.6px;
  font-family: var(--mono);
}

.geo {
  display: flex; align-items: center; gap: 7px;
  background: transparent; border: 1px solid var(--line);
  color: var(--dim); font-size: 11.5px;
  padding: 6px 10px; border-radius: 2px;
  font-family: var(--mono);
}
.geo-dot { width: 6px; height: 6px; background: var(--dim2); }
.geo.ok { color: var(--text); border-color: var(--text); }
.geo.ok .geo-dot { background: var(--text); }
.geo.err { color: var(--red); border-color: var(--red); }
.geo.err .geo-dot { background: var(--red); }

/* ---------- 通用 ---------- */
main { flex: 1; padding: 14px 16px 20px; }

.section-title {
  font-size: 11px; letter-spacing: 2px;
  color: var(--dim2); font-family: var(--mono);
  margin: 4px 0 10px;
}

.hint { font-size: 12.5px; line-height: 1.75; color: var(--dim); }

.empty { text-align: center; padding: 54px 24px; color: var(--dim); }
.empty .big { font-size: 32px; color: var(--dim2); margin-bottom: 14px; }
.empty p { font-size: 13.5px; line-height: 1.8; }

/* ---------- 概览条 ---------- */
.overview {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0; margin-bottom: 16px;
  border: 1px solid var(--text);
}
.stat {
  background: var(--panel);
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}
.stat:last-child { border-right: 0; }
.stat .k { font-size: 10.5px; color: var(--dim2); letter-spacing: .6px; margin-bottom: 5px; }
.stat .v { font-size: 17px; font-weight: 700; font-family: var(--mono); }
.stat .v small { font-size: 10px; color: var(--dim); font-weight: 400; margin-left: 2px; }

/* ---------- 筛选 ---------- */
.filters {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px;
  margin-bottom: 6px; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font-size: 12.5px; padding: 6px 12px; border-radius: 2px;
  background: transparent; border: 1px solid var(--line); color: var(--dim);
  white-space: nowrap;
}
.chip.on {
  background: var(--text); border-color: var(--text);
  color: var(--bg); font-weight: 600;
}

/* ---------- 电台卡片 ---------- */
.spot-list { display: flex; flex-direction: column; gap: 9px; }

.spot {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 13px 14px 12px 16px;
  overflow: hidden;
}
/* 按压反馈用边框加粗而不是缩发放大 —— e-ink 上缩放几乎看不出来 */
.spot:active { border-color: var(--text); }
.spot::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--c, var(--text));
}
.spot.mine { border: 1px solid var(--text); background: var(--panel2); }

.spot-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cs {
  font-family: var(--mono); font-size: 15.5px; font-weight: 700; letter-spacing: .8px;
}
.cs .suffix { color: var(--dim); font-weight: 400; }

.badge {
  font-size: 10px; padding: 2.5px 7px; border-radius: 2px; letter-spacing: .8px;
  font-family: var(--mono); font-weight: 700;
}
.badge.CQ,
.badge.QRV,
.badge.QSO { background: var(--text); color: var(--bg); }

.dist {
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  display: flex; align-items: center; gap: 4px;
}
.dist b { color: var(--text); font-size: 13.5px; font-weight: 700; }
.arrow { display: inline-block; color: var(--text); font-size: 13px; }

.freq-row {
  display: flex; align-items: baseline; gap: 8px; margin: 8px 0 7px;
  flex-wrap: wrap;
}
.freq {
  font-family: var(--mono); font-size: 27px; font-weight: 700;
  color: var(--text); letter-spacing: -0.5px; line-height: 1;
}
.freq-unit { font-size: 11px; color: var(--dim2); font-family: var(--mono); }
.mode-tag {
  font-family: var(--mono); font-size: 11px; padding: 1.5px 5px; border-radius: 2px;
  background: transparent; color: var(--dim); border: 1px solid var(--line);
}
.band-tag {
  font-family: var(--mono); font-size: 11px; padding: 1.5px 5px; border-radius: 2px;
  background: var(--panel2); color: var(--text);
}

.meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 11.5px; color: var(--dim); line-height: 1.65;
}
.meta span { display: inline-flex; align-items: center; gap: 3px; }
.meta .k { color: var(--dim2); }

.spot-foot {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 10.5px; color: var(--dim2);
}

/* ---------- 表单 ---------- */
.form-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 3px; padding: 14px; margin-bottom: 11px;
}
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--dim); margin-bottom: 7px;
}
.field-label .req { color: var(--red); }
.field-label .aux { font-family: var(--mono); font-size: 10.5px; color: var(--dim2); }

input[type="text"], input[type="number"], textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 2px; padding: 11px 12px; color: var(--text);
  font-size: 15px; font-family: var(--mono); outline: none;
}
input:focus, textarea:focus { border-color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--dim2); }
textarea { font-family: inherit; font-size: 14px; resize: none; height: 62px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.freq-input-wrap { position: relative; }
.freq-input-wrap input { font-size: 22px; font-weight: 700; color: var(--text); padding-right: 52px; }
.freq-input-wrap .unit {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 11.5px; color: var(--dim2); font-family: var(--mono); pointer-events: none;
}

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0;
}
.switch {
  width: 46px; height: 26px; border-radius: 2px; background: var(--bg);
  border: 1px solid var(--text); position: relative;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 18px;
  background: var(--dim2);
}
.switch.on { background: var(--panel2); }
.switch.on::after { left: 24px; background: var(--text); }

.geo-box {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 1px solid var(--line); border-radius: 2px;
  padding: 10px 12px; gap: 10px;
}
.geo-box .coords { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.geo-box .sub { font-size: 10.5px; color: var(--dim2); font-family: var(--mono); margin-top: 3px; }
.geo-box button {
  flex: none; background: var(--panel2); border: 1px solid var(--text);
  color: var(--text); font-size: 12px; padding: 7px 11px; border-radius: 2px;
}

/* 主按钮：反白实心，墨水屏上最醒目且不依赖颜色 */
.btn-primary {
  width: 100%; border: 1px solid var(--text); border-radius: 2px; padding: 15px;
  background: var(--text);
  color: var(--bg); font-size: 16px; font-weight: 800; letter-spacing: 1px;
  margin-top: 4px;
}
.btn-primary:active { background: var(--dim); border-color: var(--dim); }
.btn-primary:disabled { background: var(--dim2); border-color: var(--dim2); color: var(--bg); }

.btn-ghost {
  width: 100%; border: 1px solid var(--line); border-radius: 2px; padding: 13px;
  background: transparent; color: var(--dim); font-size: 14px; margin-top: 9px;
}
.btn-ghost.danger { color: var(--red); border-color: var(--red); }

/* ---------- 我的 ---------- */
.mine-card {
  background: var(--panel2);
  border: 1px solid var(--text);
  border-radius: 3px; padding: 16px; margin-bottom: 12px;
}
.mine-card .cs-line { display: flex; align-items: baseline; justify-content: space-between; }
.mine-card .big-cs { font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.timer { font-family: var(--mono); font-size: 12px; color: var(--text); }
.timer.off { color: var(--dim2); }

.kv-list { margin-top: 12px; display: grid; gap: 7px; }
.kv { display: flex; justify-content: space-between; font-size: 12.5px; }
.kv .k { color: var(--dim); }
.kv .v { font-family: var(--mono); color: var(--text); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; max-width: 560px; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 2px solid var(--text);
}
.tab {
  flex: 1; background: none; border: 0; color: var(--dim2);
  padding: 9px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10.5px;
}
.tab-ico { font-size: 17px; line-height: 1; }
.tab.on { color: var(--text); }
.tab.on .tab-ico { font-weight: 700; }

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(23, 22, 15, .45);
  z-index: 50;
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-mask.open { display: flex; }
.sheet {
  width: 100%; max-width: 560px; background: var(--bg);
  border-radius: 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--text);
  max-height: 86vh; overflow-y: auto;
}

.sheet .s-cs { font-family: var(--mono); font-size: 20px; font-weight: 700; }
.sheet .s-freq { font-family: var(--mono); font-size: 34px; font-weight: 700; color: var(--text); margin: 6px 0 3px; }
.sheet .s-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--rule-soft); font-size: 13px; }
.sheet .s-row .k { color: var(--dim); }
.sheet .s-row .v { font-family: var(--mono); }
.sheet .actions { display: flex; gap: 9px; margin-top: 16px; }
.sheet .actions a, .sheet .actions button {
  flex: 1; text-align: center; padding: 12px; border-radius: 2px;
  border: 1px solid var(--text); background: transparent; color: var(--text);
  font-size: 13.5px; text-decoration: none; font-family: inherit;
}
.sheet .actions .main { background: var(--text); color: var(--bg); font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px);
  background: var(--text); color: var(--bg); font-size: 13px;
  padding: 11px 18px; border-radius: 2px; border: 1px solid var(--text);
  opacity: 0; pointer-events: none; transition: opacity .14s; z-index: 80;
  max-width: 84vw; text-align: center; line-height: 1.5;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); border-color: var(--red); color: #fbfaf5; }

/* ---------- 视图切换段控 ---------- */
.seg {
  display: flex; gap: 0; padding: 0; margin-bottom: 12px;
  border: 1px solid var(--text); border-radius: 2px; overflow: hidden;
}
.seg-btn {
  flex: 1; padding: 9px 0; font-size: 13px; font-family: inherit;
  color: var(--dim); background: transparent; border: 0; border-radius: 0;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--text); }
.seg-btn.on { background: var(--text); color: var(--bg); font-weight: 600; }

/* ---------- 地图视图 ---------- */
.app.app-fixed { height: 100vh; height: 100dvh; overflow: hidden; }

main.map-mode {
  padding: 14px 16px 0;
  display: flex; flex-direction: column; min-height: 0;
}

.map-wrap {
  position: relative; overflow: hidden;
  border-radius: 2px; border: 1px solid var(--text);
  background: var(--bg);
}

.map-stage { position: absolute; inset: 0; }

.nation-canvas {
  position: absolute; inset: 0; display: block; z-index: 1;
  touch-action: none; cursor: grab;
}
.nation-canvas:active { cursor: grabbing; }

.tmap-canvas { position: absolute; inset: 0; z-index: 1; }

/* ---------- 地图内信息卡（点圆点后浮出） ---------- */
.map-info {
  position: absolute; left: 10px; right: 10px; bottom: 98px; z-index: 7;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .14s, transform .14s;
}
.map-info.open { opacity: 1; transform: none; pointer-events: auto; }

.mi-card {
  position: relative;
  padding: 11px 12px 12px;
  border: 1px solid var(--text);
  border-left: 4px solid var(--c, var(--text));
  border-radius: 2px;
  background: var(--panel);
}

.mi-x {
  position: absolute; right: 4px; top: 3px;
  width: 24px; height: 24px; border: 0; background: transparent;
  color: var(--dim2); font-size: 17px; line-height: 1; font-family: inherit;
}
.mi-x:active { color: var(--text); }

.mi-h { display: flex; align-items: center; gap: 6px; padding-right: 22px; }
.mi-cs {
  font-family: var(--mono); font-size: 15px; font-weight: 700; letter-spacing: .8px;
}
.mi-sp { flex: 1; }
.mi-d { font-family: var(--mono); font-size: 13px; color: var(--text); }
.mi-d small { font-size: 9px; color: var(--dim2); margin-left: 1px; }
.mi-b { font-family: var(--mono); font-size: 10.5px; color: var(--dim); margin-left: 6px; }
.mi-b i { display: inline-block; font-style: normal; margin-right: 2px; }

.mi-f { font-family: var(--mono); font-size: 17px; color: var(--text); margin-top: 7px; font-weight: 700; }
.mi-f small { font-size: 9.5px; color: var(--dim2); margin-left: 2px; font-weight: 400; }
.mi-mode {
  font-size: 10.5px; color: var(--dim); margin-left: 9px;
  padding: 1px 5px; border: 1px solid var(--line); border-radius: 2px;
}
.mi-m { font-size: 11.5px; color: var(--dim); margin-top: 6px; line-height: 1.55; }
.mi-note { font-size: 11px; color: var(--dim2); margin-top: 5px; line-height: 1.5; }

.mi-a { display: flex; gap: 7px; margin-top: 10px; }
.mi-btn {
  flex: 1; padding: 9px 0; font-size: 12px; font-family: inherit;
  color: var(--text); background: transparent;
  border: 1px solid var(--text); border-radius: 2px;
}
.mi-btn.pri { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }

.map-tools {
  position: absolute; right: 10px; top: 10px; z-index: 6;
  display: flex; flex-direction: column; gap: 5px;
}
.mt-btn {
  width: 34px; height: 34px; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--text);
  color: var(--text); font-size: 16px; line-height: 1; font-family: var(--mono);
}
.mt-btn:active { background: var(--text); color: var(--bg); }

.map-legend {
  position: absolute; left: 10px; top: 10px; z-index: 6;
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px; border-radius: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 10.5px; color: var(--dim); font-family: var(--mono);
}
.map-legend .lg { display: inline-flex; align-items: center; gap: 3px; }
.map-legend .lg i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.map-legend .lg-mode {
  color: var(--dim2); padding-right: 7px; border-right: 1px solid var(--line);
}

/* 底部横滑卡片条：实底 + 上边线，不用渐变（渐变在灰阶屏上是一道脏印子） */
.map-strip {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; gap: 7px; overflow-x: auto;
  padding: 10px 10px 10px;
  background: var(--bg);
  border-top: 1px solid var(--text);
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.map-strip::-webkit-scrollbar { display: none; }

.strip-card {
  flex: none; width: 134px; text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--text)); border-radius: 2px;
  padding: 8px 9px; color: var(--text); font-family: inherit;
}
.strip-card.on {
  border: 1px solid var(--text);
  border-left: 3px solid var(--c, var(--text));
  background: var(--panel2);
}
.strip-card .badge { font-size: 9px; padding: 1px 4px; }
.sc-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sc-cs { font-family: var(--mono); font-size: 12.5px; font-weight: 700; letter-spacing: .5px; }
.sc-freq { font-family: var(--mono); font-size: 13px; color: var(--text); margin-top: 4px; font-weight: 700; }
.sc-freq small { font-size: 9px; color: var(--dim2); margin-left: 2px; font-weight: 400; }
.sc-meta {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10.5px; color: var(--dim); margin-top: 4px;
}
.sc-meta small { font-size: 8px; color: var(--dim2); }
.strip-empty { color: var(--dim); font-size: 12px; padding: 14px 4px; flex: none; }

/* 位置精度说明 + 页脚 */
.prec-note { font-size: 11.5px; color: var(--dim2); margin-top: 7px; line-height: 1.6; }
.site-foot {
  margin: 26px 0 14px; display: flex; flex-direction: column;
  align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--dim2); font-family: var(--mono);
}
.site-foot a { color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }
.site-foot .icp { color: var(--dim2); }
