:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #171717;
  --muted: #6d6a64;
  --line: #ddd7cc;
  --accent: #0d7c66;
  --accent-strong: #075746;
  --signal: #d64a2f;
  --blue: #2855b8;
  --gold: #bd8b22;
  --shadow: 0 24px 80px rgba(31, 28, 23, 0.14);
  --soft-shadow: 0 16px 46px rgba(31, 28, 23, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(13, 124, 102, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(214, 74, 47, 0.1), transparent 28%),
    var(--bg);
  color: var(--ink);
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  gap: 18px;
  background: #11100f;
  color: #fffaf0;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-mark {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.loader-mark span {
  width: 14px;
  height: 42px;
  border-radius: 999px;
  background: var(--accent);
  animation: loadBars 0.9s ease-in-out infinite;
}

.loader-mark span:nth-child(2) {
  background: var(--gold);
  animation-delay: 0.12s;
}

.loader-mark span:nth-child(3) {
  background: var(--signal);
  animation-delay: 0.24s;
}

.loader p {
  margin: 0;
  color: #d7d0c4;
  font-size: 14px;
  letter-spacing: 0;
}

@keyframes loadBars {
  0%,
  100% {
    transform: scaleY(0.45);
    opacity: 0.55;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 290px) minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: rgba(255, 253, 248, 0.88);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #11100f;
  color: #fffaf0;
  font-weight: 800;
  box-shadow: var(--soft-shadow);
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.sidebar-actions,
.topbar-actions,
.editor-toolbar,
.panel-head,
.progress-info {
  display: flex;
  align-items: center;
}

.sidebar-actions {
  gap: 10px;
}

.btn,
.icon-btn,
.round-btn,
.segment {
  border: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 700;
}

.btn:hover,
.icon-btn:hover,
.round-btn:hover,
.segment:hover {
  transform: translateY(-1px);
}

.btn.primary {
  flex: 1;
  background: var(--accent);
  color: white;
  box-shadow: 0 14px 30px rgba(13, 124, 102, 0.24);
}

.btn.dark {
  background: #11100f;
  color: #fffaf0;
  box-shadow: 0 14px 30px rgba(17, 16, 15, 0.2);
}

.btn.ghost,
.btn.subtle {
  background: #ece6da;
  color: var(--ink);
}

.import-btn {
  flex: 1;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.deck-list,
.slide-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.deck-list {
  min-height: 0;
}

.deck-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  text-align: left;
  box-shadow: 0 8px 24px rgba(31, 28, 23, 0.05);
  animation: riseIn 0.28s ease both;
}

.deck-card.active {
  border-color: var(--accent);
  box-shadow: 0 16px 34px rgba(13, 124, 102, 0.16);
}

.deck-card strong,
.deck-card span {
  display: block;
}

.deck-card span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(221, 215, 204, 0.8);
  background: rgba(244, 241, 234, 0.72);
  backdrop-filter: blur(18px);
}

.title-edit {
  min-width: 0;
  flex: 1;
}

.title-edit input,
.title-edit textarea {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
}

.title-edit input {
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 800;
  letter-spacing: 0;
}

.title-edit textarea {
  color: var(--muted);
  line-height: 1.45;
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(31, 28, 23, 0.08);
  font-weight: 800;
}

.icon-btn.danger {
  color: var(--signal);
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(190px, 220px) minmax(0, 1fr) minmax(300px, 340px);
  gap: 14px;
  min-height: 0;
  padding: 18px;
}

.slides-panel,
.editor-panel,
.properties-panel {
  min-height: 0;
  border: 1px solid rgba(221, 215, 204, 0.9);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--soft-shadow);
}

.slides-panel,
.properties-panel {
  display: flex;
  flex-direction: column;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.slide-list {
  padding: 14px;
}

.slide-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  cursor: pointer;
  animation: riseIn 0.26s ease both;
}

.slide-card.active {
  border-color: var(--blue);
  background: #f7f9ff;
  box-shadow: 0 14px 30px rgba(40, 85, 184, 0.14);
}

.slide-index {
  grid-row: span 2;
  color: var(--blue);
  font-weight: 800;
}

.slide-card strong,
.slide-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slide-card small {
  color: var(--muted);
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 14px;
}

.editor-toolbar {
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #e9e1d3;
}

