:root {
  --bg: #000033;
  --panel: #0d0d4a;
  --line: #23236a;
  --text: #ffffff;
  --muted: #a9a9d6;
  --accent: #3a96dd;
  --purple: #6b3fa0;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
main { max-width: 440px; margin: 0 auto; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); }

.top { display: flex; justify-content: center; }
.city {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 8px 14px; border: 0; border-radius: 999px; background: var(--panel);
  font-size: 18px; font-weight: 600;
}
.city #city-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.city .chev { color: var(--muted); font-size: 22px; line-height: 1; }

.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 14px 0;
  padding: 4px; border-radius: 14px; background: var(--panel);
}
.tabs button {
  padding: 10px 0; border: 0; border-radius: 10px; background: none;
  color: var(--muted); font-size: 15px; font-weight: 600;
}
.tabs button.on { background: var(--accent); color: #fff; }

.card-wrap {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 540 / 800; max-width: 340px; margin: 0 auto; border-radius: var(--radius);
  overflow: hidden; background: var(--panel);
}
#card { display: block; width: 100%; height: 100%; }
.msg { margin: 0; padding: 24px; text-align: center; color: var(--muted); }
.loader span {
  display: block; width: 36px; height: 36px; border: 3px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
.loader[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.share {
  display: block; width: 100%; max-width: 340px; margin: 12px auto 0; padding: 12px;
  border: 0; border-radius: 12px; background: var(--accent); font-weight: 600;
}
.share:disabled { opacity: .5; cursor: default; }
.panel { margin-top: 14px; padding: 16px; border-radius: var(--radius); background: var(--panel); }
.panel h2 { margin: 0; font-size: 17px; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.chips button {
  padding: 9px 0; border: 1px solid var(--line); border-radius: 10px; background: none; font-size: 15px;
}
.chips button.on { border-color: var(--accent); background: var(--accent); }
.chips button.off { grid-column: span 2; color: var(--muted); }

.switch { position: relative; flex: none; width: 52px; height: 32px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .2s; pointer-events: none; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; transition: .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

.credit { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.sheet {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 20, .6);
}
.sheet[hidden] { display: none; }
.sheet-box {
  width: 100%; max-width: 440px; max-height: 85vh; overflow: auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; background: var(--panel);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.close { width: 40px; height: 40px; border: 0; background: none; color: var(--muted); font-size: 28px; }
#q {
  width: 100%; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
#q:focus { outline: none; border-color: var(--accent); }
.geo {
  width: 100%; margin-top: 10px; padding: 12px; border: 0; border-radius: 12px;
  background: var(--purple); font-weight: 600;
}
.results { margin: 8px 0 0; padding: 0; list-style: none; }
.results button {
  display: block; width: 100%; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: left;
}
.results small { display: block; color: var(--muted); font-size: 13px; }
.results .empty { padding: 12px 4px; color: var(--muted); }
