/* scry — the deadcode neo-brutalist design system.
   Tokens (colors, fonts, borders, shadows) come from theme.css, which is
   generated from the org website by scripts/sync-theme.sh; this file only
   maps them onto the app's markup. Rules from the website's design guide:
   visible ink borders, solid offset shadows, 2px radius, one accent action
   per view, mono for anything a machine would print. */

/* ---------------------------------------------------------------- fonts */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/static/fonts/atkinson-hyperlegible-next-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/static/fonts/atkinson-hyperlegible-next-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

/* ----------------------------------------------------------------- base */

:root {
  /* aliases so the rules below read short */
  --canvas: var(--color-canvas);
  --surface: var(--color-surface);
  --ink: var(--color-ink);
  --muted: var(--color-muted);
  --rule: var(--color-rule);
  --accent: var(--color-accent);
  --danger: var(--color-danger);
  --info: var(--color-info);
  --b: var(--border-width-brut);
  --b-sm: var(--border-width-brut-sm);
  --sans: var(--font-sans);
  --mono: var(--font-mono);

  /* vertical rhythm — one scale, used everywhere so margins share a grid */
  --s1: 0.5rem;
  --s2: 0.75rem;
  --s3: 1rem;
  --s4: 1.5rem;
  --s5: 2.5rem;
  --s6: 3.5rem;
}

/* ------------------------------------------------------------ dark mode
   Follows the OS unless the toggle (theme.js) set data-theme on <html>.
   theme.css is light-only (generated), so redefine the tokens scry uses;
   the brutalist shadows are built from --color-ink, so they flip to light
   offsets and still read on a dark canvas. Accent lime stays put, so
   anything painted on accent/tint needs dark text in either theme:
   --on-accent. Overrides are prefixed with :root so they outrank the later
   light-mode rules without touching them.

   The dark rules appear twice (OS preference, explicit choice) because CSS
   cannot share a block across a media query and an attribute selector.
   THE TWO COPIES MUST MATCH: edit one, edit the other. */

:root {
  color-scheme: light dark;
  --on-accent: #0b0b0b;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-canvas: #0e0e0c;
    --color-surface: #1a1a17;
    --color-ink: #f2f1ec;
    --color-muted: #a9a89f;
    --color-rule: #6b6a62;
    --color-info: #8c9dff; /* link underline + focus ring need 3:1 on dark */
  }

  /* text on accent / tint fills */
  :root:not([data-theme="light"]) ::selection,
  :root:not([data-theme="light"]) .skip:focus,
  :root:not([data-theme="light"]) a:not(.btn):hover,
  :root:not([data-theme="light"]) .brand .tile,
  :root:not([data-theme="light"]) header nav a:hover,
  :root:not([data-theme="light"]) header nav a[aria-current],
  :root:not([data-theme="light"]) button:not(.ghost):not(.danger),
  :root:not([data-theme="light"]) .badge.attn,
  :root:not([data-theme="light"]) .flash,
  :root:not([data-theme="light"]) .secret,
  :root:not([data-theme="light"]) .consent .warn {
    color: var(--on-accent);
  }

  /* hover states that do not paint accent keep ink text */
  :root:not([data-theme="light"]) .cards a:hover,
  :root:not([data-theme="light"]) .brand a:hover {
    color: var(--ink);
  }

  /* the ink-coloured footer would be a glaring light bar; keep it dark */
  :root:not([data-theme="light"]) footer {
    background: var(--surface);
    color: var(--ink);
  }

  /* inverted code block inside the accent box: stay dark, text light */
  :root:not([data-theme="light"]) .secret pre {
    background: var(--on-accent);
    color: var(--color-ink);
  }

  /* dot-grid texture at full ink is too loud on dark */
  :root:not([data-theme="light"]) main:has(> .auth) {
    background-image: radial-gradient(var(--rule) 1px, transparent 1px);
  }
}

/* explicit choice; keep identical to the media block above */
:root[data-theme="dark"] {
  --color-canvas: #0e0e0c;
  --color-surface: #1a1a17;
  --color-ink: #f2f1ec;
  --color-muted: #a9a89f;
  --color-rule: #6b6a62;
  --color-info: #8c9dff; /* link underline + focus ring need 3:1 on dark */
}

