:root {
  --bg: #f6f4ef; --card: #ffffff; --text: #1d1b18; --muted: #6f6a62; --line: #e4dfd5;
  --accent: #b4441f; --accent-text: #ffffff; --star: #e0a100; --rec: #2f7d4f; --error: #b3261e;
  --radius: 12px; --shadow: 0 1px 3px rgba(0,0,0,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140f; --card: #211f1a; --text: #ece7dd; --muted: #a39d92; --line: #36332b;
    --accent: #e8734a; --accent-text: #1a0d07; --star: #f2c14e; --rec: #6cc28f; --error: #f2857d;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
img { max-width: 100%; }
h1 { font-size: 1.6rem; margin: .4em 0 .6em; }
h2 { font-size: 1.1rem; margin: 0 0 .8em; }
main { max-width: 980px; margin: 0 auto; padding: 16px; min-height: 70vh; }
main.narrow { max-width: 420px; padding-top: 8vh; }
footer { text-align: center; color: var(--muted); font-size: .75rem; padding: 24px 16px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 16px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--accent); letter-spacing: -.02em; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: .95rem; }
.topbar nav a { text-decoration: none; color: var(--muted); }
.topbar nav a:hover { color: var(--text); }
.logo { text-align: center; color: var(--accent); font-size: 2.2rem; letter-spacing: -.03em; }

/* forms & buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .95rem; }
label small { font-weight: 400; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); padding: 8px 14px; }
button.primary { background: var(--accent); color: var(--accent-text); border: 0; font-weight: 700; padding: 11px 18px; }
button.small { padding: 4px 10px; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; }
button.danger { color: var(--error); }
form.inline { display: inline; }
.error { color: var(--error); font-weight: 600; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.flash { background: var(--card); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.flash .copy { margin-top: 8px; font-family: ui-monospace, monospace; font-size: .85rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; margin: 0; }
.tag.rec { color: var(--rec); border-color: var(--rec); }
.stars { color: var(--star); letter-spacing: 1px; white-space: nowrap; }

/* search */
.searchbar { margin-bottom: 16px; }
.searchbar input { font-size: 1.05rem; padding: 12px 14px; background: var(--card); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.tile .poster { width: 100%; height: auto; aspect-ratio: 2/3; }
.tile-name { font-weight: 600; line-height: 1.25; margin-top: 4px; }

/* posters */
.poster { width: 72px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; background: var(--line); display: block; }
.poster.blank { display: flex; align-items: center; justify-content: center; text-align: center; font-size: .7rem;
  padding: 4px; color: var(--muted); overflow: hidden; }
.poster.tiny { width: 36px; }
.poster.big { width: 160px; flex-shrink: 0; }

/* home */
.home { display: grid; gap: 24px; }
@media (min-width: 760px) { .home { grid-template-columns: 1fr 260px; } .watchlist { order: 2; } }
.entry { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.entry-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.who { font-size: .9rem; color: var(--muted); }
.who a { color: var(--text); font-weight: 700; text-decoration: none; }
.entry-title { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.watchlist .mini { display: flex; gap: 10px; align-items: center; text-decoration: none; padding: 6px 0; }
.pager { display: flex; justify-content: space-between; padding: 16px 0; }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-bottom: 8px;
  border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.tabs a { text-decoration: none; color: var(--muted); }
.tabs a.on { color: var(--text); font-weight: 700; }
.tabs .sort { margin-left: auto; color: var(--muted); font-size: .9rem; display: flex; gap: 10px; }

/* title page */
.title-head { display: flex; gap: 20px; margin-bottom: 20px; }
.title-head h1 { margin-top: 0; }
.avg { font-size: 1.05rem; margin: .5em 0; }
@media (max-width: 560px) {
  .title-head { flex-direction: column; }
  .poster.big { width: 140px; }
}
.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented label { flex: 1; flex-direction: row; justify-content: center; align-items: center; gap: 6px;
  padding: 10px; cursor: pointer; font-weight: 600; }
.segmented label:has(input:checked) { background: var(--accent); color: var(--accent-text); }
.segmented input { width: auto; margin: 0; accent-color: var(--accent); }
.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
.check input { width: 22px; height: 22px; accent-color: var(--rec); }
.star-input { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.star-input .label { font-weight: 600; width: 100%; }
.star-row { display: inline-flex; gap: 2px; cursor: pointer; user-select: none; touch-action: manipulation; }
.star-row:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }
.star { position: relative; font-size: 2.2rem; line-height: 1; color: var(--line); }
.star .fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; width: 0; color: var(--star); }
.star .fill::before { content: "★"; }
.remove-form { text-align: right; margin: -6px 0 20px; }
.review { padding: 12px 0; border-bottom: 1px solid var(--line); }
.review a { text-decoration: none; }
.review p { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.row { display: flex; gap: 10px; }

/* admin */
.people { width: 100%; border-collapse: collapse; }
.people td { padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.people .actions { text-align: right; white-space: nowrap; }
.people tr.disabled { opacity: .55; }
[hidden] { display: none !important; }
