:root {
  --bg: #f6f4f1;
  --card: #ffffff;
  --text: #1f1d1a;
  --muted: #6e6a64;
  --border: #e1ddd6;
  --accent: #d0602b;
  --accent-text: #ffffff;
  --error: #b93a2b;
  --ok-bg: #e6f4ea;
  --err-bg: #fbe9e7;
  --info-bg: #eef1fb;
  --game: #4f6bed;
  --book: #2e9d6a;
  --film: #c94f8a;
  --series: #c28a12;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --card: #211f1d;
    --text: #ece8e2;
    --muted: #a09a91;
    --border: #36322e;
    --accent: #f08a54;
    --accent-text: #1a1310;
    --error: #ff8a76;
    --ok-bg: #1d3426;
    --err-bg: #3c201c;
    --info-bg: #222a40;
    --game: #7d92ff;
    --book: #4cc58d;
    --film: #ec7ab0;
    --series: #e6b13d;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .25rem 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .75rem; display: flex; align-items: baseline; gap: .75rem; }
h3 { font-size: .95rem; margin: .75rem 0 .25rem; }
.card h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; color: var(--text); text-decoration: none; }
.lead { color: var(--muted); margin: 0 0 .5rem; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }

/* Header */
.top { display: flex; align-items: center; gap: 1rem; max-width: 72rem; margin: 0 auto; padding: .75rem 1rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.main-nav { display: flex; gap: .25rem; align-items: center; flex: 1; }
.main-nav a { text-decoration: none; color: var(--text); padding: .4rem .7rem; border-radius: 8px; }
.main-nav a[aria-current] { background: var(--card); box-shadow: var(--shadow); }
.main-nav .add-btn { margin-left: auto; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.me { position: relative; }
.me summary { list-style: none; cursor: pointer; }
.me summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: block; background: var(--border); }
.me .menu { position: absolute; right: 0; top: 44px; z-index: 10; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: .75rem; display: grid; gap: .5rem; min-width: 14rem; box-shadow: var(--shadow); }
.me .menu form { margin: 0; }

main { max-width: 72rem; margin: 0 auto; padding: 0 1rem 4rem; }
@media (max-width: 40rem) {
  .top { flex-wrap: wrap; }
  .main-nav { order: 3; flex-basis: 100%; }
  h1 { font-size: 1.35rem; }
}

/* Generic bits */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; margin: 1rem 0;
  box-shadow: var(--shadow); }