/* text on accent / tint fills */
:root[data-theme="dark"] ::selection,
:root[data-theme="dark"] .skip:focus,
:root[data-theme="dark"] a:not(.btn):hover,
:root[data-theme="dark"] .brand .tile,
:root[data-theme="dark"] header nav a:hover,
:root[data-theme="dark"] header nav a[aria-current],
:root[data-theme="dark"] button:not(.ghost):not(.danger),
:root[data-theme="dark"] .badge.attn,
:root[data-theme="dark"] .flash,
:root[data-theme="dark"] .secret,
:root[data-theme="dark"] .consent .warn {
  color: var(--on-accent);
}

/* hover states that do not paint accent keep ink text */
:root[data-theme="dark"] .cards a:hover,
:root[data-theme="dark"] .brand a:hover {
  color: var(--ink);
}

/* the ink-coloured footer would be a glaring light bar; keep it dark */
:root[data-theme="dark"] footer {
  background: var(--surface);
  color: var(--ink);
}

/* inverted code block inside the accent box: stay dark, text light */
:root[data-theme="dark"] .secret pre {
  background: var(--on-accent);
  color: var(--color-ink);
}

/* dot-grid texture at full ink is too loud on dark */
:root[data-theme="dark"] main:has(> .auth) {
  background-image: radial-gradient(var(--rule) 1px, transparent 1px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection {
  background: var(--accent);
  color: var(--ink);
}

:focus-visible {
  outline: var(--b) solid var(--info);
  outline-offset: 3px;
}

/* inline links: the website's .link */
a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--info);
  text-decoration-thickness: var(--b);
  text-underline-offset: 4px;
}

a:hover {
  background: var(--accent);
}

/* "brut-press": hover lifts, active presses flat */
button,
a.btn,
.confirm > summary,
.cards a {
  transition: translate 75ms ease-out, box-shadow 75ms ease-out;
}

button:hover,
a.btn:hover,
.confirm > summary:hover,
.cards a:hover {
  box-shadow: var(--shadow-brut-lift);
  translate: -2px -2px;
}

button:active,
a.btn:active,
.confirm > summary:active,
.cards a:active {
  box-shadow: none;
  translate: 4px 4px;
}

@media (prefers-reduced-motion: reduce) {
  button:hover,
  a.btn:hover,
  .confirm > summary:hover,
  .cards a:hover,
  button:active,
  a.btn:active,
  .confirm > summary:active,
  .cards a:active {
    translate: none;
  }
}

/* skip link — first focusable element, hidden until focused */
.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 0;
  top: 0;
  z-index: 30;
  background: var(--accent);
  padding: 0.75rem;
}

/* --------------------------------------------------------------- chrome */

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--canvas);
  border-bottom: var(--b) solid var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand a {
  text-decoration: none;
}

.brand a:hover {
  background: none;
}

.brand .sep {
  font-family: var(--mono);
  font-weight: 400;
  color: var(--muted);
}

.brand .tile {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  font: 700 0.875rem var(--mono);
  background: var(--accent);
  border: var(--b) solid var(--ink);
  box-shadow: var(--shadow-brut-sm);
}

.brand .dim {
  color: var(--muted);
}

header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

header nav a {
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  padding: 0.25rem 0.75rem;
  border: var(--b-sm) solid transparent;
}

/* "page" on the current page, "true" on a page below it (one feed under
   /feeds): both light the link up */
header nav a:hover,
header nav a[aria-current] {
  background: var(--accent);
  border-color: var(--ink);
}

.who {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font: 0.75rem var(--mono);
  color: var(--muted);
}

.who form {
  margin: 0;
}

/* the signed-in user is a small tile with the email's first letter; the full
   address is the title and screen-reader text, so it can never crowd the bar */
.who .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
  background: var(--accent);
  color: var(--ink);
  border: var(--b) solid var(--ink);
  border-radius: var(--radius-brut);
  font: 700 0.875rem var(--mono);
  text-transform: uppercase;
  cursor: default;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* own element beside .who; button's inline-flex would beat [hidden] */
