/* Pixora v6 — Material 3 Expressive inspired UI */

@font-face { font-family: "SiftSans"; src: url("../assets/fonts/InterDisplay-Medium.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "PixoraDisplay"; src: url("../assets/fonts/InterDisplay-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "PixoraMono"; src: url("../assets/fonts/PT-Mono-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Cabin"; src: url("../assets/fonts/Cabin-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Cabin"; src: url("../assets/fonts/Cabin-SemiBold.otf") format("opentype"); font-weight: 600; font-display: swap; }

/* ---------- Themes (colour roles) ---------- */
:root,
html[data-theme="espresso"] {
  --accent: #c58b61; --accent-ink: #1c1510;
  color-scheme: dark;
  --surface: #1a1512; --surface-1: #201a16; --surface-2: #271f1a; --surface-3: #30271f; --surface-4: #3a3129;
  --on-surface: #f3e9e0; --on-variant: #d3c2b3; --outline: #9a8a7c; --outline-v: #4e4339;
  --danger: #ffb4ab; --on-danger: #5c0a06;
  --inverse: #f3e9e0; --on-inverse: #201a15;
}
html[data-theme="cocoa"] {
  --accent: #9a5a32; --accent-ink: #fffaf3;
  color-scheme: light;
  --surface: #fbf6f0; --surface-1: #f7f0e8; --surface-2: #f2e9df; --surface-3: #ece2d6; --surface-4: #e5d9cb;
  --on-surface: #201a15; --on-variant: #51443a; --outline: #857468; --outline-v: #d8c9ba;
  --danger: #b3261e; --on-danger: #ffffff;
  --inverse: #352f2a; --on-inverse: #f8f1ea;
}
html[data-theme="paper"] {
  --accent: #3f6aa3; --accent-ink: #ffffff;
  color-scheme: light;
  --surface: #f6f6f2; --surface-1: #f0f0ea; --surface-2: #e9e9e1; --surface-3: #e1e1d7; --surface-4: #d6d6cb;
  --on-surface: #1b1d1f; --on-variant: #4a4e55; --outline: #7b8089; --outline-v: #d0d1c7;
  --danger: #b3261e; --on-danger: #ffffff;
  --inverse: #2d3035; --on-inverse: #f2f3f5;
}
html[data-theme="sakura"] {
  --accent: #c2346a; --accent-ink: #ffffff;
  color-scheme: light;
  --surface: #fdf3f5; --surface-1: #fbeaee; --surface-2: #f7e0e6; --surface-3: #f1d4dc; --surface-4: #e8c6cf;
  --on-surface: #2c1820; --on-variant: #5b3d46; --outline: #8e6670; --outline-v: #ebcdd5;
  --danger: #b3261e; --on-danger: #ffffff;
  --inverse: #3d2630; --on-inverse: #fdf0f3;
}
html[data-theme="midnight"] {
  --accent: #7f9ff0; --accent-ink: #0b1020;
  color-scheme: dark;
  --surface: #10141c; --surface-1: #141a24; --surface-2: #1a2130; --surface-3: #222a3b; --surface-4: #2c3649;
  --on-surface: #e4e9f3; --on-variant: #c0c8d7; --outline: #8b93a4; --outline-v: #3a4358;
  --danger: #ffb4ab; --on-danger: #5c0a06;
  --inverse: #e4e9f3; --on-inverse: #16202e;
}
html[data-theme="orchid"] {
  --accent: #b195ff; --accent-ink: #1d1233;
  color-scheme: dark;
  --surface: #17121f; --surface-1: #1d1728; --surface-2: #241d31; --surface-3: #2d2540; --surface-4: #372e4c;
  --on-surface: #f0eaf7; --on-variant: #d0c4dc; --outline: #998ea8; --outline-v: #44395a;
  --danger: #ffb4ab; --on-danger: #5c0a06;
  --inverse: #f0eaf7; --on-inverse: #211a2c;
}
html[data-theme="forest"] {
  --accent: #7bc296; --accent-ink: #0f2318;
  color-scheme: dark;
  --surface: #101a14; --surface-1: #142019; --surface-2: #1a2a21; --surface-3: #22362b; --surface-4: #2c4536;
  --on-surface: #e3f0e8; --on-variant: #c0d3c6; --outline: #86a08f; --outline-v: #34493c;
  --danger: #ffb4ab; --on-danger: #5c0a06;
  --inverse: #e3f0e8; --on-inverse: #13241a;
}
html[data-theme="ocean"] {
  --accent: #4fc3c8; --accent-ink: #062027;
  color-scheme: dark;
  --surface: #0b1820; --surface-1: #0f202a; --surface-2: #142933; --surface-3: #1b3442; --surface-4: #24434f;
  --on-surface: #e1f2f5; --on-variant: #b9d3da; --outline: #7fa3ad; --outline-v: #2d4b57;
  --danger: #ffb4ab; --on-danger: #5c0a06;
  --inverse: #e1f2f5; --on-inverse: #0b2029;
}

:root {
  --accent: #c58b61;
  --accent-ink: #1c1510;
  --primary: var(--accent);
  --on-primary: var(--accent-ink);
  --primary-container: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  --checker: color-mix(in srgb, var(--on-surface) 10%, transparent);
  --live: #3ddc84;

  --r-s: 12px; --r-m: 16px; --r-l: 24px; --r-xl: 32px; --r-full: 999px;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --ease-out: cubic-bezier(.05, .7, .1, 1);

  --font-body: system-ui, -apple-system, "Roboto", "Segoe UI", sans-serif;
  --font-head: var(--font-body);
  --head-weight: 600;
}

/* ---------- Typefaces + text size ---------- */
html[data-font="sift"]    { --font-body: "SiftSans", system-ui, sans-serif; --font-head: "SiftSans", system-ui, sans-serif; --head-weight: 500; }
html[data-font="studio"]  { --font-head: "PixoraDisplay", system-ui, sans-serif; --head-weight: 700; }
html[data-font="cabin"]   { --font-body: "Cabin", system-ui, sans-serif; --font-head: "Cabin", system-ui, sans-serif; --head-weight: 600; }
html[data-font="serif"]   { --font-body: "Fraunces", Georgia, serif; --font-head: "Fraunces", Georgia, serif; --head-weight: 700; }
html[data-font="grotesk"] { --font-body: "Space Grotesk", system-ui, sans-serif; --font-head: "Space Grotesk", system-ui, sans-serif; --head-weight: 700; }
html[data-font="rounded"] { --font-body: "Nunito", system-ui, sans-serif; --font-head: "Nunito", system-ui, sans-serif; --head-weight: 800; }
html[data-font="mono"]    { --font-body: "PixoraMono", ui-monospace, monospace; --font-head: "PixoraMono", ui-monospace, monospace; --head-weight: 400; }
html[data-font="code"]    { --font-body: "JetBrains Mono", ui-monospace, monospace; --font-head: "JetBrains Mono", ui-monospace, monospace; --head-weight: 600; }
html[data-font="system"]  { --font-body: system-ui, -apple-system, "Roboto", sans-serif; --font-head: var(--font-body); --head-weight: 600; }

html { font-size: 16px; }
html[data-size="small"] { font-size: 14px; }
html[data-size="large"] { font-size: 18px; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}
input, select, textarea { user-select: text; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--font-head); font-weight: var(--head-weight); letter-spacing: 0; }
h1 { font-size: 2.125rem; line-height: 1.1; }
h2 { font-size: 1.125rem; }
h3 { font-size: .8125rem; }
p { margin: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--primary); outline-offset: 2px;
}
.ic { width: 24px; height: 24px; fill: currentColor; flex: none; display: block; }
.mono { font-family: var(--font-body); font-variant-numeric: tabular-nums; color: var(--on-variant); font-size: .875rem; }
.caption { font-size: .75rem; color: var(--on-variant); }
.body-text { color: var(--on-variant); }

/* ---------- Shell ---------- */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.pages { flex: 1; min-height: 0; position: relative; }
.page { position: absolute; inset: 0; display: none; flex-direction: column; min-height: 0; }
.page.active { display: flex; animation: page-in .28s var(--ease-out); }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
html.no-motion .page.active, html.no-motion .panel, html.no-motion * { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .page.active, .panel { animation: none; } }

.page-scroll { flex: 1; overflow-y: auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }

/* ---------- Navigation ---------- */
.navbar {
  flex: none; display: flex; justify-content: space-around; align-items: center;
  height: calc(80px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface-1); border-top: 1px solid var(--outline-v);
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; padding: 0; cursor: pointer; color: var(--on-variant); font-size: .8125rem; }
.nav-pill { width: 64px; height: 32px; border-radius: var(--r-full); display: grid; place-items: center; transition: background .3s var(--ease); }
.nav-item.active { color: var(--on-surface); }
.nav-item.active .nav-pill { background: var(--primary-container); }
.nav-item.active .nav-label { font-weight: 600; }

body[data-page="editor"] .navbar,
body[data-page="new"] .navbar,
body[data-page="join"] .navbar { display: none; }

/* ---------- Top bars ---------- */
.topbar { flex: none; display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 8px 12px 8px 16px; }
.topbar.large { justify-content: space-between; align-items: flex-end; min-height: 0; padding: calc(24px + env(safe-area-inset-top)) 16px 12px 20px; }
.topbar.large h1 { font-size: 2.25rem; }
.topbar .page-title { flex: 1; min-width: 0; padding-left: 4px; }
.page-title { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.5rem; line-height: 1.2; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-full); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: .9375rem; white-space: nowrap; transition: background .2s var(--ease), transform .15s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn .ic { width: 20px; height: 20px; }
.btn-filled { background: var(--primary); color: var(--on-primary); }
.btn-tonal { background: var(--primary-container); color: var(--on-surface); }
.btn-outlined { background: transparent; color: var(--on-surface); box-shadow: inset 0 0 0 1px var(--outline); }
.btn-text { background: transparent; color: var(--primary); padding: 0 12px; }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger-outline { color: var(--danger); box-shadow: inset 0 0 0 1px var(--outline); }
.btn.wide, .button-row .btn { flex: 1; }
.button-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn.cta { width: 100%; height: 56px; margin-top: 20px; font-size: 1rem; }

.icon-btn {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: var(--r-full); background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--on-variant); transition: background .2s var(--ease);
}
.icon-btn:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.icon-btn:disabled { opacity: .38; cursor: default; background: transparent; }
.icon-btn.filled { background: var(--primary); color: var(--on-primary); }
.icon-btn.filled:hover { background: color-mix(in srgb, var(--primary) 88%, var(--on-primary)); }

