/* Fetch on the web: Seerr's shape (sidebar, top search, poster rows, big detail pages) in Fetch's
   own colours. The accent (blue unless changed) comes from Settings via --accent. */

@font-face { font-family: "Google Sans Flex"; src: url("fonts/google_sans_flex.ttf") format("truetype"); font-weight: 100 1000; font-display: swap; }

:root {
  --accent: #3d7be0; --accent-ink: #fff; --accent-soft: rgba(61, 123, 224, .18);
  --bg: #0f1116; --surface: #171a21; --surface-2: #1f232c; --surface-3: #2a2f3a; --line: #2e3440;
  --text: #eef0f4; --muted: #9aa3b2; --faint: #6b7383; --danger: #ef7061; --ok: #66bb6a; --warn: #ffb74d;
  --blue: #4da6f5; --green: #66bb6a; --amber: #ffb74d; --red: #ef7061;
  --radius: 16px; --sidebar: 248px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #eef0f4; --surface-3: #e2e5eb; --line: #d9dde5;
  --text: #15181e; --muted: #5b6474; --faint: #8a93a3; --danger: #c0392b; --ok: #2e7d32;
  --blue: #315abe; --green: #2e7d32; --amber: #e08e0b; --red: #c0392b;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 500 15px/1.45 "Google Sans Flex", system-ui, sans-serif; font-variation-settings: "ROND" 100; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }
.hidden { display: none !important; }

/* --- the frame: sidebar, top bar, page ---------------------------------------------- */

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100%; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; }
.brand img { width: 46px; height: 46px; flex: none; }
.wordmark { font-size: 34px; font-weight: 950; letter-spacing: 1px; }
.wordmark span:nth-child(4n+1) { color: var(--blue); } .wordmark span:nth-child(4n+2) { color: var(--green); }
.wordmark span:nth-child(4n+3) { color: var(--amber); } .wordmark span:nth-child(4n+4) { color: var(--red); }
.nav { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--muted); font-weight: 700; }
.nav:hover { background: var(--surface-2); color: var(--text); }
.nav.on { background: var(--accent-soft); color: var(--text); }
.nav.on svg { color: var(--accent); }
.nav svg { width: 22px; height: 22px; flex: none; }
.nav .count { margin-left: auto; font-size: 12px; background: var(--surface-3); border-radius: 99px; padding: 1px 8px; color: var(--text); }
.sidebar .grow { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.me .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 900; }
.me .who { flex: 1; min-width: 0; } .me .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who small { color: var(--muted); }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; padding: 16px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); }
.search { flex: 1; max-width: 720px; display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 46px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; border: 0; outline: 0; background: none; font-weight: 600; min-width: 0; }
.search svg { width: 20px; height: 20px; color: var(--muted); }
.page { padding: 8px 32px 64px; }
h1.big { font-size: 44px; font-weight: 950; letter-spacing: .5px; margin: 8px 0 18px; }
h2 { font-size: 22px; font-weight: 900; margin: 28px 0 12px; }

/* --- controls ------------------------------------------------------------------------ */

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 16px; border-radius: 99px; font-weight: 800; color: var(--muted); cursor: pointer; display: flex; gap: 6px; align-items: center; }
.seg button svg { width: 17px; height: 17px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: none; padding: 6px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.btn { border: 0; border-radius: 14px; padding: 11px 20px; font-weight: 850; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; justify-content: center; background: var(--surface-3); }
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: none; border: 1px solid var(--danger); color: var(--danger); }
.btn.wide { width: 100%; padding: 14px; font-size: 16px; }
.btn svg { width: 19px; height: 19px; }
.icon-btn { border: 0; background: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--accent-ink); }
.switch input:disabled + span { opacity: .5; }
.row-line { display: flex; align-items: center; gap: 14px; padding: 10px 0; }
.row-line .grow { flex: 1; min-width: 0; }
.row-line small, .muted { color: var(--muted); }
.field { width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); outline: 0; }
.field:focus { border-color: var(--accent); }
.label { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 16px 0 8px; }
.error { color: var(--danger); font-weight: 700; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 48px 0; color: var(--muted); } .empty b { display: block; color: var(--text); font-size: 22px; font-weight: 900; margin-bottom: 6px; }

/* --- posters ------------------------------------------------------------------------- */

