/* Просмотрено — личная кинокартотека.
   Тёмный зал: тёплый почти-чёрный фон, янтарный свет проектора как акцент,
   моноширинные «картотечные» ярлыки. Постеры делают визуальную работу. */

:root {
  --bg: #16130f;
  --surface: #211d17;
  --surface-2: #2b261e;
  --line: #3a332a;
  --text: #ece4d4;
  --muted: #94897a;
  --amber: #e0a458;
  --amber-dim: #8a6537;
  --danger: #c96f5a;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

a { color: var(--amber); text-decoration: none; }

/* --- картотечные ярлыки --- */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 { font-size: 28px; font-weight: 750; letter-spacing: -.01em; }

/* --- шапка --- */
.top {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.top .spacer { flex: 1; }

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
}
.btn:hover { border-color: var(--amber-dim); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #16130f; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

/* --- вкладки --- */
.tabs { display: flex; gap: 4px; }
.tab {
  color: var(--muted); text-decoration: none;
  padding: 5px 12px; border-radius: 8px; font-size: 14px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--amber); background: var(--surface); }

/* --- таймлайн: лента отметок, свежие сверху --- */
.day { margin-bottom: 26px; }
.day > .eyebrow { margin-bottom: 8px; }

.row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: none; border: 0; border-top: 1px solid var(--line);
  padding: 10px 4px; text-align: left; color: inherit;
}
.day .row:first-of-type { border-top: 0; }
.row:hover { background: var(--surface); }
.row:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; border-radius: 8px; }

.row .thumb {
  width: 40px; height: 60px; flex-shrink: 0; border-radius: 5px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
}
.row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row .thumb .noposter { font-size: 9px; padding: 4px; line-height: 1.15; }

.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 3px; }
.row-time { font-family: var(--mono); font-size: 12px; color: var(--muted); flex-shrink: 0; }

.more { margin-top: 24px; text-align: center; }

/* --- фильтры --- */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 5px 14px;
}
.chip.on { border-color: var(--amber); color: var(--amber); }
.filters input[type="search"] {
  flex: 1; min-width: 160px; max-width: 280px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  outline: none;
}
.filters input[type="search"]:focus { border-color: var(--amber-dim); }

/* --- сетка постеров --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px 14px;
}
.card { background: none; border: 0; padding: 0; text-align: left; color: inherit; }
.card .poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
}
.card .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .poster .noposter {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 10px; text-align: center; color: var(--muted); font-family: var(--mono); font-size: 12px;
}
.card:hover .poster { border-color: var(--amber-dim); }
.card:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 10px; }
.card .title { margin-top: 8px; font-weight: 600; font-size: 14px; line-height: 1.3; }
.card .sub { margin-top: 2px; font-family: var(--mono); font-size: 11px; color: var(--muted); }

.badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--amber); color: #16130f;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 2px 8px;
}

.progressbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: rgba(0,0,0,.55);
}
.progressbar i { display: block; height: 100%; background: var(--amber); }

/* --- пустое состояние --- */
.empty { text-align: center; padding: 80px 0 40px; color: var(--muted); }
.empty .eyebrow { margin-bottom: 12px; }
.empty p { margin-bottom: 20px; }

/* --- логин --- */
.login { max-width: 360px; margin: 14vh auto 0; }
.login .panel { margin-top: 16px; }
.login .code-input {
  font-family: var(--mono); font-size: 30px; letter-spacing: .45em; text-align: center;
  width: 100%;
}
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px;
}

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--muted); }
.field input, .field select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--amber-dim); }

.seg { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; width: fit-content; }
.seg button { background: none; border: 0; color: var(--muted); padding: 7px 18px; }
.seg button.on { background: var(--amber); color: #16130f; font-weight: 650; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* --- карточка айтема --- */
.detail { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.detail .poster {
  width: 240px; max-width: 100%; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); flex-shrink: 0;
}
.detail .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail .info { flex: 1; min-width: 280px; }
.detail h1 { margin: 4px 0 2px; }
.detail .original { color: var(--muted); font-size: 15px; margin-bottom: 10px; }
.links { display: flex; gap: 10px; margin-bottom: 14px; }
.ext {
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--muted);
}
.ext:hover { border-color: var(--amber-dim); color: var(--amber); }

/* --- перфорация: сетка серий --- */
.season { margin-top: 18px; }
.season .head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.season .head .eyebrow { color: var(--text); }
.season .head .count { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.season .head button { margin-left: auto; }
.film { display: flex; flex-wrap: wrap; gap: 5px; }
.ep {
  width: 34px; height: 34px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-family: var(--mono); font-size: 11px; padding: 0;
}
.ep:hover { border-color: var(--amber-dim); }
.ep.watched { background: var(--amber); border-color: var(--amber); color: #16130f; font-weight: 700; }
.ep:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* «Чем смотрено» — сводка дорожек просмотра по сериалу */
.tracks { margin-top: 16px; }
.tracks .hint { margin: 3px 0; }

.stray { margin-top: 16px; }
.stray .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stray .chips button {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px;
}

.detail .actions { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (prefers-reduced-motion: no-preference) {
  .ep, .chip, .btn { transition: background .12s, border-color .12s, color .12s; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px 10px; }
  .detail .poster { width: 170px; }
  h1 { font-size: 23px; }
}

/* Поиск в TMDB на форме добавления */
.hint { color: var(--muted, #888); font-size: 13px; margin: 6px 0 0; }
.tmdb-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tmdb-hit {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 6px; border: 1px solid var(--line, #333); border-radius: 10px;
  background: none; color: inherit; cursor: pointer; font: inherit;
}
.tmdb-hit:hover { background: var(--surface); }
.tmdb-hit img, .tmdb-noposter {
  width: 34px; height: 51px; border-radius: 6px; object-fit: cover;
  background: var(--surface); flex: none;
}
.tmdb-hit-text { display: flex; flex-direction: column; min-width: 0; }
.tmdb-hit-text span { color: var(--muted, #888); font-size: 13px; }
