*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  --bg: #0f1115;
  --header-bg: rgba(15, 17, 21, 0.94);
  --panel: #191c22;
  --border: rgba(255, 255, 255, 0.12);
  --ink: #f7f8fa;
  --muted: #b3b9c4;
  --accent: #d91b42;
  --accent-ink: #ffffff;
  --secondary-bg: #262b35;
  --secondary-ink: #f7f8fa;
  --disabled-bg: #20242d;
  --disabled-ink: #9ca3b0;
  --radius: 16px;
  --btn-radius: 999px;
  --poster-ratio: 16 / 9;
  --poster-bg: #181a20;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  --focus: #ff6b87;

  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px / 1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Header & Navigation */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 26px;
  padding-left: 2px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  line-height: 1;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
  background: var(--secondary-bg);
  border-color: var(--border);
  text-decoration: underline;
}

.nav-link.is-active {
  background: var(--panel);
  border-color: var(--accent);
}

/* Main Feed */

.feed-main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.feed-head {
  margin-bottom: 18px;
}

.feed-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}

.feed-title {
  margin: 0 0 6px;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.feed-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 68ch;
}

.feed-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.empty-state {
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* Clip Cards */

.clip-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.poster-link {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: var(--poster-ratio);
  overflow: hidden;
  background: var(--poster-bg);
}

.poster-link img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.28s ease;
}

a.poster-link:hover img {
  transform: scale(1.04);
}

.poster-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.65) 0%,
    rgba(0, 0, 0, 0.08) 46%,
    rgba(0, 0, 0, 0.14) 100%
  );
  pointer-events: none;
}

.play-badge {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding-left: 3px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 21px;
  line-height: 1;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s ease;
}

a.poster-link:hover .play-badge {
  transform: scale(1.07);
}