.segment {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment.active {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 8px 16px rgba(31, 28, 23, 0.08);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-content: start;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-grid label.wide {
  grid-column: 1 / -1;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: 0;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(13, 124, 102, 0.12);
}

.preview-stage {
  margin: 14px;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  overflow: hidden;
  background: #11100f;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), var(--soft-shadow);
}

.preview-stage .deck-slide {
  gap: 8px;
  padding: 7%;
}

.preview-stage .deck-slide .kicker {
  font-size: clamp(9px, 0.8vw, 11px);
}

.preview-stage .deck-slide h1 {
  max-width: 15ch;
  font-size: clamp(20px, 2.25vw, 34px);
  line-height: 1.02;
}

.preview-stage .deck-slide p {
  font-size: clamp(11px, 1vw, 14px);
  line-height: 1.35;
}

.preview-stage .slide-media {
  min-height: 48%;
}

.settings {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toggle-row span {
  margin: 0;
}

.toggle-row input {
  width: 46px;
  accent-color: var(--accent);
}

.save-state {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.deck-slide {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 8%;
  overflow: hidden;
  isolation: isolate;
}

.deck-slide::before {
  content: "";
  position: absolute;
  inset: auto -10% -28% 42%;
  height: 44%;
  background: rgba(255, 255, 255, 0.14);
  transform: skewY(-9deg);
  z-index: -1;
}

.deck-slide .kicker {
  color: currentColor;
  font-size: clamp(11px, 1.2vw, 15px);
  font-weight: 800;
  opacity: 0.76;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.deck-slide h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(30px, 5vw, 84px);
  line-height: 0.95;
  letter-spacing: 0;
}

.deck-slide p {
  max-width: 62ch;
  margin: 0;
  font-size: clamp(14px, 1.5vw, 22px);
  line-height: 1.45;
}

.deck-slide .meta {
  font-weight: 800;
}

.deck-slide.split {
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
}

.deck-slide.quote h1 {
  max-width: 15ch;
  font-style: italic;
}

.slide-media {
  min-height: 60%;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
}

.theme-graphite {
  background: #141414;
  color: #fff7ec;
}

.theme-atelier {
  background: #fff7e8;
  color: #141414;
}

.theme-signal {
  background: #0d7c66;
  color: #fffaf0;
}

.theme-paper {
  background: #f7f5ef;
  color: #1f3556;
}

.player {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #050505;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.player.open {
  opacity: 1;
  visibility: visible;
}

.player.fullscreen-mode {
  background: #000;
}

.player.fullscreen-mode .player-stage {
  padding: 0;
}

.player.fullscreen-mode .player-slide {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
}

.player.fullscreen-mode .player-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.player.fullscreen-mode:hover .player-controls,
.player.fullscreen-mode .player-controls:focus-within {
  opacity: 1;
  transform: translateY(0);
}

.player-stage {
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 46px);
}

.player-slide {
  width: min(100%, 150vh);
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 44px 140px rgba(0, 0, 0, 0.6);
}

.player-slide.fade-enter {
  animation: playerFade 0.36s ease both;
}

.player-slide.slide-enter {
  animation: playerSlide 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.player-slide.scale-enter {
  animation: playerScale 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.player-controls {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  color: white;
  background: rgba(5, 5, 5, 0.88);
  backdrop-filter: blur(18px);
}

.round-btn {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 26px;
}

.round-btn.small-label {
  font-size: 14px;
  font-weight: 800;
}

.round-btn.close {
  background: rgba(214, 74, 47, 0.82);
}

.player-grid {
  position: absolute;
  inset: 18px;
  z-index: 3;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(5, 5, 5, 0.86);
  color: #fffaf0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.985);
  backdrop-filter: blur(24px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

.player-grid.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.player-grid-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.player-grid-head strong,
.player-grid-head span {
  display: block;
}

.player-grid-head strong {
  font-size: clamp(22px, 3vw, 40px);
  letter-spacing: 0;
}

.player-grid-head span {
  margin-top: 4px;
  color: rgba(255, 250, 240, 0.64);
  font-size: 13px;
}

.player-grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.player-grid-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  text-align: left;
}

.player-grid-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 124, 102, 0.22);
}

.player-grid-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.12);
}

.player-grid-thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #11100f;
}

.player-grid-thumb .deck-slide {
  padding: 8%;
  gap: 6px;
}

.player-grid-thumb .deck-slide .kicker {
  font-size: 8px;
}

.player-grid-thumb .deck-slide h1 {
  max-width: 16ch;
  font-size: clamp(15px, 2.6vw, 24px);
  line-height: 1;
}

.player-grid-thumb .deck-slide p {
  font-size: 8px;
  line-height: 1.25;
}

.player-grid-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: rgba(255, 250, 240, 0.7);
  font-size: 12px;
}

.progress-wrap {
  display: grid;
  gap: 8px;
}

.progress-info {
  justify-content: space-between;
  gap: 18px;
  font-size: 13px;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #11100f;
  color: #fffaf0;
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@keyframes riseIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes playerFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes playerSlide {
  from {
    transform: translateX(30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes playerScale {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 1180px) {
  .studio-grid {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .properties-panel {
    grid-column: 1 / -1;
  }

  .preview-stage {
    max-width: 520px;
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .deck-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    max-height: 240px;
  }

  .topbar {
    flex-direction: column;
  }

  .studio-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

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

  .player-controls {
    grid-template-columns: auto 1fr auto auto;
  }

  .player-controls .close {
    grid-column: 1 / -1;
    justify-self: center;
  }

  .player-grid {
    inset: 10px;
    padding: 12px;
  }

  .player-grid-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