/* ---------- Home ---------- */
.hero {
  width: 100%; display: flex; align-items: center; gap: 16px; text-align: left; cursor: pointer;
  padding: 20px; min-height: 120px; border: 0; border-radius: var(--r-xl);
  background: var(--primary-container); color: var(--on-surface); margin: 4px 0 24px;
  transition: transform .2s var(--ease);
}
.hero:active { transform: scale(.985); }
.hero-text { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hero-text strong { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.375rem; }
.hero-text > span { color: var(--on-variant); font-size: .9375rem; }
.hero-plus { width: 56px; height: 56px; flex: none; border-radius: var(--r-l); background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }

.mosaic { flex: none; width: 72px; height: 72px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; border-radius: 22px; background: var(--surface-1); }
.mosaic i { border-radius: 5px; background: var(--c); }
.mosaic i.off { background: var(--surface-3); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 12px; }

/* ---------- Project grid ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pcard {
  position: relative; display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
  background: var(--surface-2); border-radius: var(--r-l); transition: transform .2s var(--ease);
}
.pcard:active { transform: scale(.98); }
.pthumb {
  aspect-ratio: 1; display: grid; place-items: center; padding: 14px;
  background-color: var(--surface-4);
  background-image: conic-gradient(var(--checker) 25%, transparent 0 50%, var(--checker) 0 75%, transparent 0);
  background-size: 16px 16px;
}
.pthumb img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.pmeta { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pmeta strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmeta span { font-size: .75rem; color: var(--on-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbadge {
  position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-full); font-size: .6875rem; font-weight: 600;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent); color: var(--on-surface);
}
.pdel { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; background: color-mix(in srgb, var(--surface-2) 85%, transparent); }
.pdel .ic { width: 20px; height: 20px; }
.empty { grid-column: 1 / -1; text-align: center; padding: 48px 16px; color: var(--on-variant); }
.empty strong { display: block; color: var(--on-surface); font-size: 1.0625rem; margin-bottom: 4px; }

/* ---------- Settings ---------- */
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-full); margin: 4px 0 8px; }
.segmented button {
  flex: 1; height: 40px; border: 0; border-radius: var(--r-full); background: transparent; cursor: pointer;
  color: var(--on-variant); font-weight: 600; font-size: .875rem; padding: 0 8px; transition: background .2s var(--ease);
}
.segmented button.active, .segmented button[aria-selected="true"] { background: var(--primary-container); color: var(--on-surface); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.group-title { margin: 24px 4px 10px; font-size: .875rem; color: var(--on-variant); font-weight: 600; }

.group { background: var(--surface-2); border-radius: var(--r-l); overflow: hidden; margin-bottom: 12px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px; padding: 14px 18px; width: 100%; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; text-decoration: none;
}
.row + .row { border-top: 1px solid var(--outline-v); }
.row.row-block { flex-direction: column; align-items: flex-start; gap: 4px; }
.row.inline { padding: 12px 0; margin-top: 8px; min-height: 0; border: 0; }
.row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-text strong { font-weight: 600; }
.row-text small, .row small { color: var(--on-variant); font-size: .8125rem; overflow-wrap: anywhere; }
.row-button .ic { fill: var(--primary); }
.row input[type="radio"] { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; }

input.switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 0;
  width: 52px; height: 32px; border-radius: var(--r-full); cursor: pointer;
  background: var(--surface-4); box-shadow: inset 0 0 0 2px var(--outline); transition: background .2s var(--ease);
}
input.switch::after {
  content: ""; position: absolute; top: 50%; left: 8px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--outline); transform: translateY(-50%); transition: all .2s var(--ease);
}
input.switch:checked { background: var(--primary); box-shadow: none; }
input.switch:checked::after { left: 26px; width: 24px; height: 24px; background: var(--on-primary); }