.theme-toggle {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  box-shadow: var(--shadow-brut-sm);
}

.theme-toggle[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .theme-toggle {
    min-height: 2.75rem;
  }
}

main {
  /* grow to push the footer down; content sits at a deliberate top offset */
  flex: 1 0 auto;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: var(--s6) 1.5rem var(--s5);
}

/* table-heavy pages opt into a wider measure */
main.wide {
  max-width: 72rem;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.5rem;
  background: var(--ink);
  color: var(--canvas);
  border-top: var(--b) solid var(--ink);
  font: 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

footer a {
  text-decoration-color: var(--accent);
}

footer a:hover {
  color: var(--ink);
}

footer .hex {
  color: var(--accent);
  text-transform: none;
}

/* ----------------------------------------------------------- typography */

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.025em;
  margin: 0 0 var(--s5);
}

/* the website's section header: a mono eyebrow over a hairline rule */
h2 {
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin: var(--s5) 0 var(--s3);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5rem;
}

p {
  margin: 0 0 var(--s3);
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.875em;
}

.muted {
  color: var(--muted);
}

.note,
.footnote {
  color: var(--muted);
  font-size: 0.875rem;
}

.footnote {
  margin-top: var(--s3);
}

/* a small back link above the page content */
.backlink {
  font: 0.75rem var(--mono);
  margin: calc(-1 * var(--s4)) 0 var(--s4);
}

/* ---------------------------------------------------------------- forms */

label {
  display: block;
  margin-bottom: 1.25rem;
}

label span {
  display: block;
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  border: var(--b) solid var(--ink);
  border-radius: var(--radius-brut);
  box-shadow: var(--shadow-brut-sm);
  padding: 0.75rem 1rem;
  font: 0.875rem var(--mono);
}

input:focus,
select:focus,
textarea:focus {
  box-shadow: var(--shadow-brut);
}

input[readonly] {
  background: var(--canvas);
  color: var(--muted);
  border-style: dashed;
  box-shadow: none;
}

label.checkbox input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--ink);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.form-row label {
  flex: 1 1 14rem;
  margin: 0;
}

.form-row .narrow {
  flex: 0 1 14rem;
}

/* -------------------------------------------------------------- buttons */

/* a bare <button> is the primary (.btn-primary); .ghost is the secondary
   (.btn); .danger is destructive. */
button,
a.btn,
.confirm > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font: 700 0.875rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--ink);
  background: var(--accent);
  border: var(--b) solid var(--ink);
  border-radius: var(--radius-brut);
  box-shadow: var(--shadow-brut);
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  user-select: none;
}

button.danger,
.confirm > summary {
  background: var(--danger);
  color: var(--surface);
}

button.ghost,
a.btn,
.confirm.neutral > summary {
  background: var(--surface);
  color: var(--ink);
}

/* small buttons (.btn-sm) wherever they sit in a row or the header */
.who button,
td button,
td a.btn,
.confirm > summary,
.confirm-pop button,
.secret button {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  box-shadow: var(--shadow-brut-sm);
}

a.btn:hover {
  background: var(--surface);
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.actions form {
  display: inline;
  margin: 0;
}

/* ------------------------------------------------------ inline confirm */

/* A JS-free, two-step confirm for irreversible actions. The <summary> is the
   trigger styled like a button; opening the <details> reveals the real submit
   inline. Keyboard-accessible for free, and the form still works without CSS. */
.confirm {
  display: inline-block;
  position: relative;
}

.confirm > summary {
  list-style: none;
}

.confirm > summary::-webkit-details-marker {
  display: none;
}

.confirm[open] > summary {
  box-shadow: none;
  translate: 2px 2px;
}

.confirm-pop {
  position: absolute;
  z-index: 10;
  right: 0;
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  /* cap the width and let the prompt text wrap: a long email in the message
     must not stretch the popover off the column edge and clip the button */
  width: max-content;
  max-width: min(20rem, 80vw);
  background: var(--surface);
  border: var(--b) solid var(--ink);
  box-shadow: var(--shadow-brut);
  padding: 0.75rem;
  font-size: 0.875rem;
}

.confirm-pop > span {
  overflow-wrap: anywhere;
}

.confirm-pop form {
  display: inline;
  margin: 0;
  flex: 0 0 auto;
}

/* --------------------------------------------------------------- tables */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: var(--b) solid var(--ink);
  border-radius: var(--radius-brut);
  box-shadow: var(--shadow-brut);
}

