:root {
  --bg: #f4f6fa; --card: #fff; --text: #111827; --muted: #5b6475; --line: #d9deea;
  --accent: #1d4ed8; --accent-text: #fff; --ok: #15803d; --warn: #b45309; --danger: #b91c1c;
  --code-bg: #fef3c7; --code-text: #78350f;
}
:root[data-theme="dark"] {
  --bg: #0b1220; --card: #151e30; --text: #f1f5f9; --muted: #9aa6bd; --line: #26324a;
  --accent: #3b82f6; --accent-text: #fff; --ok: #4ade80; --warn: #fbbf24; --danger: #f87171;
  --code-bg: #3b2f0b; --code-text: #fde68a;
}
* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif; line-height: 1.4;
  padding-bottom: 40px;
}
header#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 12px; background: var(--accent); color: var(--accent-text);
}
.title { display: flex; flex-direction: column; min-width: 0; }
.title b { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#count { font-size: 1.3rem; font-weight: 700; }
button, .btn, input, select { font: inherit; color: inherit; }
button.icon { min-width: 48px; min-height: 48px; font-size: 1.5rem; background: transparent; border: 0; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 48px; min-width: 48px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); text-decoration: none; cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); color: #fff; }
.btn.small { min-height: 48px; padding: 0 10px; font-weight: 500; }
main { padding: 10px; max-width: 640px; margin: 0 auto; }
#banner { padding: 10px 12px; background: var(--code-bg); color: var(--code-text); display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 0.95rem; }
#banner[hidden] { display: none; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tools .btn { flex: 1 1 30%; }
#msg { min-height: 1.4em; margin: 4px 2px 10px; color: var(--muted); font-size: 0.95rem; }
#msg.err { color: var(--danger); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px;
}
.card.current { border: 2px solid var(--accent); }
.hd { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; }
.num { background: var(--accent); color: var(--accent-text); border-radius: 999px; min-width: 2.2em; text-align: center; padding: 0 6px; font-weight: 700; font-size: 0.95rem; }
.sens { color: var(--warn); font-size: 1rem; opacity: 0.8; }
.addr { font-size: 1.15rem; margin: 4px 0; }
.meta { color: var(--muted); font-size: 1.05rem; }
.code { margin: 6px 0; padding: 6px 10px; background: var(--code-bg); color: var(--code-text); border-radius: 10px; font-size: 1.5rem; font-weight: 800; letter-spacing: 1px; direction: ltr; text-align: center; }
.shared { margin: 6px 0; color: var(--warn); font-weight: 600; }
.extra { color: var(--muted); font-size: 0.95rem; margin: 4px 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btns .btn { flex: 1 1 40%; }
.edit { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.edit .btn { flex: 1; }
.row-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line); min-height: 48px; cursor: pointer; }
.row-item .t { flex: 1; min-width: 0; }
.row-item .t b, .row-item .t span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .t span { color: var(--muted); font-size: 0.9rem; }
details.done { margin-top: 14px; }
details.done summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
.done-item { opacity: 0.8; }
.empty { text-align: center; padding: 30px 10px; }
#map { height: 300px; border-radius: 12px; margin-bottom: 10px; border: 1px solid var(--line); }
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); width: min(92vw, 460px); padding: 14px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin: 0 0 10px; font-size: 1.2rem; }
dialog label { display: block; margin-bottom: 12px; font-weight: 600; }
dialog input[type=password], dialog input[type=search], dialog input[type=text], dialog select {
  width: 100%; min-height: 48px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
dialog input[type=file] { display: block; margin-top: 6px; min-height: 48px; width: 100%; }
.row { display: flex; gap: 8px; margin-top: 6px; }
.row input { flex: 1; min-width: 0; }
#add-results .btn { width: 100%; margin: 4px 0; justify-content: flex-start; text-align: right; }
@media (max-width: 380px) { html { font-size: 17px; } .tools .btn { flex-basis: 45%; } }