.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; text-align: left; cursor: pointer;
  background: var(--surface-2); border: 0; border-radius: var(--r-l); box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .2s var(--ease);
}
.theme-card[aria-checked="true"] { box-shadow: inset 0 0 0 3px var(--primary); }
.theme-card strong { font-weight: 600; margin-top: 8px; }
.theme-card small { color: var(--on-variant); font-size: .75rem; }
.theme-preview {
  width: 100%; height: 56px; border-radius: 16px; display: block; overflow: hidden;
  background: linear-gradient(90deg, var(--s1) 0 55%, var(--s2) 55% 80%, var(--s3) 80% 100%);
}


.about-card { display: flex; gap: 16px; align-items: center; padding: 20px; margin: 8px 0 12px; background: var(--surface-2); border-radius: var(--r-xl); }
.about-card h2 { font-size: 1.375rem; margin-bottom: 2px; }
.about-card p { color: var(--on-variant); font-size: .875rem; }
.logo { width: 64px; height: 64px; flex: none; border-radius: 20px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-family: var(--font-head); font-size: 2rem; font-weight: var(--head-weight); }
.logo .ic { width: 28px; height: 28px; }

/* ---------- New project / join ---------- */
#page-new .page-scroll, #page-join .page-scroll { padding-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: .875rem; color: var(--on-variant); border: 0; padding: 0; min-width: 0; }
.field > span { display: flex; justify-content: space-between; align-items: center; }
.field legend { font-size: .875rem; color: var(--on-variant); margin-bottom: 8px; padding: 0; }
.field output { font-variant-numeric: tabular-nums; }
.hint { margin: 8px 4px 0; color: var(--on-variant); font-size: .875rem; }
.hint.error { color: var(--danger); }

