:root {
  --bg: #f1efff;
  --bg-2: #e4e0ff;
  --paper: #fffefb;
  --ink: #1e1b4b;
  --outline: #1e1b4b;
  --muted: #6c689a;
  --accent: #4a3aff;
  --accent-ink: #ffffff;
  --pink: #ff8fc0;
  --btn: #ffffff;
  --pop: 3px 3px 0 var(--outline);
  --pop-lg: 5px 5px 0 var(--outline);
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --current: #1e1b4b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15132e;
    --bg-2: #221f45;
    --ink: #eeebff;
    --outline: #07061a;
    --muted: #a19dcc;
    --accent: #6f62ff;
    --btn: #2a2752;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { height: 100%; }
body {
  background-color: var(--bg);
  /* a few soft ink splotches in the background */
  background-image:
    radial-gradient(circle at 8% 14%, color-mix(in srgb, var(--accent) 10%, transparent) 0 70px, transparent 71px),
    radial-gradient(circle at 94% 8%, color-mix(in srgb, var(--pink) 16%, transparent) 0 46px, transparent 47px),
    radial-gradient(circle at 90% 88%, color-mix(in srgb, var(--accent) 8%, transparent) 0 90px, transparent 91px),
    radial-gradient(circle at 4% 92%, color-mix(in srgb, var(--pink) 12%, transparent) 0 36px, transparent 37px);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
img { display: block; }

/* ---------- mascot ---------- */
@keyframes squish {
  0%, 82%, 100% { transform: scale(1, 1); }
  88% { transform: scale(1.08, .9); }
  94% { transform: scale(.95, 1.06); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}
.mascot { transform-origin: 50% 90%; animation: squish 4.5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .mascot, .hint img, .lost-mascot { animation: none !important; }
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  padding: 10px 16px 2px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -.5px;
  line-height: 1;
}

/* ---------- draw page ---------- */
.draw-page {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px 18px 12px 16px;
}
.paper {
  position: relative;
  border-radius: 20px;
  border: 2.5px solid var(--outline);
  box-shadow: var(--pop-lg);
  background: var(--paper);
  overflow: hidden;
}
.paper canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#ink { touch-action: none; cursor: crosshair; }
.hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #8f8ac0;
  font-size: clamp(20px, 4.5vw, 28px);
  font-weight: 500;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.hint img { opacity: .9; animation: bob 3s ease-in-out infinite; }
.hint.gone { opacity: 0; transform: scale(.9); }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 14px;
  padding: 6px 12px calc(12px + env(safe-area-inset-bottom));
}
.group { display: flex; align-items: center; gap: 4px; }
.group.dim { opacity: .4; }

.swatch, .size, .tool {
  width: 44px; height: 44px;
  border-radius: 14px;
  border: 0;
  display: grid; place-items: center;
  background: transparent;
  padding: 0;
  transition: transform .12s, background .12s;
}
/* colour swatches are little ink drops */
.swatch::after {
  content: '';
  width: 22px; height: 22px;
  background: var(--c);
  border-radius: 0 50% 50% 50%;
  transform: rotate(45deg) translate(2px, 2px);
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.14), inset 2px 2px 0 rgba(255,255,255,.3);
  transition: transform .15s;
}
.swatch.active { background: var(--btn); box-shadow: 0 0 0 2.5px var(--outline), var(--pop); }
.swatch.active::after { transform: rotate(45deg) translate(2px, 2px) scale(1.18); }

.size i {
  display: block;
  width: var(--d); height: var(--d);
  border-radius: 50%;
  background: var(--current);
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ink) 25%, transparent);
}
@media (prefers-color-scheme: dark) {
  /* keep the dark "ink" colour visible on a dark background */
  .size i { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ink) 55%, transparent); }
  .swatch::after { filter: drop-shadow(0 0 1.5px rgba(238,235,255,.7)); }
}
.size.active, .tool.active { background: var(--btn); box-shadow: 0 0 0 2.5px var(--outline), var(--pop); }
.tool svg { width: 22px; height: 22px; fill: currentColor; }
.tool:disabled { opacity: .3; }
.tool.active { color: var(--accent); }
/* smoothing level shown as one or two little dots under the icon */
.smooth { position: relative; }
.smooth::after { content: ''; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); height: 4px; border-radius: 2px; background: currentColor; }
.smooth[data-level="1"]::after { width: 4px; }
.smooth[data-level="2"]::after { width: 4px; transform: translateX(calc(-50% - 3.5px)); box-shadow: 7px 0 0 currentColor; }
.smooth[data-level="3"]::after { width: 4px; box-shadow: -6px 0 0 currentColor, 6px 0 0 currentColor; }

