/* The public page of a published design, /p/<slug> (src/server/public-page.ts, D-086).
   The product tokens of DESIGN.md §4, light and dark (system, or the reader's own
   choice in the app: data-theme). Artboards are never themed. Artboards 10, 11, 16
   on WEfaeYzPpG. */
:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-title: ui-serif, "Iowan Old Style", "Times New Roman", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --bg: #f8f8f6;
  --surface: #ffffff;
  --raise: #ffffff;
  --ink: rgba(20, 20, 19, 0.93);
  --ink2: rgba(20, 20, 19, 0.57);
  --ink3: rgba(20, 20, 19, 0.4);
  --line: rgba(20, 20, 19, 0.1);
  --hover: rgba(20, 20, 19, 0.05);
  --accent: #2f6fde;
  --primary: #141413;
  --on-primary: #ffffff;
  --canvas: #f1f1ee;
  --dot: rgba(20, 20, 19, 0.14);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  --danger: #b3261e;
  --scrim: rgba(0, 0, 0, 0.4);
  --r-ctl: 8px;
  --r-card: 14px;
  --r-pop: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191919; --surface: #1f1f1f; --raise: #262626;
    --ink: rgba(255, 255, 255, 0.93); --ink2: rgba(255, 255, 255, 0.57); --ink3: rgba(255, 255, 255, 0.38);
    --line: rgba(255, 255, 255, 0.08); --hover: rgba(255, 255, 255, 0.07);
    --accent: #5b93ff; --primary: #f2f2f0; --on-primary: #141413;
    --canvas: #161616; --dot: rgba(255, 255, 255, 0.1); --danger: #ff8a80; --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191919; --surface: #1f1f1f; --raise: #262626;
  --ink: rgba(255, 255, 255, 0.93); --ink2: rgba(255, 255, 255, 0.57); --ink3: rgba(255, 255, 255, 0.38);
  --line: rgba(255, 255, 255, 0.08); --hover: rgba(255, 255, 255, 0.07);
  --accent: #5b93ff; --primary: #f2f2f0; --on-primary: #141413;
  --canvas: #161616; --dot: rgba(255, 255, 255, 0.1); --danger: #ff8a80; --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.pp { background: var(--bg); color: var(--ink); font: 14px/20px var(--font-sans); display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; }
.ink2 { color: var(--ink2); }
.ink3 { color: var(--ink3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* buttons */
.pp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-ctl); border: 1px solid transparent; font: 500 14px/20px var(--font-sans); text-decoration: none; cursor: pointer; background: none; color: var(--ink); white-space: nowrap; }
.pp-btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.pp-btn.block { display: flex; width: 100%; }
.pp-btn.primary { background: var(--primary); color: var(--on-primary); }
.pp-btn.outline { border-color: var(--line); background: var(--surface); }
.pp-btn.ghost:hover, .pp-btn.outline:hover { background: var(--hover); }
.pp-btn:disabled { opacity: 0.5; cursor: default; }
.pp-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r-ctl); background: none; color: var(--ink); font: 16px/1 var(--font-sans); cursor: pointer; }
.pp-icon:hover { background: var(--hover); }
.pp-ico { display: block; flex: none; }

/* header (48 px) and the author bar (40 px) */
.pp-head { flex: none; height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.pp-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; }
.pp-mark { display: block; }
.pp-head-gap { flex: 1; }
.pp-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--hover); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; text-decoration: none; position: relative; overflow: hidden; flex: none; }
.pp-avatar-fallback { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.pp-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.pp-author { flex: none; height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.pp-pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; }
.pp-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink3); }

