:root {
  /* Core palette */
  --bg: #0f0f10;
  --fg: #f5f5f5;
  --muted: #a1a1a1;

  --accent: #e50914;
  --accent-2: #b20710;

  /* Surfaces */
  --surface-card: #1b1b1d;
  --surface-hover: #27272a;
  --surface-header: #121213;
  --surface-elevated: #101012;
  --surface-input: #141416;
  --surface-input-focus: #151518;
  --surface-table-alt: #111114;
  --surface-pill: #111111;
  --surface-danger: #2a1416;
  --surface-success: #122222;
  --surface-overlay: rgba(0, 0, 0, 0.65);
  --surface-resume-backdrop: rgba(0, 0, 0, 0.6);
  --surface-thumb-fallback: #000000;

  /* Borders */
  --border-strong: #1f1f21;
  --border-subtle: #242428;
  --border-soft: #2a2a2e;
  --border-soft-2: #333333;
  --border-danger: #5c1b1f;
  --border-success: #245d37;

  /* Text accents */
  --text-danger: #ffd3d6;
  --text-success: #7bf58a;

  /* Special brands */
  --discord-bg: #5865f2;
  --discord-alt-bg: #a81919;

  /* Shadows */
  --shadow-1: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 8px 20px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 18px 60px rgba(0, 0, 0, 0.65);
  --shadow-card-hover: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-live-pill: 0 1px 6px rgba(0, 0, 0, 0.4);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --radius-pill: 999px;

  /* Gradients / special */
  --perm-dot-active-bg: radial-gradient(
    circle at center,
    #000000 5%,
    #6b0c0f 25%,
    #b20710 55%,
    #e5141e 85%,
    #b20710 100%
  );

  /* Live badge */
  --live-pill-bg: #e50914;
  --live-pill-fg: #ffffff;

  /* Misc */
  --focus-ring: 0 0 0 3px rgba(178, 7, 16, 0.3);
}

/* --------- BASE --------- */
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Sans JP", "Segoe UI", Roboto, system-ui, -apple-system,
    "Apple Color Emoji", "Segoe UI Symbol", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Contained layout */
.container,
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}
.wrap {
  margin-top: 1rem;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--surface-header);
  border-bottom: 1px solid var(--border-strong);
  position: relative;
}
header h1 {
  margin: 0;
  font-size: 1.25rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-right img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
.header-right img:hover {
  transform: scale(1.05);
  transition: transform 0.15s ease-in-out;
}

/* User dropdown */
.site-header__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-menu {
  position: relative;
  margin-left: auto;
}
.user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.user-btn:focus {
  outline: none;
}
.user-btn img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
.user-dd {
  position: absolute;
  right: 0;
  top: 42px;
  min-width: 180px;
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  display: none;
  z-index: 1000;
  overflow: hidden;
}
.user-dd.open {
  display: block;
}
.user-dd .head {
  padding: 0.65rem 0.8rem;
  font-weight: 700;
  color: var(--fg);
  border-bottom: 1px solid var(--border-subtle);
}
.user-dd .item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.8rem;
  color: var(--fg);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.user-dd .item:hover {
  background: var(--surface-hover);
}
.user-dd .danger {
  color: var(--text-danger);
  background: var(--surface-danger);
  border-top: 1px solid var(--border-danger);
}
.user-dd .danger:hover {
  background: var(--accent-2);
}
.user-dd .black {
  background: var(--surface-hover);
}
.user-dd .black:hover {
  background: #42424a;
}

/* Buttons */
.btn {
  background: var(--accent);
  color: #fff;
  border: 1px solid rgba(229, 9, 20, 0.25);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.06s ease, background 0.15s ease,
    box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:hover {
  background: #77050b;
  text-decoration: none;
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.18) inset;
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(40%);
  box-shadow: none !important;
}
.btn.secondary {
  background: #1c1c1f;
  color: #e6e6e6;
  border: 1px solid var(--border-soft);
}
.btn.secondary:hover {
  background: #232327;
  border-color: #35353b;
}
.btn.danger {
  background: #1c0f12;
  color: #ffb3b8;
  border: 1px solid rgba(229, 9, 20, 0.45);
}
.btn.danger:hover {
  background: #240e12;
  border-color: var(--accent);
  color: #ffe5e7;
}
.btn.discord {
  background: var(--discord-alt-bg);
  color: #fff;
  border: 0;
  border-radius: var(--radius-md);
  padding: 0.45rem 0.8rem;
  font-weight: 800;
}
.btn.discord:hover {
  filter: brightness(1.05);
  text-decoration: none;
}
.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--surface-pill);
  border: 1px solid var(--border-soft-2);
  color: #ddd;
  font-size: 0.8rem;
}