.swatch:active, .size:active, .tool:not(:disabled):active { transform: scale(.9); }

.save {
  height: 48px;
  padding: 0 26px;
  margin-left: 4px;
  border: 2.5px solid var(--outline);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 18px;
  box-shadow: var(--pop);
  transition: transform .1s, box-shadow .1s, opacity .2s;
}
.save:not(:disabled):active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--outline); }
.save:disabled { opacity: .4; }
.save.busy { opacity: .75; }

@media (max-width: 560px) {
  .toolbar { gap: 6px 2px; }
  .colors, .sizes { gap: 0; }
  .swatch, .size, .tool { width: 40px; height: 40px; border-radius: 12px; }
  .actions { width: 100%; justify-content: space-between; padding: 0 4px; }
  .save { flex: 1; margin-left: 10px; }
}

@media (hover: hover) {
  .tool:not(:disabled):hover, .size:hover, .swatch:hover { background: var(--bg-2); }
  .size.active:hover, .swatch.active:hover, .tool.active:hover { background: var(--btn); }
  .save:not(:disabled):hover, .big:hover { filter: brightness(1.06); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(124px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- share page ---------- */
.view-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}
.view-page .topbar { width: 100%; max-width: 760px; padding-left: 0; padding-right: 0; }
.view {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
}
.framed {
  max-width: calc(100% - 5px);
  max-height: 66dvh;
  width: auto;
  height: auto;
  border-radius: 20px;
  border: 2.5px solid var(--outline);
  box-shadow: var(--pop-lg);
  background: var(--paper);
}
.share-actions {
  width: 100%;
  max-width: 520px;
  display: flex;
  gap: 12px;
  padding-right: 3px;
}
.big {
  flex: 1;
  height: 56px;
  padding: 0 24px;
  border-radius: 999px;
  border: 2.5px solid var(--outline);
  font-size: 18px;
  font-weight: 600;
  box-shadow: var(--pop);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform .1s, box-shadow .1s;
}
.big:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--outline); }
.big.primary { background: var(--accent); color: var(--accent-ink); }
.big.secondary { background: var(--btn); color: var(--ink); }
.big[hidden] { display: none; }

.link-text {
  width: 100%;
  max-width: 520px;
  margin-top: -4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 14px var(--font);
  text-align: center;
  text-overflow: ellipsis;
  outline: none;
}

.quiet-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 16px; font-weight: 500; }
.quiet-row a { color: var(--muted); text-decoration: none; padding: 8px 4px; }
.quiet-row a:hover { color: var(--ink); }