.card.narrow { max-width: 36rem; }
.msg { padding: .6rem .8rem; border-radius: 8px; background: var(--ok-bg); margin: 0 0 1rem; }
.msg-error { background: var(--err-bg); }
.msg-info { background: var(--info-bg); }
.error { color: var(--error); font-size: .85rem; display: block; }
button, .button { display: inline-block; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.button.big { display: block; text-align: center; padding: .8rem 1rem; margin: 1.25rem 0; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; }
button.danger, .danger { color: var(--error); }
.small-btn { padding: .3rem .6rem; font-size: .85rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .6rem; max-width: 100%; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
textarea { width: 100%; }
label { display: grid; gap: .25rem; font-weight: 600; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: .4rem; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.chip { font-size: .8rem; padding: .15rem .55rem; border-radius: 99px; background: var(--bg); border: 1px solid var(--border);
  text-decoration: none; color: var(--text); }
.chip.soft { border-color: transparent; color: var(--muted); }
.chip.warn { color: var(--error); }
.see-all { font-size: .85rem; font-weight: 400; }
details > summary { cursor: pointer; color: var(--accent); }
ul.plain { list-style: none; padding: 0; margin: 0; }

/* Covers and cards */
.cover { position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden;
  background: var(--border); border-bottom: 3px solid var(--muted); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-title { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: .5rem;
  text-align: center; font-weight: 700; font-size: .85rem; color: var(--muted); }
.cover.small { width: 48px; flex: none; }
.cover.big { width: 180px; flex: none; }
.kind-game { border-bottom-color: var(--game); --kind: var(--game); }
.kind-book { border-bottom-color: var(--book); --kind: var(--book); }
.kind-film { border-bottom-color: var(--film); --kind: var(--film); }
.kind-series { border-bottom-color: var(--series); --kind: var(--series); }
.fav { position: absolute; top: .3rem; right: .4rem; color: #ff5a6e; text-shadow: 0 0 3px rgba(0,0,0,.6); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1.25rem 1rem; }
@media (max-width: 40rem) { .grid { grid-template-columns: repeat(3, 1fr); gap: 1rem .6rem; } }
.card-work { display: grid; gap: .3rem; text-decoration: none; color: var(--text); min-width: 0; }
.card-work:hover .cover { outline: 2px solid var(--accent); }
.card-title { font-weight: 600; font-size: .9rem; line-height: 1.25; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { font-size: .8rem; color: var(--muted); }
.stars { color: #e0a100; letter-spacing: .05em; }

/* Home */
.welcome .kind-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.year-strip { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: baseline; margin: .5rem 0; }
.year-title { font-size: 1.6rem; font-weight: 800; color: var(--text); text-decoration: none; }
.year-count { color: var(--muted); text-decoration: none; }
.year-count strong { color: var(--text); font-size: 1.15rem; }
.progress-list, .results, .runs { list-style: none; padding: 0; margin: 0; }
.progress-list li, .results li { display: flex; align-items: center; gap: .9rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.progress-list form { margin: 0; }

/* Library */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tabs a { text-decoration: none; color: var(--text); padding: .4rem .8rem; border-radius: 99px; border: 1px solid var(--border); }
.tabs a[aria-current] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.filters input[type=search] { flex: 1 1 14rem; }

/* Entry page */
.entry-head { display: flex; gap: 1.5rem; align-items: flex-start; }
@media (max-width: 40rem) { .entry-head { flex-direction: column; } .cover.big { width: 140px; } }
.status-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.status-btn { font-weight: 500; }
.status-btn[aria-pressed=true] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
.summary { margin: 1rem 0; }
.summary p { color: var(--muted); }
.entry-form { display: grid; gap: .9rem; }
.entry-form input[type=text] { width: 100%; }
.runs li { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.runs li > span:first-child { font-weight: 600; }
.runs li a { margin-left: auto; }
.run-form { display: grid; gap: .9rem; margin-top: .75rem; }
.run-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem 1rem; align-items: end; }
.run-fields .wide { grid-column: 1 / -1; }
.run-fields input:not([type=checkbox]), .run-fields select { width: 100%; }
.danger-zone { margin-top: 2rem; }

/* Add */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-bar input { flex: 1; font-size: 1.05rem; }
.results .add-form { display: flex; gap: .4rem; margin: 0; }
@media (max-width: 40rem) { .results li { flex-wrap: wrap; } .results .add-form { width: 100%; } .results .add-form select { flex: 1; } }
.manual { margin-top: 2rem; }

/* Login */
.login { max-width: 28rem; margin: 3rem auto; text-align: center; }

/* Stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; margin: 1rem 0; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; display: grid;
  text-decoration: none; color: var(--muted); box-shadow: var(--shadow); border-top: 4px solid var(--kind, var(--border)); }
.kpi-num { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.small-kpis .kpi { border-top-width: 1px; }
.small-kpis .kpi-num { font-size: 1.4rem; }
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: .4rem; align-items: end; height: 12rem; }
.month { display: grid; grid-template-rows: auto 1fr auto; height: 100%; text-align: center; gap: .2rem; }
.month-bar { display: flex; flex-direction: column-reverse; justify-content: flex-start; height: 100%;
  background: var(--bg); border-radius: 6px; overflow: hidden; }
.seg { display: block; width: 100%; }
.seg.kind-game, .dot.kind-game { background: var(--game); }
.seg.kind-book, .dot.kind-book { background: var(--book); }
.seg.kind-film, .dot.kind-film { background: var(--film); }
.seg.kind-series, .dot.kind-series { background: var(--series); }
.month-total { font-size: .8rem; font-weight: 700; min-height: 1.2em; }
.month-label { font-size: .7rem; color: var(--muted); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .3rem; }
.two-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0 1rem; }
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.bars li { display: grid; grid-template-columns: 4.5rem 1fr 2rem; gap: .5rem; align-items: center; font-size: .9rem; }
.bar { background: var(--bg); border-radius: 4px; height: .8rem; overflow: hidden; }
.bar span { display: block; height: 100%; background: #e0a100; }
