:root {
  --paper: #faf8f3;
  --ink: #1b1a17;
  --muted: #6b665c;
  --rule: #e4dfd3;
  --accent: #b4441c;
  --note-bg: #f3eee2;
  --card: #fffdf8;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16150f;
    --ink: #ece7db;
    --muted: #9c9587;
    --rule: #2e2b23;
    --accent: #e0774d;
    --note-bg: #211f18;
    --card: #1c1a14;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--serif);
}
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 20px 64px; }
.wrap.narrow { max-width: 420px; }
.muted { color: var(--muted); }

/* Masthead */
.masthead { text-align: center; padding: 48px 0 20px; border-bottom: 3px double var(--ink); }
.brand { font-size: clamp(2.2rem, 7vw, 3.4rem); font-weight: 700; letter-spacing: -0.02em; text-decoration: none; line-height: 1.1; }
.brand.small { font-size: 1.4rem; }
.tagline { margin: 8px 0 0; color: var(--muted); font-style: italic; }

/* Category nav */
.cats { border-bottom: 1px solid var(--rule); margin-bottom: 8px; }
.cats ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; list-style: none; margin: 0; padding: 12px 0; font: 600 0.8rem/1.4 var(--sans); text-transform: uppercase; letter-spacing: 0.08em; }
.cats a { text-decoration: none; color: var(--muted); }
.cats a span { font-weight: 400; opacity: 0.7; }
.cats a:hover, .cats a[aria-current] { color: var(--accent); }

/* Sections */
.section { margin-top: 40px; }
.section > h2, .page-title {
  font: 700 0.85rem/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
  margin: 0 0 4px;
}
.section > h2 a { text-decoration: none; }
.page-title { margin-top: 36px; }
.day-label { display: flex; align-items: center; gap: 12px; font: 500 0.8rem/1 var(--sans); color: var(--muted); margin: 28px 0 0; }
.day-label::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.more { margin: 12px 0 0; font: 600 0.9rem var(--sans); }
.more a { color: var(--accent); text-decoration: none; }

/* Items */
.item { display: grid; grid-template-columns: 1fr auto; gap: 0 20px; padding: 22px 0; border-bottom: 1px solid var(--rule); }
.item:last-of-type { border-bottom: 0; }
.source { margin: 0 0 4px; font: 500 0.75rem/1.3 var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.item h3 { margin: 0; font-size: 1.3rem; line-height: 1.3; font-weight: 700; }
.item h3 a { text-decoration: none; }
.desc { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden; }
.src-link {
  display: inline-block; margin-top: 8px; padding: 2px 8px; max-width: 100%;
  font: 0.72rem/1.5 var(--sans); color: var(--muted); text-decoration: none;
  border: 1px solid var(--rule); border-radius: 99px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.src-link:hover { color: var(--accent); border-color: var(--accent); }
.thumb img { width: 132px; height: 88px; object-fit: cover; border-radius: 4px; display: block; background: var(--rule); }
.note { grid-column: 1 / -1; margin-top: 14px; padding: 12px 16px; background: var(--note-bg); border-left: 3px solid var(--accent); border-radius: 0 4px 4px 0; }
.note p { margin: 0 0 8px; }
.note p:last-child { margin-bottom: 0; }
.note-label { display: block; font: 700 0.7rem/1 var(--sans); text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin-bottom: 6px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; font-style: italic; }

@media (max-width: 560px) {
  .thumb img { width: 84px; height: 64px; }
  .item h3 { font-size: 1.12rem; }
}

/* Forms */
label, legend { display: block; font: 600 0.8rem/1.4 var(--sans); margin: 14px 0 6px; }
input, textarea, button { font: inherit; font-family: var(--sans); font-size: 0.95rem; }
input[type="text"], input[type="email"], input[type="url"], input[type="password"], input:not([type]), textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[readonly] { opacity: 0.7; }
textarea { resize: vertical; line-height: 1.5; }
button {
  padding: 9px 18px; border: 0; border-radius: 6px; background: var(--ink); color: var(--paper); font-weight: 600; cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
button.secondary:hover { border-color: var(--accent); color: var(--accent); }
button.link { background: none; color: var(--muted); padding: 0; font-weight: 500; }
button.link:hover { color: var(--accent); }
button.danger:hover { color: #c0262d; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.row.actions { margin-top: 18px; gap: 16px; }
.hp { position: absolute; left: -9999px; }

.notice { font: 0.9rem/1.5 var(--sans); padding: 10px 14px; border-radius: 6px; margin: 12px 0 0; }
.notice.ok { background: #e3efe0; color: #24502a; }
.notice.err { background: #f6e1dc; color: #7a2413; }
@media (prefers-color-scheme: dark) {
  .notice.ok { background: #1f3322; color: #b7dcb9; }
  .notice.err { background: #3a1f19; color: #f0b8a8; }
}

/* Subscribe */
.subscribe { margin: 28px 0 8px; padding: 20px; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); }
.subscribe label { margin-top: 0; font-size: 0.95rem; }
.subscribe .hint { margin: 8px 0 0; font: 0.8rem var(--sans); color: var(--muted); }
.foot { margin-top: 56px; padding-top: 8px; border-top: 3px double var(--ink); text-align: center; font: 0.8rem var(--sans); color: var(--muted); }
.foot .subscribe { text-align: left; }

.pager { display: flex; justify-content: space-between; margin-top: 32px; font: 0.9rem var(--sans); color: var(--muted); }

/* Admin */
.admin-bar { display: flex; justify-content: space-between; align-items: center; padding: 24px 0 8px; border-bottom: 3px double var(--ink); }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 20px 22px; margin-top: 24px; }
.card h2 { margin: 0 0 4px; font-size: 1.2rem; }
.card > p { font-size: 0.95rem; }
.count { font: 600 0.8rem var(--sans); color: var(--muted); background: var(--note-bg); padding: 2px 8px; border-radius: 99px; vertical-align: middle; }
.cat-pick { border: 0; padding: 0; margin: 0; }
.cat-pick label { display: inline-flex; align-items: center; gap: 6px; margin: 0 14px 6px 0; font-weight: 500; cursor: pointer; }
#img-preview { display: block; margin-top: 10px; max-width: 240px; max-height: 140px; border-radius: 4px; }
#img-preview[hidden] { display: none; }
.bookmarklet { display: inline-block; margin-left: 6px; padding: 3px 10px; border: 1px dashed var(--accent); border-radius: 4px; color: var(--accent); text-decoration: none; font: 600 0.85rem var(--sans); cursor: grab; }
code { font-size: 0.85em; background: var(--note-bg); padding: 1px 5px; border-radius: 3px; }
.admin-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.95rem; }
.admin-list li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--rule); }
.admin-list .muted { font: 0.8rem var(--sans); }
.list-actions { display: flex; gap: 12px; flex-shrink: 0; font: 0.85rem var(--sans); }
