/* D*STAR Information Query - one small stylesheet, no frameworks.
   Light and dark follow the system setting unless the visitor picks one with the header toggle;
   the layout works down to small phones. */

:root {
  --bg: #f6f7f9;  --surface: #ffffff;  --text: #1b1f24;  --muted: #5b6573;
  --border: #d9dee5;  --accent: #0b5fff;  --accent-text: #ffffff;
  --head: #eef1f5;  --notice-bg: #fff6d6;  --notice-border: #e7c24a;
  --stale-bg: #ffe8e6;  --stale-border: #e0675a;  --star: #d49b00;
  --ok: #1a7f37;  --late: #b7791f;  --bad: #cf222e;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
/* Dark theme: chosen with the toggle (data-theme="dark"), or by the system setting
   when no choice was made (and when JavaScript is off). */
:root[data-theme="dark"] {
  --bg: #0f1216;  --surface: #171b21;  --text: #e6e9ee;  --muted: #9aa4b2;
  --border: #2a313b;  --accent: #6ea2ff;  --accent-text: #0b1020;
  --head: #1d232b;  --notice-bg: #2e2810;  --notice-border: #8a7322;
  --stale-bg: #3a1714;  --stale-border: #a4453a;  --star: #f2c14e;
  --ok: #3fb950;  --late: #d29922;  --bad: #f85149;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;  --surface: #171b21;  --text: #e6e9ee;  --muted: #9aa4b2;
    --border: #2a313b;  --accent: #6ea2ff;  --accent-text: #0b1020;
    --head: #1d232b;  --notice-bg: #2e2810;  --notice-border: #8a7322;
    --stale-bg: #3a1714;  --stale-border: #a4453a;  --star: #f2c14e;
    --ok: #3fb950;  --late: #d29922;  --bad: #f85149;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 60rem; margin: 0 auto; padding: 0 1rem; }

/* Header */
header.site { background: var(--surface); border-bottom: 1px solid var(--border); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; padding-block: .75rem; }
header .title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 1rem; min-width: 0; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.byline { color: var(--muted); font-size: .85rem; }
header nav { margin-left: auto; display: flex; gap: 1rem; }
header nav a { text-decoration: none; color: var(--muted); padding: .25rem 0; }
header nav a[aria-current="page"] { color: var(--text); border-bottom: 2px solid var(--accent); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; align-self: center;
  width: 2.25rem; height: 2.25rem; padding: 0; border: 1px solid var(--border); border-radius: 50%;
  background: transparent; color: var(--text); cursor: pointer;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { background: var(--head); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

main.wrap { padding-block: 1rem 2rem; }

/* Banners and status */
.banner { border: 1px solid; border-radius: var(--radius); padding: .25rem 1rem; margin: 0 0 1rem; }
.banner.notice { background: var(--notice-bg); border-color: var(--notice-border); }
.banner.stale  { background: var(--stale-bg);  border-color: var(--stale-border); }
.banner p { margin: .5rem 0; }
.feed { color: var(--muted); font-size: .85rem; margin: 0 0 1rem; }
.health { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; margin-right: .35rem; }
.health .dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--muted); flex: none; }
.health.ok    { color: var(--ok); }    .health.ok .dot    { background: var(--ok); }
.health.late  { color: var(--late); }  .health.late .dot  { background: var(--late); }
.health.stale { color: var(--bad); }   .health.stale .dot { background: var(--bad); }

/* Lookup form */
form.lookup { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
form.lookup label { display: block; font-weight: 600; margin-bottom: .4rem; }
form.lookup .row { display: flex; gap: .5rem; }
form.lookup input {
  flex: 1; min-width: 0; font: inherit; font-family: var(--mono); text-transform: uppercase;
  padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
form.lookup input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
form.lookup button {
  font: inherit; font-weight: 600; padding: .6rem 1.1rem; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); cursor: pointer;
}

/* Results */
.result-title { font-family: var(--mono); font-size: 1.5rem; margin: 1.25rem 0 .75rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin-bottom: 1rem; }
.card h3 { margin: .25rem 0 .75rem; font-size: 1.05rem; }
.card h3 small { font-weight: 400; color: var(--muted); font-size: .8rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .5rem 0 0; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { background: var(--head); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
td.cs { font-family: var(--mono); white-space: pre; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.home { color: var(--star); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.msg { border-radius: var(--radius); padding: .75rem 1rem; border: 1px solid var(--border); background: var(--surface); }
.msg.error { border-color: var(--stale-border); background: var(--stale-bg); }
.intro { color: var(--muted); }
details summary { cursor: pointer; color: var(--accent); }

/* Footer */
footer.site { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
footer.site .wrap { padding-block: 1rem 2rem; }
footer .links { display: flex; flex-wrap: wrap; gap: 1rem; }
ul.history { list-style: none; padding: 0; margin: .5rem 0; font-family: var(--mono); font-size: .8rem; }
ul.history li { padding: .1rem 0; }
.revisions details { margin-left: 1rem; }

@media (max-width: 34rem) {
  header nav { margin-left: 0; width: 100%; order: 2; }
  header .title { flex: 1; }
  .theme-toggle { order: 1; align-self: flex-start; }
  form.lookup .row { flex-direction: column; }
  form.lookup button { width: 100%; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: .4rem; }
  th, td { padding: .4rem .45rem; }
  /* Wide tables become one labelled card per row */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--border); padding: .4rem 0; }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: .1rem 0; display: grid; grid-template-columns: 8.5rem 1fr; gap: .5rem; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-family: system-ui, sans-serif; font-size: .8rem; white-space: normal; }
}
