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

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2333;
  --muted: #6b7280;
  --primary: #b8860b;
  --primary-dark: #96690a;
  --danger: #dc2626;
  --border: #e2e5ea;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { width: min(1100px, 92%); margin: 0 auto; }

main.container { flex: 1; padding: 2rem 0 3rem; }

/* Header */
.site-header {
  background: #14181f;
  padding: 0.9rem 0;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.site-header nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.site-header nav a { color: #c9cdd6; text-decoration: none; font-size: 0.95rem; }
.site-header nav a:hover { color: #fff; }
.admin-header { background: #14181f; }

/* Footer */
.site-footer {
  background: #14181f;
  color: #8b909b;
  padding: 1rem 0;
  font-size: 0.85rem;
}

/* Headings & misc */
h1 { font-size: 1.7rem; margin-bottom: 1rem; }
h2 { font-size: 1.15rem; }
.empty { color: var(--muted); padding: 2rem 0; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 1rem; }
code { background: #eef0f4; padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.85em; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.page-head h1 { margin-bottom: 0; }

/* Flash messages */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  font-size: 0.95rem;
}
.flash-success { background: #e7f6ec; color: #166534; border: 1px solid #b7e2c5; }
.flash-error { background: #fdecec; color: #991b1b; border: 1px solid #f5c2c2; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(0.96); }
.btn-primary { background: var(--primary); border-color: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.83rem; }
.copy-url { margin-left: 0.4rem; }
.copy-url.copied { background: #e7f6ec; border-color: #b7e2c5; color: #166534; }

/* Tables (admin) */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
th { background: #fafbfc; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
td.actions { display: flex; gap: 0.4rem; align-items: center; }
td.actions form { display: inline; }

/* Forms */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  max-width: 640px;
}
.form-card.narrow { max-width: 400px; margin: 3rem auto; }
.form-card h1 { margin-bottom: 1.2rem; }
.form-card label { display: block; margin-bottom: 1rem; font-weight: 600; font-size: 0.92rem; }
.form-card input[type="text"],
.form-card input[type="password"],
.form-card textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 400;
}
.form-card input[type="file"] { display: block; margin-top: 0.35rem; font-weight: 400; }
.form-card input:focus, .form-card textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 1.2rem; }

/* Public clip grid */
.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.4rem;
}
.clip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.clip-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(20, 24, 31, 0.1); }
.clip-card .thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #14181f;
  pointer-events: none;
}
.clip-card-body { padding: 0.9rem 1rem 1.1rem; }
.clip-card-body h2 { margin-bottom: 0.3rem; }
.clip-card-body p { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.4rem; }
.date { color: var(--muted); font-size: 0.82rem; }

/* Clip detail */
.clip-detail { max-width: 860px; }
.player {
  width: 100%;
  max-height: 480px;
  background: #000;
  border-radius: var(--radius);
  margin: 1rem 0 0.6rem;
  display: block;
}
.watch-link { margin-bottom: 1.4rem; }
.watch-link a {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--primary);
}
.watch-link a:hover { color: var(--primary); }
.description { color: var(--text); margin-bottom: 1.5rem; }

/* Admin detail meta */
.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1.2rem;
  margin: 1rem 0 1.4rem;
  font-size: 0.92rem;
}
.meta dt { font-weight: 600; color: var(--muted); }

/* Comments */
.comments { max-width: 860px; margin: 2rem 0; }
.comments h2 { margin-bottom: 1rem; }
.comment-list { display: flex; flex-direction: column; gap: 0.9rem; margin: 1.6rem 0; }
.comment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
}
.comment-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.comment-meta span { color: var(--muted); font-size: 0.82rem; }
.comment-body { font-size: 0.95rem; white-space: normal; }
.comment-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; }
.comment-form label { display: block; margin-bottom: 0.9rem; font-weight: 600; font-size: 0.92rem; }
.comment-form input[type="text"],
.comment-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 400;
}
.comment-form input:focus, .comment-form textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* Episode strip (first 4 pills + more) */
.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: #f5ecd3;
  color: var(--primary-dark);
  border: 1px solid #e2d3a1;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.episode-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.2rem;
}
.ep-label {
  width: 100%;
  margin: 0 0 0.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.ep-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: filter 0.15s, border-color 0.15s;
}
.ep-pill:hover { filter: brightness(0.96); }
.ep-pill.active {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #fff;
}
.ep-pill.more {
  background: #fff;
  color: var(--primary-dark);
  cursor: pointer;
}

/* Bottom episode sheet */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 12, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  z-index: 1000;
}
.overlay.open { opacity: 1; visibility: visible; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1001;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(35, 32, 25, 0.25);
  transform: translateY(105%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 72vh;
  display: flex;
  flex-direction: column;
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 46px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  margin: 10px auto 2px;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 1.25rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.sheet-header h2 { margin: 0; font-size: 1.1rem; }
.close-btn {
  border: none;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
}
.close-btn:hover { background: #f1ead9; color: var(--text); }
.page-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.page-tab {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.page-tab.active {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #fff;
}
.ep-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  padding: 1rem 1.25rem 1.4rem;
}
.ep-grid[hidden] { display: none; }
.ep-num {
  padding: 0.55rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: filter 0.15s;
}
.ep-num:hover { filter: brightness(0.96); }
.ep-num.active {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #fff;
}
@media (max-width: 560px) {
  .ep-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
}

/* Thumbnail images */
.poster {
  width: 100%;
  max-width: 860px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  background: #14181f;
}
.thumb-preview {
  display: block;
  width: 220px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.8rem;
}
.admin-form .thumb-preview { margin-top: 0.4rem; }

/* Admin episode rows */
.episode-rows { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 0.8rem; }
.episode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbfc;
}
.episode-row input[type="number"] { width: 5.5rem; }
.episode-row input[type="text"] { flex: 1 1 160px; }
.episode-row input[type="file"] { flex: 1 1 200px; font-size: 0.82rem; }
.episode-row select,
.episode-row input[type="number"],
.episode-row input[type="text"],
.episode-row input[type="file"] {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 400;
}
.episode-file {
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.episode-remove {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--danger);
  margin: 0;
}

/* Inline form (admin genre rows) */
.inline-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.inline-form input[type="text"] {
  width: 160px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 400;
}
.inline-form input[type="text"]:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* Genre pill on clip page */
.genre-row { margin-top: 1.1rem; }
.genre-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: #f7eecd;
  color: var(--primary-dark);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: filter 0.15s;
}
.genre-pill:hover { filter: brightness(0.97); }
.genre-pill .arrow { font-size: 0.75rem; line-height: 1; }

/* Information section on clip page */
.info-section { margin-top: 1.6rem; }
.info-title {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* Recommended grid */
.recommended { margin-top: 2rem; }
.recommended h2 {
  font-size: 1.1rem;
  margin: 0 0 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.recommended h2 .count { color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.rec-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.rec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.rec-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(20, 24, 31, 0.1); }
.rec-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: #14181f;
}
.rec-poster-empty { display: block; }
.rec-body { padding: 0.65rem 0.75rem 0.85rem; display: flex; flex-direction: column; gap: 0.45rem; }
.rec-title {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rec-genre {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: #f7eecd;
  border: 1px solid #ead9a3;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
}
.thumb-empty {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #14181f;
}
@media (max-width: 767px) {
  .rec-grid { gap: 0.5rem; }
  .rec-body { padding: 0.5rem 0.55rem 0.65rem; gap: 0.35rem; }
  .rec-title { font-size: 0.7rem; }
  .rec-genre { font-size: 0.64rem; padding: 0.1rem 0.5rem; }
}
