* { box-sizing: border-box; }
body { margin: 0; background: #14181c; color: #9ab; font-family: system-ui, sans-serif; line-height: 1.4; }
main { max-width: 1400px; margin: 0 auto; padding: 32px 20px 56px; }
h1 { color: #fff; text-align: center; letter-spacing: 3px; text-transform: uppercase; margin: 0 0 32px; font-size: 28px; }
a { color: #40bcf4; }

.grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 20px 14px; }
.item { position: relative; min-width: 0; cursor: pointer; outline: none; }
.item.placeholder { cursor: default; }
.poster, .poster-missing { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; background: #2c3440; border-radius: 6px; border: 2px solid #242c34; transition: border-color .15s; }
.item:hover .poster, .item:focus-visible .poster, .item.open .poster { border-color: #00e054; }
.poster-missing { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #678; font-size: 12px; }
.week { color: #00e054; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; }
.item .week { margin-top: 6px; }
.title { color: #fff; font-size: 13px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.item.placeholder .poster-missing { background: #181d22; border: 1px dashed #2c3440; }
.item.placeholder .big { font-size: 30px; color: #2f3a46; font-weight: 700; }
.item.placeholder .week { color: #567; }
.item.placeholder .title { color: #567; font-weight: normal; }
.add-btn { margin-top: 8px; }

/* Expanded detail row */
.detail { --arrow-x: 50%; grid-column: 1 / -1; position: relative; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); background: #1c2228; border: 1px solid #242c34; border-radius: 8px; margin: 8px 0 4px; }
.detail::before { content: ''; position: absolute; top: -8px; left: var(--arrow-x); width: 14px; height: 14px; background: #1c2228; border-left: 1px solid #242c34; border-top: 1px solid #242c34; transform: translateX(-50%) rotate(45deg); }
.close { position: absolute; top: 6px; right: 10px; z-index: 2; background: none; border: 0; color: #789; font-size: 26px; line-height: 1; cursor: pointer; }
.close:hover { color: #fff; }

.info { padding: 16px 18px; min-width: 0; }
.info h2 { margin: 2px 0 8px; color: #fff; font-size: 22px; line-height: 1.25; }
.year { color: #678; font-weight: normal; font-size: 16px; }
.meta { font-size: 13px; margin: 2px 0; }
.meta b { color: #789; font-weight: 600; }

.scores { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; }
.score { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: #bcd; }
.score b { color: #fff; font-weight: 600; }
.ico { width: 22px; height: 22px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 800; color: #000; }
.badge.imdb { background: #f5c518; }
.badge.mc { font-size: 13px; }
.streaming { margin-top: 14px; padding-top: 12px; border-top: 1px solid #2c3440; }
.prov-list { display: flex; flex-wrap: wrap; gap: 6px; }
.provider { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.provider-name { font-size: 12px; background: #2c3440; border-radius: 4px; padding: 2px 6px; color: #bcd; }
.attrib { margin-top: 8px; font-size: 11px; color: #567; }

.review { display: flex; gap: 10px; padding: 16px 18px; min-width: 0; max-height: 360px; border-left: 1px solid #2c3440; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; object-fit: cover; background: #40bcf4; color: #14181c; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; text-transform: uppercase; }
.review-body { min-width: 0; flex: 1; font-size: 14px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a4552 transparent; }
.user { color: #fff; font-weight: 600; margin-right: 6px; }
.stars { color: #00e054; letter-spacing: 1px; white-space: nowrap; }
.review-text { margin: 4px 0 0; color: #bcd; overflow-wrap: anywhere; }
.muted { color: #567; font-style: italic; }

.empty { text-align: center; color: #678; }
footer { max-width: 1400px; margin: 0 auto; padding: 0 20px 32px; text-align: center; font-size: 12px; color: #567; }

/* Edit mode (only present after logging in) */
.edit-bar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; padding: 8px 20px; background: #00e054; color: #14181c; font-weight: 600; }
.edit-bar span { flex: 1; }
.edit-bar button { background: #14181c; color: #fff; }
.edit-btn { position: absolute; top: 8px; right: 44px; z-index: 2; opacity: .85; }
.editing button, .modal button { cursor: pointer; border: 0; border-radius: 6px; padding: 6px 12px; background: #00e054; color: #14181c; font-weight: 600; font-size: 13px; }
.editing .edit-btn { background: #2c3440; color: #fff; }
.modal button.secondary { background: #2c3440; color: #fff; }
.modal button.danger { background: #c0392b; color: #fff; margin-left: auto; }
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.7); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 32px 12px; }
.modal { background: #1c2228; border-radius: 8px; padding: 20px; width: 100%; max-width: 560px; color: #bcd; }
.modal h3 { margin: 0 0 12px; color: #fff; }
.modal label { display: block; font-size: 12px; margin-bottom: 10px; color: #789; }
.modal input, .modal textarea, .modal select { display: block; width: 100%; margin-top: 3px; padding: 8px 10px; border-radius: 6px; border: 1px solid #2c3440; background: #14181c; color: #fff; font: inherit; font-size: 14px; }
.modal .row { display: flex; gap: 10px; }
.modal .row label { flex: 1; }
.modal fieldset { border: 1px solid #2c3440; border-radius: 6px; margin: 0 0 12px; padding: 8px 10px 10px; }
.modal legend { color: #fff; font-weight: 600; padding: 0 6px; }
.modal fieldset select { margin-bottom: 8px; }
.modal .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.modal .err { color: #e66; font-size: 13px; min-height: 18px; margin-top: 6px; }
.results { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.modal .result { display: flex; gap: 10px; text-align: left; background: #14181c; color: #bcd; padding: 8px; font-weight: normal; width: 100%; }
.modal .result:hover { background: #242c34; }
.result img, .result .noimg { width: 46px; height: 69px; object-fit: cover; flex-shrink: 0; background: #2c3440; border-radius: 3px; }
.result b { color: #fff; }
.result i { color: #678; font-style: normal; }
.result small { color: #789; }


@media (max-width: 1099px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .detail { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .info { grid-column: 1 / -1; }
  .review { border-top: 1px solid #2c3440; max-height: 300px; }
}

@media (max-width: 699px) {
  main { padding: 20px 12px 40px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail { grid-template-columns: minmax(0, 1fr); }
  .review { border-left: 0; }
}

/* Nav + stats page */
.nav { display: flex; justify-content: center; gap: 20px; margin: -16px 0 28px; font-size: 14px; letter-spacing: 1.5px; text-transform: uppercase; }
.nav a { color: #789; text-decoration: none; padding-bottom: 2px; }
.nav a:hover, .nav a.on { color: #fff; border-bottom: 2px solid #00e054; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.panel { background: #1c2228; border: 1px solid #242c34; border-radius: 8px; padding: 16px 18px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel h2 { margin: 0 0 12px; color: #fff; font-size: 14px; letter-spacing: 1.5px; text-transform: uppercase; }
.panel small { display: block; color: #678; font-size: 12px; }
.note { margin: -4px 0 12px; font-size: 12px; color: #678; }
.tiles { display: flex; flex-wrap: wrap; gap: 12px 40px; }
.tiles div { display: flex; flex-direction: column; }
.tiles b { color: #00e054; font-size: 28px; line-height: 1.1; }
.tiles span { font-size: 12px; color: #789; }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rank li { display: flex; gap: 12px; align-items: flex-start; }
.rank b { color: #fff; }
.count { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: #00e054; color: #14181c; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.panel table { width: 100%; border-collapse: collapse; font-size: 14px; }
.panel th { text-align: left; color: #789; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; padding: 6px 10px 8px 0; border-bottom: 1px solid #2c3440; }
.panel td { padding: 8px 10px 8px 0; border-bottom: 1px solid #242c34; color: #bcd; vertical-align: top; }
.panel td b { color: #fff; }
.big-line { margin: 14px 0 0; color: #bcd; }
.big-line b { color: #fff; }
@media (max-width: 1099px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 699px) { .stats-grid { grid-template-columns: 1fr; } .panel table { font-size: 13px; } }
.rewatchables { margin-top: 14px; padding-top: 12px; border-top: 1px solid #2c3440; font-size: 13px; }
.rw-head { color: #567; font-size: 11px; margin-bottom: 4px; }
.rewatchables a { display: block; color: #9cf; text-decoration: none; padding: 1px 0; }
.rewatchables a:hover { text-decoration: underline; }

/* Compare page */
.cmp { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles.sub { margin-top: 14px; padding-top: 14px; border-top: 1px solid #242c34; }
.inl { display: inline; }
.scroll { overflow-x: auto; }
.legend { margin: 0 0 10px; font-size: 12px; color: #789; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 12px; }
.dot:first-child { margin-left: 0; }
.dot.a, .bar.a, .split .a { background: #00e054; }
.dot.b, .bar.b, .split .b { background: #40bcf4; }
.split .ab { background: #ff8000; }
.split { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 14px 0 8px; background: #2c3440; }
.bar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 70px; gap: 8px; align-items: center; font-size: 13px; margin: 4px 0; }
.bar-label { color: #bcd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-pair { display: flex; flex-direction: column; gap: 2px; }
.bar { display: block; height: 6px; border-radius: 3px; min-width: 1px; }
.bar-val { color: #789; font-size: 12px; text-align: right; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.controls input, .controls select { background: #14181c; color: #bcd; border: 1px solid #2c3440; border-radius: 4px; padding: 6px 10px; font-size: 14px; }
.controls input { flex: 1; min-width: 200px; }
@media (max-width: 699px) { .cmp { grid-template-columns: 1fr; } .bar-row { grid-template-columns: 80px minmax(0, 1fr) 60px; } }