@font-face { font-family: "Manrope"; src: url("fonts/manrope.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
:root {
  --bg: #111318; --surface: #1B1E25; --surface-2: #23262E; --line: #2A2E37; --line-2: #3A3F4A;
  --text: #EDEEF0; --text-2: #C9CDD4; --muted: #9AA0AA; --accent: #5EE0B0; --hot: #F2B544;
  --nav-h: 72px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 500 15px/1.4 Manrope, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.app { max-width: 640px; margin: 0 auto; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); min-height: 100vh; }

/* headers */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px 10px; }
.top.col { flex-direction: column; align-items: stretch; gap: 14px; padding-left: 16px; padding-right: 16px; }
.top.col h1, .title-row { padding: 0 4px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; }
.eyebrow { display: block; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.round { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.round svg { width: 20px; height: 20px; }

/* lists */
.list { padding: 4px 16px 0; display: flex; flex-direction: column; gap: 10px; }
.section { margin: 10px 4px 0; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.section.hot { color: var(--hot); }
.empty { color: var(--muted); padding: 16px 4px; margin: 0; }
.foot { color: var(--muted); font-size: 13px; padding: 4px; margin: 6px 0 0; }
.meta { font-size: 13px; color: var(--muted); }
.name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--surface-2); border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.badge.new { color: #111318; background: var(--hot); }
.badge.muted { color: var(--muted); background: transparent; border: 1px solid var(--line); }

progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 4px; border: 0; border-radius: 2px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.poster { width: 60px; aspect-ratio: 2 / 3; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.poster.blank { display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: var(--muted); }

/* home cards */
.card { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; background: var(--surface); transition: opacity .25s, transform .25s; }
.card.leaving { opacity: 0; transform: translateX(24px); }
.card-main { flex: 1; min-width: 0; display: flex; gap: 14px; align-items: center; color: inherit; text-decoration: none; }
.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.card-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 16px; }
.code { font-size: 14px; color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card progress { margin-top: 3px; }
.check { width: 50px; height: 50px; border-radius: 25px; border: 2px solid var(--line-2); background: transparent; color: var(--text-2); display: flex; align-items: center; justify-content: center; }
.check.hot { border-color: var(--accent); color: var(--accent); }
.check svg { stroke-width: 2.6; }
.check:active { background: var(--accent); color: #111318; border-color: var(--accent); }

/* rows (upcoming, search results) */
.day { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface); color: inherit; text-decoration: none; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thumb { width: 40px; aspect-ratio: 2 / 3; border-radius: 7px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }

/* segmented + chips */
.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); }
.segmented a { min-height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 9px; color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 600; }
.segmented a.on { background: var(--text); color: #111318; font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips a { flex-shrink: 0; min-height: 36px; display: flex; align-items: center; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chips a.on { background: var(--text); border-color: var(--text); color: #111318; font-weight: 700; }
.search { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { display: flex; flex-direction: column; gap: 4px; color: var(--text); text-decoration: none; min-width: 0; }
.tile-poster { position: relative; border-radius: 10px; overflow: hidden; }
.tile .poster { width: 100%; border-radius: 0; display: block; }
.tile progress { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 0; background: rgba(17, 19, 24, .6); }
.tile progress::-webkit-progress-bar { background: rgba(17, 19, 24, .6); }
.tile .name { font-size: 13px; margin-top: 2px; }
.tile .meta { font-size: 12px; }

/* buttons */
.btn { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 700; text-decoration: none; width: 100%; }
.btn svg { width: 18px; height: 18px; stroke-width: 2.6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111318; font-weight: 800; }
.btn.ghost { color: var(--muted); }
.btn.small { min-height: 38px; width: auto; padding: 0 12px; font-size: 13px; border-color: var(--line-2); background: transparent; color: var(--text-2); }
.link { background: none; border: 0; padding: 12px 4px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: underline; }
.link.danger { color: #F08A8A; }

/* show page */
.hero { height: 130px; background: var(--surface-2); position: relative; }
.back { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 16px); left: 16px; background: rgba(17, 19, 24, .75); border: 0; }
.show-head { display: flex; gap: 16px; align-items: flex-end; padding: 0 20px; margin-top: -60px; position: relative; }
.show-head .poster { width: 100px; border: 3px solid var(--bg); border-radius: 12px; }
.show-head > div { display: flex; flex-direction: column; gap: 4px; padding-bottom: 4px; min-width: 0; }
.show-head h1 { font-size: 24px; }
.count { font-size: 14px; color: var(--text-2); font-weight: 700; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 18px 20px 4px; }
.actions form { display: flex; }
.summary { padding: 6px 20px 0; margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.seasons { padding: 10px 16px 0; display: flex; flex-direction: column; gap: 8px; }
.season { border-radius: 12px; background: var(--surface); overflow: hidden; }
.season summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; font-weight: 700; cursor: pointer; list-style: none; }
.season summary::-webkit-details-marker { display: none; }
.season summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); margin-left: 12px; transition: transform .2s; }
.season[open] summary::after { transform: rotate(45deg); }
.season summary > span:first-child { flex: 1; }
.season-count { font-size: 13px; color: var(--muted); font-weight: 700; }
.season-count.done { color: var(--accent); }
.season-tools { display: flex; justify-content: flex-end; padding: 0 14px 8px; border-bottom: 1px solid var(--surface-2); }
.eps { list-style: none; margin: 0; padding: 0; }
.ep { display: flex; align-items: center; gap: 12px; padding: 6px 14px; min-height: 56px; border-bottom: 1px solid var(--surface-2); }
.ep:last-child { border-bottom: 0; }
.ep-num { width: 34px; font-size: 13px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.ep-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ep-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tick { width: 44px; height: 44px; border-radius: 22px; border: 2px solid var(--line-2); background: transparent; color: #6B717C; display: flex; align-items: center; justify-content: center; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tick svg { width: 18px; height: 18px; stroke-width: 2.8; }
.tick[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #111318; }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 0 28px; max-width: 420px; margin: 0 auto; }
.login .logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #111318; display: flex; align-items: center; justify-content: center; }
.login .logo svg { width: 30px; height: 30px; stroke-width: 2.2; }
.login .meta { font-size: 15px; margin: 0 0 14px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.login input { min-height: 52px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-size: 16px; }
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login .btn { min-height: 52px; font-size: 16px; margin-top: 4px; }
.error { color: #F08A8A; margin: 0; font-size: 14px; }

/* nav + toast */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--nav-h) + var(--safe-b)); padding: 6px 12px calc(var(--safe-b) + 8px); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: #15171D; border-top: 1px solid #23262E; }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.tabs a.on { color: var(--accent); font-weight: 700; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 20; max-width: 608px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 14px; background: var(--text); color: #111318; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast[hidden] { display: none; }
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button { flex-shrink: 0; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 0; background: #111318; color: var(--text); font-weight: 700; }
.toast button[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .card, .season summary::after { transition: none; } }
