:root {
  --bg: #0b1020;
  --panel: #121a31;
  --panel-2: #1a2646;
  --text: #ebf1ff;
  --muted: #a8b7d8;
  --accent: #67b7ff;
}

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

html,
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 0%, #172349, #070b17 70%);
  height: 100%;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 24px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.sidebar-doc {
  margin: 8px 0 0;
  font-size: 13px;
}

.sidebar-doc a {
  color: var(--accent);
  text-decoration: none;
}

.sidebar-doc a:hover {
  text-decoration: underline;
}

.sidebar-auth {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.sidebar-auth a {
  color: var(--accent);
  text-decoration: none;
}

.sidebar-auth a:hover {
  text-decoration: underline;
}

.sidebar-auth code {
  font-size: 11px;
  color: var(--text);
}

.video-list {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.video-list button {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  padding: 12px;
  cursor: pointer;
}

.video-list button:hover {
  border-color: var(--accent);
}

.video-list button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(103, 183, 255, 0.35);
}

.video-list small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.player-layout {
  padding: 24px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 16px;
}

.slide-canvas {
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  position: relative;
  min-height: 66vh;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.slide-overlay {
  position: absolute;
  inset: 0;
}

.slide-text {
  position: absolute;
  margin: 0;
  line-height: 1.2;
  white-space: pre-wrap;
}

.slide-image {
  position: absolute;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.screen-cast {
  animation: screencastPan 5.5s ease-in-out infinite alternate;
  transform-origin: center;
}

@keyframes screencastPan {
  0% {
    transform: scale(1) translate(0, 0);
  }
  100% {
    transform: scale(1.08) translate(-2%, -1%);
  }
}

.audio-pill {
  position: absolute;
  right: 16px;
  bottom: 16px;
  background: rgba(10, 20, 44, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  color: #d5e6ff;
}

.controls {
  background: rgba(4, 10, 24, 0.65);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px;
}

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

.controls-main button {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: #162548;
  color: #f5f8ff;
  padding: 8px 14px;
  cursor: pointer;
}

.controls-main button:hover {
  border-color: var(--accent);
}

.progress-wrap {
  margin-top: 10px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4ca0ff, #9fd1ff);
  transition: width 240ms linear;
}

.meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.error-box {
  background: #450c18;
  border: 1px solid #e77d95;
  border-radius: 12px;
  padding: 12px;
  color: #ffe9ee;
  margin-top: 14px;
}

.edit-icon {
  opacity: 0.5;
  transition: opacity 0.2s;
  color: var(--text);
}

.edit-icon:hover {
  opacity: 1;
  color: var(--accent);
}

.create-btn {
  background: rgba(103, 183, 255, 0.1) !important;
  color: #a4d3ff !important;
  border-color: rgba(103, 183, 255, 0.25) !important;
  font-weight: 500;
  text-align: center !important;
}

.create-btn:hover {
  background: rgba(103, 183, 255, 0.2) !important;
}

.edit-layout {
  padding: 24px;
}

.edit-panel {
  background: rgba(4, 10, 24, 0.65);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 32px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  max-width: 800px;
  margin: 0 auto;
}

.edit-panel h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.edit-id-text, .edit-link-text {
  margin: 4px 0;
  color: var(--muted);
}

.edit-link-text a {
  color: var(--accent);
  text-decoration: none;
}

.edit-link-text a:hover {
  text-decoration: underline;
}

.edit-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.edit-section h3 {
  margin-top: 0;
}

.edit-label {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.embed-snippet {
  width: 100%;
  min-height: 5rem;
  margin-top: 8px;
  padding: 12px;
  box-sizing: border-box;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  resize: vertical;
}

.format-details {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.15);
}

.format-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.format-details .hint {
  margin-top: 10px;
}

.list-disc {
  margin: 8px 0 0;
  padding-left: 1.25rem;
}

.upload-controls {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.upload-controls input[type="file"] {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #162548;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  flex: 1;
}

.upload-controls button {
  background: var(--accent);
  color: #000;
  border: none;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 24px;
  cursor: pointer;
}

.upload-controls button:hover {
  background: #8ecbff;
}

.upload-status {
  margin-top: 12px;
  font-size: 14px;
  min-height: 20px;
}

.btn-edit-secondary {
  margin-top: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(103, 183, 255, 0.45);
  background: rgba(103, 183, 255, 0.12);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.btn-edit-secondary:hover {
  border-color: var(--accent);
  background: rgba(103, 183, 255, 0.2);
}

.edit-section-danger {
  border-top-color: rgba(255, 120, 140, 0.25);
}

.btn-edit-danger {
  margin-top: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255, 120, 140, 0.5);
  background: rgba(180, 40, 60, 0.25);
  color: #ffd0d8;
  font-weight: 600;
  cursor: pointer;
}

.btn-edit-danger:hover {
  background: rgba(200, 50, 70, 0.4);
  border-color: #ff8a9a;
}

pre {
  background: #000;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #a4d3ff;
  font-size: 13px;
}

.watch-mode .app,
.render-mode .app {
  grid-template-columns: 1fr;
}

.watch-mode .sidebar,
.render-mode .sidebar {
  display: none;
}

/* Встраивание в iframe: /embed/<id> или /watch/<id>?embed=1 */
html.embed-mode,
body.embed-mode {
  height: 100%;
  margin: 0;
}

body.embed-mode {
  overflow: hidden;
}

.embed-mode .app {
  min-height: 100%;
  max-height: 100vh;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.embed-mode .player-layout {
  padding: 8px 12px 12px;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.embed-mode .slide-canvas {
  min-height: min(72vh, calc(100vh - 140px));
  max-height: calc(100vh - 120px);
}

.embed-mode .controls {
  flex-shrink: 0;
}

.embed-mode .meta {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.render-mode .controls {
  display: none;
}

.render-mode .player-layout {
  padding: 0;
  grid-template-rows: 1fr;
}

.render-mode .slide-canvas {
  min-height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .slide-canvas {
    min-height: 52vh;
  }
}