/* the confirm popovers must escape the scroll box when there is room */
@media (min-width: 601px) {
  .table-wrap {
    overflow: visible;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--canvas);
  border-bottom: var(--b) solid var(--ink);
  padding: 0.75rem;
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* dates/times read as data: mono, tabular */
td.muted {
  font: 0.75rem var(--mono);
  font-variant-numeric: tabular-nums;
}

tbody tr:hover td {
  background: var(--canvas);
}

/* ----------------------------------------------------------- components */

.badge {
  display: inline-flex;
  align-items: center;
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
  border: var(--b-sm) solid var(--ink);
  padding: 0.125rem 0.5rem;
  white-space: nowrap;
}

.badge.attn {
  background: var(--accent);
}

.badge.off {
  color: var(--muted);
}

.badge.bad {
  background: var(--danger);
  color: var(--surface);
}

/* callouts: a brut box with a thick left edge */
.error,
.flash {
  border: var(--b) solid var(--ink);
  border-left-width: 12px;
  box-shadow: var(--shadow-brut);
  padding: 0.75rem 1rem;
  margin-bottom: var(--s4);
  font-weight: 700;
}

.error {
  background: var(--danger);
  color: var(--surface);
}

.flash {
  background: var(--accent);
}

/* a framed block of "output" */
.panel {
  background: var(--surface);
  border: var(--b) solid var(--ink);
  border-radius: var(--radius-brut);
  box-shadow: var(--shadow-brut);
  padding: 1.25rem;
  margin-bottom: var(--s5);
}

.panel .status {
  margin: 0 0 1rem;
}

.panel .caption {
  color: var(--muted);
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-right: 0.5rem;
}

/* key/value rows rendered like aligned config output: LABEL ···· value */
.kv {
  margin: 0;
}

.kv .row {
  display: flex;
  align-items: baseline;
  gap: 0 0.6ch;
  padding: 0.25rem 0;
}

.kv dt {
  flex: 0 0 auto;
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.kv .lead {
  flex: 1 1 auto;
  align-self: stretch;
  border-bottom: 2px dotted var(--rule);
  transform: translateY(-0.3em);
  min-width: 1.5rem;
}

.kv dd {
  flex: 0 1 auto;
  margin: 0;
  text-align: right;
  font: 0.875rem var(--mono);
  overflow-wrap: anywhere;
}

/* one-time reveal of a freshly created secret (API key, invite link) — the
   loudest moment in the app: accent box, biggest shadow, an ink code block */
.secret {
  background: var(--accent);
  border: var(--b) solid var(--ink);
  box-shadow: var(--shadow-brut-lg);
  padding: 1.25rem;
  margin: var(--s4) 0 var(--s5);
}

.secret .warn {
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
}

/* click selects the whole value (the JS-free copy affordance) */
.secret pre {
  margin: 0 0 0.75rem;
  padding: 1rem;
  background: var(--ink);
  color: var(--canvas);
  border: var(--b) solid var(--ink);
  overflow-x: auto;
  cursor: pointer;
  user-select: all;
  -webkit-user-select: all;
}

.secret .hint {
  font-size: 0.875rem;
  margin: 0;
}

/* "no output" */
.empty {
  color: var(--muted);
  border: var(--b) dashed var(--rule);
  padding: 1.25rem;
  font: 0.875rem var(--mono);
}

/* the website's AppCard: pressable tiles with a launch arrow */
.cards {
  list-style: none;
  margin: var(--s5) 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1.5rem;
}

.cards a {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  background: var(--surface);
  border: var(--b) solid var(--ink);
  border-radius: var(--radius-brut);
  box-shadow: var(--shadow-brut);
  padding: 1.25rem;
  text-decoration: none;
  font-weight: 400;
}

.cards a:hover {
  background: var(--surface);
}

.cards strong {
  font-size: 1.25rem;
}

.cards span {
  color: var(--muted);
  font-size: 0.875rem;
}

.cards a::after {
  content: "Open →";
  margin-top: auto;
  padding-top: 0.75rem;
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------------------------------------------------------- auth screens */

/* login / signup / reset: one raised card on the dot-grid hero texture */
main:has(> .auth) {
  max-width: none;
  background-image: radial-gradient(var(--ink) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -11px -11px;
}

.auth {
  max-width: 28rem;
  margin: 4vh auto 0;
  background: var(--surface);
  border: var(--b) solid var(--ink);
  border-radius: var(--radius-brut);
  box-shadow: var(--shadow-brut-lg);
  padding: 2rem;
}

.auth h1 {
  font-size: 2rem;
  margin-bottom: var(--s4);
}

.auth button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
}

.auth .note {
  margin: var(--s4) 0 0;
}

/* --------------------------------------------------- oauth: consent + apps */

/* The consent screen is a decision, not a report, so it is boxed as one
   self-contained thing the user acts on. */
.consent {
  background: var(--surface);
  border: var(--b) solid var(--ink);
  box-shadow: var(--shadow-brut-lg);
  padding: 1.5rem;
  margin: var(--s4) 0;
}

.consent-lede {
  margin-top: 0;
  font-size: 1.125rem;
}

.consent .warn {
  background: var(--color-tint-2);
  border: var(--b) solid var(--ink);
  border-left-width: 12px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin: var(--s4) 0;
}

/* What an app is being granted, as a checklist rather than prose — the point is
   that it is scannable before clicking Approve. */
.scopes {
  list-style: none;
  padding-left: 0;
  margin: var(--s2) 0;
}

.scopes li {
  border-left: var(--b) solid var(--ink);
  padding: 0.25rem 0 0.25rem 0.75rem;
  margin-bottom: 0.5rem;
  font: 0.875rem var(--mono);
}

/* the same list inside a table cell, where it has to stay compact */
.scopes.tight {
  margin: 0;
}

.scopes.tight li {
  border-left: 0;
  padding: 0;
  margin: 0;
  font-size: 0.75rem;
}

/* registered redirect URIs in the admin clients table */
.uris {
  list-style: none;
  padding-left: 0;
  margin: 0;
  font-size: 0.8rem;
}

.uris li + li {
  margin-top: 0.25rem;
}

/* ------------------------------------------------------------- responsive */

/* On phones the multi-column tables would scroll off-screen (and hide the
   action buttons). Collapse each row into a stacked card, labelling cells
   from their header text via data-label. */
@media (max-width: 600px) {
  header {
    padding: 0.75rem 1rem;
  }

  main {
    padding: var(--s5) 1rem var(--s4);
  }

  .auth {
    padding: 1.25rem;
  }

  .table-wrap {
    background: none;
    border: 0;
    box-shadow: none;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap thead {
    position: absolute;
    left: -9999px;
  }

  .table-wrap tr {
    background: var(--surface);
    border: var(--b) solid var(--ink);
    box-shadow: var(--shadow-brut);
    margin-bottom: 1rem;
    padding: 0.75rem;
  }

  .table-wrap td {
    border: none;
    padding: 0.25rem 0;
  }

  tbody tr:hover td {
    background: none;
  }

  .table-wrap td::before {
    content: attr(data-label);
    display: block;
    font: 700 0.75rem var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }

  /* cells with no header (the actions column) shouldn't print an empty label */
  .table-wrap td[data-label=""]::before {
    display: none;
  }

  .confirm-pop {
    right: auto;
    left: 0;
  }
}

/* ---------------------------------------------------------------- posts */

/* One post rendering on every page (posts.html): a compact row (excerpt
   lists, read posts, link-only posts), or the expanded card with the full
   body (unread posts in a subscription, any post with a body on a feed's
   page signed in). */
.posts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 5rem;
}

.post.card {
  margin: var(--s3) 0 var(--s5);
  padding: 0;
  border-bottom: 0;
}

.post.card article {
  background: var(--surface);
  border: var(--b) solid var(--ink);
  border-radius: var(--radius-brut);
  box-shadow: var(--shadow-brut);
  padding: 1.25rem 1.75rem 1.5rem;
}

/* title and meta on the left, the card's top Mark read on the right */
.post-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.post-title {
  flex: 1 1 auto;
  min-width: 0;
}

.mark-top {
  flex: none;
}

.mark-top form {
  margin: 0;
}

.post.card .post-head {
  margin-bottom: var(--s4);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--rule);
}

/* post titles are h2 (no level skipped under the page's h1), so undo the
   h2 eyebrow style */
.post h2 {
  font: 700 1.125rem/1.3 var(--sans);
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  border: 0;
  padding: 0;
  margin: 0 0 0.25rem;
  overflow-wrap: anywhere;
}

.post.card h2 {
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 0.375rem;
}

/* a list of titles reads better unruled: underline only on hover/focus,
   and visited ones fade */
.post h2 a {
  text-decoration: none;
}

.post h2 a:hover,
.post h2 a:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--info);
}

