:root {
  color-scheme: light;
  --page: #f3f6fb;
  --text: #172b3a;
  --muted: #526176;
  --panel: #fff;
  --border: #d4dce7;
  --link: #174da3;
  --visited: #7041a0;
  --hover: #edf3fc;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #080b14;
  --text: #f8fafc;
  --muted: #b0bbce;
  --panel: #0f1524;
  --border: #526179;
  --link: #a5bdff;
  --visited: #d0b3ff;
  --hover: #1a2439;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #080b14;
    --text: #f8fafc;
    --muted: #b0bbce;
    --panel: #0f1524;
    --border: #526179;
    --link: #a5bdff;
    --visited: #d0b3ff;
    --hover: #1a2439;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 1rem; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 1rem/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--link); }
a:visited { color: var(--visited); }
a:focus-visible, button:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 4px;
}
.page-shell { width: min(100% - 2rem, 56rem); margin: 2rem auto 3rem; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
h1 { margin: 0; font-size: clamp(1.75rem, 5vw, 2.25rem); letter-spacing: -.035em; }
h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.panel {
  min-width: 0;
  padding: clamp(1rem, 4vw, 1.75rem);
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--panel);
}
.theme-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
.theme-controls button {
  min-height: 44px;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: .65rem;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.theme-controls button:disabled { color: var(--muted); cursor: default; }
.theme-controls button:hover:not(:disabled) { background: var(--hover); }
.theme-controls .theme-toggle {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 15px;
}
.theme-toggle svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.moon-icon { display: none; }
:root[data-theme="dark"] .sun-icon { display: none; }
:root[data-theme="dark"] .moon-icon { display: block; }
#connection-status, #connection small, .notice { color: var(--muted); }
#connection-status { margin: .4rem 0 1.1rem; }
#connection dl {
  display: grid;
  grid-template-columns: minmax(6rem, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: .7rem 1.25rem;
  margin: 0 0 1.2rem;
}
#connection dt { color: var(--muted); }
#connection dd { margin: 0; overflow-wrap: anywhere; }
#connection-ip {
  font: 600 clamp(1.25rem, 4vw, 1.75rem)/1.4 ui-monospace, monospace;
  letter-spacing: -.035em;
}
#connection small { display: block; }
.directory { list-style: none; margin: 1rem 0 0; padding: 0; }
.directory li + li { border-top: 1px solid var(--border); }
.directory li { overflow-wrap: anywhere; }
.directory a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 48px;
  padding: .85rem .5rem;
  border-radius: .4rem;
  text-underline-offset: .2em;
}
.directory a:hover { background: var(--hover); }
.link-arrow { flex-shrink: 0; text-decoration: none; }
.directory .archive {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .35rem 1rem;
  padding: .85rem .5rem;
  color: var(--muted);
}
.archived-site { min-width: 0; }
.archive-badge { font-size: .85rem; }
.skip-link {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 1;
  padding: .6rem 1rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background: var(--panel);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
@media (max-width: 26rem) {
  .page-shell { margin-top: 1rem; }
  #connection dl { grid-template-columns: 1fr; gap: .15rem; }
  #connection dd + dt { margin-top: .6rem; }
}
