/* letterbox'd — dark theme with a 2.35:1 letterbox motif */

:root {
  --bg: #0e1116;
  --bg-2: #151a22;
  --card: #1a202a;
  --card-2: #222a36;
  --line: #2c3542;
  --text: #e8ecf1;
  --text-2: #9aa5b1;
  --text-3: #6b7683;
  --accent: #f0b429;
  --accent-dim: #8a6a1c;
  --watching: #f0b429;
  --planned: #5b9dd9;
  --completed: #69b47b;
  --dropped: #8a93a0;
  --danger: #d96464;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}

/* --- top bar: a letterbox frame around the logo -------------------------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
}

.logo-frame {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 0 10px;
}
.lb-bar {
  height: 4px;
  background: #000;
  border-radius: 2px;
}
.logo-text {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.4px;
  line-height: 1.1;
  color: var(--text);
}
.logo-text small {
  color: var(--accent);
  font-size: 12px;
  vertical-align: super;
}

#nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
#nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 600;
}
#nav a.active {
  background: var(--card-2);
  color: var(--text);
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

#foot {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  padding: 18px 0 26px;
}

/* --- generic -------------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 0 14px;
}
.page-head h1 {
  font-size: 20px;
  margin: 0;
}
.page-head .sub {
  color: var(--text-3);
  font-size: 13px;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-bar input { flex: 1; }

.btn {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
}
.btn:hover { background: #2a3442; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #14100a;
}
.btn.primary:hover { background: #f7c245; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }

.empty {
  text-align: center;
  color: var(--text-3);
  padding: 48px 16px;
}
.empty .big { font-size: 34px; margin-bottom: 8px; }

.error-box {
  background: #2a1a1a;
  border: 1px solid #4a2626;
  color: #e0a0a0;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

/* --- filter chips ---------------------------------------------------------- */

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.chip {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
}
.chip.active {
  background: var(--card-2);
  border-color: var(--accent-dim);
  color: var(--text);
}
.chip .count { color: var(--text-3); margin-left: 4px; }

/* --- shows grid ------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.08s ease, border-color 0.08s ease;
}
.card:active { transform: scale(0.98); }
.card:hover { border-color: #3a4553; }

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poster .fallback {
  font-size: 44px;
  font-weight: 800;
  color: #39424f;
}
/* letterbox bars over the poster: the app's motif */
.poster .lb-top, .poster .lb-bottom {
  position: absolute;
  left: 0; right: 0;
  height: 14%;
  background: #000;
  z-index: 1;
}
.poster .lb-top { top: 0; }
.poster .lb-bottom { bottom: 0; }

.card .meta {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.card .title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .sub {
  color: var(--text-3);
  font-size: 12px;
}
.card .row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #10131a;
}
.pill.watching  { background: var(--watching); }
.pill.planned   { background: var(--planned); color: #0d141c; }
.pill.completed { background: var(--completed); }
.pill.dropped   { background: var(--dropped); }

.rating-tag {
  font-weight: 800;
  color: var(--accent);
}

/* --- detail view -------------------------------------------------------------- */

.back {
  display: inline-block;
  color: var(--text-2);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
}
.back:hover { color: var(--text); }

.banner {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.banner .lb-bar { height: 22px; background: #000; border-radius: 0; }
.banner .inner {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(180deg, #171d26, #12161d);
  align-items: flex-start;
}
.banner .poster {
  width: 120px;
  flex: 0 0 120px;
  border-radius: 6px;
}
.banner .info { min-width: 0; flex: 1; }
.banner h1 {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.15;
}
.banner .facts {
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 6px;
}
.banner .genres {
  color: var(--text-3);
  font-size: 13px;
  margin-bottom: 8px;
}
.banner .overview {
  color: var(--text-2);
  font-size: 14px;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.controls label {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
}
.controls select { min-width: 120px; }

.stats {
  color: var(--text-2);
  font-size: 13px;
  margin: 0 0 18px;
}
.stats b { color: var(--text); }

.season {
  margin-bottom: 20px;
}
.season > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 0;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.season > summary::-webkit-details-marker { display: none; }
.season > summary .scount {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
}
.season[open] > summary .scount { display: none; }
.sbar {
  flex: 1;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.sbar i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.epgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.ep {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  text-align: left;
  color: var(--text);
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}
.ep .num {
  font-weight: 800;
  color: var(--text-3);
  font-size: 12px;
  min-width: 20px;
}
.ep .name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.ep .badge {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  min-width: 14px;
  text-align: right;
}
.ep .note-dot {
  color: var(--text-3);
  font-size: 11px;
}
.ep.watched {
  background: var(--card-2);
  border-color: #38434f;
}
.ep.watched .num { color: var(--accent); }
.ep.watched .name { color: var(--text); }
.ep.unwatched .name { color: var(--text-3); }
.ep .check {
  color: var(--completed);
  font-size: 12px;
  font-weight: 800;
}

/* --- log ---------------------------------------------------------------------- */

.log-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.log-item .when {
  flex: 0 0 84px;
  color: var(--text-3);
  font-size: 12px;
  padding-top: 2px;
}
.log-item .what {
  flex: 1;
  min-width: 0;
}
.log-item .what .line1 {
  font-weight: 700;
  font-size: 14px;
}
.log-item .what .line1 a:hover { color: var(--accent); }
.log-item .what .line2 {
  color: var(--text-3);
  font-size: 12px;
  margin-top: 1px;
}
.log-item .note {
  color: var(--text-2);
  font-size: 13px;
  font-style: italic;
  margin-top: 4px;
}
.log-item .score {
  flex: 0 0 34px;
  text-align: center;
  font-weight: 800;
  color: var(--accent);
  font-size: 16px;
  padding-top: 1px;
}

/* --- search results --------------------------------------------------------------- */

.result {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.result .thumb {
  width: 52px;
  height: 78px;
  border-radius: 6px;
  background: #000;
  overflow: hidden;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.result .thumb img { width: 100%; height: 100%; object-fit: cover; }
.result .thumb .fallback { font-size: 20px; color: #39424f; font-weight: 800; }
.result .info { flex: 1; min-width: 0; }
.result .info .t { font-weight: 700; }
.result .info .s { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.result .info .o { color: var(--text-2); font-size: 12px; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --- rating picker ------------------------------------------------------------------ */

.rating-row {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.rating-row button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  padding: 0;
}
.rating-row button.sel {
  background: var(--accent);
  border-color: var(--accent);
  color: #14100a;
}
.rating-row button:hover { border-color: var(--accent-dim); }

/* --- modal ---------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 9, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 18px 18px 26px;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 14px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
}
.modal h2 {
  margin: 0 0 4px;
  font-size: 17px;
}
.modal .msub {
  color: var(--text-3);
  font-size: 13px;
  margin-bottom: 14px;
}
.modal .mrow {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.modal .field { margin-bottom: 14px; }
.modal .field label {
  display: block;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.modal textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
}

/* --- password prompt ------------------------------------------------------------------- */

.pw-box { max-width: 360px; }
.pw-box input { width: 100%; }

/* small screens */
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .epgrid { grid-template-columns: 1fr 1fr; }
  .banner .poster { width: 92px; flex-basis: 92px; }
}
