:root {
  --bg: #0b1615;
  --surface: #12211f;
  --surface-2: #182b28;
  --line: #24403b;
  --text: #e6f2ef;
  --muted: #8fb0aa;
  --accent: #5eead4;
  --accent-ink: #04211d;
  --gold: #ffd666;
  --danger: #ff8a80;
  --danger-bg: #3a1714;
  --radius: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f7f6;
    --surface: #ffffff;
    --surface-2: #eef5f3;
    --line: #d4e3df;
    --text: #0f2623;
    --muted: #557570;
    --accent: #0f766e;
    --accent-ink: #ffffff;
    --gold: #b7791f;
    --danger: #b42318;
    --danger-bg: #fdecea;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }

h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
code { font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.danger-text { color: var(--danger); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 9px; flex: none; }
.brand p { margin: 0; }

.pill {
  flex: none;
  font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.pill.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pill.on::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; animation: pulse 1.6s infinite; }
.pill.err { color: var(--danger); }
@keyframes pulse { 50% { opacity: 0.3; } }

.banner { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.banner.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

.found-list { display: grid; gap: 8px; }
.found {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
}
.found .name { font-weight: 600; }
.found .slots { font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; font-size: 15px;
  padding: 10px 14px; border-radius: 12px; cursor: pointer; min-height: 44px;
}
.btn.small { font-size: 13px; padding: 6px 10px; min-height: 34px; border-radius: 10px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.linkish { appearance: none; border: 0; background: none; color: var(--accent); font: inherit; padding: 0; cursor: pointer; text-decoration: underline; }

input[type="text"], input[type="url"], input[type="number"], input[type="search"], input[type="password"], input:not([type]) {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 44px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.switch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; margin: 6px 0; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row > input { flex: 1; min-width: 0; }
.add-code { display: flex; gap: 6px; flex: none; }
.add-code input { width: 64px; text-transform: uppercase; text-align: center; }

.country-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; border-top: 1px solid var(--line); }
.country-list li { border-bottom: 1px solid var(--line); }
.country-list label { display: flex; align-items: center; gap: 12px; padding: 10px 2px; cursor: pointer; min-height: 48px; }
.country-list input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.country-list .cname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country-list .code { color: var(--muted); font-size: 13px; margin-left: 4px; }
.badge { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); flex: none; }
.badge.has { color: var(--accent); }
.badge.hit { color: var(--accent-ink); background: var(--gold); }

.settings { display: grid; gap: 12px; }
.settings label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.settings label.switch-row { display: flex; font-weight: 400; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; margin: 0; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list .t { color: var(--muted); font-size: 12px; }
.alert-list .b { white-space: pre-line; color: var(--muted); }

.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 85%, transparent); display: grid; place-items: center; padding: 16px; z-index: 10; }
.overlay[hidden] { display: none; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 10px; }
