:root {
  --bg: #e8f4ff;
  --card: #fff;
  --text: #1a2b3c;
  --muted: #5a6f80;
  --danger: #e03d4c;
  --primary: #2f8fed;
  --border: rgba(0, 60, 120, 0.12);
  --shadow: rgba(0, 40, 100, 0.08);
}

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

html,
body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

body {
  padding: 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  max-width: 720px;
  margin: 0 auto;
}

.editor-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.editor-back {
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
}

.editor-back:active {
  opacity: 0.75;
}

.editor-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

@media (min-width: 520px) {
  .editor-actions {
    width: auto;
    margin-left: auto;
  }
}

.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 12px;
  padding: 10px 16px;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-add {
  background: #5ad67a;
  color: #fff;
  padding-inline: 20px;
}

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

.btn:active {
  transform: scale(0.98);
}

.editor-note {
  margin: 0 0 20px;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.editor-note code {
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 6px;
}

.save-status {
  min-height: 1.5em;
  margin: 0 0 16px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.save-status.is-ok {
  color: #1a8f4a;
}

.save-status.is-warn {
  color: #c45c00;
}

.add-row {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px var(--shadow);
  border: 1px solid var(--border);
}

.add-label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
}

.add-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.add-input {
  flex: 1 1 200px;
  min-width: 0;
  font-family: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
}

.add-input:focus {
  outline: none;
  border-color: var(--primary);
}

.add-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 700;
  font-size: 0.9rem;
}

.video-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.video-item {
  display: flex;
  align-items: stretch;
  gap: 14px;
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px var(--shadow);
}

.video-thumb-wrap {
  flex: 0 0 auto;
  width: 120px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #ddd;
}

.video-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.video-title {
  margin: 0;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.3;
  word-break: break-word;
}

.video-id {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  word-break: break-all;
}

.video-item-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.video-item-actions .btn {
  padding: 10px 14px;
}
