:root {
  --bg: #0f0f12;
  --surface: #1a1a20;
  --surface-2: #24242c;
  --line: #2e2e38;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --accent: #ffd400;
  --accent-ink: #111;
  --ok: #3ddc84;
  --err: #ff5d5d;
  --radius: 12px;
  --top-h: 52px;
  --tab-h: 58px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-top: calc(var(--top-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; }
.center { text-align: center; justify-content: center; }

#topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 8px;
  background: rgba(15,15,18,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
#title { flex: 1; margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { font-size: 30px; line-height: 1; width: 36px; height: 40px; margin-left: -6px; }
.sync-dot { width: 32px; height: 32px; display: grid; place-items: center; }
.sync-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.sync-dot.ok::after { background: var(--ok); }
.sync-dot.syncing::after { background: var(--accent); animation: pulse 1s infinite; }
.sync-dot.error::after { background: var(--err); }
@keyframes pulse { 50% { opacity: .3; } }

#tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(20,20,25,.95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; }
#tabs a.active { color: var(--accent); }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#view { max-width: 1040px; margin: 0 auto; padding: 12px 16px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty b { color: var(--text); display: block; font-size: 17px; margin-bottom: 6px; }

/* bölüm başlıkları */
.sec { margin-bottom: 8px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sec-h h2 { margin: 22px 0 10px; }
.sec:first-child .sec-h h2 { margin-top: 6px; }
.count { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 99px; vertical-align: 2px; }
.more, .link { color: var(--accent); font-size: 14px; font-weight: 600; white-space: nowrap; padding: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; background: var(--surface-2); font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--err); color: #fff; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
select.btn { appearance: none; -webkit-appearance: none; border: 0; padding-right: 30px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23ffd400' fill='none' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center; color: var(--accent); }

/* liste satırı */
.rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface); border-radius: var(--radius); }
.rows > .row, .date-h + .row, .row + .row { margin-bottom: 0; }
#view > .row { margin-bottom: 8px; }
.row.slim { padding: 8px 10px; }
.thumb { width: 56px; height: 84px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; }
.thumb.sm { width: 36px; height: 54px; border-radius: 6px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.bar.thin { height: 3px; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.done i { background: var(--ok); }
.empty-season .season-h { cursor: default; }
.empty-season .name { color: var(--muted); }
.soon { flex: none; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; background: var(--accent); color: var(--accent-ink); vertical-align: 1px; }

.check { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); color: var(--muted); font-weight: 900; font-size: 18px; display: grid; place-items: center; }
.check:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check.sm { width: 36px; height: 36px; font-size: 15px; color: transparent; }
.check.sm:not(:disabled):hover, .check.sm.on { color: var(--accent-ink); }
.check.sm:not(.on):not(:disabled):hover { color: var(--accent); }
.check:disabled { opacity: .3; cursor: default; }

/* poster kartları: yatay kaydırmalı şerit ve ızgara */
.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: 112px; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 0 16px 6px; scrollbar-width: none; overscroll-behavior-x: contain; }
.carousel::-webkit-scrollbar { display: none; }
.carousel .card { scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.card { position: relative; min-width: 0; }
.card .p { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.card .t { font-size: 13px; font-weight: 600; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .y { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { position: absolute; top: 6px; left: 6px; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,.75); }
.badge.on { background: var(--accent); color: var(--accent-ink); }
.fav-mark { position: absolute; top: 4px; right: 6px; color: #ff6b8a; font-size: 16px; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.ph { display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 6px; }

/* Diziler sekmesi: filtreler ve araç çubuğu */
.chips-f { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 10px; padding: 2px 16px 4px; scrollbar-width: none; }
.chips-f::-webkit-scrollbar { display: none; }
.chip-f { flex: none; font-size: 14px; font-weight: 600; padding: 7px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.chip-f span { color: var(--muted); font-weight: 500; margin-left: 2px; }
.chip-f.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-f.on span { color: var(--accent-ink); opacity: .7; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px; outline: none; }
.toolbar input:focus { border-color: var(--accent); }
.toolbar select { flex: none; }
.heart { color: #ff6b8a; }
.times { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: rgba(61,220,132,.15); color: var(--ok); vertical-align: 1px; margin-left: 4px; }
.rw { color: var(--accent); font-weight: 600; }
.rw-info { border: 1px solid rgba(255,212,0,.35); }
a.stat { display: block; }

/* arama */
.search { position: relative; margin-bottom: 14px; }
.search input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px; outline: none; }
.search input:focus { border-color: var(--accent); }

/* detay */
.hero { position: relative; margin: -12px -16px 0; min-height: 180px; background: var(--surface) center/cover no-repeat; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 20%, var(--bg)); }
.head { position: relative; z-index: 1; display: flex; gap: 14px; margin-top: -90px; align-items: flex-end; }
.head .poster { width: 110px; aspect-ratio: 2/3; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.head-main { flex: 1; min-width: 0; }
.head h2 { margin: 0 0 4px; font-size: 21px; }
.fav { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); font-size: 22px; color: var(--muted); }
.fav.on { color: #ff6b8a; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.overview { color: #cfcfd8; margin: 12px 0 0; cursor: pointer; }
.overview.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.overview.clamp::after { content: ""; }
.info { background: var(--surface); border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.next-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 10px 0; }
.next-card .btn { flex: none; }

.season { background: var(--surface); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.season-h { display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.season-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.season-main .name { font-weight: 700; }
.season-h .arrow { color: var(--muted); font-size: 20px; width: 14px; transition: transform .2s; }
.season.open .arrow { transform: rotate(90deg); }
.mini { flex: none; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--accent); }
.mini.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ep { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line); min-height: 52px; }
.ep-main { flex: 1; min-width: 0; }
.ep-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep.future { opacity: .55; }
.ep.is-next { box-shadow: inset 3px 0 0 var(--accent); }

/* profil */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 20px; color: var(--accent); }
.stat span { font-size: 13px; color: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; background: var(--surface); border-radius: var(--radius); padding: 12px 10px 8px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; min-width: 0; }
.chart .col i { display: block; width: 100%; max-width: 26px; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.chart .v { font-size: 10px; color: var(--muted); }
.chart .l { font-size: 10px; color: var(--muted); white-space: nowrap; }

.form { max-width: 380px; margin: 30px auto; }
.form input { width: 100%; padding: 12px 14px; margin-bottom: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px; }
.form .err { color: var(--err); min-height: 20px; font-size: 14px; }
.logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 12px; }

.date-h { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); margin: 18px 0 8px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px;
  width: max-content; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast-btn { color: var(--accent); font-weight: 700; flex: none; }

/* seçim penceresi */
.sheet-bg { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; animation: up .2s; }
.sheet p { margin: 0 0 8px; font-size: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); } }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
  .carousel { grid-auto-columns: 140px; gap: 16px; margin: 0; padding: 0 0 6px; }
  .rows { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
  .hero { min-height: 280px; border-radius: 0 0 16px 16px; }
  .head .poster { width: 150px; }
  .head { margin-top: -120px; }
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 16px; }
}