.seg-two { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-full); }
.seg-opt { position: relative; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt span {
  display: flex; align-items: center; justify-content: center; height: 44px; border-radius: var(--r-full);
  font-weight: 600; font-size: .9375rem; color: var(--on-variant); transition: background .2s var(--ease);
}
.seg-opt input:checked + span { background: var(--primary-container); color: var(--on-surface); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

.custom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.custom-row .select, .custom-row .text-input { height: 52px; }

.text-input, .select {
  appearance: auto; width: 100%; height: 48px; padding: 0 14px; border: 0; border-radius: var(--r-m);
  background: var(--surface-3); color: var(--on-surface); font: inherit; font-size: 1rem;
}
.text-input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-grid; place-items: center; min-width: 52px; height: 40px; padding: 0 14px; border-radius: var(--r-m);
  background: var(--surface-4); color: var(--on-surface); font-weight: 600; font-size: .9375rem;
}
.chip input:checked + span { background: var(--primary); color: var(--on-primary); }
.chip input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Editor ---------- */
.page-editor { display: none; }
.page-editor.active { display: grid; grid-template-rows: auto minmax(0, 1fr); animation: page-in .28s var(--ease-out); }
.editor-top { background: var(--surface); }
.title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 4px; }
.title-input {
  width: 100%; min-width: 0; border: 0; background: transparent; color: var(--on-surface);
  font: inherit; font-weight: 600; font-size: 1.0625rem; padding: 2px 0; outline: none; text-overflow: ellipsis;
}
.title-input:focus-visible { outline: none; box-shadow: 0 2px 0 var(--primary); }

