:root {
  color-scheme: dark;
  --bg: #111410;
  --surface: #191d16;
  --surface-2: #22281d;
  --surface-3: #2b3322;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f6ef;
  --muted: #aeb7a3;
  --green: #93c84f;
  --green-dark: #40611d;
  --amber: #f2ad3c;
  --danger: #df6868;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 5%, rgba(147, 200, 79, 0.18), transparent 25rem),
    radial-gradient(circle at 85% 18%, rgba(242, 173, 60, 0.12), transparent 26rem),
    var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button {
  align-items: center;
  background: #2b3322;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  touch-action: manipulation;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

button:hover {
  background: #354028;
  border-color: rgba(147, 200, 79, 0.45);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #10150c;
  font-weight: 800;
}

button.ghost {
  background: transparent;
  border-color: rgba(242, 173, 60, 0.65);
  color: #ffd88b;
}

button.danger {
  border-color: rgba(223, 104, 104, 0.5);
  color: #ffc0c0;
}

input,
select {
  background: #11150f;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid #d8ef91;
  outline-offset: 2px;
}

.app-frame {
  margin: 0 auto;
  max-width: 1500px;
  min-height: 100vh;
  padding: 18px;
}

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

.brand {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--green), #d7ee86);
  border-radius: 8px;
  color: #10150c;
  display: inline-flex;
  font-weight: 900;
  height: 46px;
  justify-content: center;
  width: 46px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  margin-top: 3px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.session-chip,
.mode-pill,
.count {
  background: rgba(147, 200, 79, 0.12);
  border: 1px solid rgba(147, 200, 79, 0.3);
  border-radius: 999px;
  color: #dff6a4;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  justify-content: center;
  min-height: 30px;
  min-width: 34px;
  padding: 6px 10px;
}

.mode-pill.ad {
  background: rgba(242, 173, 60, 0.13);
  border-color: rgba(242, 173, 60, 0.42);
  color: #ffd88b;
}

.player-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 390px;
  height: calc(100vh - 98px);
  min-height: 640px;
}

.player-panel,
.queue-panel,
.settings-card,
.library-section {
  background: rgba(25, 29, 22, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.player-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.player-copy {
  align-items: end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.player-copy h1,
.player-copy p {
  margin: 0;
}

.player-copy h1 {
  font-size: clamp(1.5rem, 3vw, 2.7rem);
  letter-spacing: 0;
}

.player-copy > p {
  color: var(--muted);
  max-width: 520px;
  text-align: right;
}

.eyebrow {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.stage {
  align-items: center;
  aspect-ratio: 16 / 9;
  background: #050505;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  display: flex;
  justify-content: center;
  min-height: 320px;
  overflow: hidden;
  position: relative;
}

video {
  background: #050505;
  height: 100%;
  width: 100%;
}

.empty-state {
  color: var(--muted);
  display: grid;
  gap: 8px;
  inset: 0;
  place-items: center;
  position: absolute;
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

.empty-state.hidden,
.hidden {
  display: none;
}

.transport {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1.35fr 1fr;
}

#skipAdBtn {
  grid-column: 1 / -1;
}

.now-row {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.now-title {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.counter-text {
  color: var(--muted);
}

.queue-panel {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 16px;
}

.section-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

h2,
h3 {
  letter-spacing: 0;
  margin: 0;
}

.public-list,
.playlist {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  margin: 0;
  min-height: 0;
  overflow: auto;
  padding: 0 3px 0 0;
}

.search-field {
  color: var(--muted);
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.search-field span {
  font-size: 0.82rem;
  font-weight: 800;
}

.playlist-tabs {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
}

.playlist-tabs button {
  min-height: 38px;
}

.playlist-tabs button.active {
  background: rgba(147, 200, 79, 0.18);
  border-color: rgba(147, 200, 79, 0.6);
  color: #dff6a4;
}

.public-list li,
.playlist li {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
}

.public-list li.active,
.playlist li.active {
  border-color: rgba(147, 200, 79, 0.75);
}

.public-list li {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 38px minmax(0, 1fr);
  min-height: 58px;
  padding: 8px;
}

.public-list li > button:not(.inline-star) {
  align-items: flex-start;
  background: transparent;
  border: 0;
  display: grid;
  gap: 4px;
  min-height: 42px;
  padding: 4px 2px;
  text-align: left;
  width: 100%;
}

.public-list li > button:not(.inline-star):hover {
  background: transparent;
}

.inline-star,
.star-button {
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 1.05rem;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  min-height: 38px;
  padding: 0;
  width: 38px;
}

.inline-star.active,
.star-button.active,
.item-actions button.active {
  background: rgba(242, 173, 60, 0.16);
  border-color: rgba(242, 173, 60, 0.58);
  color: #ffd88b;
}

.star-button {
  flex: 0 0 auto;
  margin-left: auto;
}

.empty-list-note {
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

.public-list small,
.item-meta {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-panel {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 30;
}

.admin-panel.open {
  pointer-events: auto;
}

.admin-backdrop {
  background: rgba(0, 0, 0, 0);
  inset: 0;
  position: absolute;
  transition: background 180ms ease;
}

.admin-panel.open .admin-backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.admin-sheet {
  background: #141812;
  border-left: 1px solid var(--line);
  box-shadow: -26px 0 80px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  margin-left: auto;
  max-width: 980px;
  overflow: auto;
  padding: 18px;
  position: relative;
  transform: translateX(105%);
  transition: transform 220ms ease;
  width: min(980px, 100%);
}

.admin-panel.open .admin-sheet {
  transform: translateX(0);
}

.admin-header,
.admin-status-row {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.pin-field {
  color: var(--muted);
  display: grid;
  gap: 6px;
  max-width: 260px;
  width: 100%;
}

.status-text {
  color: var(--muted);
  margin: 0;
}

.status-text.error {
  color: #ffb3b3;
}

.settings-card,
.library-section {
  box-shadow: none;
  padding: 16px;
}

.settings-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.settings-grid label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  min-width: 0;
}

.switch {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  gap: 8px;
}

.switch input {
  accent-color: var(--green);
  height: 18px;
  min-height: 18px;
  width: 18px;
}

.library-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
  min-height: 560px;
}

.library-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.file-row,
.url-form {
  display: grid;
  gap: 8px;
}

.file-picker {
  width: 100%;
}

.file-picker.accent {
  border-color: rgba(242, 173, 60, 0.55);
}

.hidden-file-input {
  clip: rect(0 0 0 0);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.url-form {
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr) auto;
  margin: 8px 0 12px;
}

.playlist li {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  min-height: 58px;
  padding: 9px;
}

.item-main {
  align-items: flex-start;
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: left;
}

.item-title {
  display: block;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  display: block;
  font-size: 0.82rem;
  white-space: nowrap;
}

.item-actions {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(4, 34px);
}

.item-actions button {
  min-height: 34px;
  padding: 0;
}

.install-dialog {
  background: #171b14;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  max-width: 440px;
  padding: 0;
}

.install-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.install-dialog form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.install-dialog h2,
.install-dialog p {
  margin: 0;
}

.install-dialog ul {
  color: var(--muted);
  margin: 0;
  padding-left: 20px;
}

@media (max-width: 1120px) {
  .player-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .queue-panel {
    min-height: 420px;
    max-height: 620px;
  }
}

@media (max-width: 820px) {
  body {
    background: var(--bg);
  }

  .app-frame {
    padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .session-chip {
    grid-column: 1 / -1;
  }

  .player-panel,
  .queue-panel {
    border-radius: 10px;
    padding: 12px;
  }

  .player-copy {
    align-items: flex-start;
    display: grid;
  }

  .player-copy > p {
    text-align: left;
  }

  .stage {
    border-radius: 8px;
    min-height: 190px;
  }

  .transport {
    background: rgba(17, 20, 16, 0.97);
    bottom: 0;
    grid-template-columns: 1fr 1.2fr 1fr;
    padding: 10px 0 0;
    position: sticky;
    z-index: 8;
  }

  .transport button {
    min-height: 48px;
  }

  .now-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .now-title,
  .item-title,
  .item-meta,
  .public-list small {
    white-space: normal;
  }

  .admin-sheet {
    border-left: 0;
    max-width: none;
    padding: 14px;
  }

  .admin-header,
  .admin-status-row,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .library-grid,
  .settings-grid,
  .url-form {
    grid-template-columns: 1fr;
  }

  .library-grid {
    min-height: 0;
  }

  .playlist {
    max-height: 58vh;
  }

  .playlist li {
    grid-template-columns: 1fr;
  }

  .item-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .item-actions button {
    min-height: 40px;
  }
}