/* Cards & grids */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--fg);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
}
.card.empty {
  opacity: 0.7;
}
.card .thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-thumb-fallback);
}
.card .title {
  padding: 0.6rem 0.8rem;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  color: var(--fg);
}
.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.sec-head h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}
.sec-head span {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}
th {
  color: var(--accent-2);
  text-align: left;
}
tr:hover {
  background: var(--surface-hover);
}
.role {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  color: #fff;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
}

/* Thumbnails (index/folder) */
.card .thumb,
.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--surface-thumb-fallback);
  border-radius: var(--radius-sm);
}
.card.empty {
  filter: grayscale(80%) brightness(0.5);
  opacity: 0.6;
  pointer-events: none;
}

/* Folder cover image */
.cover {
  display: block;
  max-width: 512px;
  max-height: 512px;
  width: auto;
  height: auto;
  margin: 1.5rem auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  object-fit: cover;
}

/* Crumbs */
.crumbs {
  margin: 1rem 0;
  color: var(--muted);
}
a.back {
  color: var(--accent);
}

/* Float panel (setlist editor) */
.float-panel {
  position: fixed;
  top: 10vh;
  left: 10vw;
  width: min(900px, 92vw);
  max-height: 80vh;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3), 0 0 0 1px rgba(229, 9, 20, 0.06);
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
}
.float-panel.minimized {
  top: auto !important;
  bottom: 0;
  left: 10px;
  right: auto;
  width: 420px;
  height: auto;
  display: flex;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(229, 9, 20, 0.06);
}
.float-panel.minimized .float-head {
  cursor: pointer;
}
.float-panel.minimized .float-body,
.float-panel.minimized .float-actions {
  display: none !important;
}

.float-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  cursor: move;
  background: linear-gradient(180deg, var(--surface-header) 0%, var(--surface-elevated) 100%);
  border-bottom: 1px solid #1e1e22;
  user-select: none;
  box-shadow: inset 0 -1px 0 rgba(229, 9, 20, 0.12);
}
.float-title {
  font-weight: 800;
  letter-spacing: 0.3px;
}
.drag-handle {
  display: inline-flex;
  gap: 3px;
  margin-right: 0.25rem;
  opacity: 0.85;
}
.drag-dot {
  width: 4px;
  height: 4px;
  background: #732027;
  border-radius: 50%;
}
.float-body {
  padding: 0.8rem;
  overflow: auto;
  background: var(--bg);
}
.float-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  border-top: 1px solid #1e1e22;
  padding: 0.6rem 0.85rem;
  background: var(--surface-elevated);
}

/* Setlist table */
table.setlist {
  width: 100%;
  border-collapse: collapse;
}
table.setlist th {
  color: #e6e6e6;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 0.55rem 0.5rem;
  background: var(--surface-table-alt);
  border-bottom: 1px solid #1e1e22;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.setlist td {
  border-bottom: 1px solid #1a1a1e;
  padding: 0.5rem;
  vertical-align: middle;
}
table.setlist tr:hover td {
  background: #121215;
}
table.setlist input {
  width: 100%;
  background: var(--surface-input);
  color: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.6rem;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease,
    background 0.15s ease;
}
table.setlist input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.14);
  background: var(--surface-input-focus);
}
table.setlist td:last-child {
  text-align: right;
}