.editor-body {
  min-height: 0; display: grid;
  grid-template-areas: "stage" "dock";
  grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto;
}

.tool-dock {
  grid-area: dock; display: flex; justify-content: space-between; align-items: center; gap: 4px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface-1); border-top: 1px solid var(--outline-v);
}
.tool-dock .tool { flex: 1 1 0; min-width: 0; max-width: 48px; }
.tool {
  position: relative; width: 48px; height: 48px; border: 0; border-radius: var(--r-l); background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--on-variant); transition: background .2s var(--ease), color .2s var(--ease);
}
.tool.active { background: var(--primary-container); color: var(--on-surface); }
.tool:not(.active):hover { background: color-mix(in srgb, var(--on-surface) 7%, transparent); }
.tool-dot { position: absolute; right: 9px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--cur, #805638); box-shadow: 0 0 0 2px var(--surface-1); }

.stage {
  grid-area: stage; min-width: 0; min-height: 0; overflow: auto; position: relative;
  display: grid; padding: 56px 16px 40px;
}
.frame {
  margin: auto; position: relative; flex: none; border-radius: 10px; overflow: hidden;
  background-color: var(--surface-4);
  background-image: conic-gradient(var(--checker) 25%, transparent 0 50%, var(--checker) 0 75%, transparent 0);
  background-size: 16px 16px;
  box-shadow: 0 1px 0 var(--outline-v), 0 12px 32px -12px color-mix(in srgb, #000 45%, transparent);
}
.frame.no-checker { background-image: none; background-color: transparent; }
#artboard {
  display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges;
  touch-action: none; cursor: crosshair; -webkit-user-drag: none;
}
.stage-meta {
  position: absolute; left: 0; right: 0; bottom: 8px; display: flex; justify-content: center; gap: 16px;
  font-size: .75rem; color: var(--on-variant); font-variant-numeric: tabular-nums; pointer-events: none;
}

/* Room status chip: sits in the empty space above the canvas */
.room-chip {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 6px 14px; border-radius: var(--r-full); font-size: .8125rem; font-weight: 600;
  background: var(--surface-2); color: var(--on-surface); box-shadow: 0 0 0 1px var(--outline-v);
  font-variant-numeric: tabular-nums; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
.room-chip-sep { color: var(--on-variant); }
.room-chip #roomTimer { color: var(--on-variant); font-weight: 500; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--outline); flex: none; }
.room-chip.live .live-dot { background: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 25%, transparent); }
.room-chip.warn #roomTimer { color: var(--danger); }

/* Options: full-screen page on phones, opened from the editor, Back returns */
.panel { display: none; position: fixed; inset: 0; z-index: 50; background: var(--surface); flex-direction: column; overflow: hidden; }
.panel.open { display: flex; animation: page-in .28s var(--ease-out); }
.panel-top {
  flex: none; display: flex; align-items: center; gap: 8px; min-height: 64px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 8px; border-bottom: 1px solid var(--outline-v);
}
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 20px calc(32px + env(safe-area-inset-bottom)); }

.panel-section { padding: 16px 0; border-top: 1px solid var(--outline-v); }
.panel-section:first-of-type { border-top: 0; padding-top: 4px; }
.panel-section > h2 { font-size: .875rem; color: var(--on-variant); font-weight: 600; margin-bottom: 12px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { font-size: .875rem; color: var(--on-variant); font-weight: 600; }
.panel-section .group { margin-bottom: 0; }
.panel-section #roomNote { margin-top: 10px; }

.current-color { margin-bottom: 8px; }
.colour-input { display: inline-flex; align-items: center; gap: 10px; position: relative; cursor: pointer; font-size: .875rem; color: var(--on-variant); }
.colour-input input[type="color"] {
  appearance: none; -webkit-appearance: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; background: none;
}
.colour-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.colour-input input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--outline); }
.colour-input input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }

