:root {
  color-scheme: dark;
  --bg: #0e1117;
  --panel: #181c25;
  --panel-2: #11151d;
  --panel-3: #0b0e14;
  --line: #2b3342;
  --text: #f5f7fb;
  --muted: #9aa5b8;
  --accent: #7c5cff;
  --accent-2: #a48fff;
  --danger: #ff637d;
  --ok: #47d18c;
  --warn: #ffd36a;
  --shadow: 0 22px 70px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124,92,255,.2), transparent 34rem),
    radial-gradient(circle at top right, rgba(71,209,140,.11), transparent 30rem),
    linear-gradient(180deg, #111620 0%, #0e1117 58%),
    var(--bg);
  color: var(--text);
}

.shell {
  width: min(1500px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.admin-shell { max-width: 1280px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 4vw, 48px); letter-spacing: -0.045em; }
h2 { margin-bottom: 8px; letter-spacing: -0.025em; }
h3 { margin-bottom: 12px; }
h4 { margin-bottom: 8px; }

.eyebrow, .section-label {
  color: var(--accent-2);
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 12px;
  margin-bottom: 6px;
}

.section-label { color: #c9bdff; margin: 12px 0 8px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; margin-bottom: 0; }
code { background: #0b0d12; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.hidden { display: none !important; }

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.012)), var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.setup-panel, .login-panel {
  max-width: 760px;
  padding: 28px;
}

.login-panel {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}

.login-form, .compact-form, .segment-form, .form-inline-card {
  display: grid;
  gap: 10px;
}

.app {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}

.sidebar {
  padding: 18px;
  position: sticky;
  top: 16px;
}

.sidebar-head, .selected-head, .segment-toolbar, .topbar-actions, .admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.playlist-section + .playlist-section { margin-top: 14px; }

.playlist-list {
  display: grid;
  gap: 8px;
  max-height: 38vh;
  overflow: auto;
  padding-right: 3px;
}

.playlist-list.compact { max-height: 24vh; }
.list-empty { margin: 0 0 6px; font-size: 14px; }

.playlist-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  cursor: pointer;
  background: rgba(17,21,29,.88);
  color: var(--text);
  text-align: left;
  transition: border-color .15s, transform .15s, background .15s;
}

.playlist-item:hover { border-color: rgba(124,92,255,.72); transform: translateY(-1px); }
.playlist-item.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(124,92,255,.58); background: rgba(124,92,255,.12); }
.playlist-item strong { display: block; margin-bottom: 4px; }
.playlist-item span { color: var(--muted); font-size: 13px; }

.content { display: grid; gap: 18px; min-width: 0; }
.player-panel, .selected-panel { padding: 18px; }

.player-layout {
  display: grid;
  grid-template-columns: minmax(280px, 580px) minmax(280px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.video-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #08090d;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
}

#player, #player iframe { width: 100%; height: 100%; }

.now-box {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 24px;
  background:
    radial-gradient(circle at top right, rgba(124,92,255,.18), transparent 16rem),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015)),
    var(--panel-2);
  padding: 18px;
  min-height: 100%;
  display: grid;
  align-content: center;
}

.player-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
#nowTitle { font-size: clamp(22px, 3vw, 34px); margin: 4px 0 8px; }
#nowMeta { min-height: 1.3em; }

.progress-wrap { margin: 18px 0; }
.progress-line { height: 8px; border-radius: 999px; background: #090b10; overflow: hidden; border: 1px solid var(--line); }
.progress-line span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--ok)); }
.progress-times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }

.transport-row, .mode-row, .controls, .form-actions, .filter-buttons, .selected-actions, .side-links, .admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.transport-row { align-items: center; justify-content: center; margin-top: 8px; }
.mode-row { justify-content: center; margin-top: 10px; }

button, .button, select, input, textarea { font: inherit; }

button, .button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #222737;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 780;
  text-decoration: none;
  transition: transform .12s, background .12s, border-color .12s, opacity .12s;
}