/* ---------- paper picker ---------- */
.paper-tray {
  position: fixed;
  left: 50%;
  bottom: calc(118px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--btn);
  border: 2.5px solid var(--outline);
  border-radius: 20px;
  box-shadow: var(--pop-lg);
}
.paper-tray[hidden] { display: none; }
.tray-row { display: flex; gap: 8px; justify-content: center; }
.pattern-opt, .paper-opt {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 2px solid color-mix(in srgb, var(--ink) 20%, transparent);
  padding: 0;
  display: grid; place-items: center;
  transition: transform .12s;
}
.pattern-opt { background: #fffefb; }
.tool-opt { width: 52px; height: 52px; border-radius: 14px; border: 2px solid color-mix(in srgb, var(--ink) 20%, transparent); background: var(--bg); color: var(--ink); display: grid; place-items: center; padding: 0; transition: transform .12s; }
.tool-opt svg { width: 24px; height: 24px; fill: currentColor; }
.tool-opt[aria-pressed="true"] { border-color: var(--outline); box-shadow: 0 0 0 2px var(--accent); color: var(--accent); background: var(--btn); }
.tool-opt:active { transform: scale(.92); }
.group.dim-sizes .sizes, .sizes.dim { opacity: .4; }
.paper-opt { background: var(--pc); border-radius: 50%; }
.pattern-opt[aria-pressed="true"], .paper-opt[aria-pressed="true"] { border-color: var(--outline); box-shadow: 0 0 0 2px var(--accent); }
.pattern-opt:active, .paper-opt:active { transform: scale(.92); }
.pattern-opt i { width: 26px; height: 26px; border-radius: 4px; }
.pat-dots { background: radial-gradient(circle, rgba(79,70,229,.55) 1.4px, transparent 1.6px) 0 0 / 8.66px 8.66px; }
.pat-lines { background: repeating-linear-gradient(to bottom, transparent 0 6px, rgba(79,70,229,.45) 6px 7.5px); }
@media (max-width: 560px) {
  .paper-tray { bottom: calc(104px + env(safe-area-inset-bottom)); }
}

/* ---------- small links ---------- */
.header-link { margin-left: auto; color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; padding: 8px 2px; }
.header-link:hover { color: var(--ink); }
.linklike { background: none; border: 0; padding: 8px 4px; color: var(--muted); font: inherit; }
.linklike:hover:not(:disabled) { color: var(--ink); }
.linklike:disabled { cursor: default; }
.expires { margin: -14px 0 0; color: var(--muted); font-size: 13px; }
.legal { margin-top: auto; padding-top: 20px; display: flex; gap: 8px; color: var(--muted); font-size: 13px; }
.legal a { color: var(--muted); text-decoration: none; }
.legal a:hover { color: var(--ink); }

/* ---------- text pages (terms, privacy) ---------- */
.doc { width: 100%; max-width: 640px; margin: 12px 0 32px; background: var(--paper); color: #1e1b4b; border: 2.5px solid var(--outline); border-radius: 20px; box-shadow: var(--pop-lg); padding: 24px 22px; line-height: 1.55; font-size: 16px; }
.doc h1 { font-size: 28px; margin: 0 0 4px; }
.doc h1.section { margin-top: 36px; padding-top: 28px; border-top: 2px dashed #d9d5f5; scroll-margin-top: 16px; }
.doc h2 { font-size: 18px; margin: 22px 0 4px; }
.doc p, .doc ul { margin: 0 0 10px; }
.doc .updated { color: #6c689a; font-size: 14px; margin-bottom: 16px; }
.doc a { color: #4a3aff; }

/* ---------- admin login ---------- */
.login { margin-top: 22vh; width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.login input {
  width: 100%;
  height: 52px;
  padding: 0 20px;
  border: 2.5px solid var(--outline);
  border-radius: 999px;
  background: var(--btn);
  color: var(--ink);
  font: 500 17px var(--font);
  box-shadow: var(--pop);
  outline: none;
}
.login input:focus { box-shadow: var(--pop), 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
.login-error { margin: 0; color: #e0306e; font-weight: 500; }
form.header-link { padding: 0; }

/* ---------- 404 ---------- */
.lost {
  text-align: center;
  margin-top: 16vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lost-mascot { animation: bob 3.5s ease-in-out infinite; margin-bottom: 12px; }
.lost h1 { font-weight: 700; font-size: 32px; margin: 0 0 6px; }
.lost p { color: var(--muted); margin: 0 0 26px; font-size: 17px; }
.lost .big { flex: none; }

/* ---------- Inky Space ---------- */
.space-page {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
.join {
  height: 100dvh;
  overflow-y: auto;
  max-width: 380px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.join[hidden], .room[hidden] { display: none; }
.join .logo { align-self: center; margin-top: 6vh; }
.join-sub { text-align: center; color: var(--muted); margin: 0 0 10px; font-size: 16px; }
.join-label { font-weight: 600; font-size: 15px; margin-top: 6px; }
.join-name {
  height: 52px;
  padding: 0 20px;
  border: 2.5px solid var(--outline);
  border-radius: 999px;
  background: var(--btn);
  color: var(--ink);
  font: 500 17px var(--font);
  box-shadow: var(--pop);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.join-name:focus { box-shadow: var(--pop), 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
.avatar-pad {
  align-self: center;
  width: 180px; height: 180px;
  border: 2.5px solid var(--outline);
  border-radius: 24px;
  box-shadow: var(--pop-lg);
  background: #fffefb;
  overflow: hidden;
}
.avatar-pad canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.avatar-tools { display: flex; justify-content: center; gap: 2px; margin-top: 4px; }
.join-warn {
  margin: 14px 0 0;
  padding: 12px 14px 12px 32px;
  background: color-mix(in srgb, var(--accent) 8%, var(--btn));
  border: 2px solid color-mix(in srgb, var(--outline) 30%, transparent);
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}
.join-warn li + li { margin-top: 4px; }
.join-terms { align-self: center; color: var(--muted); font-size: 13px; }
.join-go { flex: none; margin-top: 8px; }
.join-note { text-align: center; color: #e0306e; margin: 0; min-height: 20px; font-weight: 500; }

.room { position: fixed; inset: 0; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.room-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
.room-bar .logo { font-size: 26px; }
.room-bar .account-chip { margin-left: auto; }
/* who's here and when it resets: a small card in the bottom left, opposite the zoom buttons */
.room-meta {
  position: absolute;
  left: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 6px 12px 6px 8px;
  background: var(--btn);
  border-radius: 16px;
  box-shadow: 0 0 0 2px var(--outline), var(--pop);
  pointer-events: none;
}
.room-meta:empty { display: none; }
.who { display: flex; align-items: center; }
.who .avatar { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--outline); margin-left: -6px; background: #fffefb; }
.who .avatar:first-child { margin-left: 0; }
.who span { margin-left: 8px; font-weight: 600; font-size: 14px; }
.wipe { color: var(--muted); font-size: 12px; }

.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
  background: var(--bg-2);
  border-top: 2px solid color-mix(in srgb, var(--outline) 25%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--outline) 25%, transparent);
}
.world {
  position: absolute;
  left: 0; top: 0;
  transform-origin: 0 0;
  background-color: #fffefb;
  background-image: radial-gradient(circle, rgba(79, 70, 229, .22) 2.2px, transparent 2.7px);
  background-size: 40px 40px;
  background-position: -20px -20px;
  box-shadow: 0 0 0 3px var(--outline), 10px 10px 0 var(--outline);
}
.world canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cursor {
  position: absolute;
  left: 0; top: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: transform 80ms linear;
  will-change: transform;
}
.cursor::before {
  content: '';
  position: absolute;
  left: -5px; top: -5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px #fff;
}
.cursors.moving .cursor { transition: none; }
.cursor .avatar { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--outline); margin: 12px 0 0 10px; background: #fffefb; }
.cursor span {
  margin-top: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.zoom { position: absolute; right: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.zoom .tool { background: var(--btn); box-shadow: 0 0 0 2px var(--outline), var(--pop); font-size: 22px; font-weight: 600; line-height: 1; }
.space-page .toolbar { padding-top: 8px; }
.room-btn { position: relative; }
.room-btn b { position: absolute; right: 3px; bottom: 2px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 11px; line-height: 16px; text-align: center; padding: 0 3px; }
.room-btn b:empty { display: none; }
.room-list { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.room-opt { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 10px 14px; border-radius: 12px; border: 2px solid color-mix(in srgb, var(--ink) 15%, transparent); background: var(--bg); color: var(--ink); font-weight: 600; font-size: 15px; }
.room-opt small { color: var(--muted); font-weight: 500; font-size: 13px; }
.room-opt[aria-pressed="true"] { border-color: var(--outline); box-shadow: 0 0 0 2px var(--accent); background: var(--btn); }
@media (max-width: 560px) {
  /* phones: colours and sizes on top, then the space switcher and tools */
  .space-page .toolbar .colors { order: 1; }
  .space-page .toolbar .sizes { order: 2; }
  .space-page .toolbar .rooms-group { order: 3; }
  .space-page .toolbar .actions { order: 4; width: auto; }
}

/* ---------- account page ---------- */
.acct { width: 100%; max-width: 420px; margin-top: 12px; }
.acct-loading { color: var(--muted); text-align: center; margin-top: 20vh; }
.acct-card {
  background: var(--btn);
  border: 2.5px solid var(--outline);
  border-radius: 22px;
  box-shadow: var(--pop-lg);
  padding: 20px 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.acct-card[hidden], .acct-form[hidden] { display: none; }
.acct-card h1 { margin: 0; font-size: 26px; }
.acct-card p { margin: 0; }
.acct-tabs { display: flex; gap: 6px; background: var(--bg); border-radius: 999px; padding: 4px; }
.acct-tab { flex: 1; border: 0; border-radius: 999px; padding: 9px 0; background: transparent; font-weight: 600; color: var(--muted); }
.acct-tab.on { background: var(--btn); color: var(--ink); box-shadow: 0 0 0 2px var(--outline); }
.acct-form { display: flex; flex-direction: column; gap: 12px; }
.acct-form label, .acct-label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
.acct-form input {
  height: 48px;
  padding: 0 16px;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  font: 500 16px var(--font);
  outline: none;
}
.acct-form input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
.acct-form small { font-weight: 500; color: var(--muted); font-size: 13px; }
.acct-form .avatar-pad { align-self: center; }
.acct-form .big, .acct-card > .big { flex: none; }
.acct-note, .acct-muted { color: var(--muted); font-size: 14px; }
.acct-small { align-self: center; font-size: 14px; }
.acct-error { color: #e0306e; font-weight: 500; min-height: 1.2em; margin: 0; }
.acct-error:empty, .acct-ok:empty { display: none; }
.acct-ok { color: #0e9f5a; font-weight: 500; }
.acct-code {
  font: 600 clamp(16px, 5vw, 22px) ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  letter-spacing: 1px;
  white-space: nowrap;
  text-align: center;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg);
  border: 2px dashed var(--outline);
  user-select: all;
  -webkit-user-select: all;
}
.acct-card .row { flex-wrap: nowrap; }
.acct-more { border-top: 2px solid color-mix(in srgb, var(--outline) 15%, transparent); padding-top: 12px; }
.acct-more summary { cursor: pointer; font-weight: 600; margin-bottom: 4px; }
.acct-more[open] summary { margin-bottom: 12px; }
.big.danger { background: #ff4d8d; color: #fff; }

/* account button in the drawing page's header */
.topbar .account-chip, .room-bar .account-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; padding: 6px 2px; }
.topbar .account-chip .avatar, .room-bar .account-chip .avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--outline); }
.topbar .header-link + .account-chip { margin-left: 14px; }

/* ---------- sketch titles, bylines and owner controls ---------- */
.sketch-head { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: -6px; text-align: center; }
.sketch-head:empty { display: none; }
.sketch-title { margin: 0; font-size: clamp(22px, 5vw, 30px); line-height: 1.15; overflow-wrap: anywhere; }
.sketch-title[hidden] { display: none; }
.byline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; text-decoration: none; padding: 2px 4px; }
.byline:hover { color: var(--ink); }
.byline .avatar { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--outline); }

.owner-card {
  width: 100%;
  max-width: 520px;
  background: var(--btn);
  border: 2.5px solid var(--outline);
  border-radius: 22px;
  box-shadow: var(--pop);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.owner-card[hidden] { display: none; }
.owner-title { display: flex; gap: 8px; }
.owner-title input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  font: 500 16px var(--font);
  outline: none;
}
.owner-title input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
.tool-text, .pill {
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 2.5px solid var(--outline);
  background: var(--btn);
  color: var(--ink);
  font: 600 15px var(--font);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
}
.tool-text { background: var(--accent); color: var(--accent-ink); }
.pill { height: 38px; padding: 0 14px; font-size: 14px; border-width: 2px; }
.pill:hover, .tool-text:hover { filter: brightness(1.06); }
.pill.danger { color: #e0306e; border-color: color-mix(in srgb, #e0306e 60%, var(--outline)); }
.pill[hidden] { display: none; }
.owner-toggle { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; cursor: pointer; }
.owner-toggle input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.owner-toggle span { display: flex; flex-direction: column; gap: 2px; }
.owner-toggle small { color: var(--muted); font-weight: 500; font-size: 13px; }
.owner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.owner-msg { margin: -4px 0 0; color: var(--muted); font-size: 14px; font-weight: 500; }
.owner-msg:empty { display: none; }

/* ---------- galleries (profile and your sketches) ---------- */
.profile { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 20px; margin-top: 10px; }
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head .avatar { width: 72px; height: 72px; border-radius: 50%; border: 2.5px solid var(--outline); box-shadow: var(--pop); flex: none; }
.profile-head h1 { margin: 0; font-size: 28px; overflow-wrap: anywhere; }
.profile-head p { margin: 2px 0 0; }
.profile-draw { flex: none; align-self: center; margin-top: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.profile .gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.gallery-card { display: flex; flex-direction: column; gap: 6px; color: var(--ink); text-decoration: none; min-width: 0; }
.gallery-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid var(--outline);
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--outline);
  transition: transform .12s;
}
.gallery-card[href]:hover img { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--outline); }
.gallery-card span { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-card .untitled { color: var(--muted); font-weight: 500; }
.gallery-card small { color: var(--muted); font-size: 12px; margin-top: -4px; }
.gallery-hidden { opacity: .35; }
.gallery-empty { color: var(--muted); text-align: center; margin: 10px 0; }
.gallery-empty a { color: var(--accent); }
.acct-sketches { margin-top: 18px; }
.acct-sketches h2 { margin: 0; font-size: 22px; }
.profile-link { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 14px; padding: 6px 6px 6px 14px; }
.profile-link a { flex: 1; min-width: 0; color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }

/* premium bits on the account page */
.acct-premium { background: color-mix(in srgb, var(--accent) 12%, transparent); border: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.acct-premium b { color: var(--accent); font-size: 16px; }
.acct-premium ul { margin: 0; padding-left: 20px; font-size: 14px; font-weight: 500; display: flex; flex-direction: column; gap: 2px; }
.acct-premium small { color: var(--muted); font-size: 13px; }
.acct-premium small[hidden] { display: none; }
.acct-premium[hidden], .acct-more[hidden] { display: none; }
.handle-field { display: flex; align-items: center; border: 2.5px solid var(--outline); border-radius: 14px; background: var(--bg); padding-left: 14px; overflow: hidden; }
.handle-field span { color: var(--muted); font-weight: 500; white-space: nowrap; }
.acct-form .handle-field input { border: 0; border-radius: 0; padding-left: 2px; flex: 1; min-width: 0; height: 43px; }
.handle-field:focus-within { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
.acct-form .handle-field input:focus { box-shadow: none; }

/* Space join: signed in, joining as your account */
.join-custom { display: contents; }
.join-custom[hidden], .join-as[hidden] { display: none; }
.join-as { display: flex; align-items: center; gap: 14px; padding: 14px; margin-top: 6px; border: 2.5px solid var(--outline); border-radius: 18px; background: var(--btn); box-shadow: var(--pop); }
.join-as canvas { width: 64px; height: 64px; border-radius: 50%; border: 2.5px solid var(--outline); background: #fffefb; flex: none; }
.join-as > div { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.join-as .join-label { margin: 0; color: var(--muted); font-size: 13px; }
.join-as b { font-size: 20px; overflow-wrap: anywhere; }
.join-as .join-edit { padding-top: 4px; font-size: 14px; color: var(--accent); text-decoration: none; }
.join-skip { align-self: center; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; }
.join-skip input { width: 18px; height: 18px; accent-color: var(--accent); }
/* skipping the join page: hidden until we know whether we can */
.join.deciding { visibility: hidden; }
/* the join column scrolls instead of squashing its contents */
.join > *, .join-custom > * { flex-shrink: 0; }

/* ---------- premium custom colours ---------- */
.custom-swatch { position: relative; }
/* a little rainbow dot marks the swatch you can change */
.custom-swatch::before {
  content: '';
  position: absolute;
  right: 4px; bottom: 4px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: conic-gradient(#ff4d4d, #ffd23f, #3ddc84, #3dc8ff, #6b5bff, #ff4dd8, #ff4d4d);
  box-shadow: 0 0 0 2px var(--bg);
  z-index: 1;
}
.custom-swatch.active::before { box-shadow: 0 0 0 2px var(--btn); }
@media (max-width: 560px) {
  /* six swatches plus the sizes still fit on one row */
  .colors.has-custom .swatch { width: 36px; }
}
.color-tray { width: 268px; align-items: stretch; }
.color-slot { width: 40px; height: 40px; }
.cp-sv { position: relative; height: 150px; border-radius: 12px; overflow: hidden; border: 2px solid var(--outline); touch-action: none; cursor: crosshair; }
.cp-sv canvas { width: 100%; height: 100%; display: block; }
.cp-hue {
  position: relative;
  height: 24px;
  border-radius: 999px;
  border: 2px solid var(--outline);
  background: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00);
  touch-action: none;
  cursor: pointer;
}
.cp-knob {
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.cp-hue .cp-knob { top: 50%; width: 22px; height: 22px; }
.cp-hex-row { display: flex; justify-content: center; }
.cp-hex {
  width: 110px;
  height: 36px;
  border: 2px solid color-mix(in srgb, var(--ink) 20%, transparent);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: 600 15px ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  text-align: center;
  text-transform: lowercase;
}

/* premium avatar extras: thickness row and a colour tray that opens in place */
.avatar-sizes { display: flex; justify-content: center; gap: 4px; }
.avatar-sizes .size { width: 40px; height: 40px; }
.color-tray.inline { position: static; transform: none; align-self: center; margin: 2px auto 0; box-shadow: var(--pop); }

/* eraser ring: a two-tone outline so it shows on light paper, dark paper and ink */
.brush-ring {
  position: absolute;
  left: 0; top: 0;
  z-index: 3;
  border-radius: 50%;
  border: 1.5px solid rgba(30, 27, 75, .8);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .9), inset 0 0 0 1px rgba(255, 255, 255, .9);
  pointer-events: none;
}
.brush-ring[hidden] { display: none; }
.viewport.erasing { cursor: none; }

/* without premium: the custom swatch is greyed out and opens a short note */
.custom-swatch.locked { --c: #b8b4d6; opacity: .75; }
.custom-swatch.locked:hover { opacity: 1; }
.teaser-tray { width: 260px; text-align: center; gap: 6px; }
.teaser-tray b { font-size: 17px; }
.teaser-tray p { margin: 0; color: var(--muted); font-size: 14px; font-weight: 500; }
.teaser-tray .teaser-offer { color: var(--ink); font-weight: 600; margin-top: 4px; }
.teaser-tray .big { flex: none; height: 46px; font-size: 16px; margin-top: 6px; }
/* signed out while new accounts get a free month: the header link says so */
.topbar .account-chip.offer, .room-bar .account-chip.offer { color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 6px 12px; border: 2px solid var(--outline); }

/* avatar eraser: colours dim while it's on, like the main toolbar */
.avatar-tools.erasing .swatch { opacity: .4; }
.avatar-tools .avatar-eraser.active { background: var(--btn); box-shadow: 0 0 0 2.5px var(--outline), var(--pop); color: var(--accent); }
.avatar-tools { flex-wrap: wrap; }
@media (max-width: 560px) {
  .avatar-tools .swatch, .avatar-tools .tool { width: 36px; }
}

/* ---------- personal spaces in the switcher ---------- */
.room-gap { border: 0; border-top: 2px dashed color-mix(in srgb, var(--ink) 15%, transparent); margin: 4px 2px; }
.room-opt.locked { opacity: .55; }
.room-opt.locked small { color: var(--accent); font-weight: 600; }
.room-tray { max-height: calc(100dvh - 200px); overflow-y: auto; }
.space-members { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 280px; padding-top: 10px; border-top: 2px solid color-mix(in srgb, var(--ink) 12%, transparent); }
.space-members[hidden] { display: none; }
.space-members > b { font-size: 15px; }
.space-members small { color: var(--muted); font-size: 12px; }
.member-list { display: flex; flex-direction: column; gap: 6px; }
.member { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.member .avatar { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--outline); flex: none; }
.member span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-remove { padding: 2px 4px; font-size: 13px; }
.member-empty { margin: 0; color: var(--muted); font-size: 13px; }
.member-empty[hidden] { display: none; }
.invite { display: flex; gap: 6px; }
.invite input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border: 2px solid var(--outline); border-radius: 12px; background: var(--bg); color: var(--ink); font: 500 14px var(--font); user-select: text; -webkit-user-select: text; }
.invite button { height: 38px; padding: 0 14px; border: 2px solid var(--outline); border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: 600 14px var(--font); }
.acct-offer { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.acct-offer[hidden] { display: none; }
.acct-offer .linklike { padding: 0; color: var(--accent); font-weight: 600; }
.avatar-sizes { flex-wrap: wrap; align-items: center; }
.avatar-sizes .tool + .size { margin-left: 12px; }
.avatar-sizes .tool { width: 40px; height: 40px; }

/* eyedropper in the custom colour tray */
.cp-hex-row { gap: 8px; align-items: center; }
.cp-dropper { width: 36px; height: 36px; border-radius: 10px; border: 2px solid color-mix(in srgb, var(--ink) 20%, transparent); background: var(--bg); color: var(--ink); display: grid; place-items: center; padding: 0; }
.cp-dropper svg { width: 20px; height: 20px; fill: currentColor; }
.picking-colour, .picking-colour * { cursor: crosshair !important; }
