:root {
  --bg: #ffffff;
  --bar: #f6f5f2;
  --text: #1d1c1a;
  --muted: #6b6860;
  --border: #e0ddd6;
  --hover: #ebe9e4;
  --accent: #2d5bd7;
  --accent-soft: #e3eafc;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --bar: #201f1d;
    --text: #ecebe8;
    --muted: #a19e96;
    --border: #3a3834;
    --hover: #2c2b28;
    --accent: #8aa8ff;
    --accent-soft: #24304d;
    --danger: #ff8a80;
    --danger-soft: #3a1f1d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- navbar --- */
.bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .4rem .75rem;
  padding-top: calc(.4rem + env(safe-area-inset-top, 0px));
  background: var(--bar);
  border-bottom: 1px solid var(--border);
}
.sites {
  display: flex;
  gap: .15rem;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.sites::-webkit-scrollbar { display: none; }
.sites a {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .65rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.sites a:hover { background: var(--hover); }
.sites a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.sites a:focus-visible, .address input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sites img { width: 16px; height: 16px; border-radius: 3px; flex: none; }
.address { flex: 1 1 14rem; min-width: 8rem; margin: 0; }
.address input {
  width: 100%;
  padding: .4rem .8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
}
@media (max-width: 44rem) {
  .bar { flex-wrap: wrap; gap: .4rem; }
  .address { flex-basis: 100%; }
}

/* --- page area --- */
#frame {
  flex: 1;
  display: block;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}
.notice {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  background: var(--danger-soft);
  color: var(--danger);
  border-bottom: 1px solid var(--border);
}
.notice span { flex: 1; }
button {
  padding: .35rem .8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}

/* --- bootstrap screen (only when served at /go/...) --- */
html.boot .bar, html.boot #frame { display: none; }
.booting {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}
.booting p { max-width: 32rem; margin: 0; }
.booting.failed .spinner { display: none; }
.booting.failed p { color: var(--text); }
.booting a { color: var(--accent); }
.boot-actions { display: flex; gap: 1rem; align-items: center; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
