/* Regal dark-purple theme. Colours live in variables; purple is reserved for navigation and codes. */
:root {
  color-scheme: dark; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #130e24; --bg-2: #1a1332; --surface: #211a40; --surface-2: #2b2255; --line: #3e3170;
  --text: #f3effc; --muted: #a99fc8; --offwhite: #f8f5ff;
  --accent: #a77bff; --accent-strong: #8b5cf6; --accent-deep: #6d3fe0; --accent-glow: #c4a5ff;
  --gold: #e9c46a; --good: #4ade80; --bad: #ff8fa3;
  background: var(--bg); color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(1200px 600px at 20% -10%, #231a47 0%, var(--bg) 60%) fixed; min-height: 100vh; }
[hidden] { display: none !important; }
.page { width: min(1500px, calc(100% - 32px)); margin: 18px auto 80px; }
a { color: var(--accent-glow); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0; font-size: clamp(1.3rem, 2.5vw, 1.8rem); letter-spacing: -.02em; }
h2 { margin: 0 0 4px; font-size: 1.1rem; }
h3 { margin: 0; font-size: .98rem; }
h4 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.muted { color: var(--muted); font-size: .88rem; margin: 6px 0; }
.muted-inline { color: var(--muted); font-size: .82rem; }
code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: .85em; }
select, input, textarea, button { font: inherit; }
select, input, textarea { min-width: 0; color: var(--text); background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Buttons */
button, .action-link { color: var(--offwhite); background: linear-gradient(180deg, var(--accent-strong), var(--accent-deep)); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; font-size: .86rem; font-weight: 600; text-decoration: none; }
button.secondary { background: var(--surface); border-color: var(--line); font-weight: 500; }
button:hover:not(:disabled), .action-link:hover { filter: brightness(1.15); text-decoration: none; }
.action-link { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; white-space: nowrap; flex-shrink: 0; }
.nav-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 13px; color: var(--offwhite); background: var(--surface-2); border: 1px solid var(--accent); border-radius: 8px; font-size: .84rem; font-weight: 600; text-decoration: none; white-space: nowrap; box-shadow: 0 0 0 1px #0004 inset; }
.nav-btn:hover { background: var(--accent-deep); text-decoration: none; }
.nav-btn.is-active { background: linear-gradient(180deg, var(--accent-strong), var(--accent-deep)); border-color: var(--accent-glow); }
.nav-next { background: linear-gradient(180deg, var(--accent-strong), var(--accent-deep)); border-color: var(--accent-glow); box-shadow: 0 0 14px #8b5cf655; }
.nav-prev { background: var(--surface-2); }
button.nav-btn { width: 100%; }

/* Movie code: always a purple button with off-white text */
.code-button { display: inline-flex; align-items: center; padding: 3px 11px; color: var(--offwhite) !important; background: var(--accent-strong); border: 1px solid var(--accent-glow); border-radius: 8px; font-weight: 700; font-size: .85rem; letter-spacing: .02em; text-decoration: none !important; white-space: nowrap; }
a.code-button:hover { background: var(--accent-deep); }
.code-button.compact { padding: 1px 7px; font-size: .72rem; }
.code-tag { display: inline-block; padding: 1px 8px; color: var(--offwhite); background: var(--accent-strong); border-radius: 6px; font-weight: 700; font-size: .82em; }
.actress-button { display: inline-flex; padding: 3px 11px; color: var(--offwhite); background: var(--surface-2); border: 1px solid var(--accent); border-radius: 999px; font-size: .84rem; text-decoration: none !important; }
.actress-button:hover { background: var(--accent-deep); }
.genre-chip { display: inline-flex; padding: 2px 9px; color: var(--accent-glow); background: #8b5cf61f; border: 1px solid #8b5cf655; border-radius: 6px; font-size: .78rem; text-decoration: none !important; }
.genre-chip:hover { background: #8b5cf64d; }
.badge-subbed { display: inline-flex; padding: 1px 8px; color: #052e16; background: var(--good); border-radius: 6px; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.sep, .dot { color: var(--muted); }

/* Header */
.app-header { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.listing-header { display: grid; gap: 10px; }
.brand { color: var(--gold); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; }
.catalog-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.movie-header { display: grid; gap: 9px; }
.title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.movie-title { overflow-wrap: anywhere; }
.people-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.release { color: var(--muted); font-size: .82rem; margin-left: 4px; }
.channel-header { display: grid; gap: 9px; }
.ch-row { display: grid; align-items: center; gap: 8px; }
.ch-row-1 { grid-template-columns: 20% minmax(0, 1fr) 20%; }
.ch-row-2 { grid-template-columns: 30% minmax(0, 1fr) 30%; }
.ch-row select { width: 100%; min-height: 36px; font-weight: 600; }
.ch-current { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; min-width: 0; text-align: center; }
.ch-title { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }

/* Player */
.player-shell { width: 100%; aspect-ratio: 16/9; max-height: calc(100vh - 190px); min-height: 240px; background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.player-shell iframe, .player-shell video { display: block; width: 100%; height: 100%; border: 0; background: #000; }
.resume-toast { display: flex; align-items: center; gap: 10px; margin: 10px 0; padding: 9px 12px; background: var(--surface); border: 1px solid var(--accent); border-radius: 8px; }
.status-panel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.status-panel > div { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; min-width: 0; }
.label { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 3px; }
.label-inline { color: var(--muted); font-size: .88rem; }

/* Chapters: horizontally scrollable strip of fixed-size cards */
.scene-section { margin-top: 16px; }
.section-heading { display: flex; align-items: baseline; gap: 12px; margin-bottom: 9px; }
.stats { color: var(--muted); font-size: .82rem; }
.scenes { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-color: var(--accent-deep) var(--bg-2); }
.scene { flex: 0 0 220px; height: 172px; display: flex; flex-direction: column; overflow: hidden; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.scene.selected { border-color: var(--gold); }
.scene:focus-within, .scene:hover { border-color: var(--accent); }
.scene-image { flex: 0 0 98px; display: block; background: #000; cursor: zoom-in; }
.scene-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.scene-main { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 8px 10px; text-align: left; color: var(--text); background: transparent; border: 0; border-radius: 0; font-weight: 400; overflow: hidden; }
button.scene-main:hover:not(:disabled) { background: var(--surface-2); filter: none; }
.scene-title { font-size: .88rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.scene-time { color: var(--accent-glow); font-weight: 700; font-size: .92rem; font-variant-numeric: tabular-nums; }
.scene-key { color: var(--muted); font-size: .7rem; }
/* Without an image the same card size is filled by larger title and time text. */
.scene.no-image .scene-main { align-items: flex-start; justify-content: center; padding: 14px; gap: 8px; }
.scene.no-image .scene-title { font-size: 1.2rem; -webkit-line-clamp: 3; }
.scene.no-image .scene-time { font-size: 1.7rem; }
.scene.readonly .scene-main { cursor: default; }

/* Remote: row 1 = chapter jumps, row 2 = seek + play/pause */
.remote-layout { margin: 14px 0 10px; display: grid; gap: 8px; }
.remote-row { display: grid; gap: 8px; }
.remote-chapters { grid-template-columns: 1fr 1fr; }
.remote-seek { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.remote-row button { min-height: 50px; min-width: 0; padding: 8px 10px; font-size: .9rem; touch-action: manipulation; }
.remote-seek button { background: var(--surface-2); border-color: var(--line); }
.remote-seek .play-toggle { background: linear-gradient(180deg, var(--accent-strong), var(--accent-deep)); border-color: var(--accent-glow); font-size: 1rem; }
.chap-btn { display: flex; align-items: center; gap: 10px; background: linear-gradient(180deg, var(--accent-strong), var(--accent-deep)); }
.chap-prev { justify-content: flex-start; text-align: left; }
.chap-next { justify-content: flex-end; text-align: right; }
.chap-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chap-arrow { font-size: 1.2rem; font-weight: 800; }
.chap-btn.is-empty, .chap-btn:disabled { background: var(--bg-2); border-color: var(--line); color: #6f6690; opacity: .7; }

.utility-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chapter-manager, .diagnostics, .subtitle-row, .video-list, .download-block, .code-summary { margin: 12px 0; padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.chapter-manager p, .diagnostics > p { color: var(--muted); font-size: .88rem; margin: 0; }
.chapter-create { display: grid; grid-template-columns: minmax(100px, .7fr) auto minmax(160px, 1.1fr) minmax(125px, .7fr); align-items: end; gap: 9px; margin: 12px 0; }
.chapter-create label, .custom-chapter-row label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: .76rem; min-width: 0; }
.inline-check { flex-direction: row !important; align-items: center; gap: 7px !important; }
.inline-check input { width: auto; }
.custom-chapter-list { display: grid; gap: 8px; }
.custom-chapter-row { display: grid; grid-template-columns: minmax(100px, .7fr) minmax(150px, 1.2fr) minmax(110px, .6fr) auto minmax(160px, 1fr) auto; gap: 8px; align-items: end; padding: 9px; background: var(--bg-2); border-radius: 8px; }
.custom-chapter-row.invalid input, .custom-chapter-row.invalid select { border-color: var(--bad); }
.export-details { margin-top: 14px; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; }
summary { cursor: pointer; font-weight: 650; }
.export-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 8px; flex-wrap: wrap; }
.export-actions { display: flex; flex-wrap: wrap; gap: 7px; }
[data-chapter-export] { display: block; width: 100%; resize: vertical; font: .8rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.export-status { margin: 8px 0 0; overflow-wrap: anywhere; }
.export-status[data-state="error"] { color: var(--bad) !important; }
.export-status[data-state="success"] { color: var(--good) !important; }

.subtitle-row { display: flex; align-items: center; gap: 10px; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 34px; padding: 0; }
.video-list { padding: 0; overflow: hidden; }
.video-picker > summary { list-style: none; padding: 12px 14px; white-space: normal; overflow-wrap: anywhere; line-height: 1.4; font-weight: 600; }
.video-picker > summary::-webkit-details-marker { display: none; }
.video-picker > summary::after { content: "▾"; float: right; margin-left: 10px; color: var(--accent-glow); }
.video-picker[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.video-picker-list { list-style: none; margin: 0; padding: 6px; max-height: 340px; overflow-y: auto; display: grid; gap: 4px; }
.video-pick { width: 100%; text-align: left; white-space: normal; overflow-wrap: anywhere; line-height: 1.4; background: var(--bg-2); border: 1px solid var(--line); font-weight: 500; }
.video-pick.is-current { border-color: var(--gold); background: var(--surface-2); }

.diagnostics .capabilities { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.capability { border-radius: 5px; padding: 4px 6px; background: var(--bg-2); font-size: .74rem; }
.capability.yes b { color: var(--good); } .capability.no b { color: var(--bad); }
.log { margin: 0; padding-left: 22px; max-height: 180px; overflow: auto; color: var(--muted); font: .75rem/1.5 ui-monospace, monospace; }

.home-button { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 20; width: 50px; height: 50px; padding: 0; display: grid; place-items: center; border-radius: 50%; box-shadow: 0 4px 18px #000a, 0 0 18px #8b5cf666; }

/* Listings */
.route-list { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 9px; }
.route-list > li, .provider-block { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.route-list > li { display: grid; gap: 8px; }
.route-list.tight > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 14px; }
.route-list > li > a { font-weight: 650; }
.route-list span { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.listing-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.route-list textarea { display: block; width: 100%; margin: 8px 0; font: .78rem/1.45 ui-monospace, monospace; }
.domain-list { display: flex; flex-wrap: wrap; gap: 8px 18px; list-style: none; margin: 12px 0 0; padding: 0; }
.domain-list li { display: flex; gap: 7px; align-items: center; }
.provider-block { margin: 10px 0; } .provider-block p { margin: 0; color: var(--muted); font-size: .88rem; }
.movie-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.movie-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.movie-row-body { flex: 1; min-width: 0; display: grid; gap: 5px; }
.movie-row-body strong { overflow-wrap: anywhere; }
.movie-meta { color: var(--muted); font-size: .82rem; }
.movie-genres { display: flex; flex-wrap: wrap; gap: 5px; }
.search-form { display: flex; gap: 8px; margin: 8px 0 12px; }
.search-form input { flex: 1; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.video-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 14px 0; }
.video-card { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.video-card-player { aspect-ratio: 16/9; background: #000; }
.video-card-player iframe, .video-card-player video { display: block; width: 100%; height: 100%; border: 0; }
.video-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; }
.video-card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.video-card-meta h3 { overflow-wrap: anywhere; } .video-card-meta p { color: var(--muted); margin: 4px 0 0; font-size: .8rem; }
.code-summary p { margin: 6px 0; }
.section-label { margin: 16px 0 8px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.month-links { display: flex; flex-wrap: wrap; gap: 6px; }
.download-block button { margin: 6px 0; }

/* Calendar */
.cal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.cal-nav strong { min-width: 150px; text-align: center; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 10px 0; }
.cal-head { text-align: center; color: var(--muted); font-size: .75rem; padding: 4px 0; }
.cal-day { min-height: 84px; padding: 5px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.cal-day.empty { background: transparent; border-color: transparent; }
.cal-day.today { border-color: var(--gold); }
.cal-day.has-items { background: var(--surface-2); }
.cal-num { color: var(--muted); font-size: .72rem; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: #0a0618cc; backdrop-filter: blur(3px); }
.modal-panel { width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 16px 18px; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 10px 40px #000b; }
.modal-panel .section-heading { justify-content: space-between; align-items: center; }
.keys-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.keys-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.keys-table td:first-child { white-space: nowrap; width: 1%; padding-right: 16px; }
kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--bg-2); color: var(--offwhite); font: .82rem ui-monospace, monospace; }
.image-modal { background: #05030cf0; cursor: zoom-out; }
.image-modal figure { margin: 0; max-width: 100%; max-height: 100%; display: grid; gap: 10px; justify-items: center; }
.image-modal img { max-width: 100%; max-height: calc(100vh - 100px); object-fit: contain; border-radius: 8px; }
.image-modal figcaption { color: var(--muted); }
.modal-close { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 1.1rem; }

@media (max-width: 1000px) { .scenes { scroll-padding: 0 12px; } .video-grid { grid-template-columns: 1fr; } }
@media (max-width: 650px) {
  .page { width: calc(100% - 18px); margin-top: 10px; }
  .player-shell { min-height: 0; max-height: none; }
  .ch-row-1 { grid-template-columns: 24% minmax(0, 1fr) 24%; } .ch-row-2 { grid-template-columns: 30% minmax(0, 1fr) 30%; }
  .nav-btn { padding: 6px 8px; font-size: .78rem; }
  .remote-row button { font-size: .78rem; padding: 6px 4px; }
  .chap-btn { font-size: .8rem; }
  .scene { flex-basis: 190px; height: 160px; } .scene-image { flex-basis: 88px; }
  .status-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chapter-create, .custom-chapter-row { grid-template-columns: 1fr; }
  .video-card-meta, .listing-row { align-items: flex-start; flex-direction: column; }
  .movie-row { flex-wrap: wrap; }
  .calendar-grid { grid-template-columns: 1fr; }
  .cal-head, .cal-day.empty, .cal-day:not(.has-items) { display: none; }
  .cal-day { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .cal-num::before { content: "Day "; }
}