.palette-group + .palette-group { margin-top: 10px; }
.palette-title { font-size: .75rem; font-weight: 600; color: var(--on-variant); margin: 10px 0 6px; font-family: var(--font-body); }
.palette-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.swatch {
  aspect-ratio: 1; border: 0; border-radius: 10px; cursor: pointer; background: var(--c);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 18%, transparent);
  transition: transform .15s var(--ease);
}
.swatch:hover { transform: scale(1.06); }
.swatch.selected { box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--on-surface); }

input[type="range"] { width: 100%; accent-color: var(--primary); margin: 6px 0; }
.select { height: 48px; }
.panel .row.inline { border: 0; background: none; }

/* ---------- Dialogs & snackbar ---------- */
.dialog {
  width: min(92vw, 400px); max-width: 400px; padding: 0; border: 0; border-radius: var(--r-xl);
  background: var(--surface-3); color: var(--on-surface); box-shadow: 0 24px 60px -20px color-mix(in srgb, #000 60%, transparent);
}
.dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog[open] { animation: dialog-in .25s var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 24px; margin: 0; }
.dialog-form h2 { font-size: 1.5rem; }
.dialog-actions { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 8px; margin-top: 8px; }

.snackbar {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60;
  margin: 0 auto; max-width: 420px; padding: 14px 18px; border-radius: 16px;
  background: var(--inverse); color: var(--on-inverse); font-size: .9375rem; box-shadow: 0 8px 24px -8px color-mix(in srgb, #000 50%, transparent);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.snackbar.show { opacity: 1; transform: none; }


/* ---------- Tablet / desktop ---------- */
@media (min-width: 840px) {
  .only-mobile { display: none !important; }
  .app { flex-direction: row; }
  .navbar {
    flex-direction: column; justify-content: flex-start; gap: 8px; width: 96px; height: auto;
    padding: 20px 0 calc(20px + env(safe-area-inset-bottom)); border-top: 0; border-right: 1px solid var(--outline-v);
  }
  .nav-item { flex: none; }
  .page-scroll { padding: 0 32px 40px; }
  .page-scroll > * { max-width: 960px; }
  #page-new .page-scroll > *, #page-join .page-scroll > * { max-width: 560px; }
  .topbar.large { padding: 32px 40px 16px; }
  .topbar.large h1 { font-size: 2.5rem; }
  .hero { max-width: 960px; }
  .project-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
  .segmented { max-width: 640px; }
  .tab-panel { max-width: 640px; }
  .theme-grid { grid-template-columns: repeat(4, 1fr); }
  .theme-card { padding: 10px; }

  .editor-top { padding: 8px 16px 8px 12px; }
  .editor-body {
    grid-template-areas: "dock stage panel";
    grid-template-columns: 88px minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr);
  }
  .tool-dock {
    flex-direction: column; justify-content: flex-start; gap: 8px; padding: 16px 0;
    background: var(--surface-1); border-top: 0; border-right: 1px solid var(--outline-v);
  }
  .tool { width: 56px; height: 56px; }
  .tool-dock .tool { flex: none; max-width: none; }
  .stage { padding: 56px 24px 48px; }

  /* Desktop: options are a permanent right column */
  .panel {
    display: flex !important; position: static; inset: auto; z-index: auto;
    background: var(--surface-1); border-left: 1px solid var(--outline-v);
  }
  .panel.open { animation: none; }
  .panel-top { display: none; }
  .panel-body { padding: 8px 20px 24px; }
  .snackbar { bottom: 24px; left: auto; right: 24px; margin: 0; }
}

/* v7: keep the room status chip inside small screens */
.room-chip { max-width: calc(100% - 32px); }
.room-chip #roomChipText, .room-chip #roomTimer { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* v8.2.0 */
canvas { touch-action: none; }
.btn, .icon-btn, .tool, .chip, .theme-card, .swatch, .nav-item, .pcard, .segmented button, .seg-opt span {
  transition: transform .18s var(--ease-out), background-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease), opacity .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active, .icon-btn:active, .tool:active, .chip:active span, .theme-card:active, .swatch:active, .segmented button:active, .pcard:active {
  transform: scale(.96);
}
.snackbar { transition: transform .35s var(--ease-out), opacity .25s var(--ease); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