.post h2 a:visited,
.post.read h2,
.post.read h2 a {
  color: var(--muted);
}

/* off-site cue on story and discussion links. [href^="http"] is exactly the
   external ones: the feed-name link is a relative path, and an unsafe URL
   renders as #ZgotmplZ. The first content declaration is the fallback for
   browsers without alt-text syntax; the second gives the arrow an empty
   alt, so screen readers do not announce it on every link. */
.post h2 a[href^="http"]::after,
.item-meta a[href^="http"]::after {
  content: "↗";
  content: "↗" / "";
  margin-left: 0.25em;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
}

.item-meta,
.feed-meta {
  font: 0.75rem var(--mono);
  color: var(--muted);
  margin: 0 0 var(--s1);
}

/* the item line carries up to five fields, so it gets more size than the
   feed header's; --muted on --canvas is 6.6:1, past AA's 4.5:1 */
.item-meta {
  font-size: 0.875rem;
  line-height: 1.5;
}

.feed-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: var(--s4);
}

/* the feed's address, easy to copy; user-select: all picks the whole URL on
   one click without any script */
.feed-url {
  margin-bottom: var(--s4);
}

.feed-url label {
  margin-bottom: 0;
}

.feed-url input {
  user-select: all;
  color: var(--ink);
}

.post-head .item-meta {
  margin: 0;
}

