/* kudos: one stylesheet, no JavaScript. Engineering tool first. */

:root {
  --fg: #111;
  --muted: #666;
  --bg: #fff;
  --panel: #f4f4f4;
  --border: #ccc;
  --link: #0645ad;
  --top: #222;
  --top-fg: #eee;
  --accent: #c0392b;
  --error-bg: #fbe9e7;
  --notice-bg: #e8f5e9;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #ddd;
    --muted: #999;
    --bg: #181818;
    --panel: #222;
    --border: #444;
    --link: #8ab4f8;
    --top: #000;
    --top-fg: #ddd;
    --error-bg: #3a1f1c;
    --notice-bg: #1c3a20;
  }
  .k-area { fill: #777 !important; stroke: #aaa !important; }
  .k-end { fill: #ddd !important; stroke: #181818 !important; }
  .k-start { stroke: #181818 !important; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 var(--sans);
}

a { color: var(--link); }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 16px;
}

header.top {
  background: var(--top);
  color: var(--top-fg);
  margin-bottom: 1.5rem;
}
header.top .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.6rem;
  flex-wrap: wrap;
}
header.top a, header.top .link { color: var(--top-fg); text-decoration: none; }
header.top a:hover, header.top .link:hover { text-decoration: underline; }
header.top .brand { font-weight: bold; font-family: var(--mono); font-size: 1.1rem; }
header.top nav { display: flex; gap: 1rem; align-items: center; }

footer.container {
  margin-top: 3rem;
  padding-bottom: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}
footer > div { border-top: 1px solid var(--border); padding-top: 0.75rem; }

h1 { font-size: 1.6rem; margin: 0 0 0.4rem; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.6rem; font-weight: 600; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.prose { white-space: pre-wrap; max-width: 70ch; }
.crumbs { margin: 0 0 0.3rem; color: var(--muted); font-family: var(--mono); font-size: 0.9rem; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--panel); padding: 0 3px; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0 5px;
  border: 1px solid var(--border);
  color: var(--muted);
  vertical-align: middle;
}

.error, .notice {
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--accent);
  background: var(--error-bg);
}
.notice { border-left-color: #2e7d32; background: var(--notice-bg); }

/* Tables */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { font-weight: 600; border-bottom: 2px solid var(--border); white-space: nowrap; }
thead th.num { font-family: var(--sans); font-size: inherit; }
.num { text-align: right; font-family: var(--mono); font-size: 0.9rem; white-space: nowrap; }
table.activities td:first-child { width: 45%; }
table.data { max-width: 640px; }
table.stats { width: auto; }
table.stats th { font-weight: normal; color: var(--muted); padding-right: 1.5rem; white-space: nowrap; }
table.stats td { font-family: var(--mono); font-size: 0.95rem; }

/* Activity page */
.activity {
  display: grid;
  grid-template-columns: minmax(0, 640px) minmax(220px, 1fr);
  gap: 1.5rem;
  align-items: start;
  margin-top: 1rem;
}
.activity.no-figures { display: block; }
figure { margin: 0 0 1rem; border: 1px solid var(--border); background: var(--panel); }
figure svg { display: block; width: 100%; height: auto; color: var(--fg); }
.actions { margin-top: 2rem; }

/* Forms */
form label { display: block; margin-bottom: 0.9rem; max-width: 36rem; }
form.narrow label { max-width: 22rem; }
form label small { display: block; color: var(--muted); }
form label.check { display: flex; gap: 0.5rem; align-items: center; }
input:not([type=checkbox]), select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.2rem;
  padding: 5px 6px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
}
textarea { font-family: var(--sans); }
button, .button {
  display: inline-block;
  padding: 5px 14px;
  font: inherit;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
}
form.danger button { background: var(--accent); border-color: var(--accent); color: #fff; }
form.inline { display: inline; margin: 0; }
button.link {
  background: none; border: none; padding: 0; color: var(--link); cursor: pointer; font: inherit;
}

.scroll { overflow-x: auto; }

@media (max-width: 760px) {
  .activity { grid-template-columns: 1fr; }
  th, td { padding: 4px 5px; }
  /* Activity lists stack: title and details across the full width, then
     the numbers as one compact line (their units make headers unnecessary). */
  table.activities thead { display: none; }
  table.activities tr {
    display: flex; flex-wrap: wrap; gap: 0 0.9rem;
    padding: 7px 0; border-bottom: 1px solid var(--border);
  }
  table.activities td { border: 0; padding: 0; }
  table.activities td:first-child { flex-basis: 100%; width: auto; margin-bottom: 3px; }
  table.activities td.nowrap, table.activities td.num { font-size: 0.85rem; text-align: left; }
  table.activities td:empty { display: none; }
}

/* Social */
.meta { color: var(--muted); margin: 0.2rem 0 0.6rem; }
.meta a { color: inherit; }
button.secondary { background: var(--bg); color: var(--fg); }
.inline-form { margin: 0.5rem 0; }
.comment { border-left: 3px solid var(--border); padding: 0 0 0 0.75rem; margin: 0 0 1rem; }
.comment-head { margin: 0; font-size: 0.9rem; }
.comment-head .muted { margin-left: 0.4rem; }
button.muted-link { color: inherit; }
button.muted-link:hover, .comment-head a.plain:hover { text-decoration: underline; }
.comment .prose { margin: 0.2rem 0 0; }
.comment-form { margin-top: 1rem; }
nav.tabs { display: flex; gap: 1.25rem; margin: 0.25rem 0 1rem; }
nav.tabs strong { border-bottom: 2px solid var(--fg); }
nav.tabs a { color: var(--muted); }
table.people td:first-child { width: 60%; }
table.totals td:first-child { color: var(--muted); }

/* Mail */
.address code { font-size: 1rem; padding: 4px 8px; user-select: all; word-break: break-all; }
ol.mail-log { list-style: none; padding: 0; margin: 0; }
ol.mail-log li { border-bottom: 1px solid var(--border); padding: 0.6rem 0; }
.mail-head { margin: 0; }
.mail-head .status { margin-right: 0.3rem; }
.mail-head .muted { display: inline-block; margin-left: 0.3rem; font-size: 0.9rem; }
pre.mail-result {
  margin: 0.4rem 0 0; font: 0.85rem/1.4 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.mail-links { margin: 0.3rem 0 0; font-size: 0.9rem; }
.status { font-size: 0.8rem; padding: 0 5px; border: 1px solid var(--border); }
.status-processed { color: #2e7d32; border-color: #2e7d32; }
.status-rejected, .status-failed { color: var(--accent); border-color: var(--accent); }

/* Long tables collapse with plain <details>, no JavaScript. */
details.table > summary { cursor: pointer; list-style-position: outside; margin-left: 1rem; }
details.table > summary h2 { display: inline-block; margin: 2rem 0 0.6rem; }

footer .commit { font-family: var(--mono); font-size: 0.8rem; }
a.plain { color: inherit; text-decoration: none; }
a.plain:hover { text-decoration: underline; }

/* Activity lists: title on one line, details on a quieter second line. */
table.activities a.title { font-weight: 500; }
table.activities .meta { color: var(--muted); font-size: 0.85rem; margin: 1px 0 0; }
table.activities .meta a { color: inherit; }
