/* reader — hand-written site styles. Theme via CSS custom properties:
   light is the base, dark overrides under prefers-color-scheme. No
   framework, no JS required anywhere. */

:root {
  color-scheme: light dark;
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #26221c;
  --muted: #6b6459;
  --line: #ddd6c9;
  --accent: #8a4b2d;
  --accent-ink: #ffffff;
  --unread: #2d5d8a;
  --star: #a97b1f;
  --danger: #a03325;
  --flash-ok-bg: #e6efe2;
  --flash-err-bg: #f4e1dd;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #201d19;
    --panel: #2a2621;
    --ink: #e8e2d6;
    --muted: #a49a8a;
    --line: #453f36;
    --accent: #c98a5e;
    --accent-ink: #201d19;
    --unread: #7aa8cc;
    --star: #d1a545;
    --danger: #d16a5a;
    --flash-ok-bg: #2c3a28;
    --flash-err-bg: #462b26;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

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

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar .brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}

.topbar nav { display: flex; gap: 0.75rem; }

.topbar nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
}

.topbar nav a.active {
  color: var(--ink);
  background: var(--bg);
}

.badge {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.35em;
  border-radius: 999px;
  background: var(--unread);
  color: var(--panel);
  font-size: 0.78rem;
  text-align: center;
  vertical-align: 0.1em;
}

main.container {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.site-footer {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.flash { padding: 0.6rem 0.9rem; border-radius: 7px; margin: 0 0 1rem; }
.flash.ok { background: var(--flash-ok-bg); }
.flash.err { background: var(--flash-err-bg); }

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

form.stack label { display: block; margin: 0 0 0.75rem; }
form.stack label span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.2rem; }

input[type="text"], input[type="url"], input[type="password"],
input[type="number"], input[type="file"], select {
  width: 100%;
  max-width: 28rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

button {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  cursor: pointer;
}

button.quiet {
  background: transparent;
  color: var(--accent);
}

button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.inline-form { display: inline; }

/* ---- item list ---- */

.scope-tabs { display: flex; gap: 0.5rem; margin: 0 0 1rem; flex-wrap: wrap; }
.scope-tabs a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.scope-tabs a.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* Reading layout: source sidebar + list pane. The sidebar picks WHAT
   to read (folders/sources, unread counts), the pane-head tabs pick
   WHICH OF IT (unread/starred/all) — the two compose. */
.reading-layout {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.reading-layout > .side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 0.6rem;
}

.src-nav a {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.32rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.92rem;
}
.src-nav a:hover { background: var(--bg); }
.src-nav a.active { background: var(--accent); color: var(--accent-ink); }
.src-nav a .n {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.src-nav a.active .n { color: var(--accent-ink); }
.src-nav a.indent { padding-left: 1.85rem; }
.src-nav .group { margin: 0 0 1.1rem; }
.src-nav .group:last-child { margin-bottom: 0; }
.src-nav .group-name {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0.55rem 0.3rem;
}

.pane-head { display: flex; align-items: baseline; gap: 0.9rem; flex-wrap: wrap; margin: 0 0 0.9rem; }
.pane-head .sel-name { font-weight: 650; }
.pane-head .sel-edit { font-size: 0.85rem; }
.pane-head .scope-tabs { margin-left: auto; }

/* Phones: the fixed sidebar doesn't fit — swap it for a native
   <details> list (JS-free) above the pane. */
.side-mobile { display: none; }
@media (max-width: 720px) {
  .reading-layout { grid-template-columns: 1fr; gap: 0.75rem; }
  .reading-layout > .side { display: none; }
  .side-mobile {
    display: block;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 0.4rem 0.6rem;
  }
  .side-mobile summary { cursor: pointer; padding: 0.25rem 0; }
  .pane-head .scope-tabs { margin-left: 0; width: 100%; }
}

ul.items { list-style: none; margin: 0; padding: 0; }

ul.items li {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
}

ul.items li .title { text-decoration: none; color: var(--ink); }
ul.items li.unread .title { font-weight: 650; }
ul.items li .src { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
ul.items li .when { margin-left: auto; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
ul.items li .star { color: var(--star); }

.pager { display: flex; gap: 1rem; padding: 1rem 0; }

.empty { color: var(--muted); padding: 2rem 0; }

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

.item-head h1 { margin: 0 0 0.25rem; font-size: 1.45rem; line-height: 1.3; }
.item-head .meta { color: var(--muted); font-size: 0.88rem; margin: 0 0 1rem; }
.item-actions { display: flex; gap: 0.5rem; margin: 0 0 1.25rem; flex-wrap: wrap; }

/* The content canvas is ALWAYS light, in both themes: newsletters set
   their text colors inline (dark grays meant for a white background)
   but usually no background, so rendering them on the dark panel makes
   them unreadable. Fixed paper-white with fixed ink/link colors gives
   inline-styled email the canvas it was designed for and unstyled feed
   content consistent contrast. */
.item-content {
  background: #fdfdfb;
  color: #1c1c1c;
  color-scheme: light;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem 1.4rem;
  overflow-x: auto;
  overflow-wrap: break-word;
}

.item-content a { color: #8a4b2d; }
.item-content img { max-width: 100%; height: auto; }
.item-content pre.mail-text { white-space: pre-wrap; font: inherit; margin: 0; }

/* ---- subscriptions ---- */

.sub-section { margin: 0 0 2rem; }
.sub-section h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }

table.subs { width: 100%; border-collapse: collapse; }
table.subs th, table.subs td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.subs th { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
table.subs td.num { text-align: right; }
table.subs .kind { color: var(--muted); font-size: 0.82rem; }
table.subs .error { color: var(--danger); font-size: 0.82rem; }
table.subs code { font-size: 0.85rem; }

.add-forms { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.add-forms > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.1rem;
}
.add-forms h3 { margin: 0 0 0.6rem; font-size: 1rem; }
.hint { color: var(--muted); font-size: 0.85rem; }

/* ---- gate ---- */

.gate-wrap { max-width: 22rem; margin: 12vh auto 0; padding: 0 1rem; }
.gate-wrap h1 { font-size: 1.3rem; }
.gate-err { color: var(--danger); }