button:hover, .button:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.24); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); }
button.ghost, .button.ghost { background: transparent; }
button.danger, .danger { color: #ffd7df; border-color: rgba(255,99,125,.42); }
button.small, .button.small { padding: 7px 10px; font-size: 13px; }
button.active { background: rgba(124,92,255,.28); border-color: var(--accent); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.round-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.main-play {
  min-width: 132px;
  min-height: 48px;
  background: #f5f7fb;
  color: #11151d;
  border-color: #f5f7fb;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #363f52;
  border-radius: 13px;
  background: #0b0e14;
  color: var(--text);
  padding: 11px 12px;
}

textarea { resize: vertical; }
label { color: #c8cfdd; font-size: 14px; font-weight: 750; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 650; color: var(--muted); }
.check-row.inline { margin-top: 0; align-self: end; }
.check-row input { width: auto; }

.compact-form {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

.side-links { margin-top: 14px; }
.empty-state {
  border: 1px dashed #3b4254;
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 18px;
  padding: 24px;
}
.empty-state.subtle { padding: 14px; background: rgba(17,21,29,.62); }

.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.badge { border: 1px solid var(--line); background: var(--panel-2); color: #dce2f0; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; }
.badge.global { color: #d7fbe6; border-color: rgba(71,209,140,.5); }
.badge.pending { color: #fff2c6; border-color: rgba(255,211,106,.5); }
.badge.private { color: #dce2f0; }

.segment-form {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  margin: 18px 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid.wide-left { grid-template-columns: 1.35fr 1fr; }
.times-grid { grid-template-columns: 150px 150px 1fr; }
.compact-two { grid-template-columns: 1fr auto; align-items: end; }
.align-end { align-self: end; }

.segment-toolbar { margin: 18px 0 12px; }
.segment-list { display: grid; gap: 10px; }

.segment-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 18px;
  padding: 14px;
}
.segment-card.playing { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(124,92,255,.55); }
.segment-card h4 { margin: 0 0 6px; font-size: 16px; }
.segment-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.segment-note { color: #c6ccda; margin: 8px 0 0; font-size: 14px; }
.segment-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-content: start; }
.segment-actions button { padding: 8px 10px; font-size: 13px; }
.star { color: var(--warn); }
.profile-badge { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: var(--panel-2); color: #dce2f0; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #0c0e13;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 15px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  max-width: min(460px, calc(100% - 44px));
  z-index: 20;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.admin-card { padding: 18px; min-width:0; overflow:hidden; }
.stat-card { grid-column: 1 / -1; }
.admin-list { display: grid; gap: 10px; margin-top: 12px; }
.admin-list-card {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  padding: 14px;
  overflow: hidden;
}
.admin-list-card strong { display: block; margin-bottom: 5px; }
.admin-list-card .muted { display: block; font-size: 13px; }
.profile-edit-form {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}
.profile-edit-form input { min-width: 0; }
.form-inline-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  padding: 14px;
  margin: 12px 0;
}

@media (max-width: 1180px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .player-layout { grid-template-columns: 1fr; }
  .playlist-list, .playlist-list.compact { max-height: none; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 16px, 1500px); padding-top: 12px; padding-bottom: 24px; }
  .topbar, .login-panel, .selected-head, .segment-toolbar, .admin-head { align-items: stretch; flex-direction: column; }
  .topbar-actions, .selected-actions { justify-content: flex-start; }
  .login-panel { display: flex; }
  .player-panel, .selected-panel, .sidebar, .setup-panel, .login-panel, .admin-card { padding: 14px; border-radius: 18px; }
  .form-grid, .form-grid.wide-left, .times-grid, .compact-two { grid-template-columns: 1fr; }
  .segment-card, .admin-list-card, .profile-edit-form { min-width: 0; grid-template-columns: 1fr; }
  .segment-actions, .admin-actions { justify-content: flex-start; }
  .now-box { border-radius: 20px; padding: 14px; }
  .round-btn { width: 42px; height: 42px; }
  .main-play { flex: 1; min-width: 120px; }
  .mode-row button { flex: 1; }
  h1 { font-size: 32px; }
  #nowTitle { font-size: 24px; }
}
