/* ==========================================================================
   Public pages: instance home, profiles, share pages, locked/gone, auth.
   Loaded on top of app.css for <body class="… pub"> (see Document in views/layout.tsx).
   Calm and neutral: the content is the hero, the brand accent is used sparingly.
   Light and dark follow prefers-color-scheme.
   ========================================================================== */

body.pub {
  /* surfaces */
  --ink: #0b0b0e;
  --surface: #141418;
  --surface-2: #1c1c21;
  --glass: rgba(20, 20, 24, 0.72);
  --input: #0f0f12;
  /* text */
  --text: #ededf0;
  --text-2: #c9c9d1;
  --muted: #a1a1ab;
  --faint: #6c6c76;
  /* lines */
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.13);
  /* accent: --accent comes from the owner (inline style); these derive from it */
  --accent-solid: color-mix(in srgb, var(--accent) 88%, #000);
  --accent-solid: oklch(from var(--accent) min(l, 0.54) c h); /* any owner accent keeps white text AA */
  --link: color-mix(in srgb, var(--accent) 62%, #fff);
  --link: oklch(from var(--accent) max(l, 0.78) min(c, 0.16) h);
  --ring: color-mix(in srgb, var(--accent) 70%, #fff);
  --warn-fg: #f5c451;
  --bad: #f87171;
  /* depth */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 16px 48px -16px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--line);
  --shadow-media: 0 24px 64px -28px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --ambient-opacity: 0.16;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  background: var(--ink);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
}
html:has(> body.pub) { color-scheme: dark; background: #0b0b0e; }

@media (prefers-color-scheme: light) {
  html:has(> body.pub) { color-scheme: light; background: #f7f7f8; }
  body.pub {
    --ink: #f7f7f8;
    --surface: #ffffff;
    --surface-2: #f1f1f3;
    --glass: rgba(255, 255, 255, 0.78);
    --input: #ffffff;
    --text: #111114;
    --text-2: #3a3a42;
    --muted: #5f5f69;
    --faint: #9a9aa3;
    --line: rgba(17, 17, 20, 0.08);
    --line-2: rgba(17, 17, 20, 0.14);
    --accent-solid: color-mix(in srgb, var(--accent) 90%, #000);
    --accent-solid: oklch(from var(--accent) min(l, 0.54) c h);
    --link: color-mix(in srgb, var(--accent) 80%, #000);
    --link: oklch(from var(--accent) min(l, 0.5) c h);
    --ring: var(--accent);
    --warn-fg: #9a5b00;
    --bad: #c62828;
    --shadow-sm: 0 1px 2px rgba(17, 17, 20, 0.06);
    --shadow: 0 1px 2px rgba(17, 17, 20, 0.04), 0 12px 36px -12px rgba(17, 17, 20, 0.14), 0 0 0 1px var(--line);
    --shadow-media: 0 2px 6px rgba(17, 17, 20, 0.05), 0 24px 56px -24px rgba(17, 17, 20, 0.3), 0 0 0 1px rgba(17, 17, 20, 0.07);
    --ambient-opacity: 0.2;
  }
}

/* ---------- basics ---------- */
.pub ::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.pub h1, .pub h2, .pub h3 { letter-spacing: -0.015em; }
.pub .muted { color: var(--muted); }
.pub .error { color: var(--bad); font-size: 0.875rem; margin: 0; }
.pub p a, .pub .code-foot a { color: var(--link); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.pub p a:hover, .pub .code-foot a:hover { text-decoration-color: currentColor; }
.pub :focus { outline: none; }
.pub :focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.pub .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pub code { background: var(--surface-2); }

.pub .avatar {
  background: linear-gradient(180deg, color-mix(in srgb, var(--a) 82%, #fff), var(--a));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  font-weight: 600;
}

/* ---------- buttons ---------- */
.pub .btn, .pub .pill {
  height: 36px; padding: 0 14px; gap: 7px; border-radius: 9px;
  font: 550 0.84rem/1 var(--font); letter-spacing: -0.005em;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.pub .btn:hover, .pub .pill:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 22%, transparent); }
.pub .btn:active, .pub .pill:active { transform: translateY(0.5px); }
.pub .btn svg, .pub .pill svg { width: 16px; height: 16px; flex: none; }
.pub .btn.primary, .pub .pill.primary {
  background: var(--accent-solid); color: #fff; border-color: transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.pub .btn.primary:hover, .pub .pill.primary:hover { background: color-mix(in srgb, var(--accent-solid) 88%, #fff); filter: none; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.pub .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.pub .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.pub .btn.big { height: 42px; padding: 0 18px; font-size: 0.9rem; border-radius: 10px; }
.pub .btn.small, .pub .pill.small { height: 30px; padding: 0 10px; font-size: 0.8rem; border-radius: 8px; }
.pub .pill.icon { width: 36px; padding: 0; }

/* ---------- inputs ---------- */
.pub label { color: var(--text-2); font-size: 0.82rem; font-weight: 550; gap: 6px; }
.pub input, .pub select, .pub textarea {
  height: 40px; padding: 0 12px; border-radius: 9px; font: 0.92rem var(--font);
  background: var(--input); color: var(--text); border: 1px solid var(--line-2); box-shadow: var(--shadow-sm);
}
.pub input::placeholder { color: var(--faint); }
.pub input:focus, .pub select:focus, .pub textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent); outline: none;
}
.pub input[aria-invalid="true"] { border-color: var(--bad); }

/* ---------- cards, dialogs, toast ---------- */
.pub .card { background: var(--surface); border: 0; border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }

.pub dialog.help {
  background: var(--surface); color: var(--text); border: 0; border-radius: 14px; padding: 22px 22px 18px;
  box-shadow: 0 24px 80px -20px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--line-2); width: min(360px, calc(100vw - 32px));
}
.pub dialog.help h3 { font-size: 0.95rem; font-weight: 600; margin: 0; }
.pub dialog::backdrop { background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(2px); }
.pub dialog[open] { animation: pub-in 0.18s ease-out both; }
.pub .help dl { gap: 10px 14px; margin: 16px 0 18px; font-size: 0.875rem; }
.pub .help form { display: flex; justify-content: flex-end; }
.pub kbd {
  font: 600 0.75rem/1 var(--mono); min-width: 24px; padding: 5px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2); border-bottom-width: 2px;
}

.pub .toast {
  background: #18181b; color: #fafafa; border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.4); border-radius: 10px; font: 550 0.85rem var(--font);
  padding: 10px 14px; backdrop-filter: none; transition: opacity 0.2s ease, transform 0.2s ease;
}
.pub .toast::before { width: 6px; height: 6px; box-shadow: none; background: #4ade80; }

@keyframes pub-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Share page
   ========================================================================== */
body.pub.share { min-height: 100dvh; display: flex; flex-direction: column; overflow-x: hidden; background: var(--ink); }
.pub.share > *:not(.ambient):not(.lightbox):not(.toast):not(dialog) { position: relative; z-index: 1; }

/* A faint wash of the image's colors behind a neutral page. Static: no motion, no grain. */
.pub .ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.pub .ambient img, .pub .ambient canvas {
  position: absolute; inset: -15%; width: 130%; height: 130%; max-width: none; object-fit: cover;
  filter: blur(100px) saturate(0.85); opacity: var(--ambient-opacity); transform: translateZ(0);
}
.pub .ambient canvas { opacity: 0; transition: opacity 1s ease; }
.pub .ambient.live canvas { opacity: var(--ambient-opacity); }
.pub .ambient.live img { opacity: 0; }
.pub .ambient::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 85% at 50% 40%, transparent 35%, var(--ink) 92%);
}
/* no image (code, files, audio, locked, gone): a quiet top light in the accent */
.pub .ambient:not(.has-img)::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(55% 45% at 50% -8%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 70%);
}

/* top bar */
.pub .share-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) clamp(16px, 2.6vw, 28px) 10px;
}
.pub .owner { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; text-decoration: none; border-radius: 10px; }
.pub .owner .avatar { flex: none; }
.pub .owner-text { display: grid; line-height: 1.3; min-width: 0; }
.pub .owner-text b { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub .owner-text span { color: var(--muted); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub .owner:hover b { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.pub .share-actions { display: flex; gap: 6px; flex: none; align-items: center; }
.pub.share .pill:not(.primary) { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

/* stage */
.pub .stage { flex: 1; display: grid; place-items: center; width: 100%; min-height: 0; padding: 10px clamp(12px, 3vw, 40px); }
.pub .frame {
  --h: calc(100dvh - 176px);
  margin: 0; position: relative; overflow: hidden; border-radius: 12px; box-shadow: var(--shadow-media);
  width: min(100%, 1600px, calc(var(--h) * var(--ar))); aspect-ratio: var(--ar);
  background-color: var(--surface-2);
  /* checkerboard so transparent screenshots read well */
  background-image: conic-gradient(rgba(127, 127, 127, 0.1) 25%, transparent 0 50%, rgba(127, 127, 127, 0.1) 0 75%, transparent 0);
  background-size: 16px 16px;
  animation: pub-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.pub.kind-video .frame { background: #000; }
.pub .frame img, .pub .frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.pub .frame img { cursor: zoom-in; }
.pub .zoom-hint {
  position: absolute; right: 10px; top: 10px; width: 32px; height: 32px; border: 0; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer; color: #fff;
  background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity 0.15s ease;
}
.pub .frame:hover .zoom-hint, .pub .zoom-hint:focus-visible { opacity: 1; }
@media (hover: none) { .pub .zoom-hint { display: none; } }

/* info bar */
.pub .share-info {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
  padding: 12px clamp(16px, 2.6vw, 28px) max(16px, env(safe-area-inset-bottom));
}
.pub .info-main { min-width: 0; flex: 1 1 320px; }
.pub .share-title { font-size: 0.95rem; font-weight: 600; margin: 0 0 2px; letter-spacing: -0.01em; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub .share-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin: 0; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.pub .share-meta > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.pub .share-meta > span + span::before { content: "·"; margin: 0 8px; color: var(--faint); }
.pub .share-meta .kind svg { opacity: 0.85; }
.pub .share-meta .notice { color: var(--warn-fg); font-weight: 550; }
.pub .info-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.pub .palette { display: flex; gap: 6px; }
.pub .palette button {
  width: 20px; height: 20px; padding: 0; border-radius: 6px; cursor: pointer; position: relative;
  border: 0; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.28); transition: transform 0.15s ease; animation: none;
}
.pub .palette button:hover { transform: translateY(-2px); }
.pub .palette button::after {
  content: attr(data-hex); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  font: 600 11px var(--mono); color: #fafafa; background: #18181b; padding: 4px 7px; border-radius: 6px;
  opacity: 0; pointer-events: none; transition: opacity 0.12s; white-space: nowrap;
}
.pub .palette button:hover::after, .pub .palette button:focus-visible::after { opacity: 1; }

.pub .powered {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 99px;
  font-size: 0.75rem; color: var(--muted); text-decoration: none; white-space: nowrap;
  border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: color 0.15s, border-color 0.15s;
}
.pub .powered b { color: var(--text); font-weight: 600; letter-spacing: -0.01em; }
.pub .powered:hover { color: var(--text); border-color: var(--line-2); }

/* cards on the stage: text, file, audio */
.pub .stage-text, .pub .stage-file, .pub .stage-audio { align-items: start; padding-top: clamp(8px, 4vh, 48px); }
.pub .stage-file, .pub .stage-audio { align-items: center; padding-bottom: 6vh; }

.pub .code-card { width: min(1100px, 100%); padding: 0; overflow: hidden; animation: pub-in 0.4s ease-out both; }
.pub .code-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.pub .code-icon { width: 28px; height: 28px; flex: none; border-radius: 7px; display: grid; place-items: center; color: var(--muted); background: var(--surface-2); }
.pub .code-name { font-size: 0.875rem; font-weight: 600; margin: 0; flex: 1; min-width: 0; letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub .code-meta { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.pub .code {
  margin: 0; padding: 14px 0; overflow: auto; max-height: calc(100dvh - 230px);
  font: 13px/1.7 var(--mono); counter-reset: ln; tab-size: 2; background: var(--surface);
}
.pub .code:focus-visible { outline-offset: -2px; border-radius: 0; }
.pub .code code { background: none; padding: 0; font-size: inherit; display: block; color: var(--text); }
.pub .code .ln { display: inline-block; width: 100%; padding-right: 20px; }
.pub .code .ln::before { counter-increment: ln; content: counter(ln); display: inline-block; width: 3.6em; padding-right: 1.4em; text-align: right; color: var(--faint); user-select: none; }
.pub .code .ln:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.pub .code-foot { padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; }

/* syntax colors, tuned per theme */
.pub { --hl-kw: #c4a5ff; --hl-str: #a5d6a7; --hl-num: #f4b67a; --hl-com: #7a7a86; --hl-fn: #82c8f5; --hl-attr: #f09ab8; --hl-type: #f2d27a; }
@media (prefers-color-scheme: light) {
  .pub { --hl-kw: #7c3aed; --hl-str: #15803d; --hl-num: #b45309; --hl-com: #8a8a94; --hl-fn: #0369a1; --hl-attr: #be185d; --hl-type: #a16207; }
}
.pub .hljs-keyword, .pub .hljs-selector-tag, .pub .hljs-literal { color: var(--hl-kw); }
.pub .hljs-string, .pub .hljs-attr-value, .pub .hljs-template-string, .pub .hljs-regexp { color: var(--hl-str); }
.pub .hljs-number, .pub .hljs-symbol { color: var(--hl-num); }
.pub .hljs-comment, .pub .hljs-quote { color: var(--hl-com); font-style: italic; }
.pub .hljs-title, .pub .hljs-title.function_, .pub .hljs-section { color: var(--hl-fn); }
.pub .hljs-attr, .pub .hljs-attribute, .pub .hljs-property, .pub .hljs-tag, .pub .hljs-name { color: var(--hl-attr); }
.pub .hljs-built_in, .pub .hljs-type, .pub .hljs-title.class_ { color: var(--hl-type); }
.pub .hljs-meta, .pub .hljs-variable, .pub .hljs-params { color: var(--text); }
.pub .hljs-emphasis { font-style: italic; } .pub .hljs-strong { font-weight: 700; }

.pub .file-title { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.pub .file-sub { color: var(--muted); font-size: 0.84rem; margin: 0; overflow-wrap: anywhere; }

.pub .file-card { width: min(420px, 100%); padding: 36px 28px 28px; display: grid; justify-items: center; gap: 6px; text-align: center; animation: pub-in 0.4s ease-out both; }
.pub .file-badge {
  position: relative; width: 64px; height: 64px; margin-bottom: 14px; border-radius: 16px; display: grid; place-items: center;
  color: var(--muted); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.pub .file-badge svg { width: 30px; height: 30px; stroke-width: 1.6; }
.pub .file-badge span {
  position: absolute; right: -10px; bottom: -6px; font: 700 0.66rem/1 var(--font); letter-spacing: 0.04em;
  background: var(--accent-solid); color: #fff; padding: 4px 6px; border-radius: 6px; box-shadow: 0 0 0 3px var(--surface);
}
.pub .file-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; width: 100%; }
.pub .file-actions .btn { flex: 1 1 150px; }

.pub .audio-card { width: min(500px, 100%); padding: 28px; display: grid; gap: 4px; text-align: left; animation: pub-in 0.4s ease-out both; }
.pub .audio-card audio { width: 100%; margin-top: 18px; }
.pub .eq { display: flex; align-items: center; gap: 3px; height: 64px; margin: 0 0 18px; padding: 0 2px; }
.pub .eq i {
  flex: 1; height: var(--h); min-height: 3px; border-radius: 99px; background: color-mix(in srgb, var(--text) 16%, transparent);
  transform-origin: center; animation: none; transition: background-color 0.3s ease;
}
.pub.playing .eq i { background: color-mix(in srgb, var(--accent) 75%, var(--text)); animation: pub-eq 1.1s ease-in-out infinite alternate; animation-delay: calc(var(--i) * -83ms); }
@keyframes pub-eq { from { transform: scaleY(0.45); } to { transform: scaleY(1); } }

/* extension viewers */
.pub .ext-stage .pl-frame { border: 0; border-radius: 12px; box-shadow: var(--shadow-media); background: var(--surface); }

/* lightbox */
.pub .lightbox { background: color-mix(in srgb, var(--ink) 96%, transparent); backdrop-filter: blur(6px); }
.pub .lb-hud {
  bottom: max(20px, env(safe-area-inset-bottom)); font-size: 0.78rem; color: var(--muted); background: var(--surface);
  padding: 7px 12px; border-radius: 99px; box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Centered pages: locked, gone
   ========================================================================== */
body.pub.center-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px 96px; }
.pub .lock-card, .pub .gone-card {
  width: min(380px, 100%); display: grid; gap: 12px; justify-items: center; text-align: center; padding: 32px 28px 28px;
  animation: pub-in 0.4s ease-out both; backdrop-filter: none;
}
.pub .lock-card h1, .pub .gone-card h1 { font-size: 1.25rem; font-weight: 600; margin: 4px 0 0; }
.pub .lock-card p, .pub .gone-card p { margin: 0; font-size: 0.9rem; }
.pub .lock-card input, .pub .lock-card .btn { width: 100%; }
.pub .lock-card input { margin-top: 8px; }
.pub .center-icon {
  width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center;
  color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.pub .owner-inline { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; color: var(--text); text-decoration: none !important; }
.pub .owner-inline b { font-weight: 600; }
.pub.center-page .powered { position: fixed !important; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 3; }

/* ==========================================================================
   Auth: login, setup, signup, invite, connect
   ========================================================================== */
body.pub.auth-page {
  min-height: 100dvh; display: grid; place-items: center; align-content: center; gap: 20px; padding: 32px 16px;
  background:
    radial-gradient(50% 40% at 50% -5%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--ink);
}
.pub .auth-card { width: min(400px, 100%); padding: 32px; animation: pub-in 0.4s ease-out both; backdrop-filter: none; }
.pub .auth-logo { display: inline-flex; border-radius: 10px; }
.pub .auth-card h1 { font-size: 1.4rem; font-weight: 650; letter-spacing: -0.02em; margin: 20px 0 6px; }
.pub .auth-card .auth-sub { margin: 0 0 4px; font-size: 0.9rem; }
.pub .auth-card form { margin-top: 22px; gap: 14px; }
.pub .auth-card form .btn.big { width: 100%; margin-top: 6px; }
.pub .auth-card > p.small { margin: 18px 0 0; font-size: 0.85rem; }
.pub .auth-card > .btn.big { width: 100%; margin-top: 20px; }
.pub .auth-host { font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.pub .auth-host:hover { color: var(--text); }
.pub .connect-viz { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 24px 0 16px; }
.pub .connect-node { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); border: 0; box-shadow: inset 0 0 0 1px var(--line); }
.pub .connect-line { width: 72px; height: 2px; background: var(--line-2); position: relative; overflow: hidden; border-radius: 2px; }
.pub .connect-line i { position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: pub-flow 1.6s ease-in-out infinite; }
@keyframes pub-flow { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.pub .auth-card p.center { font-size: 0.9rem; }
.pub .auth-card p b { color: var(--text); font-weight: 600; }

/* ==========================================================================
   Instance home + profiles
   ========================================================================== */
body.pub.home { min-height: 100dvh; overflow-x: hidden; display: flex; flex-direction: column; }
.pub .home-top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  width: 100%; max-width: 1280px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) clamp(16px, 4vw, 40px) 18px;
}
.pub .brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; font-size: 0.95rem; letter-spacing: -0.01em; text-decoration: none; border-radius: 8px; }
.pub .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub .brand svg { flex: none; }
.pub .home-nav { display: flex; align-items: center; gap: 14px; flex: none; }
.pub .home-owners { display: flex; }
.pub .home-owners a { display: inline-flex; border-radius: 50%; text-decoration: none; }
.pub .home-owners a + a { margin-left: -8px; }
.pub .home-owners .avatar { box-shadow: 0 0 0 2px var(--ink); }

.pub .home-main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.pub .home-intro { padding: clamp(28px, 7vh, 72px) 0 clamp(28px, 5vh, 48px); max-width: 680px; }
.pub .home-title { font-size: clamp(1.75rem, 3.6vw, 2.5rem); font-weight: 650; letter-spacing: -0.03em; line-height: 1.12; margin: 0; overflow-wrap: anywhere; }
.pub .home-sub { color: var(--muted); font-size: 1.02rem; line-height: 1.55; margin: 12px 0 0; max-width: 560px; }
.pub .home-stats { display: flex; flex-wrap: wrap; margin: 16px 0 0; color: var(--muted); font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.pub .home-stats span + span::before { content: "·"; margin: 0 10px; color: var(--faint); }
.pub .home-stats b { color: var(--text); font-weight: 600; }

.pub .profile-intro { display: flex; align-items: center; gap: 20px; max-width: 760px; }
.pub .profile-intro .avatar { flex: none; }
.pub .profile-handle { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.pub .profile-intro .home-sub { margin-top: 10px; }

.pub .home-gallery { padding: 0 0 24px; }
.pub .gallery-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 20px; margin-bottom: 16px; border-top: 1px solid var(--line); }
.pub .gallery-head h2 { font-size: 0.95rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.pub .gallery-count { color: var(--muted); font-size: 0.8rem; }
.pub .home-empty { color: var(--muted); padding: 48px 0; text-align: center; margin: 0; }
.pub.profile .home-gallery { padding-top: 4px; }

.pub .masonry { columns: 4 240px; column-gap: 12px; }
.pub .m-item {
  display: block; position: relative; margin: 0 0 12px; break-inside: avoid; border-radius: 10px; overflow: hidden;
  text-decoration: none; color: #fff; isolation: isolate;
  background: color-mix(in srgb, var(--tint) 14%, var(--surface-2));
  transition: box-shadow 0.25s ease;
}
.pub .m-item::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent);
}
.pub .m-item img { display: block; width: 100%; height: auto; aspect-ratio: var(--ar); object-fit: cover; transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.pub .m-item:hover { box-shadow: 0 14px 32px -16px rgba(0, 0, 0, 0.45); }
.pub .m-item:hover img { transform: scale(1.025); }
.pub .m-item:focus-visible { outline-offset: 3px; border-radius: 10px; }
.pub .m-cap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; display: grid; gap: 1px; padding: 36px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.32) 55%, transparent);
  opacity: 0; transform: translateY(4px); transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 0.8rem; line-height: 1.35; white-space: normal;
}
.pub .m-cap b { font-weight: 600; font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub .m-cap span { color: rgba(255, 255, 255, 0.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub .m-item:hover .m-cap, .pub .m-item:focus-visible .m-cap { opacity: 1; transform: none; }
.pub .m-kind {
  position: absolute; top: 8px; left: 8px; z-index: 1; display: inline-flex; align-items: center; gap: 4px;
  font: 600 0.68rem/1 var(--font); letter-spacing: 0.02em; color: #fff; padding: 4px 6px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.pub .m-kind svg { fill: currentColor; stroke: none; }

.pub .home-foot { text-align: center; padding: 40px 16px max(40px, env(safe-area-inset-bottom)); }
.pub .powered-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.82rem; text-decoration: none; border-radius: 6px; }
.pub .powered-inline b { color: var(--text-2); font-weight: 600; }
.pub .powered-inline:hover { color: var(--text); }

/* ==========================================================================
   Small screens
   ========================================================================== */
@media (max-width: 720px) {
  .pub .kbd-btn { display: none !important; }
  .pub .share-actions .lbl { display: none; }
  .pub .share-actions .pill { width: 38px; height: 38px; padding: 0; }
  .pub .share-actions { gap: 6px; }
  .pub .share-top { padding-bottom: 8px; }
  .pub .stage { padding: 6px 12px; }
  .pub .stage { flex: none; padding-top: 10px; }
  .pub .stage-image, .pub .stage-gif, .pub .stage-video { min-height: 0; }
  .pub .frame { --h: calc(100dvh - 230px); border-radius: 10px; }
  .pub .share-info { padding-top: 14px; gap: 14px; }
  .pub .info-main { flex-basis: 100%; }
  .pub .info-right { width: 100%; justify-content: space-between; }
  .pub .share-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .pub .code-head .lbl, .pub .code-meta { display: none; }
  .pub .code-head .pill.small { width: 32px; padding: 0; }
  .pub .code { font-size: 12.5px; max-height: none; }
  .pub .code .ln::before { width: 2.6em; padding-right: 1em; }
  .pub .stage-text { padding-top: 6px; }
  .pub .card { padding: 24px 20px; }
  .pub .code-card { padding: 0; }
  .pub .file-card { padding: 32px 20px 20px; }
  .pub .file-actions .btn { flex-basis: 100%; }
  .pub .auth-card { padding: 28px 22px; }

  .pub .home-top { padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: 14px; }
  .pub .home-intro { padding: 24px 0 28px; }
  .pub .home-sub { font-size: 0.95rem; }
  .pub .masonry { columns: 2; column-gap: 8px; }
  .pub .m-item { margin-bottom: 8px; border-radius: 8px; }
  .pub .profile-intro { gap: 16px; align-items: flex-start; }
  .pub .profile-intro .avatar { width: 56px !important; height: 56px !important; font-size: 21px !important; }
}
@media (max-width: 380px) {
  .pub .home-owners { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pub *, .pub *::before, .pub *::after { animation: none !important; transition: none !important; }
}
@media (prefers-contrast: more) {
  body.pub { --line: rgba(127, 127, 127, 0.45); --line-2: rgba(127, 127, 127, 0.6); --muted: var(--text-2); }
  .pub .ambient { display: none; }
}

/* ==========================================================================
   Listings: text cards next to the picture tiles, admin and report actions (src/routes/public-page.tsx)
   ========================================================================== */
.pub .m-cell { position: relative; break-inside: avoid; margin: 0 0 12px; }
.pub .m-cell .m-item { margin: 0; }
.pub .m-card {
  display: grid; gap: 8px; padding: 16px 16px 14px; color: var(--text);
  background: var(--surface); border-radius: 10px;
}
.pub .m-card:hover { box-shadow: 0 14px 32px -18px rgba(0, 0, 0, 0.35); }
.pub .m-card-kind { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.01em; }
.pub .m-card-title { font-size: 0.98rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pub .m-card-ex { color: var(--text-2); font-size: 0.86rem; line-height: 1.5; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.pub .m-card-ex.mono { font: 0.76rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre; -webkit-line-clamp: 6; overflow: hidden; color: var(--muted); }
.pub .m-card-meta { color: var(--faint); font-size: 0.76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub .m-acts { position: absolute; top: 8px; right: 8px; z-index: 2; margin: 0; opacity: 0; transition: opacity 0.15s ease; }
.pub .m-cell:hover .m-acts, .pub .m-acts:focus-within { opacity: 1; }
.pub .m-act {
  display: inline-block; font: 600 0.7rem/1 var(--font); color: #fff; padding: 5px 7px; border-radius: 6px; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); text-decoration: none;
}
.pub .m-act:hover { background: rgba(0, 0, 0, 0.75); }
@media (hover: none) { .pub .m-acts { opacity: 1; } }
.pub .home-flash {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 0; padding: 10px 14px;
  border-radius: 10px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); font-size: 0.86rem; color: var(--text-2);
}
.pub .report-link { color: var(--faint); font-size: 0.78rem; text-decoration: none; }
.pub .report-link:hover { color: var(--muted); text-decoration: underline; }
.pub .report-card textarea {
  width: 100%; margin-top: 8px; padding: 10px 12px; border-radius: 10px; resize: vertical; font: inherit; font-size: 0.9rem;
  background: var(--input); color: var(--text); border: 1px solid var(--line-2);
}
.pub .report-card > a { text-align: center; }
@media (max-width: 720px) {
  .pub .m-cell { margin-bottom: 8px; }
  .pub .m-card { padding: 12px; border-radius: 8px; }
}
