:root {
  --bg: #1a1a1e;
  --bg-card: #25252b;
  --bg-input: #2d2d34;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --accent: #a855f7;
  --accent-hover: #9333ea;
  --border: #3f3f46;
  --status-waiting: #eab308;
  --status-connected: #22c55e;
  --status-disconnected: #ef4444;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100%;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.dock-header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.dock-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dock-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  flex-shrink: 0;
}

.dock-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: default;
  border-radius: 4px;
  padding: 0.2rem 0.35rem;
}

.status-indicator .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator .status-dot.connected {
  background: var(--status-connected);
}

.status-indicator .status-dot.disconnected {
  background: var(--status-disconnected);
}

.status-indicator .status-dot.waiting {
  background: var(--status-waiting);
}

.status-indicator .status-label {
  white-space: nowrap;
}

.queue-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-settings-btn {
  padding: 0.35rem 0.5rem;
  font-size: 1.1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}

.header-settings-btn:hover {
  color: var(--text);
  background: var(--bg-input);
}

.tabs {
  flex-shrink: 0;
  display: flex;
  gap: 0;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  flex-direction: column;
  gap: 1rem;
}

.tab-panel.active {
  display: flex;
}

.section-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.now-playing {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.now-playing-content {
  display: flex;
  gap: 0.75rem;
}

.now-playing-thumb {
  width: 80px;
  min-width: 80px;
  height: 45px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.now-playing-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.now-playing-info {
  flex: 1;
  min-width: 0;
}

.now-playing-title {
  font-size: 0.85rem;
  margin: 0 0 0.2rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing-requested {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.progress-wrap {
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.25rem;
  cursor: pointer;
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
}

.progress-times {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.now-playing-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.icon-btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--border);
}

.btn-add {
  padding: 0.5rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-add:hover {
  background: var(--accent-hover);
}

.volume-wrap {
  margin-left: auto;
}

.volume-wrap input[type="range"] {
  width: 72px;
  height: 6px;
  accent-color: var(--accent);
}

.eye-toggle {
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
}

.eye-toggle[aria-pressed="true"] {
  opacity: 1;
}

.eye-toggle[aria-pressed="false"] {
  opacity: 0.6;
}

.add-song {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.add-song-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.add-song-row input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.add-song-row input::placeholder {
  color: var(--text-muted);
}

.connection-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.connection-status.waiting {
  color: var(--status-waiting);
}

.connection-status.connected {
  color: var(--status-connected);
}

.connection-status.disconnected {
  color: var(--status-disconnected);
}

.toolbar {
  display: flex;
  gap: 0.5rem;
}

.toolbar-btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
}

.toolbar-btn:hover {
  color: var(--text);
}

.queue-section {
  display: flex;
  flex-direction: column;
}

.queue-section .section-heading {
  margin-bottom: 0.5rem;
}

.queue-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}

.queue-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.queue-list li:last-child {
  border-bottom: none;
}

.queue-list li.playing {
  background: rgba(168, 85, 247, 0.15);
}

.queue-list li[draggable="true"] {
  cursor: grab;
}

.queue-list li.queue-item-dragging {
  cursor: grabbing;
  opacity: 0.7;
}

.queue-list li.queue-item-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.queue-item-thumb {
  width: 48px;
  min-width: 48px;
  height: 27px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.queue-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.queue-item-body {
  flex: 1;
  min-width: 0;
}

.queue-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.queue-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

.queue-item-remove {
  flex-shrink: 0;
  padding: 0.2rem 0.4rem;
  font-size: 1rem;
  line-height: 1;
  min-width: 1.5rem;
}

.queue-empty {
  color: var(--text-muted);
  padding: 1rem;
  font-style: italic;
  font-size: 0.9rem;
}

.spin-section {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border);
}

.spin-hint {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spin-wheel-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto 1rem;
}

.spin-wheel-canvas {
  display: block;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 3px solid var(--border);
}

.spin-wheel-pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 14px solid var(--accent);
  pointer-events: none;
}

.spin-result {
  text-align: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: 8px;
}

.spin-winner-label {
  margin: 0 0 0.25rem 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.spin-winner-title {
  margin: 0 0 0.75rem 0;
  font-weight: 600;
  word-break: break-word;
}

.spin-result .btn-spin {
  display: block;
  margin: 0.75rem auto 0;
}

.btn-spin {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: block;
  margin: 0 auto;
}

.btn-spin:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-spin:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 0;
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  overflow-y: auto;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}

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

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.settings-header .icon-btn {
  font-size: 1.25rem;
  padding: 0.35rem 0.5rem;
  color: var(--text-muted);
  transition: color 0.2s ease, background 0.2s ease;
}

.settings-header .icon-btn:hover {
  color: var(--text);
  background: var(--bg-input);
}

.settings-connection-status {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 1.5rem 1.5rem 1rem;
  border: 1px solid var(--border);
  line-height: 1.5;
}

.settings-connection-status.state-waiting {
  background: rgba(234, 179, 8, 0.15);
  color: var(--status-waiting);
  border-color: var(--status-waiting);
}

.settings-connection-status.state-connected {
  background: rgba(34, 197, 94, 0.15);
  color: var(--status-connected);
  border-color: var(--status-connected);
}

.settings-connection-status.state-disconnected {
  background: rgba(239, 68, 68, 0.1);
  color: var(--status-disconnected);
  border-color: var(--status-disconnected);
}

.connection-status-sub {
  margin-bottom: 0.35rem;
}

.settings-save-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.settings-save-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  margin: 0;
}

.settings-save-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.settings-disconnect-btn {
  width: 100%;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin: 0;
}

.settings-disconnect-btn:hover {
  background: var(--bg-input);
  color: var(--text);
  border-color: var(--border);
}

.settings-panel-section {
  padding: 0 1.5rem 1rem;
}

.settings-section-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 1.5rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.settings-panel-section:first-of-type .settings-section-heading {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.settings-twitch-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 1.5rem 1rem;
  line-height: 1.5;
}

.settings-help-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  line-height: 1.4;
}

.rotation-settings {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.rotation-settings label {
  margin-top: 0;
}

.rotation-settings input[type="range"] {
  width: 100%;
  margin: 0.5rem 0;
  accent-color: var(--accent);
}

.slider-value {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.25rem;
}

.slider-value span {
  font-weight: 600;
  color: var(--accent);
}

.settings-panel label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.settings-panel .settings-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.settings-panel .settings-checkbox-label:hover {
  background: var(--bg-input);
}

.settings-panel .settings-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.settings-panel .settings-checkbox-label span {
  user-select: none;
  font-size: 0.9rem;
  color: var(--text);
}

.settings-panel input[type="text"],
.settings-panel select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.settings-panel input[type="text"]:focus,
.settings-panel select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.settings-panel select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a1a1aa' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.settings-panel button {
  padding: 0.625rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  border: none;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.settings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
