
:root {
  --bg: #fbfaf8;
  --bg-tint: #f4f1ec;
  --panel: #fff;
  --raised: #fff;
  --ink: #22201d;
  --muted: #6d6963;
  --faint: #757068;
  --line: #e7e3dc;
  --line-soft: #efece6;
  --accent: #7c5cff;
  --accent-soft: #f0ecff;
  --accent-ink: #5b3fd6;
  --accent-fill: #5b3fd6;
  --warn: #a24915;
  --warn-soft: #fdf1e8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(30, 25, 20, 0.04), 0 8px 24px -12px rgba(30, 25, 20, 0.14);
  --shadow-lift: 0 1px 2px rgba(30, 25, 20, 0.05), 0 14px 34px -14px rgba(30, 25, 20, 0.2);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a; --bg-tint: #1b1a1f; --panel: #1f1e23; --raised: #26242c;
    --ink: #eceaf0; --muted: #a6a1ad; --faint: #8f8a99;
    --line: #302e37; --line-soft: #2a2830;
    --accent: #a693ff; --accent-soft: #272338; --accent-ink: #c4b6ff; --accent-fill: #4f36c4;
    --warn: #e2a06b; --warn-soft: #2e2419;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lift: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 34px -14px rgba(0, 0, 0, 0.7);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  overflow-x: hidden;
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}
/* Focus must never be invisible, even where a rule below clears the outline. */
:focus { outline-color: var(--accent); }

/* Visible only to assistive technology. The clip-path pair keeps it out of the
   layout without the display:none that would hide it from screen readers too. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  border: 0;
}
/* The first tab stop on every page. */
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px;
  background: var(--raised); color: var(--ink); border: 1px solid var(--accent);
  box-shadow: var(--shadow-lift); transition: top 120ms ease;
}
.skip:focus { top: 8px; }
main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------------ header */

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 24px; max-width: 900px; margin: 0 auto;
}
.brand {
  font-weight: 600; letter-spacing: -0.03em; font-size: 18px;
  display: inline-flex; align-items: center; gap: 8px;
}
/* A quiet mark rather than a logo: the product is meant to be unobtrusive. */
.brand::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}

/* -------------------------------------------------------------- user menu */

/* The menu is a <details>, so it works with scripting off and needs no JS to open,
   close, or handle the keyboard. The browser supplies all of that; CSS supplies
   only the appearance. */
.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
  /* A comfortable target on touch, without inflating the avatar itself. */
  padding: 5px; margin: -5px;
  -webkit-tap-highlight-color: transparent;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::marker { content: ""; }

.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em; flex: none;
  color: hsl(var(--hue, 260) 62% 32%);
  background: hsl(var(--hue, 260) 68% 92%);
  box-shadow: inset 0 0 0 1px hsl(var(--hue, 260) 45% 82%);
  transition: box-shadow 120ms ease;
}
@media (prefers-color-scheme: dark) {
  .avatar {
    color: hsl(var(--hue, 260) 75% 86%);
    background: hsl(var(--hue, 260) 32% 26%);
    box-shadow: inset 0 0 0 1px hsl(var(--hue, 260) 30% 38%);
  }
}
.menu summary:hover .avatar { box-shadow: inset 0 0 0 1px var(--faint); }
.menu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chev {
  width: 0; height: 0; flex: none;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--faint);
  transition: transform 120ms ease;
}
.menu[open] .chev { transform: rotate(180deg); }

/* Click-outside-to-close, without script: an open menu lays a transparent backdrop
   over the page, and the backdrop belongs to the summary, so a click on it toggles
   the <details> shut. The cursor:pointer below is load-bearing — iOS Safari only dispatches
   the click to a non-interactive element when it looks clickable. */