.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: 158px; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; scroll-snap-type: x proximity; scrollbar-width: thin; }
h2.more a { display: flex; align-items: baseline; gap: 12px; }
h2.more span { font-size: 14px; font-weight: 800; color: var(--accent); display: inline-flex; align-items: center; opacity: 0; transform: translateX(-6px); transition: opacity .15s, transform .15s; }
h2.more span svg { width: 16px; height: 16px; }
h2.more a:hover span, h2.more a:focus-visible span { opacity: 1; transform: none; }
@media (hover: none) { h2.more span { opacity: 1; transform: none; } }
.card.seeall .art { display: grid; place-content: center; justify-items: center; gap: 6px; font-weight: 900; color: var(--accent); background: var(--accent-soft); box-shadow: none; border: 1px dashed var(--accent); }
.card.seeall .art svg { width: 30px; height: 30px; }
.listbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.listbar a.chip { text-decoration: none; }
.toggle { display: inline-flex; gap: 8px; align-items: center; font-weight: 700; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 17px; height: 17px; }
p.end { text-align: center; padding: 28px 0 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 18px 14px; }
.card { position: relative; display: block; cursor: pointer; scroll-snap-align: start; }
.card .art { position: relative; aspect-ratio: 2 / 3; border-radius: 14px; overflow: hidden; background: var(--surface-2); box-shadow: 0 4px 18px rgba(0,0,0,.25); transition: transform .18s; }
.card.square .art { aspect-ratio: 1; }
.card:hover .art { transform: translateY(-3px) scale(1.02); }
.card img.poster { width: 100%; height: 100%; object-fit: cover; }
.card .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); }
.card .ph svg { width: 40px; height: 40px; }
.card .badge { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 900; padding: 3px 9px; border-radius: 99px; background: rgba(0,0,0,.62); color: #fff; letter-spacing: .3px; }
.card .have { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; }
.card .have svg { width: 16px; height: 16px; }
.card .count { position: absolute; bottom: 8px; left: 8px; font-size: 12px; font-weight: 900; padding: 3px 9px; border-radius: 99px; background: rgba(0,0,0,.65); color: #fff; }
.card .count.done { background: var(--ok); }
.card.dim .art img { opacity: .42; }
/* Seerr's hover: the poster darkens and shows what it is. */
.card .hover { position: absolute; inset: 0; padding: 12px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,.92), rgba(0,0,0,.55) 55%, rgba(0,0,0,.1)); opacity: 0; transition: opacity .18s; }
.card:hover .hover, .card:focus-visible .hover { opacity: 1; }
.card .hover b { font-size: 15px; line-height: 1.2; }
.card .hover p { margin: 0; font-size: 12px; opacity: .85; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.card .title { margin-top: 8px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- detail pages ---------------------------------------------------------------------- */

.hero { position: relative; margin: -8px -32px 0; padding: 48px 32px 32px; min-height: 360px; overflow: hidden; }
.hero .backdrop { position: absolute; inset: 0; background-size: cover; background-position: center 25%; opacity: .45; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 4%, color-mix(in srgb, var(--bg) 55%, transparent) 55%, color-mix(in srgb, var(--bg) 30%, transparent)); }
.hero .inner { position: relative; z-index: 1; display: flex; gap: 32px; align-items: flex-end; }
.hero .cover { width: 220px; flex: none; border-radius: 16px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.5); background: var(--surface-2); aspect-ratio: 2 / 3; }
.hero .cover.square { aspect-ratio: 1; }
.hero .cover img { width: 100%; height: 100%; object-fit: cover; }
.hero h1 { font-size: 46px; font-weight: 950; line-height: 1.05; margin: 0 0 10px; }
.hero .facts { color: var(--muted); font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 8px; background: var(--surface-3); }
.detail { display: grid; grid-template-columns: 1fr 380px; gap: 40px; margin-top: 24px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px; align-self: start; position: sticky; top: 92px; }
.panel h3 { margin: 0 0 6px; font-size: 20px; font-weight: 900; }
.overview { font-size: 16px; line-height: 1.6; max-width: 70ch; }
.status-pill { display: inline-flex; gap: 8px; align-items: center; padding: 10px 16px; border-radius: 12px; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); font-weight: 900; }
.parts { border-top: 1px solid var(--line); }
.parts .row-line { border-bottom: 1px solid var(--line); }
.parts img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }

/* --- downloads and coming up ------------------------------------------------------------- */

.dl { display: flex; gap: 16px; padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 10px; }
.dl img, .dl .noimg { width: 64px; height: 96px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.dl.square img, .dl.square .noimg { height: 64px; }
.dl .grow { flex: 1; min-width: 0; }
.dl b { font-size: 17px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s; }
.dl.problem .bar i { background: var(--danger); }
.problem-text { color: var(--danger); font-size: 13px; font-weight: 700; margin-top: 4px; }
.release { color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.day { font-size: 26px; font-weight: 950; margin: 26px 0 10px; }
.cal { display: flex; gap: 14px; align-items: center; padding: 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; }
.cal img, .cal .noimg { width: 46px; height: 69px; border-radius: 9px; object-fit: cover; background: var(--surface-2); flex: none; }
.cal .when { font-weight: 900; text-align: right; }

/* --- sign in --------------------------------------------------------------------------- */

.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% 0%, var(--accent-soft), transparent), var(--bg); }
.signin .box { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 34px; display: grid; gap: 12px; }
.signin .brand { justify-content: center; padding: 0; }
.signin .brand img { width: 60px; height: 60px; }
.signin .wordmark { font-size: 46px; }
.code { font-size: 42px; font-weight: 950; letter-spacing: 8px; text-align: center; color: var(--accent); }
.dots { display: flex; gap: 12px; flex-wrap: wrap; }
.dot { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.dot.on { border-color: var(--text); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-3); color: var(--text); padding: 12px 20px; border-radius: 14px; font-weight: 800; box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 50; }
.dialog-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 40; padding: 20px; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 26px; width: min(460px, 100%); display: grid; gap: 14px; }
.dialog h3 { margin: 0; font-size: 22px; font-weight: 900; }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* --- small screens: the sidebar becomes a bottom bar ---------------------------------------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around; padding: 6px; z-index: 20; border-right: 0; border-top: 1px solid var(--line); }
  .sidebar .brand, .sidebar .grow, .me, .nav .label-text, .nav .count { display: none; }
  .nav { flex-direction: column; gap: 2px; padding: 8px 12px; font-size: 11px; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  .topbar { flex-wrap: wrap; } .topbar .search { flex-basis: 100%; }
  .page { padding-bottom: 96px; }
  .hero { margin: -8px -16px 0; padding: 24px 16px; }
  .hero .inner { flex-direction: column; align-items: flex-start; } .hero .cover { width: 150px; } .hero h1 { font-size: 32px; }
  .detail { grid-template-columns: 1fr; } .panel { position: static; }
  .carousel { grid-auto-columns: 128px; } .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  h1.big { font-size: 34px; }
}
.panel .note { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-weight: 700; }
