:root {
  color-scheme: light;
  --bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.92);
  --surface: #f2f4f6;
  --surface-hover: #f7f8f9;
  --text: #111318;
  --muted: #69717d;
  --line: #e2e5e9;
  --subtle: #6f7782;
  --tag-text: #555e69;
  --fallback: #8a919a;
  --error: #c53636;
  --accent: #078a54;
  --accent-soft: rgba(7, 138, 84, 0.1);
  --max: 1040px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b0d10;
    --header-bg: rgba(11, 13, 16, 0.92);
    --surface: #12151a;
    --surface-hover: #171b21;
    --text: #f4f5f7;
    --muted: #9299a5;
    --line: #252a32;
    --subtle: #606772;
    --tag-text: #b1b7c0;
    --fallback: #656c77;
    --error: #ff8585;
    --accent: #5ee1a2;
    --accent-soft: rgba(94, 225, 162, 0.12);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.header-inner, .tabs, main {
  width: min(calc(100% - 32px), var(--max));
  margin-inline: auto;
}

.header-inner {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.16em;
}

h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.1rem); line-height: 1; letter-spacing: -0.045em; }
.updated { margin: 0 0 2px; color: var(--muted); font-size: 0.78rem; text-align: right; }
.update-group { display: flex; align-items: center; justify-content: flex-end; min-height: 34px; gap: 10px; }
.refresh {
  display: grid;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 8px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms, background 150ms, border-color 150ms;
}
.refresh:hover, .refresh:focus-visible { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); outline: none; }
.refresh:disabled { cursor: wait; opacity: 0.65; }
.refresh[hidden] { display: none !important; }
.refresh svg { display: block; width: 17px; height: 17px; margin: auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; transform-origin: 50% 50%; }
.refresh.loading svg { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 28px; }
.tab {
  appearance: none;
  padding: 13px 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
}
.tab span { margin-left: 4px; font-size: 0.72rem; opacity: 0.7; }
.tab.active { border-color: var(--accent); color: var(--text); }

main { padding: 20px 0 56px; }
.status { padding: 50px 0; color: var(--muted); text-align: center; }
.status.error { color: var(--error); }
.media-list { margin: 0; padding: 0; list-style: none; }
.media-row { border-bottom: 1px solid var(--line); }
.media-link {
  display: grid;
  grid-template-columns: 42px 78px minmax(0, 1fr) 24px;
  gap: 18px;
  align-items: center;
  min-height: 130px;
  padding: 14px 12px 14px 0;
  color: inherit;
  text-decoration: none;
  transition: background 150ms ease;
}
.media-link:hover, .media-link:focus-visible { background: var(--surface-hover); outline: none; }
.rank { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; text-align: center; }
.rank::before { content: "#"; opacity: 0.45; }
.poster-wrap { position: relative; width: 78px; aspect-ratio: 2 / 3; overflow: hidden; border-radius: 7px; background: var(--surface); }
.poster { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; }
.poster[src=""] { display: none; }
.poster-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--fallback); font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; }
.details { display: flex; min-width: 0; flex-direction: column; gap: 0; }
.title-line { display: flex; align-items: flex-start; gap: 12px; }
.title { margin: 0; font-size: 1.02rem; line-height: 1.3; letter-spacing: -0.015em; }
.rating { display: inline-flex; flex: none; height: 23px; margin-top: 3px; padding: 0 7px; align-items: center; justify-content: center; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 0.7rem; font-weight: 750; line-height: 1; }
.meta { display: flex; align-items: center; min-width: 0; margin: 10px 0; overflow: hidden; color: var(--muted); font-size: 0.78rem; line-height: 1.25; white-space: nowrap; }
.meta-fact { flex: none; }
.meta-fact + .meta-fact::before { content: "·"; margin: 0 5px; opacity: 0.7; }
.meta-short { display: none; }
.genres { display: flex; flex-wrap: wrap; gap: 5px; }
.genre { padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--tag-text); font-size: 0.67rem; line-height: 1; }
.arrow { color: var(--subtle); font-size: 0.9rem; transition: color 150ms, transform 150ms; }
.media-link:hover .arrow { color: var(--accent); transform: translate(2px, -2px); }
.blacklist-action {
  display: grid;
  flex: none;
  width: 23px;
  height: 23px;
  margin-top: 3px;
  margin-left: -5px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 99px;
  background: color-mix(in srgb, var(--error) 12%, transparent);
  color: var(--error);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1;
  transition: color 150ms, background 150ms;
}
.blacklist-action svg { display: block; width: 14px; height: 14px; margin: auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }
.blacklist-action:hover, .blacklist-action:focus-visible { background: color-mix(in srgb, var(--error) 22%, transparent); color: var(--error); outline: none; }
.blacklist-action:disabled { cursor: wait; opacity: 0.6; }

@media (min-width: 720px) {
  .header-inner, .tabs, main { width: min(calc(100% - 64px), var(--max)); }
  .media-link { grid-template-columns: 54px 92px minmax(0, 1fr) 30px; gap: 24px; min-height: 166px; padding: 16px 18px 16px 0; }
  .poster-wrap { width: 92px; }
  .title { font-size: 1.18rem; }
  .meta { font-size: 0.84rem; }
}

@media (max-width: 520px) {
  .header-inner, .tabs, main { width: min(calc(100% - 22px), var(--max)); }
  .header-inner { padding-top: 20px; }
  .updated { max-width: 110px; }
  .update-group { gap: 7px; }
  .media-link { grid-template-columns: 30px 68px minmax(0, 1fr); gap: 12px; min-height: 122px; padding-right: 2px; }
  .poster-wrap { width: 68px; }
  .arrow { display: none; }
  .title-line { gap: 7px; }
  .title { font-size: 0.94rem; }
  .rating { margin-top: 1px; padding: 0 6px; font-size: 0.65rem; }
  .blacklist-action { margin-top: 1px; margin-left: 0; }
  .meta { font-size: 0.73rem; }
  .details > .meta { margin-top: 5px; margin-bottom: 15px; }
  .meta-compact .meta-full { display: none; }
  .meta-compact .meta-short { display: inline; }
  .genres { max-height: 22px; overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
