:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #181a1f;
  --panel-2: #20242a;
  --line: #333943;
  --text: #f4f6f8;
  --muted: #aab3bd;
  --accent: #30d158;
  --accent-2: #f6c453;
  --danger: #ff5a5f;
  --focus: #72a7ff;
  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: var(--bg);
  color: var(--text);
}

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

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.95fr);
  min-height: 100vh;
}

.player-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #070809;
}

.video-wrap {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 420px;
  padding: 24px;
}

video {
  width: min(100%, 1280px);
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 132px);
  background: #000;
  outline: 1px solid #222831;
}

.state-badge {
  position: absolute;
  top: 28px;
  left: 28px;
  min-width: 76px;
  border: 1px solid rgba(244, 246, 248, 0.18);
  background: rgba(10, 12, 14, 0.76);
  padding: 7px 10px;
  font-size: 13px;
  text-align: center;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
  padding: 0 24px 24px;
}

.status-row > div {
  min-width: 0;
  border: 1px solid rgba(244, 246, 248, 0.08);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(28, 32, 38, 0.96), rgba(18, 21, 26, 0.96));
  padding: 12px 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 1px 0 rgba(0, 0, 0, 0.18);
}

.status-row .eyebrow {
  margin-bottom: 5px;
  font-size: 10px;
}

.status-row strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow,
.metrics span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: 100vh;
  overflow: auto;
  background: var(--panel);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 18px 20px 20px;
}

.quick-controls {
  display: grid;
  gap: 12px;
}

.quick-mpd {
  display: grid;
  gap: 7px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.advanced-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 18, 23, 0.72);
  overflow: clip;
}

.advanced-panel[open] {
  background: rgba(16, 18, 23, 0.92);
}

.advanced-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  user-select: none;
}

.advanced-panel > summary::-webkit-details-marker {
  display: none;
}

.advanced-panel > summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
}

.advanced-panel[open] > summary::after {
  content: "▴";
}

.advanced-body {
  display: grid;
  gap: 14px;
  padding: 0 16px 16px;
}

label {
  display: grid;
  gap: 7px;
}

label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101217;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 76px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(114, 167, 255, 0.22);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #09100d;
  font-weight: 800;
  cursor: pointer;
}

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

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

.secondary-button {
  background: var(--accent-2);
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.ghost-button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.diagnostics {
  border-top: 1px solid var(--line);
  background: transparent;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.metrics > div {
  min-width: 0;
  padding: 14px 16px;
  background: var(--panel-2);
}

pre {
  height: 240px;
  margin: 0;
  overflow: auto;
  padding: 16px;
  background: #0d0f12;
  color: #dce7d9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

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

  .player-area {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .video-wrap {
    min-height: 280px;
  }

  video {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .status-row,
  .form-grid,
  .action-row,
  .quick-actions,
  .metrics {
    grid-template-columns: 1fr;
  }

  .settings-form {
    padding: 18px;
  }

  .video-wrap {
    padding: 12px;
  }

  .state-badge {
    top: 16px;
    left: 16px;
  }
}
