:root {
  --bg: #f4f1e9;
  --card: #fbf9f3;
  --ink: #2c2c26;
  --muted: #6b6a62;
  --green: #1f5c46;
  --green-soft: rgba(31, 92, 70, 0.08);
  --red: #b4342b;
  --gold: #c8a45c;
  --line: rgba(44, 44, 38, 0.12);
  --shadow: 0 1px 0 rgba(44, 44, 38, 0.05);
}

[data-theme="dark"] {
  --bg: #171a17;
  --card: #212521;
  --ink: #e8e6dc;
  --muted: #9a998e;
  --green: #5fb896;
  --green-soft: rgba(95, 184, 150, 0.12);
  --red: #e07a72;
  --gold: #d4b478;
  --line: rgba(232, 230, 220, 0.14);
  --shadow: none;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

.app-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.app-head .ttl { font-size: 17px; font-weight: 600; letter-spacing: 2px; }
.app-head .ttl small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); letter-spacing: 1px; }

main { padding: 14px 14px 20px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.card h3 .accent { color: var(--green); }

.mini { font-size: 12.5px; color: var(--muted); }

.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); flex-shrink: 0; }
.kv .v { text-align: right; word-break: break-all; }

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

.btn {
  appearance: none;
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}
.btn.ghost { background: transparent; color: var(--green); }
.btn.red { border-color: var(--red); background: var(--red); }
.btn.small { font-size: 12.5px; padding: 6px 12px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; }

input, select {
  width: 100%;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus { outline: none; border-color: var(--green); }
label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 4px; }

.stats { display: flex; gap: 8px; margin-bottom: 12px; }
.stat {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.stat .n { font-size: 18px; font-weight: 600; color: var(--green); }
.stat .l { font-size: 11px; color: var(--muted); }

#mapBox { width: 100%; height: 340px; border-radius: 12px; overflow: hidden; background: var(--green-soft); position: relative; }
#mapBox svg, #mapBox .tmap-map { width: 100%; height: 100%; }
#mapBox .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }

.item { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.item:last-child { border-bottom: none; }
.item .t1 { font-size: 14px; font-weight: 500; }
.item .t2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tag {
  display: inline-block;
  font-size: 11px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 6px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: 1px;
}
.tag.red { color: var(--red); background: rgba(180, 52, 43, 0.1); }
.item { position: relative; padding-right: 30px; }
.item .del {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; line-height: 22px; text-align: center;
  border-radius: 50%; color: var(--red); font-size: 16px; font-weight: 600;
  background: rgba(180,52,43,0.08); cursor: pointer;
}

.day-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 2px; border-bottom: 1px dashed var(--line); cursor: pointer; }
.day-card:last-child { border-bottom: none; }
.day-card .d { font-size: 14.5px; font-weight: 600; }
.day-card .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.day-card .go { color: var(--gold); font-size: 12.5px; flex-shrink: 0; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 11px;
  color: var(--muted);
  padding: 9px 0 7px;
  cursor: pointer;
}
.tabbar button .ic { display: block; font-size: 19px; line-height: 1.2; }
.tabbar button.on { color: var(--green); font-weight: 600; }

.view { display: none; }
.view.on { display: block; }
.hidden { display: none !important; }

.switch { position: relative; width: 46px; height: 26px; border-radius: 13px; background: var(--line); transition: background 0.2s; flex-shrink: 0; cursor: pointer; border: none; appearance: none; }
.switch.on { background: var(--green); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left 0.2s; }
.switch.on::after { left: 23px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: rgba(28, 30, 27, 0.92);
  color: #f4f1e9;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 99;
  max-width: 82vw;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.errbox { background: rgba(180, 52, 43, 0.1); border: 1px solid var(--red); color: var(--red);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; margin-bottom: 12px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 19, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 200;
}
.modal.hidden { display: none; }
.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--green);
  border-bottom: 1px solid var(--line);
}
.modal-head .x {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.modal-body { padding: 16px; }
.modal-body .steps { margin: 10px 0 6px; padding-left: 20px; }
.modal-body .steps li { margin: 9px 0; line-height: 1.55; }
.modal-body code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--green-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12.5px;
  color: var(--green);
}

.code-box {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--green-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  word-break: break-all;
  color: var(--ink);
}

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 0;
  border-radius: 8px;
  cursor: pointer;
}
.seg button.on { background: var(--green); color: #fff; font-weight: 600; }

.login-hero { text-align: center; padding: 26px 0 10px; }
.login-hero .big { font-size: 26px; font-weight: 600; letter-spacing: 6px; color: var(--green); }
.login-hero .sub { font-size: 12px; color: var(--muted); letter-spacing: 2px; margin-top: 4px; }

.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