/* the stage and the panel */
.pp-main { flex: 1; min-height: 0; display: flex; }
.pp-stage { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--canvas); background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 20px 20px; touch-action: none; cursor: grab; outline: none; }
.pp-stage.dragging { cursor: grabbing; }
.pp-fallback { position: absolute; inset: 24px 24px 80px; display: flex; align-items: center; justify-content: center; }
.pp-fallback img { max-width: 100%; max-height: 100%; height: auto; border-radius: 4px; box-shadow: var(--shadow); background: #fff; }
.pp-stage.live .pp-fallback { display: none; }
.pp-world { position: absolute; left: 0; top: 0; margin: 0; padding: 0; list-style: none; transform-origin: 0 0; }
.pp-stage:not(.live) .pp-world { display: none; }
.pp-board { position: absolute; background: #fff; border-radius: 4px; box-shadow: 0 0 0 1px var(--line); transition: opacity 160ms ease-out; }
.pp-board.dim { opacity: 0.25; }
.pp-board-name { position: absolute; left: 0; bottom: 100%; margin-bottom: 8px; color: var(--ink2); font: 12px/16px var(--font-mono); white-space: nowrap; transform-origin: 0 100%; }
.pp-frame { display: block; border: 0; width: 100%; height: 100%; border-radius: 4px; background: #fff; }
.pp-shield { position: absolute; inset: 0; }
/* the canvas media (D-175): where they sit on the canvas, beside their artboards; badges stay about screen size */
.pp-media { position: absolute; border-radius: 4px; transition: opacity 160ms ease-out; }
.pp-media.dim { opacity: 0.25; }
.pp-m-pic { display: block; width: 100%; height: 100%; object-fit: fill; border-radius: 4px; user-select: none; -webkit-user-drag: none; }
.pp-m-image .pp-m-pic { box-shadow: 0 0 0 1px var(--line); }
.pp-m-btn { position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 4px; background: #fff; color: inherit; font: inherit; cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.pp-m-video .pp-m-btn { background: #141413; color: #fff; overflow: hidden; }
.pp-m-btn:focus-visible { outline: none; box-shadow: 0 0 0 calc(3px * var(--inv, 1)) var(--accent); }
.pp-m-badge { position: absolute; left: 8px; top: 8px; transform: scale(min(var(--inv, 1), 6)); transform-origin: 0 0; padding: 2px 8px; border-radius: 999px; background: rgba(20, 20, 19, 0.82); color: #fff; font: 500 12px/18px var(--font-sans); white-space: nowrap; pointer-events: none; }
.pp-m-play { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; transform: scale(min(var(--inv, 1), 4)); display: grid; place-items: center; border-radius: 50%; background: rgba(20, 20, 19, 0.82); color: #fff; pointer-events: none; transition: background 120ms ease-out; }
.pp-m-play .pp-ico { width: 22px; height: 22px; margin-left: 3px; }
.pp-m-btn:hover .pp-m-play { background: var(--accent); }
.pp-m-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 12px 10px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.6)); color: #fff; font: 500 16px/22px var(--font-sans); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
/* the dock: every control 32 px high on one centre line, hairlines between the groups (Play | artboards | zoom, Fit) */
.pp-dock { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--raise); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); cursor: default; white-space: nowrap; }
.pp-dock .pp-btn { height: 32px; border-radius: 999px; font-size: 13px; }
.pp-dock .pp-icon { width: 32px; height: 32px; border-radius: 999px; }
.pp-dock-play { gap: 6px; padding: 0 14px 0 12px; }
.pp-dock-play .pp-ico { width: 12px; height: 12px; }
.pp-dock-fit { padding: 0 12px; }
.pp-group { display: inline-flex; align-items: center; gap: 2px; }
.pp-sep { flex: none; width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.pp-step, .pp-zoom { display: inline-block; text-align: center; color: var(--ink2); line-height: 32px; font-variant-numeric: tabular-nums; }
.pp-step { min-width: 84px; font-size: 13px; }
.pp-zoom { min-width: 48px; font-size: 13px; }
.pp-play-bar .pp-zoom { min-width: 44px; font: 12px var(--font-mono); }
.pp-stage.playing .pp-dock, .pp-stage.playing .pp-world { visibility: hidden; }

/* Play */
.pp-play { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--canvas); cursor: default; }
.pp-play[hidden] { display: none; }
.pp-play-bar { flex: none; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; white-space: nowrap; }
.pp-play-bar .pp-icon .pp-ico { width: 14px; height: 14px; }
.pp-back { gap: 2px; padding-left: 4px; }
.pp-back .pp-ico { width: 14px; height: 14px; }
.pp-play-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pp-play-step { min-width: 56px; }
.pp-play-bar .pp-icon:disabled, .pp-back:disabled { opacity: 0.35; cursor: default; background: none; }
/* Fit / Fill and zoom (D-145): the box scales inside this scrolling stage; the page itself never pinch-zooms here */
.pp-play-stage { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; overscroll-behavior: contain; touch-action: pan-x pan-y; }
.pp-play-content { position: relative; }
.pp-play-box { position: absolute; overflow: hidden; border-radius: 4px; box-shadow: var(--shadow); background: #fff; }
.pp-seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--hover); flex: none; }
.pp-seg button { height: 24px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink2); font: inherit; font-size: 13px; cursor: pointer; }
.pp-seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.pp-seg button[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.pp-zoom-btn { height: 28px; border: 0; background: transparent; font: inherit; font-size: 12px; cursor: pointer; border-radius: 6px; }
.pp-zoom-btn:hover { background: var(--hover); }
.pp-play-box .pp-frame { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.pp-panel { flex: none; width: 360px; display: flex; flex-direction: column; gap: 12px; padding: 24px; border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.pp-title { margin: 0; font: 500 24px/32px var(--font-title); overflow-wrap: anywhere; }
.pp-by { margin: 0; display: flex; align-items: center; gap: 8px; }
.pp-initial { width: 22px; height: 22px; border-radius: 50%; background: var(--hover); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; position: relative; overflow: hidden; flex: none; }
.pp-meta { margin: 0; color: var(--ink2); }
.pp-desc { margin: 4px 0 0; overflow-wrap: anywhere; }
.pp-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pp-hint { margin: 0; color: var(--ink2); font-size: 12px; line-height: 16px; }
.pp-rows { display: flex; flex-direction: column; margin-top: 8px; }
.pp-row > span { flex: none; }
.pp-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 40px; border-top: 1px solid var(--line); font-weight: 500; }
.pp-row:last-child { border-bottom: 1px solid var(--line); }
.pp-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: 16px; }
.pp-made { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; text-decoration: none; font-size: 13px; }
.pp-made .pp-mark { width: 16px; height: 16px; }
.pp-report { border: 0; background: none; color: var(--ink2); font: 13px var(--font-sans); cursor: pointer; padding: 4px; }
.pp-report:hover { color: var(--ink); }
.pp-mobile-bar { display: none; }

/* the Report dialog */
.pp-dialog { width: min(400px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: var(--r-pop); background: var(--raise); color: var(--ink); box-shadow: var(--shadow); }
.pp-dialog::backdrop { background: var(--scrim); }
.pp-dialog h2 { margin: 0 0 4px; font: 500 20px/28px var(--font-title); }
.pp-dialog fieldset { border: 0; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pp-radio { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pp-radio input { accent-color: var(--accent); margin: 0; }
.pp-dialog textarea, .pp-dialog input[type="email"] { width: 100%; margin: 0 0 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); color: var(--ink); font: 14px/20px var(--font-sans); }
.pp-dialog textarea { min-height: 64px; resize: vertical; }
.pp-error { margin: 0 0 8px; color: var(--danger); font-size: 13px; }
.pp-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
/* a PDF's pages and the video player (D-175) */
.pp-lightbox { width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; display: none; flex-direction: column; overflow: hidden; }
.pp-lightbox[open] { display: flex; }
.pp-lightbox [hidden] { display: none !important; }
.pp-lb-bar { flex: none; display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pp-lb-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.pp-lb-bar .pp-icon:disabled { opacity: 0.35; cursor: default; background: none; }
.pp-lb-body { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 16px; background: var(--canvas); }
.pp-lb-page { display: block; max-width: 100%; height: auto; background: #fff; box-shadow: var(--shadow); border-radius: 2px; }
.pp-lb-video { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 160px); background: #000; border-radius: 4px; overflow: hidden; }
.pp-lb-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pp-lb-note { flex: none; padding: 8px 16px 12px; }
.pp-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 8px 14px; border-radius: var(--r-ctl); background: var(--primary); color: var(--on-primary); font-size: 13px; box-shadow: var(--shadow); z-index: 10; }
.pp-toast[hidden] { display: none; }

/* 410 and 404 */
.pp-gone { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--canvas); }
.pp-gone-card { max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.pp-gone-card h1 { margin: 0; font: 500 22px/30px var(--font-title); }
.pp-gone-card p { margin: 0 0 8px; color: var(--ink2); }
.pp-gone-card .pp-note { color: var(--ink); font-size: 13px; }

/* phones: one artboard at a time, the panel under it, Remix in a bar at the bottom */
@media (max-width: 760px) {
  .pp-hide-sm { display: none !important; }
  body.pp:not(.pp-gone-body) { height: auto; min-height: 100%; }
  .pp-main { flex-direction: column; }
  .pp-stage { flex: none; height: 62vh; min-height: 320px; }
  .pp-panel { width: auto; border-left: 0; border-top: 1px solid var(--line); padding: 20px 16px 96px; overflow: visible; }
  .pp-actions [data-remix], .pp-actions [data-remix] + .pp-hint { display: none; }
  .pp-mobile-bar { display: block; position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .pp-mobile-bar .pp-btn { height: 44px; }
  /* the Remix split button's menu opens upwards from the bottom bar (remix.css opens it downwards) */
  .pp-mobile-bar .rx-menu { top: auto; bottom: calc(100% + 6px); }
  .pp-author { gap: 8px; overflow-x: auto; }
  .pp-author > * { flex: none; white-space: nowrap; }
  .pp-author .pp-pill { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .pp-board, .pp-media, .pp-m-play { transition: none; }
}
