/* Editor layout after Canva / Adobe Express: icon rail · one picture-led panel · the slides. */
body { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 10; }

.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 8; background: rgba(13, 10, 20, .9); backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand img { border-radius: 9px; }
.brand b { font-family: var(--display); font-weight: 900; font-size: 18px; }
.brand em { font-style: normal; color: var(--muted); font-size: 13px; margin-left: 4px; }
.progress { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: flex; align-items: baseline; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--muted); text-decoration: none; }
.chip b { color: var(--text); font-family: var(--display); font-size: 14px; font-variant-numeric: tabular-nums; }
.chip.link { color: var(--pink-2); font-weight: 700; }

.top-actions { display: none; gap: 8px; }
.top-actions .primary, .top-actions .ghost { padding: 10px 18px; font-size: 15px; }

.editor {
  display: grid; grid-template-columns: 76px minmax(0, 400px) minmax(0, 1fr); gap: 0;
  min-height: calc(100vh - 140px);
}

/* icon rail */
.rail { display: flex; flex-direction: column; gap: 4px; padding: 14px 8px; border-right: 1px solid var(--line); position: sticky; top: 62px; align-self: start; }
.tab { display: grid; justify-items: center; gap: 3px; padding: 10px 4px; border-radius: 14px; background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 700; }
.tab .ti { font-size: 22px; line-height: 1; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; transition: background .15s ease; }
.tab:hover .ti { background: var(--surface-2); }
.tab.on { color: var(--text); }
.tab.on .ti { background: linear-gradient(135deg, var(--pink), var(--violet)); box-shadow: 0 6px 18px rgba(233, 30, 99, .35); }

