/* The slide editor (slide-editor.js), in B · Pennant. It reads the host's tokens (the desk's app.css :root) and falls
   back to Pennant's light values, so a page without them (flaghand.com's maker) still looks right. T-678's layout: the
   toolbar floats over the slide, the strip sits under it; on a phone the toolbar moves under the slide. The slide
   itself is the renderer's picture: nothing here draws on it except the handles, the caret and the selection. */
.se {
  --se-sheet: var(--sheet, #fffaf3); --se-well: var(--well, #f6ebdf); --se-ink: var(--ink, #24110c); --se-ink-2: var(--ink-2, #5a3f37);
  --se-muted: var(--muted, #7a6159); --se-hair: var(--hair, rgba(36, 17, 12, .11)); --se-act: var(--act, #c8321e); --se-act-text: var(--act-text, #c8321e);
  --se-proof: 0 0 0 .5px rgba(60, 10, 4, .18), 0 1px 2px rgba(60, 10, 4, .06), 0 18px 40px -16px rgba(60, 10, 4, .34);
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; min-width: 0;
  color: var(--se-ink); font: 500 15px/1.3 var(--font, "Familjen Grotesk", -apple-system, BlinkMacSystemFont, system-ui, sans-serif);
  -webkit-user-select: none; user-select: none;
}
:root[data-theme="dark"] .se { --se-proof: 0 0 0 .5px rgba(255, 220, 200, .16), 0 18px 40px -16px rgba(0, 0, 0, .7); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .se { --se-proof: 0 0 0 .5px rgba(255, 220, 200, .16), 0 18px 40px -16px rgba(0, 0, 0, .7); } }
.se button { font: inherit; color: inherit; letter-spacing: inherit; -webkit-tap-highlight-color: transparent; }
.se :focus-visible:not(.se-canvas) { outline: 2px solid var(--se-ink); outline-offset: 2px; }
.se-canvas:focus-visible { outline: none; }

/* ---- the toolbar: one floating bar, its groups split by hairlines; a text's tools take two rows ---- */
.se-top { display: flex; align-items: flex-end; justify-content: center; width: 100%; min-height: 100px; }
.se-tools {
  display: flex; align-items: center; gap: 0; max-width: 100%; min-height: 52px; padding: 4px; border-radius: 12px;
  background: var(--se-sheet); box-shadow: var(--se-proof); overflow-x: auto; scrollbar-width: none;
}
.se-tools::-webkit-scrollbar { display: none; }
.se-tools.se-two { flex-direction: column; align-items: center; gap: 4px; }
.se-row { display: flex; align-items: center; max-width: 100%; }
.se-row + .se-row { align-self: stretch; justify-content: center; padding-top: 4px; border-top: 1px solid var(--se-hair); }
.se-tools:empty { display: none; }
.se-group { display: flex; align-items: center; gap: 2px; flex: none; padding: 0 6px; }
.se-group + .se-group { border-left: 1px solid var(--se-hair); }
.se-tool {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 12px;
  border: 0; border-radius: 10px; background: none; color: var(--se-ink); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.se-tool.se-icon { width: 44px; padding: 0; color: var(--se-ink-2); }
.se-tool:hover { background: var(--se-well); color: var(--se-ink); }
.se-tool:disabled { opacity: .35; cursor: default; background: none; }
.se-tool.on, .se-tool[aria-pressed="true"] { background: var(--se-well); color: var(--se-ink); }

/* Shape and Shade: a native menu, shown as the label and its value. */
.se-select { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 10px 0 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.se-select:hover { background: var(--se-well); }
.se-select > span { color: var(--se-muted); font-size: 14px; font-weight: 500; }
.se-pick { appearance: none; -webkit-appearance: none; margin: 0; padding: 0 16px 0 0; border: 0; background: none; color: var(--se-ink); font: 600 15px/1 var(--font, system-ui); cursor: pointer; }
.se-pick:focus-visible { outline: none; }
.se-select:focus-within { box-shadow: 0 0 0 2px var(--se-ink); }
.se-select::after {
  content: ""; position: absolute; right: 10px; top: 50%; width: 9px; height: 6px; margin-top: -2px; background: var(--se-ink-2); pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 6'%3E%3Cpath d='M1 1l3.5 3.5L8 1' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 6'%3E%3Cpath d='M1 1l3.5 3.5L8 1' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Styles: "Aa" in each style, on the slide's own photo. The chosen one gets the ink ring. */
.se-styles { gap: 4px; }
.se-swatch {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0; border: 0; border-radius: 9px;
  background: #6d625a center / cover no-repeat; cursor: pointer; overflow: hidden;
}
.se-swatch.on { box-shadow: 0 0 0 2px var(--se-sheet), 0 0 0 3.5px var(--se-ink); }
.se-swatch:hover { filter: brightness(1.06); }
.se-aa { padding: 1px 4px; font-size: 16px; font-weight: 600; line-height: 1.15; letter-spacing: 0; }
.se-p-outline { color: #fff; -webkit-text-stroke: 3px #000; paint-order: stroke fill; }
.se-p-white { color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .55); }
.se-p-black { color: #111; }
.se-p-yellow { color: #ffd84d; -webkit-text-stroke: 3px #000; paint-order: stroke fill; }
.se-p-white_box { color: #111; background: rgba(255, 255, 255, .95); border-radius: 5px; }
.se-p-white_box_50 { color: #111; background: rgba(255, 255, 255, .5); border-radius: 5px; }
.se-p-black_box { color: #fff; background: rgba(0, 0, 0, .88); border-radius: 5px; }
.se-p-black_box_50 { color: #fff; background: rgba(0, 0, 0, .5); border-radius: 5px; }
.se-p-tiktok_white { color: #000; background: #fff; border-radius: 4px; }
.se-p-tiktok_black { color: #fff; background: #000; border-radius: 4px; }

/* Fonts, each label set in itself. */
.se-font { height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: none; color: var(--se-ink); font-size: 17px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.se-font:hover { background: var(--se-well); }
.se-font.on { background: var(--se-well); }

/* Size: minus, the number, plus, on the well. */
.se-size { gap: 0; }
.se-size .se-tool.se-icon { width: 40px; color: var(--se-ink); }
.se-num { min-width: 34px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- the slide ---- */
.se-stage { position: relative; display: grid; place-items: center; width: 100%; min-width: 0; }
.se-canvas { position: relative; border-radius: 16px; background: var(--se-well); box-shadow: var(--se-proof); outline: none; touch-action: manipulation; }
.se-canvas[hidden] { display: none; }
.se-canvas:focus-visible:not([data-pointer]) { box-shadow: var(--se-proof), 0 0 0 2px var(--se-sheet), 0 0 0 4px var(--se-ink); }
.se-img { display: block; width: 100%; height: 100%; border-radius: 16px; object-fit: fill; pointer-events: auto; -webkit-user-drag: none; }
.se-img:not([src]) { visibility: hidden; }
.se-chrome { position: absolute; inset: 0; border-radius: 16px; overflow: hidden; opacity: .62; pointer-events: none; }
.se-chrome[hidden] { display: none; }
.se-hits { position: absolute; inset: 0; pointer-events: none; }
.se-hit { position: absolute; padding: 0; border: 0; border-radius: 4px; background: none; cursor: move; pointer-events: auto; touch-action: none; }
.se-hit:hover, .se-hit:focus-visible { outline: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, .7), 0 0 0 2px rgba(0, 0, 0, .2); }
.se-hit[aria-pressed="true"] { box-shadow: none; }

/* The chosen text: a white ring 3 px outside its box with a soft dark halo, so it reads on any picture; white handles. */
.se-ring { position: absolute; pointer-events: none; }
.se-ring[hidden] { display: none; }
.se-ring::before { content: ""; position: absolute; inset: -3px; border-radius: 3px; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(0, 0, 0, .22), 0 0 10px rgba(0, 0, 0, .28); }
.se-handle { position: absolute; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 .5px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .35); pointer-events: auto; touch-action: none; }
.se-handle::after { content: ""; position: absolute; inset: -14px; }
.se-nw { left: -3px; top: -3px; cursor: nwse-resize; }
.se-ne { left: calc(100% + 3px); top: -3px; cursor: nesw-resize; }
.se-sw { left: -3px; top: calc(100% + 3px); cursor: nesw-resize; }
.se-se { left: calc(100% + 3px); top: calc(100% + 3px); cursor: nwse-resize; }
.se-w, .se-e { width: 6px; height: 18px; margin: -9px 0 0 -3px; border-radius: 3px; top: 50%; cursor: ew-resize; }
.se-w { left: -3px; }
.se-e { left: calc(100% + 3px); }
.se-ring.typing .se-handle { display: none; }
.se-guide { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; margin-left: -.5px; background: var(--se-act); pointer-events: none; }
.se-guide[hidden] { display: none; }

/* Typing in place: the field can't be seen; the caret and the selection stand on the renderer's own letters. */
.se-field { position: absolute; z-index: -1; margin: 0; padding: 0; border: 0; opacity: 0; resize: none; overflow: hidden; color: transparent; background: none; caret-color: transparent; font-size: 16px; pointer-events: none; }
.se-caret { position: absolute; width: 2px; margin-left: -1px; border-radius: 1px; background: #fff; box-shadow: 0 0 0 .5px rgba(0, 0, 0, .5), 0 0 4px rgba(0, 0, 0, .4); pointer-events: none; }
.se-caret[hidden] { display: none; }
.se-caret.blink { animation: se-blink 1.06s steps(1) .5s infinite; }
@keyframes se-blink { 50% { opacity: 0; } }
.se-marks { position: absolute; inset: 0; pointer-events: none; }
.se-mark { position: absolute; background: rgba(120, 170, 255, .42); }
.se[data-typing] .se-hit { cursor: text; }
.se[data-typing] .se-canvas { cursor: text; }

/* No slides yet: the slide's place, and the two ways to start. */
.se-empty { display: grid; place-items: center; border-radius: 16px; background: var(--se-well); }
.se-empty[hidden] { display: none; }
.se-empty-in { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.se-start { min-width: 168px; min-height: 52px; padding: 0 24px; border: 0; border-radius: 12px; background: var(--se-sheet); color: var(--se-ink); font-size: 16px; font-weight: 600; cursor: pointer; }
.se-start.primary { background: var(--se-ink); color: var(--se-sheet); }
.se-start:hover { opacity: .88; }

.se-warn { margin: -8px 0 0; color: var(--se-act-text); font-size: 13.5px; line-height: 1.4; text-align: center; max-width: 420px; }
.se-warn:empty { display: none; }

/* ---- the strip ---- */
.se-strip { position: relative; display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 6px 6px; overflow-x: auto; scrollbar-width: thin; }
.se-thumb {
  position: relative; flex: none; width: var(--se-thumb-w, 44px); height: 78px; padding: 0; border: 0; border-radius: 7px;
  background: var(--se-well); cursor: pointer; overflow: hidden; touch-action: pan-x; transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.se-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; }
.se-thumb img:not([src]) { visibility: hidden; }
.se-thumb.on { box-shadow: 0 0 0 2px var(--se-sheet), 0 0 0 3.5px var(--se-ink); }
.se-thumb.lifted { z-index: 2; overflow: visible; box-shadow: 0 0 0 2px var(--se-sheet), 0 0 0 3.5px var(--se-ink), 0 12px 24px -8px rgba(40, 10, 4, .45); transition: none; cursor: grabbing; }
.se-thumb.lifted img { border-radius: 7px; }
.se-strip.sorting .se-thumb:not(.lifted) { opacity: .7; }
.se-add { display: grid; place-items: center; width: 44px; color: var(--se-ink-2); }
.se-add:hover { color: var(--se-ink); }
.se-bar { position: absolute; top: 8px; height: 78px; width: 2px; border-radius: 1px; background: var(--se-ink); pointer-events: none; }

/* ---- photos: a tray over the bottom of the editor ---- */
.se-tray {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; max-height: min(70%, 440px); padding: 16px 20px 20px; overflow-y: auto;
  border-radius: 16px; background: var(--se-sheet); box-shadow: var(--shadow, 0 0 0 .5px rgba(60, 10, 4, .25), 0 30px 60px -20px rgba(70, 8, 0, .55));
  animation: se-rise 180ms ease-out; -webkit-user-select: none; user-select: none;
}
.se-tray[hidden] { display: none; }
@keyframes se-rise { from { transform: translateY(16px); opacity: 0; } }
.se-tray-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.se-tray-head b { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.se-done { min-height: 44px; padding: 0; border: 0; background: none; color: var(--se-ink); font-weight: 500; font-size: 14.5px; cursor: pointer; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 5px; }
.se-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.se-tile { position: relative; aspect-ratio: 64 / 114; padding: 0; border: 0; border-radius: 7px; background: var(--se-well); color: var(--se-ink-2); cursor: pointer; overflow: hidden; }
.se-tile:hover { color: var(--se-ink); }
.se-tile:disabled { cursor: progress; opacity: .6; }
.se-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.se-upload, .se-blank { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 4px; font-size: 12.5px; font-weight: 600; line-height: 1.2; text-align: center; }
.se-used { position: absolute; left: 4px; top: 4px; padding: 1px 5px; border-radius: 5px; background: var(--se-sheet); color: var(--se-ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- a phone: the slide first, then the toolbar on two rows, then the strip ---- */
@media (max-width: 650px) {
  .se { gap: 14px; }
  .se-top { order: 3; min-height: 0; }
  .se-stage { order: 1; }
  .se-warn { order: 2; margin: 0; }
  .se-row { flex-wrap: wrap; justify-content: center; }
  .se-tools { flex-wrap: wrap; justify-content: center; width: 100%; padding: 6px 4px; overflow: visible; }
  .se-strip { order: 4; align-self: stretch; margin: 0 -2px; padding-left: 4px; padding-right: 4px; }
  .se-group { padding: 0 2px; }
  .se-group + .se-group { border-left: 0; }
  /* Ten styles across a phone: tall tiles, each still 44 high. */
  .se-styles { gap: 2px; padding: 0 2px; }
  .se-swatch { width: 32px; height: 44px; border-radius: 8px; }
  .se-swatch .se-aa { padding: 1px 2px; font-size: 13px; }
  .se-tray { position: fixed; left: 0; right: 0; bottom: 0; max-height: 72vh; border-radius: 16px 16px 0 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .se-tray, .se-caret.blink { animation: none; }
  .se-thumb { transition: none; }
}