.preview-badge {
  position: absolute;
  z-index: 1;
  left: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(10, 12, 16, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  line-height: 1.25;
}

.poster-link.is-disabled {
  cursor: default;
}

.poster-link.is-disabled img {
  filter: grayscale(35%) brightness(0.74);
}

.poster-link.is-disabled .play-badge {
  background: rgba(42, 46, 56, 0.88);
  color: #d6dae2;
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 15px 15px;
}

.card-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.dest-note {
  margin: 6px 0 14px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dest-host {
  font-weight: 700;
  color: var(--ink);
}

.card-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 10px;
  border-radius: var(--btn-radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.12s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-secondary {
  background: var(--secondary-bg);
  color: var(--secondary-ink);
  border-color: var(--border);
}

a.btn:hover,
button.btn:hover {
  filter: brightness(1.08);
  text-decoration: underline;
}

a.btn:active,
button.btn:active {
  transform: translateY(1px);
}

.btn.is-disabled {
  cursor: default;
  background: var(--disabled-bg);
  color: var(--disabled-ink);
  border-color: var(--border);
}

/* Six Visually Distinct Themes */

/* 1. Studio (Dark Charcoal) */
.t1 {
  --bg: #0f1115;
  --header-bg: rgba(15, 17, 21, 0.94);
  --panel: #191c22;
  --accent: #d91b42;
}

/* 2. Paper (Clean Light) */
.t2 {
  --bg: #f3f5f8;
  --header-bg: rgba(243, 245, 248, 0.94);
  --panel: #ffffff;
  --border: rgba(20, 24, 34, 0.12);
  --ink: #161820;
  --muted: #515866;
  --accent: #c41435;
  --accent-ink: #ffffff;
  --secondary-bg: #e7ebf1;
  --secondary-ink: #161820;
  --disabled-bg: #eceff4;
  --disabled-ink: #586070;
  --radius: 14px;
  --btn-radius: 10px;
  --shadow: 0 6px 20px rgba(18, 28, 45, 0.08);
  --focus: #9b0f29;
}

.t2 .play-badge {
  width: 70px;
  height: 44px;
  border-radius: 12px;
}

/* 3. Midnight (Deep Indigo) */
.t3 {
  --bg: #0e0c1d;
  --header-bg: rgba(14, 12, 29, 0.94);
  --panel: #1b1734;
  --border: rgba(164, 148, 255, 0.22);
  --ink: #f4f2ff;
  --muted: #b7b1dc;
  --accent: #6640de;
  --secondary-bg: #29234d;
  --secondary-ink: #f4f2ff;
  --disabled-bg: #221d40;
  --disabled-ink: #9c95c4;
  --radius: 24px;
  --btn-radius: 999px;
  --shadow: 0 10px 28px rgba(7, 4, 24, 0.45);
  --focus: #b39eff;
}

.t3 .play-badge {
  background: rgba(18, 14, 42, 0.78);
  border: 2px solid #ffffff;
}

/* 4. Cinema (Obsidian Widescreen) */
.t4 {
  --bg: #050505;
  --header-bg: rgba(5, 5, 5, 0.96);
  --panel: #141414;
  --border: rgba(255, 255, 255, 0.16);
  --ink: #f5f5f5;
  --muted: #b5b5b5;
  --accent: #b84314;
  --secondary-bg: #242424;
  --secondary-ink: #f5f5f5;
  --disabled-bg: #1d1d1d;
  --disabled-ink: #9b9b9b;
  --radius: 0px;
  --btn-radius: 4px;
  --poster-ratio: 2 / 1;
  --shadow: none;
  --focus: #ff8c5a;
}

.t4 .play-badge {
  width: 58px;
  height: 46px;
  border-radius: 4px;
}

.t4 .preview-badge {
  border-radius: 2px;
}

/* 5. Mint (Light Sage-Mint) */
.t5 {
  --bg: #eaf5f1;
  --header-bg: rgba(234, 245, 241, 0.94);
  --panel: #ffffff;
  --border: rgba(0, 102, 84, 0.18);
  --ink: #10241f;
  --muted: #3f6058;
  --accent: #006654;
  --accent-ink: #ffffff;
  --secondary-bg: #dcece6;
  --secondary-ink: #10241f;
  --disabled-bg: #e5f0ec;
  --disabled-ink: #476860;
  --radius: 22px;
  --btn-radius: 14px;
  --shadow: 0 6px 20px rgba(0, 74, 60, 0.08);
  --focus: #004d3f;
}

.t5 .poster-link {
  margin: 10px 10px 0;
  border-radius: 14px;
}

.t5 .play-badge {
  justify-self: start;
  align-self: start;
  margin: 12px;
  width: 44px;
  height: 44px;
  font-size: 17px;
}

/* 6. Sunset (Warm Plum) */
.t6 {
  --bg: #1f111a;
  --header-bg: rgba(31, 17, 26, 0.94);
  --panel: #311c29;
  --border: rgba(255, 160, 200, 0.2);
  --ink: #fdf4f8;
  --muted: #d2b2c2;
  --accent: #bc2461;
  --secondary-bg: #45293b;
  --secondary-ink: #fdf4f8;
  --disabled-bg: #392130;
  --disabled-ink: #b997a8;
  --radius: 18px;
  --btn-radius: 10px;
  --poster-ratio: 1.55 / 1;
  --shadow: 0 10px 26px rgba(18, 6, 14, 0.4);
  --focus: #ff7eb3;
}

.t6 .play-badge {
  background: linear-gradient(135deg, #e53d2b, #9c1474);
}

/* Share Preview Page */

.share-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.share-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.share-title {
  margin: 16px 0 0;
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.share-cover {
  margin: 16px 0 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--poster-bg);
}

.share-cover img {
  display: block;
  width: 100%;
  height: auto;
}

.share-desc {
  margin: 14px 0 0;
  font-size: 15px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.share-footer {
  margin-top: 20px;
  display: flex;
}

/* Admin Control Panel */

.admin-main {
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.admin-head h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 4vw, 30px);
  letter-spacing: -0.03em;
}

.admin-user {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
}

.alert {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
  font-size: 14px;
}

.alert p {
  margin: 6px 0 0;
}

.alert-ok {
  background: rgba(16, 136, 90, 0.16);
  border-color: rgba(46, 204, 140, 0.45);
}

.alert-warn {
  background: rgba(217, 146, 24, 0.16);
  border-color: rgba(245, 178, 56, 0.45);
}

.alert-error {
  background: rgba(217, 27, 66, 0.18);
  border-color: rgba(255, 92, 119, 0.55);
}

.alert-link,
.error-list a {
  text-decoration: underline;
  font-weight: 600;
}

.error-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.error-list li + li {
  margin-top: 4px;
}

.admin-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 18px;
}

.admin-section h2 {
  margin: 0 0 8px;
  font-size: 19px;
}

.section-help {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field {
  margin-top: 12px;
}

.field:first-child,
.field-row .field {
  margin-top: 0;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  color-scheme: dark;
  font: inherit;
  font-size: 14px;
}

.field textarea {
  resize: vertical;
}

.field textarea.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: #ff6b87;
}

.field-error {
  margin: 6px 0 0;
  font-size: 13px;
  color: #ff9cb0;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.menu-slot {
  padding: 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.dest-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dest-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.dest-item.has-error {
  border-color: #ff6b87;
}

.dest-thumb img,
.thumb-empty {
  display: grid;
  place-items: center;
  width: 88px;
  height: 50px;
  border-radius: 7px;
  border: 1px solid var(--border);
  object-fit: cover;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel);
}

.dest-input {
  min-width: 0;
}

.dest-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.dest-meta label {
  font-size: 13px;
  font-weight: 700;
}

.slot-host,
.slot-disabled {
  font-size: 12px;
  color: var(--muted);
}

.dest-input input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.save-bar {
  position: sticky;
  bottom: 10px;
  z-index: 6;
  padding: 10px;
  border-radius: 14px;
  background: var(--header-bg);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.save-btn {
  width: 100%;
  border-radius: 10px;
}

.inline-logout-form {
  display: inline;
  margin: 0;
}

.nav-btn {
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.auth-main {
  max-width: 520px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0 0 12px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.auth-submit {
  width: 100%;
  margin-top: 16px;
  border-radius: 10px;
}

.setup-steps h2 {
  margin: 14px 0 8px;
  font-size: 16px;
}

.setup-steps ol {
  margin: 0 0 12px;
  padding-left: 20px;
  font-size: 14px;
  color: var(--ink);
}

.setup-steps li + li {
  margin-top: 8px;
}

.account-section {
  margin-top: 22px;
}

.account-save-btn {
  margin-top: 14px;
  width: 100%;
  border-radius: 10px;
}

/* Responsive Breakpoints */

@media (min-width: 641px) {
  .feed-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 16px;
  }

  .field-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 981px) {
  .feed-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px 18px;
  }
}

@media (max-width: 420px) {
  .header-inner {
    padding: 10px 12px;
  }

  .brand {
    font-size: 18px;
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 12px;
  }

  .feed-main {
    padding: 14px 12px 32px;
  }

  .dest-item {
    grid-template-columns: 1fr;
  }

  .dest-thumb img,
  .thumb-empty {
    width: 100%;
    height: 110px;
  }
}