.item-meta .badge {
  font-size: 0.625rem;
  padding: 0 0.375rem;
}

.excerpt {
  margin: var(--s1) 0 0;
  overflow-wrap: anywhere;
}

.posts .more {
  padding-top: var(--s4);
}

.posts .more .count {
  font: 0.75rem var(--mono);
  color: var(--muted);
}

/* htmx puts .htmx-request on the Older link while it loads (its own
   indicator styles are off for the CSP); this is the loading state and
   stops a second click */
.posts .more a.htmx-request {
  opacity: 0.6;
  cursor: progress;
  pointer-events: none;
}

.posts .more a.htmx-request::after {
  content: "…";
}

.posts .end {
  padding-top: var(--s4);
  text-align: center;
  font: 0.75rem var(--mono);
  color: var(--muted);
}

/* the catalog's site host under a feed name: a hint, not a second link */
.site-host {
  color: var(--muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

/* long feed URLs and errors must wrap inside table cells */
td code {
  overflow-wrap: anywhere;
}

.last-error summary {
  cursor: pointer;
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.last-error code {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
}

@media (max-width: 600px) {
  /* a sticky header eats too much of a phone screen */
  header {
    position: static;
  }

  /* the links in an item's meta line (feed, discussion) are small text; pad them to a
     comfortable tap target without changing the markup */
  .item-meta a {
    display: inline-block;
    padding: 0.625rem 0;
  }
}

/* -------------------------------------------------------------- reading */

/* Tap targets on this page: at least 32px on desktop, 44px on phones
   (--tap, raised in the phone block below). */
:root {
  --tap: 2rem;
  /* fixed, not theme tokens: see .prose pre */
  --code-bg: #0b0b0b;
  --code-fg: #f2f1ec;
}

/* visually hidden, still read aloud */
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* count, view switch, mark-all: one row on desktop */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  margin: calc(-1 * var(--s3)) 0 var(--s3);
}

/* the negative margin tucks the toolbar under a visible h1; below a feed's
   header or a visually hidden h1 it keeps its normal gap */
.sub + #reading-panel .toolbar,
.vh + #reading-panel .toolbar,
.vh + .toolbar {
  margin-top: 0;
}

/* segmented view switch: Unread | Following | Everything, or Unread | All */
.seg {
  display: inline-flex;
  border: var(--b-sm) solid var(--ink);
  box-shadow: var(--shadow-brut-sm);
  background: var(--surface);
}

.seg a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  padding: 0 0.875rem;
}

.seg .n {
  margin-left: 0.375rem;
  font-variant-numeric: tabular-nums;
}

.seg a + a {
  border-left: var(--b-sm) solid var(--ink);
}

.seg a[aria-current],
.seg a[aria-current]:hover {
  background: var(--ink);
  color: var(--canvas);
}

.mark-all {
  margin: 0 0 0 auto;
}

.mark-all button {
  min-height: var(--tap);
  padding: 0.375rem 1rem;
  font-size: 0.75rem;
}

/* subscribed feeds as filter chips, each with its unread count; they wrap,
   so the current one is always in view */
.sub-feeds {
  margin: 0 0 var(--s5);
  padding-bottom: var(--s3);
  border-bottom: var(--b) solid var(--ink);
}

.sub-feeds ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sub-feeds li {
  max-width: 100%;
}

.sub-feeds a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  max-width: min(22rem, 100%);
  min-height: var(--tap);
  font: 700 0.75rem var(--mono);
  text-decoration: none;
  padding: 0 0.625rem;
  background: var(--surface);
  border: var(--b-sm) solid var(--ink);
  white-space: nowrap;
}

