:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --ink: #141414;
  --muted: #6b6b6b;
  --line: #e7e7e7;
  --red: #d1323c;
  --red-soft: #fbe9ea;
  --ok: #1f8a4c;
  --ok-soft: #e4f4ea;
  --panel: #ffffff;
  --chip: #f2f2f2;
  --serif: "Noto Serif", Georgia, "Times New Roman", serif;
  --sans: Roboto, -apple-system, "Segoe UI", Arial, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111213; --ink: #f1f1f1; --muted: #a2a2a2; --line: #2a2c2e;
    --red-soft: #3a1c1f; --ok: #4cc27d; --ok-soft: #173525; --panel: #1a1b1d; --chip: #232527;
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111213; --ink: #f1f1f1; --muted: #a2a2a2; --line: #2a2c2e;
    --red-soft: #3a1c1f; --ok: #4cc27d; --ok-soft: #173525; --panel: #1a1b1d; --chip: #232527;
  }
}
* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--sans); overflow-x: clip;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Hlavička */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar { display: flex; align-items: center; justify-content: space-between; padding: 10px max(16px, env(safe-area-inset-left)) 2px; max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.logo { background: var(--red); color: #fff; font-weight: 700; font-size: 20px; padding: 2px 9px; border-radius: 6px; letter-spacing: .5px; }
.sub { font-family: var(--serif); font-size: 18px; color: var(--muted); }
.iconbtn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.iconbtn:active { background: var(--chip); }
.actions { display: flex; gap: 2px; }
#refresh.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { font-size: 13px; color: var(--muted); padding: 0 16px 6px; max-width: 760px; margin: 0 auto; }
.status.stale { color: var(--red); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 10px; scrollbar-width: none; max-width: 760px; margin: 0 auto; scroll-snap-type: x proximity; scroll-padding-inline: 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 0; background: var(--chip); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; scroll-snap-align: start; min-height: 36px; }
.tab[aria-selected="true"] { background: var(--red); color: #fff; }
.tab .n { margin-left: 6px; font-size: 12px; opacity: .8; }

/* Seznam */
main { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; }
.filter { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 4px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; min-height: 36px; }
.switch input { width: 18px; height: 18px; accent-color: var(--red); }
.count { font-size: 13px; color: var(--muted); }
.error { background: var(--red-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 8px 0; }

.card { position: relative; padding: 18px 0 22px; border-bottom: 1px solid var(--line); cursor: pointer; }
.card .img { aspect-ratio: 3 / 2; background: var(--chip); overflow: hidden; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card h3 { font-family: var(--serif); font-weight: 500; font-size: clamp(22px, 5.6vw, 28px); line-height: 1.25; margin: 14px 0 10px; text-wrap: pretty; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 15px; color: var(--ink); }
.meta .dim { color: var(--muted); }
.pill { background: var(--red); color: #fff; text-transform: uppercase; font-weight: 700; font-size: 13px; padding: 4px 12px; border-radius: 6px; letter-spacing: .3px; }
.card.read .img, .card.read h3 { opacity: .45; }
.card.read .pill { background: var(--muted); }
.done { display: inline-flex; align-items: center; gap: 4px; background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.mark {
  position: absolute; top: 28px; right: 10px; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.card.read .mark { background: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.skel { height: 360px; border-radius: 4px; margin: 18px 0; background: linear-gradient(90deg, var(--chip), var(--line), var(--chip)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.more { display: block; width: 100%; margin: 20px 0; min-height: 48px; border: 2px solid var(--red); color: var(--red); background: transparent; border-radius: 10px; font-weight: 700; cursor: pointer; }
.more:disabled { opacity: .5; }

/* Detail */
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; justify-items: center; }
.sheet[hidden] { display: none; }
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.panel {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--panel); border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom));
  animation: up .22s ease-out;
}
@media (min-width: 700px) { .sheet { align-items: center; } .panel { border-radius: 18px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.close { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.55); color: #fff; z-index: 2; }
.dimg { aspect-ratio: 3 / 2; background: var(--chip); }
.dimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dbody { padding: 16px 18px 0; }
.dbody h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 1.25; margin: 12px 0; }
.perex { font-size: 17px; line-height: 1.55; margin: 0 0 18px; }
.perex.loading { color: var(--muted); }
.primary { display: flex; align-items: center; justify-content: center; min-height: 50px; background: var(--red); color: #fff; text-decoration: none; font-weight: 700; border-radius: 10px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.secondary { min-height: 46px; border: 1px solid var(--line); background: var(--chip); border-radius: 10px; font-weight: 500; cursor: pointer; }
.readat { font-size: 13px; color: var(--muted); text-align: center; margin: 12px 0 0; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; border: 1px solid rgba(255,255,255,.18); box-shadow: 0 6px 24px rgba(0,0,0,.35); font-size: 14px; z-index: 60; }

:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
