:root {
  --bg: #111827;
  --panel: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #374151;
  --sidebar-w: 240px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.session-hint {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.sidebar-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.sidebar-block-border {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.catalog-list {
  max-height: 200px;
}

#catalog-search {
  margin-bottom: 6px;
  font-size: 12px;
  padding: 5px 8px;
}

.preset-item.active {
  border-color: var(--accent);
}

.overlay-url-box {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.overlay-url-box input {
  flex: 1;
  font-size: 11px;
}

.layout {
  display: flex;
  gap: 10px;
  padding: 10px;
  align-items: flex-start;
  min-height: calc(100vh - 42px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 62px);
  position: sticky;
  top: 10px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.main-columns {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field-inline span {
  flex-shrink: 0;
  min-width: 52px;
}

.field-inline input {
  flex: 1;
}

.field span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-hint {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.file-field input[type='file'] {
  font-size: 12px;
  padding: 4px 0;
  border: none;
  background: transparent;
  color: var(--text);
}

input,
select {
  width: 100%;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.btn {
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
}

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

.btn.secondary {
  background: #374151;
}

.btn.secondary:hover {
  background: #4b5563;
}

.btn.primary {
  background: #059669;
}

.btn.primary:hover {
  background: #047857;
}

.btn.btn-block {
  width: 100%;
}

.btn.btn-icon {
  padding: 4px 8px;
  min-width: 28px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.actions-tight .btn {
  padding: 4px 8px;
}

.offset-actions .btn {
  min-width: 0;
  flex: 1;
}

.player-container {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
}

#youtube-player,
#youtube-player iframe {
  width: 100%;
  height: 100%;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.status-grid div {
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 7px;
}

.status-grid strong {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
  font-weight: 500;
}

.status-grid span {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.preview h3 {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.preview-current {
  min-height: 52px;
  padding: 8px;
  border-radius: 5px;
  background: #111827;
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.35;
}

.preview-next {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  min-height: 16px;
}

.help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.help summary {
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
}

.help ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.presets-save {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.presets-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.presets-empty {
  color: var(--muted);
  font-size: 11px;
  padding: 4px 0;
  line-height: 1.4;
}

.preset-item {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #111827;
}

.preset-item.active {
  border-color: var(--accent);
}

.preset-load {
  flex: 1;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.preset-load:hover {
  background: #1a2332;
}

.preset-item.active .preset-load {
  background: rgba(37, 99, 235, 0.15);
}

.preset-name {
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-meta {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-delete {
  flex-shrink: 0;
  width: 26px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.preset-delete:hover {
  background: #7f1d1d;
  color: #fff;
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 200px;
    position: static;
  }

  .main-columns {
    grid-template-columns: 1fr;
  }
}
