@font-face {
  font-family: "Aspekta";
  src: url("fonts/AspektaVF.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --blue: #0091cf;
  --ink: #0a1622;
  --bg: #f8fafc;
  --line: #d5e3ec;
  --muted: #475569;
  --ui-bg: #eef3f7;
  --ui-panel: #ffffff;
  --sans: "Aspekta", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--ui-bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }

/* ---------- App shell ---------- */

#app {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 216px 1fr;
  grid-template-areas: "top top" "side stage";
  height: 100dvh;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--ui-panel);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.topbar .brand { height: 22px; flex: none; }
.topbar .sep { width: 1px; height: 22px; background: var(--line); flex: none; }
.deck-title {
  flex: 1 1 120px;
  min-width: 60px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px;
  font-weight: 500;
  font-size: 15px;
}
.deck-title:hover { border-color: var(--line); }
.deck-title:focus { outline: none; border-color: var(--blue); background: #fff; }
.save-state { font: 500 11px var(--mono); color: #94a3b8; text-transform: uppercase; letter-spacing: .12em; flex: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.btn:hover { border-color: #a9c6d8; background: #f6fafd; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #007fb6; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
select.btn { padding-right: 8px; }

.menu { position: relative; flex: none; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 210px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(10, 22, 34, .14);
}
.menu-list[hidden] { display: none; }
.menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.menu-list button:hover { background: #eef6fb; }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- Slide list ---------- */

.sidebar {
  grid-area: side;
  overflow-y: auto;
  padding: 14px 14px 80px;
  border-right: 1px solid var(--line);
  background: #f3f7fa;
}
.thumbs { display: flex; flex-direction: column; gap: 12px; }
.thumb-row { display: flex; gap: 8px; align-items: flex-start; }
.thumb-num { width: 16px; padding-top: 4px; font: 500 11px var(--mono); color: #94a3b8; text-align: right; flex: none; }
.thumb {
  position: relative;
  flex: 1;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  outline: 1px solid var(--line);
  cursor: pointer;
  background: var(--bg);
  container-type: inline-size;
}
.thumb.active { outline: 2px solid var(--blue); }
.thumb.drop-before::before, .thumb.drop-after::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: var(--blue);
  z-index: 3;
}
.thumb.drop-before::before { top: 0; }
.thumb.drop-after::after { bottom: 0; }
.thumb .slide { transform: scale(var(--s)); }
.thumb-actions {
  position: absolute;
  top: 4px; right: 4px;
  display: none;
  gap: 4px;
  z-index: 4;
}
.thumb:hover .thumb-actions { display: flex; }
.thumb-actions button {
  width: 24px; height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, .95);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.thumb-actions svg { width: 13px; height: 13px; }
.add-slide {
  margin: 14px 0 0 24px;
  width: calc(100% - 24px);
  justify-content: center;
  border-style: dashed;
  background: transparent;
}

/* ---------- Stage ---------- */

.stage {
  grid-area: stage;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.stage-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 0;
  flex-wrap: wrap;
}
.hint { font-size: 12.5px; color: #64748b; margin-left: auto; }
.hint kbd {
  font: 500 11px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fff;
}
.canvas-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 16px 20px 24px;
}
.canvas {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(10, 22, 34, .06), 0 16px 48px rgba(10, 22, 34, .12);
}
.canvas .slide { transform: scale(var(--s)); }

/* ---------- Slide ---------- */

.slide {
  position: absolute;
  left: 0; top: 0;
  width: 1600px;
  height: 900px;
  transform-origin: 0 0;
  overflow: hidden;
  background-color: var(--bg);
  background-size: 100% 100%;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 34px;
  line-height: 1.4;
}
.slide.dark { background-color: var(--ink); color: #dbe6ef; }

.slide .logo { position: absolute; top: 92px; right: 120px; height: 46px; }
.slide .page-num {
  position: absolute;
  right: 120px; bottom: 82px;
  font: 500 18px var(--mono);
  letter-spacing: .14em;
  color: #8aa2b5;
}
.slide .content { position: absolute; inset: 92px 120px 110px; display: flex; flex-direction: column; }

.f { margin: 0; outline: none; min-width: 1ch; }
.f b, .f strong { color: var(--blue); font-weight: inherit; }
.f i, .f em { font-style: italic; }
.f code {
  font-family: var(--mono);
  font-size: .8em;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  padding: .06em .32em;
  border-radius: .25em;
  background: rgba(0, 145, 207, .08);
  border: 1px solid rgba(0, 145, 207, .22);
  color: #035f8a;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.dark .f code { background: rgba(0, 145, 207, .14); border-color: rgba(0, 145, 207, .38); color: #7cc8ec; }
.f a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: rgba(0, 145, 207, .45);
  text-decoration-thickness: .06em;
  text-underline-offset: .14em;
}
.f a:hover { text-decoration-color: var(--blue); }
#present .f a { cursor: pointer; }

.eyebrow-wrap { display: flex; align-items: center; gap: 18px; min-height: 46px; padding-right: 280px; }
.eyebrow-wrap .sq { width: 14px; height: 14px; background: var(--blue); flex: none; }
.eyebrow {
  font: 500 22px/1.4 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--blue);
}

.t-hero, .t-title, .tagline, .lay-quote .quote { text-wrap: balance; }
.t-hero {
  font-size: 104px;
  line-height: 1.08;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.t-title {
  font-size: 68px;
  line-height: 1.12;
  font-weight: 400;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-top: 30px;
}
.t-sub { font-size: 36px; line-height: 1.4; color: var(--muted); }
.t-body { font-size: 32px; line-height: 1.5; color: #334155; }
.t-meta { font: 500 22px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #64748b; }
.dark .t-hero, .dark .t-title { color: #fff; }
.dark .t-sub, .dark .t-body { color: #9fb3c4; }
.dark .t-meta { color: #7f97ab; }

.bullets { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 26px; font-size: 36px; line-height: 1.35; }
.bullets li { position: relative; padding-left: 58px; }
.bullets li::before {
  content: "";
  position: absolute;
  left: 0; top: .2em;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M6.5 11.3l3 3 6-6.3' stroke='%23fff' stroke-width='2.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}

.card {
  background: rgba(255, 255, 255, .86);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 44px 46px;
  position: relative;
}
.card::before { content: ""; position: absolute; left: -1.5px; top: -1.5px; width: 40px; height: 4px; background: var(--blue); border-radius: 16px 0 0 0; }
.dark .card { background: rgba(255, 255, 255, .04); border-color: #1e3446; }
.card h3 { font-size: 40px; line-height: 1.2; font-weight: 400; letter-spacing: -0.02em; margin: 0 0 18px; color: var(--ink); }
.dark .card h3 { color: #fff; }

.slot {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  min-height: 0;
  background: #fff;
  border: 1.5px solid var(--line);
  box-shadow: 0 24px 60px rgba(10, 22, 34, .10);
}
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.slot.cover img { object-fit: cover; }
.dark .slot { background: #0f2131; border-color: #1e3446; }

/* Layouts */
.lay-title { justify-content: center; padding-bottom: 40px; }
.lay-title .t-hero { margin-top: 44px; max-width: 1200px; }
.lay-title .t-sub { margin-top: 36px; max-width: 1000px; }
.lay-title .t-meta { position: absolute; left: 0; bottom: 0; }

.lay-section { justify-content: center; }
.lay-section .t-num { font: 500 120px/1 var(--mono); color: var(--blue); letter-spacing: -0.02em; }
.lay-section .t-hero { margin-top: 40px; max-width: 1150px; }
.lay-section .t-sub { margin-top: 32px; max-width: 1000px; }

.lay-statement { justify-content: center; padding-bottom: 30px; }
.t-kicker { font-size: 44px; line-height: 1.3; font-weight: 400; letter-spacing: -0.015em; color: var(--muted); }
.dark .t-kicker { color: #9fb3c4; }
.lay-statement .t-hero { margin-top: 28px; max-width: 1250px; }

.lay-detail .cols { grid-template-columns: 1fr 1.08fr; gap: 56px; margin-top: 48px; }
.lay-detail .t-body { font-size: 31px; }
.tech-card { padding: 34px 40px 38px; align-self: start; }
.tech-label { font: 500 20px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--blue); margin-bottom: 20px; }
.tech { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 16px; font-size: 25px; line-height: 1.45; color: #334155; }
.dark .tech { color: #9fb3c4; }
.tech li { position: relative; padding-left: 28px; }
.tech li::before { content: ""; position: absolute; left: 0; top: .56em; width: 10px; height: 10px; background: var(--blue); }

.lay-bullets .bullets { margin-top: 56px; max-width: 1180px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 56px; flex: 1; min-height: 0; align-content: start; }
.cols.three { grid-template-columns: 1fr 1fr 1fr; }

.content.lay-image { display: grid; grid-template-columns: 1fr 1.15fr; gap: 64px; }
.lay-image .text { display: flex; flex-direction: column; min-width: 0; }
.lay-image .t-body { margin-top: 36px; }
.lay-image .slot { margin-top: 68px; }

.lay-full .slot { flex: 1; margin-top: 40px; }
.lay-full .t-title { margin-top: 20px; font-size: 56px; }
.lay-full .caption { margin-top: 18px; font-size: 22px; color: #64748b; text-align: center; }

.stat-num { font-size: 120px; line-height: 1; font-weight: 600; letter-spacing: -0.04em; color: var(--blue); }
.stat-label { margin-top: 22px; font-size: 30px; line-height: 1.4; color: #334155; }
.dark .stat-label { color: #9fb3c4; }

.lay-quote { justify-content: center; align-items: center; text-align: center; padding: 0 80px; }
.lay-quote .mark { width: 88px; height: 70px; color: var(--blue); }
.lay-quote .quote { margin-top: 40px; font-size: 56px; line-height: 1.3; font-weight: 500; letter-spacing: -0.02em; color: var(--ink); max-width: 1180px; }
.dark .lay-quote .quote { color: #fff; }
.lay-quote .t-meta { margin-top: 48px; }

.lay-closing { justify-content: center; align-items: center; text-align: center; }
.lay-closing .big-logo { height: 132px; margin-top: -30px; }
.lay-closing .tagline { margin-top: 60px; font-size: 64px; line-height: 1.2; letter-spacing: -0.02em; color: var(--ink); }
.dark .lay-closing .tagline { color: #fff; }
.lay-closing .t-meta { margin-top: 40px; }

/* Free-placed images */
.free-layer { position: absolute; inset: 0; pointer-events: none; }
.free {
  position: absolute;
  pointer-events: auto;
}
.free img { display: block; width: 100%; height: auto; border-radius: inherit; pointer-events: none; }

/* ---------- Editor-only affordances ---------- */

.editing-on .f[data-ph]:empty::before { content: attr(data-ph); color: #b4c4d1; }
.editing-on .dark .f[data-ph]:empty::before { color: #3a5367; }
.thumb .slide { pointer-events: none; }
#canvas .f:hover { box-shadow: 0 0 0 2px rgba(0, 145, 207, .28); border-radius: 6px; cursor: text; }
#canvas .f[contenteditable="true"] { box-shadow: 0 0 0 3px var(--blue); border-radius: 6px; cursor: text; }
#canvas .slot { cursor: pointer; }
.editing-on .slot:empty::after {
  content: "Paste or drop an image\Aor double-click to choose";
  white-space: pre;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font: 500 24px/1.6 var(--mono);
  color: #8aa2b5;
  background: repeating-linear-gradient(45deg, transparent 0 14px, rgba(0, 145, 207, .04) 14px 28px);
}
#canvas .slot.selected, #canvas .free.selected { outline: 4px solid var(--blue); outline-offset: 4px; }
#canvas .free { cursor: move; }
#canvas .free .handle { touch-action: none; }
#canvas .free { touch-action: none; }

/* Empty frames and labels are editor hints. They do not show when presenting or printing. */
#present .slot:empty, #print .slot:empty { visibility: hidden; }
#present .eyebrow-wrap:has(.eyebrow:empty), #print .eyebrow-wrap:has(.eyebrow:empty) { visibility: hidden; }
.free .handle {
  display: none;
  position: absolute;
  right: -16px; bottom: -16px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--blue);
  cursor: nwse-resize;
}
#canvas .free.selected .handle { display: block; }
.canvas.drag-over { outline: 3px dashed var(--blue); outline-offset: 6px; }

/* ---------- Template picker ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 22, 34, .45);
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(980px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 26px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(10, 22, 34, .3);
}
.modal-card h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.modal-card p { margin: 0 0 20px; color: #64748b; font-size: 14px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.tpl { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.tpl .thumb { pointer-events: none; }
.tpl:hover .thumb { outline: 2px solid var(--blue); }
.tpl span { display: block; margin-top: 8px; font-size: 14px; font-weight: 500; }

/* ---------- Present mode ---------- */

#present {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: grid;
  place-items: center;
  user-select: none;
}
#present.idle { cursor: none; }
#present[hidden] { display: none; }
#present .canvas { border-radius: 0; box-shadow: none; }
#present .progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--blue); transition: width .2s; }

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 300;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(10, 22, 34, .3);
}
.toast[hidden] { display: none; }

/* ---------- Print: one slide per page ---------- */

#print { position: fixed; left: -100000px; top: 0; }
@page { size: 1600px 900px; margin: 0; }
@media print {
  #app, #present, .modal, .toast { display: none !important; }
  #print { position: static; }
  .print-page { position: relative; width: 1600px; height: 900px; overflow: hidden; break-after: page; }
  .print-page:last-child { break-after: auto; }
  .slide { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Narrow screens ---------- */

@media (max-width: 820px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "top" "stage" "side";
  }
  .topbar { flex-wrap: wrap; padding: 8px 10px; }
  .topbar .label, .topbar .sep, .save-state { display: none; }
  .deck-title { order: 10; flex-basis: 100%; }
  .sidebar { border-right: 0; border-top: 1px solid var(--line); padding: 10px; overflow-x: auto; overflow-y: hidden; }
  .thumbs { flex-direction: row; }
  .thumb-row { flex: 0 0 150px; }
  .add-slide { margin: 0; width: auto; }
  .sidebar-inner { display: flex; gap: 12px; align-items: flex-start; }
  .hint { display: none; }
  .canvas-wrap { padding: 10px; }
  .stage-tools { padding: 8px 10px 0; }
}
.tpl:focus { outline: none; }
.tpl:focus-visible .thumb { outline: 2px solid var(--blue); }
.btn:focus:not(:focus-visible) { outline: none; }

/* ---------- Publish dialog ---------- */

.publish-card { width: min(520px, 100%); }
.publish-card p b { font-weight: 600; color: var(--ink); }
.field { display: block; font-size: 13px; font-weight: 500; color: #475569; }
.field-row { display: flex; align-items: center; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.field-row:focus-within { border-color: var(--blue); }
.field-row input { flex: 1; min-width: 0; border: 0; outline: none; background: none; padding: 9px 10px; font: 500 14px var(--mono); }
.field-row .suffix { padding-right: 10px; font: 500 14px var(--mono); color: #94a3b8; }
.publish-status { min-height: 20px; margin-top: 14px; font-size: 14px; line-height: 1.5; color: #334155; overflow-wrap: anywhere; }
.publish-status a { color: var(--blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- Published viewer (viewer.js) ---------- */

body.viewer { background: #000; overflow: hidden; }
body.viewer #present { position: fixed; }
@media print {
  body.viewer { background: none; overflow: visible; }
  body.viewer #present { display: block !important; position: static; background: none; }
  body.viewer #presentCanvas { width: auto !important; height: auto !important; overflow: visible; }
  body.viewer #presentCanvas .slide { display: block !important; position: relative; transform: none; break-after: page; }
  body.viewer #presentCanvas .slide:last-child { break-after: auto; }
  body.viewer .progress { display: none; }
}
