:root {
  color-scheme: dark;
  --bg: #0c0f0e;
  --panel: #151a18;
  --panel-2: #101412;
  --border: #303936;
  --text: #eef7f1;
  --muted: #a8b8b0;
  --accent: #ffd338;
  --accent-2: #22c7b8;
  --danger: #ff6b5f;
  --shadow: rgba(0, 0, 0, 0.38);
  --font-size: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans Thai", Tahoma, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 16px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(34, 199, 184, 0.08), transparent 36%),
    linear-gradient(180deg, #111512 0%, #090b0a 100%);
}

.stage-panel,
.control-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(21, 26, 24, 0.92);
  box-shadow: 0 18px 60px var(--shadow);
}

.stage-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.stage-toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #ffd338;
  color: #16120a;
  font-size: 13px;
  letter-spacing: 0;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.time-readout {
  min-width: 112px;
  display: flex;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.icon-button,
.primary-button,
.secondary-button,
.segment {
  min-height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 120ms ease;
}

.icon-button {
  width: 42px;
  color: var(--text);
  background: #202724;
  border: 1px solid #39433f;
}

.icon-button.small {
  width: 36px;
  min-height: 34px;
}

.icon-button:hover,
.secondary-button:hover,
.segment:hover {
  background: #2a332f;
}

.icon-button.loading svg {
  animation: spin 900ms linear infinite;
}

.icon-button:active,
.primary-button:active,
.secondary-button:active,
.segment:active {
  transform: translateY(1px);
}

.icon-button svg,
.primary-button svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.seek-wrap {
  padding: 0 14px 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  align-self: center;
  background: #030504;
  overflow: hidden;
}

.stage-panel:fullscreen {
  background: #030504;
}

.video-frame:fullscreen {
  background: #030504;
}

#player,
#player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #6f7c76;
  font-size: clamp(22px, 4vw, 44px);
  font-weight: 800;
  background: repeating-linear-gradient(
    -45deg,
    #050706,
    #050706 18px,
    #070b09 18px,
    #070b09 36px
  );
}

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

.lyrics-overlay {
  --outline: rgba(0, 0, 0, 0.92);
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.lyrics-stack {
  position: absolute;
  left: clamp(16px, 4vw, 54px);
  right: clamp(16px, 4vw, 54px);
  display: grid;
  gap: 10px;
  text-align: center;
}

.lyrics-overlay.pos-top .lyrics-stack {
  top: 8%;
}

.lyrics-overlay.pos-middle .lyrics-stack {
  top: 50%;
  transform: translateY(-50%);
}

.lyrics-overlay.pos-bottom .lyrics-stack {
  bottom: 10%;
}

.side-line {
  min-height: 30px;
  color: rgba(238, 247, 241, 0.7);
  font-size: clamp(16px, calc(var(--font-size) * 0.34), 30px);
  font-weight: 700;
  line-height: 1.2;
  text-shadow:
    0 2px 1px var(--outline),
    0 0 10px var(--outline);
  overflow-wrap: anywhere;
}

.side-line.next {
  color: rgba(238, 247, 241, 0.58);
}

.karaoke-line {
  position: relative;
  min-height: calc(var(--font-size) * 1.28);
  display: grid;
  place-items: center;
}

.lyric-base,
.lyric-fill {
  grid-area: 1 / 1;
  width: 100%;
  color: #f8fff9;
  font-size: var(--font-size);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-shadow:
    0 3px 0 var(--outline),
    2px 2px 0 var(--outline),
    -2px 2px 0 var(--outline),
    0 0 18px rgba(0, 0, 0, 0.85);
}

.lyric-fill {
  color: var(--accent);
  clip-path: inset(0 100% 0 0);
  text-shadow:
    0 3px 0 #2a2100,
    2px 2px 0 #2a2100,
    -2px 2px 0 #2a2100,
    0 0 18px rgba(255, 211, 56, 0.45);
}

.control-panel {
  min-height: 0;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-section.grow {
  display: grid;
  gap: 12px;
}

.panel-section.list-section {
  flex: 1;
  min-height: 220px;
  border-bottom: 0;
  display: flex;
  flex-direction: column;
}

.section-title {
  margin-bottom: 12px;
}

.section-title.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.25;
}

h2 {
  font-size: 15px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.compact {
  margin-top: 14px;
}

label,
.range-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input[type="url"],
input[type="number"],
textarea {
  width: 100%;
  border: 1px solid #36413c;
  border-radius: 8px;
  background: #0e1210;
  color: var(--text);
  outline: 0;
}

input[type="url"],
input[type="number"] {
  min-height: 42px;
  padding: 0 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(34, 199, 184, 0.16);
}

.primary-button,
.secondary-button {
  padding: 0 14px;
  font-weight: 750;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #151009;
}

.primary-button:hover {
  background: #ffe16a;
}

.secondary-button {
  border: 1px solid #3a4541;
  background: #202724;
  color: var(--text);
}

.status-text {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.status-text.error {
  color: var(--danger);
}

.status-text.ok {
  color: var(--accent-2);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid #333e39;
  border-radius: 8px;
  background: #0f1412;
}

.segment {
  color: var(--muted);
  background: transparent;
  min-height: 36px;
  font-weight: 750;
}

.segment.active {
  background: #25302c;
  color: var(--text);
  box-shadow: inset 0 0 0 1px #47534e;
}

.range-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.number-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.mini-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

textarea {
  min-height: 250px;
  max-height: 38vh;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
  font-family: Consolas, "Noto Sans Thai", monospace;
  font-size: 14px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.count-pill {
  min-width: 74px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #252d2a;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.lyrics-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 6px;
  padding-right: 2px;
}

.empty-list {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.lyric-row {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  background: #111613;
  border: 1px solid #27302c;
  text-align: left;
}

.lyric-row:hover {
  background: #1a211e;
}

.lyric-row.active {
  border-color: rgba(255, 211, 56, 0.85);
  background: rgba(255, 211, 56, 0.12);
}

.lyric-time {
  color: var(--accent-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lyric-text {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-height: none;
  }

  .stage-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    gap: 10px;
    padding: 10px;
  }

  .stage-toolbar {
    flex-wrap: wrap;
  }

  .brand {
    min-width: 0;
  }

  .transport {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .time-readout {
    min-width: 92px;
  }

  .video-frame {
    min-height: 230px;
  }

  .input-action,
  .action-row {
    grid-template-columns: 1fr;
  }

  .lyrics-stack {
    left: 12px;
    right: 12px;
  }

  .karaoke-line {
    min-height: calc(var(--font-size) * 1.55);
  }
}
