*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light dark;
  --bg: #f4f4f5;
  --surface: #fff;
  --text: #18181b;
  --muted: #71717a;
  --border: #d4d4d8;
  --accent: #2563eb;
  --accent-text: #fff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b;
    --surface: #27272a;
    --text: #fafafa;
    --muted: #a1a1aa;
    --border: #3f3f46;
    --accent: #3b82f6;
    --accent-text: #fff;
  }
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 1.25rem 2rem;
  max-width: 960px;
  margin: 0 auto;
}

#url-section {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
}

#url-section input {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

#url-section button,
#controls-section button,
header #lang-toggle {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

#url-section button,
#controls-section button {
  padding: 0.55rem 1rem;
}

header #lang-toggle {
  padding: 0.4rem 0.75rem;
}

#load-btn {
  flex: 0 0 auto;
  align-self: stretch;
  white-space: nowrap;
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

#load-btn:hover {
  filter: brightness(1.05);
}

header #lang-toggle:hover,
#controls-section button:not(.active):hover {
  background: var(--bg);
}

#error-message {
  flex: 1 1 100%;
  margin: 0;
  min-height: 1.5rem;
  color: #dc2626;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  #error-message {
    color: #f87171;
  }
}

#player-section {
  width: 100%;
}

#player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

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

#controls-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#ab-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-width: 0;
}

#ab-controls button {
  flex-shrink: 0;
}

#point-a-display,
#point-b-display {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.95rem;
  min-width: 0;
  flex: 1 1 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 479px) {
  #ab-controls {
    gap: 0.2rem 0.35rem;
  }

  #set-a-btn,
  #set-b-btn {
    padding: 0.4rem 0.5rem;
    font-size: 0.8125rem;
  }

  #point-a-display,
  #point-b-display {
    font-size: 0.8rem;
  }
}

#speed-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#speed-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.speed-btn-wrap {
  display: inline-flex;
}

.speed-btn-wrap button {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  min-width: 3rem;
}

.speed-btn-wrap button:hover {
  background: var(--bg);
}

button.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

.speed-btn-wrap[data-disabled='true'] button {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

#ad-placeholder {
  max-width: 960px;
  margin: 0 auto 2rem;
  padding: 0 1.25rem;
  height: 90px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