/* panel */
.drawer { border-right: 1px solid var(--line); padding: 18px 18px 28px; position: sticky; top: 62px; align-self: start; max-height: calc(100vh - 150px); overflow-y: auto; scrollbar-width: thin; }
.pane { display: none; gap: 12px; }
.pane.on { display: grid; }
.pane-head h2 { font-size: 24px; }
.pane-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.sub { font-family: var(--body); font-weight: 700; font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 6px 0 -2px; }
.pane-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.tool { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 13px; font-size: 13px; font-weight: 700; }
.tool:hover { background: #2b2339; }
.tool.small { padding: 2px 8px; font-size: 13px; }
.next { margin-top: 4px; background: none; border: 1px dashed rgba(233, 30, 99, .5); color: var(--pink-2); border-radius: 14px; padding: 11px; font-weight: 800; font-family: var(--display); }
.next:hover { background: rgba(233, 30, 99, .08); }

/* formats: picture cards */
.format-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fcard { position: relative; border: 2px solid transparent; border-radius: 16px; padding: 0; overflow: hidden; background: var(--surface-2); text-align: left; }
.fcard canvas { width: 100%; aspect-ratio: 4 / 5; display: block; }
.fcard .fmeta { position: absolute; inset: auto 0 0; padding: 26px 10px 9px; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .85)); }
.fcard .fname { font-family: var(--display); font-weight: 900; font-size: 15px; display: block; }
.fcard .fpitch { font-size: 11px; color: #d7cfe3; line-height: 1.35; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fcard.on { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(233, 30, 99, .22); }
.fcard .badge { position: absolute; top: 8px; left: 8px; font-size: 18px; background: rgba(0, 0, 0, .5); border-radius: 10px; padding: 3px 6px; }

/* stories: thumbnails of their first slide */
.story-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.scard { position: relative; border: 2px solid transparent; border-radius: 14px; overflow: hidden; padding: 0; background: var(--surface-2); }
.scard canvas { width: 100%; aspect-ratio: 4 / 5; display: block; }
.scard .smeta { position: absolute; left: 8px; bottom: 8px; font-size: 11px; font-weight: 800; background: rgba(0, 0, 0, .6); border-radius: 999px; padding: 3px 8px; }
.scard .smeta.posted { background: var(--ok); color: #06140b; }
.scard.on { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(233, 30, 99, .22); }
.hooks { display: grid; gap: 6px; }
.hook { text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-weight: 700; font-size: 14px; }
.hook.on { border-color: var(--pink-2); background: rgba(233, 30, 99, .14); }

/* cast */
.cast-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cast-grid.rivals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.person { position: relative; border: 2px solid transparent; border-radius: 16px; overflow: hidden; padding: 0; background: var(--surface-2); }
.person img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; display: block; }
.person span { position: absolute; inset: auto 0 0; padding: 14px 4px 5px; text-align: center; font-family: var(--display); font-weight: 900; font-size: 12.5px; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .75)); }
.person.on { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(233, 30, 99, .22); }
.person.on::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--pink); display: grid; place-items: center; font-size: 12px; font-weight: 900; }
.names { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.names summary { cursor: pointer; font-weight: 800; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.names .inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }

/* style tiles with small previews */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tile { border: 2px solid var(--line); border-radius: 14px; background: var(--surface-2); padding: 8px; display: grid; gap: 6px; justify-items: center; font-size: 12px; font-weight: 800; color: var(--muted); }
.tile.on { border-color: var(--pink); color: var(--text); background: rgba(233, 30, 99, .1); }
.tile .pv { width: 100%; height: 54px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #5a3a7a, #2a1638); position: relative; overflow: hidden; }
.pv .t { font-family: var(--display); font-weight: 900; font-size: 14px; color: #fff; }
.pv .t.outline { -webkit-text-stroke: 3px #000; paint-order: stroke fill; }
.pv .t.box { background: #fff; color: #111; padding: 1px 6px; border-radius: 5px; }
.pv .t.shadow { text-shadow: 0 2px 8px rgba(0, 0, 0, .9); }
.pv .bar { position: absolute; left: 18%; right: 18%; height: 7px; border-radius: 4px; background: #fff; }
.pv.light { background: #fff; } .pv.dark { background: #000; }
.pv .bub { position: absolute; height: 10px; border-radius: 6px; }
.pv .shape { border: 2px solid #fff; border-radius: 5px; }

.inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.steps-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; color: #d9d2e4; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.howto { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; color: #d9d2e4; }

/* slides */
.preview { min-width: 0; padding: 18px 0 18px 22px; }
.preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.preview-head h2 { font-size: 24px; }
.preview-head p { margin: 0; font-size: 13px; }
.slides { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.slide { margin: 0; cursor: pointer; }
.slide canvas { width: 100%; height: auto; aspect-ratio: 4 / 5; border-radius: 14px; background: var(--surface-2); display: block; border: 1px solid var(--line); }
.slides.tall .slide canvas { aspect-ratio: 9 / 16; }
.slide:hover canvas { border-color: var(--pink-2); }
.slide figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.slide figcaption b { color: var(--text); }
.req { color: var(--pink-2); font-weight: 700; }
.slide.locked canvas { border-color: rgba(233, 30, 99, .5); }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; display: flex; gap: 8px; justify-content: center;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(13, 10, 20, 0), rgba(13, 10, 20, .96) 30%);
}
.savebar .primary { flex: 1; max-width: 520px; padding: 15px; font-size: 17px; white-space: nowrap; }
.savebar .ghost { flex: none; padding-inline: 18px; white-space: nowrap; }

dialog.sheet { width: min(560px, calc(100vw - 32px)); max-height: 88vh; overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 24px; padding: 20px; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .6); }
dialog.sheet > * + * { margin-top: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h3 { font-size: 20px; }
.close { background: var(--surface-2); border: 1px solid var(--line); border-radius: 50%; width: 34px; height: 34px; }
#editorFields { display: grid; gap: 10px; }

/* the stage: one big slide, arrows, a filmstrip */
.stage { display: none; }
.big { margin: 0; display: grid; justify-items: center; gap: 8px; min-height: 0; }
.big canvas { height: 100%; max-height: 100%; width: auto; max-width: 100%; border-radius: 18px; box-shadow: 0 24px 70px rgba(0, 0, 0, .55); cursor: pointer; background: var(--surface-2); min-height: 0; }
.big figcaption { font-size: 13px; color: var(--muted); }
.big figcaption b { color: var(--text); }
.nav { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 26px; line-height: 1; display: grid; place-items: center; }
.nav:hover { background: var(--surface-2); }
.nav:disabled { opacity: .3; }
.slide.sel canvas { border: 2px solid var(--pink); box-shadow: 0 0 0 3px rgba(233, 30, 99, .25); }

/* desktop: a full-window editor, every column scrolls on its own */
@media (min-width: 821px) {
  body { padding-bottom: 0; padding-left: 0; padding-right: 0; height: 100vh; overflow: hidden; }
  .topbar { padding-inline: 18px; position: relative; top: 0; }
  .top-actions { display: flex; }
  .savebar { display: none; }
  .editor { height: calc(100vh - 57px); min-height: 0; }
  .rail { position: static; height: 100%; }
  .drawer { position: static; max-height: none; height: 100%; overflow-y: auto; padding: 18px 18px 40px; }
  .preview { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; padding: 14px 22px 14px; gap: 12px; min-height: 0; background: radial-gradient(900px 600px at 50% 40%, rgba(233, 30, 99, .08), transparent 70%); }
  .preview-head { margin: 0; align-items: center; }
  .stage { display: grid; grid-template-columns: 46px minmax(0, 1fr) 46px; align-items: center; gap: 18px; min-height: 0; height: 100%; }
  .big { height: 100%; grid-template-rows: minmax(0, 1fr) auto; }
  .slides { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
  .slides .slide { flex: none; width: 92px; }
  .slides.tall .slide { width: 66px; }
  .slide figcaption { font-size: 11px; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .slide figcaption .req { display: none; }
}

/* tablets: narrower panel */
@media (max-width: 1100px) and (min-width: 821px) {
  .editor { grid-template-columns: 72px minmax(0, 320px) minmax(0, 1fr); }
  .progress .chip:not(.link) { display: none; }
}

/* phones: tabs across the top, the panel, then the slides */
@media (max-width: 820px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .rail { flex-direction: row; position: sticky; top: 58px; z-index: 7; background: rgba(13, 10, 20, .95); backdrop-filter: blur(12px); border-right: 0; border-bottom: 1px solid var(--line); padding: 6px 0; justify-content: space-between; }
  .tab { flex: 1; padding: 6px 2px; }
  .tab .ti { width: 36px; height: 36px; font-size: 19px; }
  .drawer { position: static; max-height: none; overflow: visible; border-right: 0; padding: 16px 0; }
  .preview { padding: 6px 0 12px; }
  .slides { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand em, .chip.link { display: none; }
}
.pv .t.dark { background: rgba(0, 0, 0, .78); color: #fff; padding: 1px 6px; border-radius: 5px; }
.pv .t.neon { color: #fff; text-shadow: 0 0 6px #ff3d9a, 0 0 12px #ff3d9a; }
.pv .t.yellow { color: #FFE14D; -webkit-text-stroke: 3px #000; paint-order: stroke fill; }
.pv .f { color: #fff; font-size: 20px; line-height: 1; -webkit-text-stroke: 2px #000; paint-order: stroke fill; }
.pv .f.nunito { font-family: "Nunito", sans-serif; font-weight: 900; }
.pv .f.bebas { font-family: "Bebas Neue", sans-serif; font-size: 24px; }
.pv .f.marker { font-family: "Permanent Marker", cursive; font-size: 18px; }
.pv .f.serif { font-family: "DM Serif Display", serif; }
.pv .f.mono { font-family: "Space Mono", monospace; font-size: 16px; }
.cast-grid.lovers { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.person .auto { display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; background: var(--surface-2); font-size: 26px; }