/* a long feed name truncates; the count beside it never does */
.sub-feeds .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-feeds a[aria-current] {
  background: var(--accent);
  color: var(--on-accent); /* dark text on lime in both themes */
  box-shadow: var(--shadow-brut-sm);
}

.sub-feeds .paused {
  font-weight: 400;
  color: var(--muted);
}

.count {
  font: 700 0.6875rem/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
  background: var(--ink);
  color: var(--canvas);
  padding: 0 0.375rem;
  border-radius: var(--radius-brut);
}

.count:empty {
  display: none;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.post.card .post-actions {
  margin-top: var(--s4);
  padding-top: var(--s3);
  border-top: 1px solid var(--rule);
}

.post-actions form {
  margin: 0 0 0 auto;
}

.post-actions button,
.post-actions a.btn,
.mark-top button,
.sub button {
  min-height: var(--tap);
  padding: 0.25rem 0.875rem;
  font-size: 0.75rem;
  box-shadow: var(--shadow-brut-sm);
}

/* a read post's body, on demand */
.reread {
  flex: 1 1 100%;
  order: 2;
}

.reread > summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  cursor: pointer;
  font: 700 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-right: 0.5rem;
}

.reread[open] > .prose {
  margin-top: var(--s2);
  padding-top: var(--s3);
  border-top: 1px dashed var(--rule);
}

/* in-flight actions (htmx puts .htmx-request on the form; its own
   indicator styles are off for the CSP) */
.post form.htmx-request button,
.mark-all.htmx-request button,
.sub form.htmx-request button {
  opacity: 0.6;
  cursor: progress;
}

.caught-up {
  background: var(--accent);
  color: var(--on-accent);
  border: var(--b) solid var(--ink);
  box-shadow: var(--shadow-brut);
  padding: 1.25rem 1.5rem;
}

.caught-up p:last-child {
  margin: 0;
}

/* subscribe control: catalog cell and a feed's page */
.sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.sub form {
  margin: 0;
}

.sub-state {
  font: 0.75rem var(--mono);
  color: var(--muted);
}

.feed-meta + .sub {
  margin: calc(-1 * var(--s2)) 0 var(--s4);
}