.menu[open] summary::before {
  content: ""; position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 10; cursor: pointer;
}
.menu .sheet {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 20;
  width: max-content; min-width: 250px; max-width: min(320px, calc(100vw - 32px));
  padding: 6px;
  background: var(--raised); border: 1px solid var(--faint);
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(30, 25, 20, 0.08), 0 18px 40px -12px rgba(30, 25, 20, 0.34);
}
@media (prefers-color-scheme: dark) {
  .menu .sheet {
    border-color: var(--line);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 18px 40px -12px rgba(0, 0, 0, 0.85);
  }
}
.menu .card {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px;
  border-bottom: 1px solid var(--line-soft); margin-bottom: 6px;
}
.menu .card .id { min-width: 0; }
.menu .card .name {
  font-size: 14px; font-weight: 500; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.menu .card .sub { font-size: 12px; color: var(--faint); }
.menu .sheet a,
.menu .sheet button {
  display: block; width: 100%; text-align: left; padding: 10px;
  min-height: 40px; line-height: 20px;
  border: 0; background: none; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
}
.menu .sheet a:hover,
.menu .sheet button:hover { background: var(--bg-tint); }
.menu .sheet form { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.menu .sheet form button { color: var(--muted); }

/* ---------------------------------------------------------------- category nav */

nav.cats {
  display: flex; gap: 2px; flex-wrap: wrap;
  max-width: 900px; margin: 0 auto 28px; padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
nav.cats a {
  display: flex; align-items: baseline; gap: 7px;
  padding: 9px 13px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 120ms ease, background 120ms ease;
}
nav.cats a:hover { color: var(--ink); background: var(--bg-tint); }
nav.cats a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
nav.cats a.push { margin-left: auto; }
/* Emphasised: something is waiting on you. */
nav.cats b {
  font-weight: 600; font-size: 11px; font-style: normal; color: var(--accent-ink);
  background: var(--accent-soft); border-radius: 20px; padding: 1px 7px;
}
/* De-emphasised: present, but nothing is owed. */
nav.cats i { font-style: normal; font-size: 12px; color: var(--faint); }

main {
  max-width: 900px; margin: 0 auto;
  padding: 0 24px 80px;
  /* Installed on a phone, the app owns the whole screen including the notch. */
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
.top { padding-top: calc(18px + env(safe-area-inset-top)); }

h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.03em; margin: 0 0 5px; }
.blurb { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
/* A quiet rule introducing the ambient group, so the break reads as deliberate. */
.divider {
  display: flex; align-items: center; gap: 12px; margin: 30px 0 14px;
  color: var(--faint); font-size: 13px;
}
.divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* --------------------------------------------------------------------- cruxes */

.crux {
  position: relative; display: block; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px 15px 19px; margin-bottom: 9px; box-shadow: var(--shadow);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.crux:hover { border-color: var(--faint); box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.crux .claim {
  font-weight: 500; margin-bottom: 6px; letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.crux .meta {
  color: var(--muted); font-size: 13px; display: flex; gap: 8px;
  flex-wrap: wrap; align-items: center;
}
/* The accent edge marks the one thing that matters: someone is waiting. */
.crux::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent); opacity: 0.85;
}
/* Ambient cruxes are present but visually quieter. Nothing is hidden. */
.crux.ambient { background: transparent; box-shadow: none; border-color: var(--line-soft); }
.crux.ambient::before { display: none; }
.crux.ambient .claim { font-weight: 400; color: var(--muted); }
.crux.ambient:hover { background: var(--panel); box-shadow: var(--shadow); }

.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; line-height: 1.6;
  border: 1px solid var(--line); color: var(--muted); text-transform: lowercase;
  background: var(--bg-tint);
}
.tag.hazard { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.tag.degraded { color: var(--faint); }

.empty {
  color: var(--muted); padding: 56px 24px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg-tint);
}
.empty p { margin: 0 0 6px; }
.empty .hint { font-size: 13px; color: var(--faint); max-width: 44ch; margin: 0 auto; }

/* -------------------------------------------------------------------- controls */

button, .btn {
  font: inherit; font-size: 13px; font-weight: 500; padding: 8px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer;
  display: inline-block; transition: border-color 120ms ease, background 120ms ease;
}
button:hover, .btn:hover { border-color: var(--faint); background: var(--bg-tint); }
/* Coarse pointers get the platform minimum target size. */
@media (pointer: coarse) {
  button, .btn { min-height: 44px; padding: 11px 16px; }
  nav.cats a { padding: 12px 13px; }
}
button.primary {
  background: var(--accent-fill); border-color: var(--accent-fill); color: #fff;
}
button.primary:hover { filter: brightness(1.12); }
button.danger:hover { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

input, select {
  font: inherit; width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--faint); }
.field { display: block; margin-bottom: 14px; }
.field .label { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 5px; }
.pair { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }

/* ---------------------------------------------------------------------- detail */

.detail {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.detail h1, .detail h2 {
  font-size: 20px; margin: 0 0 12px; font-weight: 600; letter-spacing: -0.02em;
}
.detail h3,
.detail h2.sub-head {
  font-size: 12px; font-weight: 600; color: var(--faint); margin: 28px 0 0;
  text-transform: uppercase; letter-spacing: 0.07em;
}
.kv {
  display: grid; grid-template-columns: 116px 1fr; gap: 9px 14px;
  font-size: 14px; margin: 18px 0; padding: 16px 0;
  border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.msg { border-top: 1px solid var(--line-soft); padding: 14px 0; font-size: 14px; }
.msg:last-child { padding-bottom: 0; }
.msg .from { font-weight: 500; }
.msg .sub { color: var(--muted); }
.msg .auth {
  font-size: 12px; color: var(--faint); margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------------------------------------------------------------------- rows */

.stream {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-width: 0;
  flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px; margin-bottom: 9px;
  box-shadow: var(--shadow);
}
.stream .who {
  font-weight: 500; color: var(--ink); font-size: 15px; overflow-wrap: anywhere;
}
.stream .sub {
  color: var(--muted); font-size: 13px; display: flex; gap: 8px;
  align-items: center; flex-wrap: wrap; margin-top: 2px;
}
.stream .actions { margin-top: 0; }
/* A status light, so a broken mailbox is legible before reading a word. */
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--faint);
  display: inline-block; flex: none;
}
.dot.ok { background: #3f9c62; }
.dot.bad { background: var(--warn); }

/* --------------------------------------------------------------------- login */

.login {
  max-width: 400px; margin: 12vh auto; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 34px 30px; box-shadow: var(--shadow);
}
.login h1 { margin-bottom: 8px; }
.login p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.login .fine { font-size: 13px; color: var(--faint); }
.login input { margin-bottom: 10px; text-align: center; }
.login button { width: 100%; padding: 11px; font-size: 14px; }

.notice {
  background: var(--accent-soft); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: 13px 15px; font-size: 14px; margin-bottom: 18px; text-align: left;
}
.notice.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.back {
  color: var(--muted); font-size: 14px; display: inline-block; margin-bottom: 16px;
}
.back:hover { color: var(--ink); }
.link { color: var(--accent-ink); }
.link:hover { text-decoration: underline; }

/* Small shared utilities, so views need no inline styles. */
.rail { margin-top: 26px; }
.flush { margin: 0; }
.fine-print { color: var(--muted); font-size: 13px; margin: 20px 0 0; }

@media (max-width: 560px) {
  .top, nav.cats, main { padding-left: 16px; padding-right: 16px; }
  /* One scrolling row beats a three-line wrap on a phone. */
  /* The scroll container must span the viewport, not a centred 900px box: a
     max-width block with auto margins still sizes to its flex content, so the
     row pushed the page wide instead of scrolling inside itself. Full-bleed
     here, with the padding restoring the gutter at each end of the scroll. */
  nav.cats {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%; max-width: 100%; margin-left: 0; margin-right: 0;
  }
  nav.cats::-webkit-scrollbar { display: none; }
  nav.cats a { flex: none; }
  nav.cats a.push { margin-left: 0; }
  .login { margin: 6vh auto; padding: 26px 20px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .pair { grid-template-columns: 1fr; }
  .stream { align-items: flex-start; }
}