/* Player controls (custom) */
.vctrl {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface-header);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  margin: 0.5rem auto 0;
  max-width: 1080px;
}
.vc-btn {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}
.vc-btn:hover {
  background: var(--surface-hover);
}
.vc-time {
  min-width: 160px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.vc-seek {
  position: relative;
  flex: 1;
  height: 8px;
  background: #1a1a1a;
  border-radius: var(--radius-pill);
  cursor: pointer;
  overflow: hidden;
}
.vc-buffer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: #500000;
  opacity: 0.6;
}
.vc-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--accent);
}
.vc-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.35);
  pointer-events: none;
}
.vc-vol {
  width: 110px;
}
.vc-quality {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.45rem;
}
@media (max-width: 700px) {
  .vc-time {
    display: none;
  }
  .vc-vol {
    width: 80px;
  }
}

/* Video wrapper & skip intro */
.video-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}
.skip-intro {
  position: absolute;
  bottom: 7.5rem;
  right: 4rem;
  background: var(--accent);
  color: var(--fg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.skip-intro:hover {
  background: #e01018;
}

/* Live stream player + badge */
.live-player-wrap {
  position: relative;
}
.live-badge {
  position: absolute;
  left: 42px;
  bottom: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--live-pill-bg);
  color: var(--live-pill-fg);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-live-pill);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 3;
}
.live-badge.hidden {
  opacity: 0;
}
@media (max-width: 640px) {
  .live-badge {
    bottom: 10px;
  }
}
#livePlayer::-webkit-media-controls-current-time-display,
#livePlayer::-webkit-media-controls-time-remaining-display,
#livePlayer::-webkit-media-controls-timeline {
  display: none !important;
}
.player-wrap:hover .live-badge {
  opacity: 0.6;
}
.player-wrap.controls-hidden .live-badge {
  opacity: 0;
}

/* Resume prompt */
.resume-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: var(--surface-resume-backdrop);
  z-index: 5000;
}
.resume-backdrop.open {
  display: grid;
}
.resume-modal {
  width: min(520px, 92vw);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3);
  padding: 1rem 1.25rem;
}
.resume-modal h3 {
  margin: 0 0 0.35rem 0;
}
.resume-modal .muted {
  margin: 0 0 0.75rem 0;
}
.resume-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.resume-actions .btn.secondary {
  background: #1c1c1f;
  border: 1px solid #2a2a2e;
}
.resume-actions .btn.secondary:hover {
  background: #232327;
}

/* Permissions table (admin permissions) */
#perm-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
#perm-table th,
#perm-table td {
  display: table-cell !important;
  vertical-align: middle;
  padding: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
}
#perm-table td.perm,
#perm-table th.perm {
  text-align: left;
  width: 40%;
}
#perm-table th.role-head,
#perm-table td.dotwrap {
  width: calc(60% / 5);
}
#perm-table td.dotwrap {
  cursor: pointer;
}
#perm-table .dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #444444;
  background: transparent;
  cursor: pointer;
  transition: 0.2s ease;
  outline: none;
}
#perm-table .dot:focus {
  box-shadow: var(--focus-ring);
  border-color: var(--accent-2);
}
#perm-table .dot:hover {
  border-color: var(--accent-2);
}
#perm-table .dot.active {
  border-color: #e5141e;
  background: var(--perm-dot-active-bg);
  box-shadow: 0 0 6px rgba(229, 20, 30, 0.4);
}

/* Admin modal overlays */
.overlay[hidden] {
  display: none;
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
}
.overlay__backdrop {
  position: absolute;
  inset: 0;
  background: var(--surface-overlay);
  backdrop-filter: blur(2px);
}
.overlay__panel {
  position: relative;
  width: min(1100px, 96vw);
  height: min(92vh, 1000px);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(10px);
  opacity: 0;
  transition: 0.18s ease;
}
.overlay.show .overlay__panel {
  transform: none;
  opacity: 1;
}
.overlay__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface-header);
  border-bottom: 1px solid var(--border-strong);
}
.overlay__title {
  margin: 0;
  font-size: 1rem;
}
.overlay__close {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}
.overlay__close:hover {
  background: var(--surface-hover);
}
.overlay__body {
  padding: 1rem;
  overflow: auto;
  height: 100%;
}

/* Toast / messages */
.toast {
  position: fixed;
  bottom: 12px;
  right: 12px;
  background: #1a1a1d;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: #ddd;
  display: none;
}

/* Utilities */
.text-muted {
  color: var(--muted);
}
.center {
  text-align: center;
}
.hidden {
  display: none !important;
}