/* ----------------------------------------------------- article content */

/* Feed HTML, sanitized at ingest. Everything here must hold up against
   arbitrary markup: headings of any level, wide images, tables and code.
   Ingest demotes headings two levels (h1 -> h3), so content normally
   starts at h3; h1 and h2 still come from rows stored before that. */
.prose {
  font-size: 1.0625rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose dl,
.prose figure,
.prose table,
.prose pre,
.prose blockquote {
  margin: 0 0 1.1em;
}

.prose a {
  font-weight: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  font: 700 1rem/1.3 var(--sans);
  letter-spacing: -0.005em;
  text-transform: none;
  color: var(--ink);
  border: 0;
  padding: 0;
  margin: 1.6em 0 0.5em;
}

.prose h1,
.prose h2,
.prose h3 {
  font-size: 1.3125rem;
}

.prose h4 {
  font-size: 1.125rem;
}

.prose h6 {
  font-size: 0.9375rem;
  color: var(--muted);
}

.prose img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

/* a picture on its own line gets the brut frame */
.prose p > img:only-child,
.prose figure img {
  display: block;
  border: var(--b-sm) solid var(--ink);
}

.prose figure {
  margin-left: 0;
  margin-right: 0;
}

.prose figcaption {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.prose ul,
.prose ol {
  padding-left: 1.5em;
}

.prose li + li {
  margin-top: 0.25em;
}

.prose li > ul,
.prose li > ol {
  margin: 0.25em 0 0;
}

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 0.5em 1em;
  border-left: 6px solid var(--ink);
  background: var(--canvas);
}

.prose blockquote > :last-child {
  margin-bottom: 0;
}

.prose code {
  font-size: 0.875em;
  background: var(--canvas);
  border: 1px solid var(--rule);
  padding: 0.05em 0.3em;
  border-radius: var(--radius-brut);
}

/* code blocks stay dark in both themes (an ink block would turn into a
   glaring light slab in dark mode); the border keeps their edge visible on
   the dark canvas */
.prose pre {
  overflow-x: auto;
  padding: 1rem 1.125rem;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-brut);
  line-height: 1.5;
  font-size: 0.8125rem;
}

.prose pre code {
  font-size: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

/* Tables can't be wrapped without rewriting the HTML, so the table box
   itself scrolls. Cells never break inside a word (the .prose default
   would let a narrow screen squeeze them to a letter per line), so a wide
   table overflows and scrolls instead of crushing its columns. */
.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9375rem;
  /* room for the collapsed outer border, which the scroll box would clip */
  padding: 1px;
}

.prose th,
.prose td {
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  text-align: left;
  vertical-align: top;
  background: none;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--rule);
  overflow-wrap: normal;
  word-break: normal;
  min-width: 4rem;
}

.prose th {
  font-weight: 700;
  background: var(--canvas);
  white-space: nowrap;
}

.prose tbody tr:hover td {
  background: none;
}

.prose hr {
  border: 0;
  border-top: 2px dashed var(--rule);
  margin: 2em 0;
}

.prose dt {
  font-weight: 700;
}

.prose dd {
  margin: 0 0 0.5em 1.25em;
}

.prose sup,
.prose sub {
  line-height: 0;
}

@media (max-width: 600px) {
  :root {
    --tap: 2.75rem;
  }

  .toolbar {
    margin-top: calc(-1 * var(--s2));
  }

  .mark-all {
    flex: 1 1 100%;
    margin: 0;
  }

  .mark-all button {
    width: 100%;
  }

  .post.card {
    margin-bottom: var(--s4);
  }

  .post.card article {
    padding: 0.75rem 1rem 1rem;
    box-shadow: var(--shadow-brut-sm);
  }

  .post.card h2 {
    font-size: 1.25rem;
  }

  .prose {
    font-size: 1rem;
  }

  /* the bottom actions split the row for thumbs */
  .post.card .post-actions a.btn,
  .post.card .post-actions form {
    flex: 1 1 0;
  }

  .post.card .post-actions button,
  .post.card .post-actions a.btn {
    width: 100%;
  }
}
