/* Draw — clean, Procreate-like dark interface. */
:root {
  --bar: #2a2a2c;
  --bar-2: #1c1c1e;
  --panel: #2a2a2c;
  --panel-2: #353538;
  --panel-3: #3d3d41;
  --panel-4: #48484c;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2f2f7;
  --text-2: rgba(235, 235, 245, 0.62);
  --text-3: rgba(235, 235, 245, 0.38);
  --accent: #2f80ff;
  --accent-2: #5b9bff;
  --danger: #ff453a;
  --ok: #30d158;
  --stage: #18181a;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
  --r: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--stage);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; position: fixed; inset: 0; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { display: block; }
.ico { display: inline-grid; place-items: center; flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------- editor ---------- */
#editor {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#stage { position: absolute; inset: 0; display: block; touch-action: none; }
#cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: calc(48px + var(--safe-t));
  padding: var(--safe-t) calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--bar);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  z-index: 10;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 4px; }
.tb-right { justify-content: flex-end; gap: 2px; }
.tb-mid { display: flex; justify-content: center; align-items: center; gap: 6px; min-width: 0; }
.tb-icon {
  width: 36px; height: 34px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-2);
  flex: none;
}
.tb-icon:active { background: rgba(255, 255, 255, 0.14); }
.tb-icon.on { color: var(--accent-2); background: rgba(47, 128, 255, 0.2); }
.tb-text {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 8px 12px 8px 8px;
  color: #e9e9ee;
  border-radius: 10px;
}
.tb-text:active { opacity: 0.6; }
.tb-circ {
  width: 36px; height: 36px;
  margin: 0 3px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bar-2);
  color: #f5f5f7;
  transition: background 0.15s, color 0.15s;
}
.tb-circ:active { background: #000; }
.tb-circ.on, .tb-circ.open { background: var(--accent); color: #fff; }
.tb-tool {
  width: 46px; height: 44px;
  display: grid; place-items: center;
  color: #f5f5f7;
  border-radius: 10px;
  transition: color 0.15s;
  --eraser-cut: var(--bar);
}
.tb-tool.on { color: var(--accent-2); }
.tb-tool.open { color: var(--accent-2); }
.tb-tool:active { opacity: 0.7; }
.tb-color { width: 50px; height: 44px; display: grid; place-items: center; }
.tb-color span {
  width: 30px; height: 30px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.92), 0 0 0 3.5px rgba(0, 0, 0, 0.35);
}
.tb-color.open span { box-shadow: 0 0 0 2px var(--accent-2), 0 0 0 4px rgba(0, 0, 0, 0.35); }

.presence {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  max-width: 34vw;
  white-space: nowrap;
}
.presence:has(.avatars) { padding-left: 4px; color: var(--text); }
.presence .pres-label { overflow: hidden; text-overflow: ellipsis; }
.presence .status { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.presence .status.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.22); }
.presence .status.off { background: var(--danger); }
.presence.open { background: rgba(47, 128, 255, 0.25); }

.avatar {
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: none;
  box-shadow: 0 0 0 2px var(--bar);
}
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -8px; }
.avatar.more { background: var(--panel-4); color: #fff; width: 26px; height: 26px; font-size: 11px; }

/* sidebar */
.sidebar {
  position: absolute;
  left: var(--safe-l);
  top: 50%;
  transform: translateY(-46%);
  width: 50px;
  padding: 12px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--bar);
  border-radius: 0 16px 16px 0;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35);
  z-index: 9;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.right-hand .sidebar { left: auto; right: var(--safe-r); border-radius: 16px 0 0 16px; }
.vslider { touch-action: none; }
.vs-track {
  position: relative;
  width: 32px;
  height: clamp(110px, 22vh, 196px);
  border-radius: 10px;
  background: #3b3b3f;
  touch-action: none;
  cursor: ns-resize;
}
.vs-thumb {
  position: absolute; left: 4px; top: 0;
  width: 24px; height: 15px;
  border-radius: 6px;
  background: #d8d8dd;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.vslider.active .vs-thumb { background: #fff; }
.modify {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 2px solid #9d9da3;
}
.modify i { width: 10px; height: 10px; border-radius: 3px; background: transparent; }
.modify.on { border-color: var(--accent-2); background: rgba(47, 128, 255, 0.25); }
.modify.on i { background: var(--accent-2); }
.sb-btn { width: 42px; height: 34px; display: grid; place-items: center; color: #a1a1a7; border-radius: 10px; }
.sb-btn.on { color: #fff; background: rgba(255, 255, 255, 0.06); }

#bubble {
  position: absolute;
  left: calc(62px + var(--safe-l));
  top: 50%;
  display: flex; align-items: center; gap: 14px;
  min-height: 64px;
  padding: 10px 18px 10px 12px;
  background: var(--bar);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transform: translateY(-50%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s, transform 0.12s;
  z-index: 12;
}
.right-hand #bubble { left: auto; right: calc(62px + var(--safe-r)); }
#bubble.show { opacity: 1; transform: translateY(-50%) scale(1); }
#bubble i { display: block; border-radius: 50%; min-width: 2px; min-height: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); }
#bubble span { font-size: 16px; font-weight: 700; min-width: 42px; font-variant-numeric: tabular-nums; }

#editor.ui-hidden .topbar { transform: translateY(-100%); opacity: 0; pointer-events: none; }
#editor.ui-hidden .sidebar { transform: translate(-120%, -46%); opacity: 0; pointer-events: none; }
#editor.ui-hidden.right-hand .sidebar { transform: translate(120%, -46%); }

/* live partner cursors & own hover ring */
.peer-cursor { position: absolute; left: 0; top: 0; transition: opacity 0.35s; will-change: transform; }
.peer-cursor.gone { opacity: 0; }
.peer-cursor .ring {
  position: absolute;
  width: var(--r, 10px); height: var(--r, 10px);
  left: calc(var(--r, 10px) / -2); top: calc(var(--r, 10px) / -2);
  min-width: 8px; min-height: 8px;
  border-radius: 50%;
  border: 2px solid var(--c);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75);
}
.peer-cursor .tag {
  position: absolute;
  left: calc(var(--r, 10px) / 2 + 8px);
  top: calc(var(--r, 10px) / 2 + 2px);
  background: var(--c);
  color: #fff;
  font-size: 12px; font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.25);
}
#brush-ring {
  position: absolute; left: 0; top: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.12s;
}
#brush-ring.show { opacity: 1; }

#loupe {
  position: fixed; left: 0; top: 0;
  width: 104px; height: 104px;
  margin: -52px 0 0 -52px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  z-index: 40;
  background: linear-gradient(var(--new, #fff) 50%, var(--old, #000) 50%);
  -webkit-mask: radial-gradient(circle, transparent 33px, #000 34px, #000 51px, transparent 52px);
  mask: radial-gradient(circle, transparent 33px, #000 34px, #000 51px, transparent 52px);
  transition: opacity 0.1s;
}
#loupe.show { opacity: 1; }
.drop-blob {
  position: fixed; left: 0; top: 0;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  z-index: 300;
  transition: opacity 0.1s;
}
.drop-blob.show { opacity: 1; }

.loading-note {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: none; align-items: center; gap: 12px;
  color: var(--text-2);
  font-weight: 600;
}
#editor.loading .loading-note { display: flex; }
#editor.loading .topbar, #editor.loading .sidebar { opacity: 0.4; pointer-events: none; }
.spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- popovers ---------- */
.pop {
  position: fixed;
  z-index: 50;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 0;
  transform: translateY(-6px) scale(0.985);
  transform-origin: top center;
  transition: opacity 0.15s ease, transform 0.15s ease;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}
.pop.in { opacity: 1; transform: none; }
.pop-arrow {
  position: absolute; top: -7px;
  width: 16px; height: 16px;
  margin-left: -8px;
  background: var(--panel);
  transform: rotate(45deg);
  border-radius: 3px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.pop-body { position: relative; overflow: auto; overscroll-behavior: contain; border-radius: var(--r); max-height: inherit; min-height: 0; -webkit-overflow-scrolling: touch; }
.pop.sub { z-index: 60; }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.pop-head h3 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--text); }
.icon-btn:active { background: rgba(255, 255, 255, 0.08); }

/* brush library */
.pop-brushes .pop-body { overflow: hidden; display: flex; }
.lib { display: flex; flex-direction: column; width: 100%; max-height: min(74dvh, 660px); }
.lib-cols { display: grid; grid-template-columns: 200px 1fr; flex: 1; min-height: 0; }
.lib-cats { overflow: auto; padding: 2px 10px 14px 14px; display: flex; flex-direction: column; gap: 7px; overscroll-behavior: contain; }
.lib-cat {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 14px;
  border-radius: 11px;
  background: var(--panel-3);
  font-size: 15px; font-weight: 600;
  text-align: left;
  flex: none;
}
.lib-cat .ico { color: #d8d8de; }
.lib-cat.on { background: var(--accent); }
.lib-cat.on .ico { color: #fff; }
.lib-right { display: flex; flex-direction: column; min-height: 0; background: #232325; border-radius: 0 0 var(--r) 0; border-left: 1px solid rgba(0, 0, 0, 0.25); }
.lib-list { overflow: auto; flex: 1; padding: 8px 10px; overscroll-behavior: contain; min-height: 200px; }
.lib-brush { display: block; width: 100%; text-align: left; padding: 10px 12px 4px; border-radius: 12px; }
.lib-brush + .lib-brush { margin-top: 2px; }
.lib-brush canvas { display: block; margin: 2px auto 0; max-width: 100%; opacity: 0.92; }
.lib-name { display: block; font-size: 13.5px; font-weight: 600; color: #e6e6eb; }
.lib-brush.on { background: var(--accent); }
.lib-brush.on .lib-name { color: #fff; }
.lib-brush.on canvas { opacity: 1; }
.lib-foot { padding: 10px 16px 14px; border-top: 1px solid var(--line); }

/* layers */
.lrows { display: flex; flex-direction: column; gap: 6px; padding: 0 12px 12px; }
.lrow {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px;
  padding: 8px 10px 8px 8px;
  border-radius: 12px;
  background: var(--panel-3);
  cursor: pointer;
  touch-action: pan-y;
  transition: background 0.12s;
}
.lrow.on { background: var(--accent); }
.lrow.hidden-layer .lthumb, .lrow.hidden-layer .lname { opacity: 0.45; }
.lrow.dragging { z-index: 5; box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5); transition: none; }
.lrow.drop-above::before { content: ""; position: absolute; left: 10px; right: 10px; top: -4px; height: 3px; border-radius: 2px; background: var(--accent-2); }
.lthumb {
  width: 60px; height: 44px; flex: none;
  display: grid; place-items: center;
}
.lthumb canvas {
  border-radius: 3px;
  background: repeating-conic-gradient(#dcdce0 0 25%, #fff 0 50%) 50% / 8px 8px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.lthumb.locked canvas { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(255, 255, 255, 0.35); }
.lname { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lname b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lname small { font-size: 12px; color: var(--text-2); }
.lrow.on .lname small { color: rgba(255, 255, 255, 0.78); }
.lblend { min-width: 30px; height: 34px; padding: 0 4px; border-radius: 8px; font-size: 14px; font-weight: 700; color: var(--text-2); }
.lrow.on .lblend { color: #fff; }
.lcheck {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  color: transparent;
}
.lcheck.on { background: #fff; border-color: #fff; color: var(--panel-3); }
.lrow.on .lcheck.on { color: var(--accent); }
.lrow.bg { margin-top: 4px; background: var(--panel-2); }
.bgsw { width: 60px; height: 44px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.12); flex: none; }

/* menus */
.menu { padding: 6px 6px 8px; }
.menu.pad { padding: 14px; }
.mrow {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 12px 12px;
  border-radius: 11px;
  font-size: 15.5px;
  text-align: left;
  color: var(--text);
}
.mrow:not(.static):active { background: rgba(255, 255, 255, 0.07); }
@media (hover: hover) { .mrow:not(.static):hover { background: rgba(255, 255, 255, 0.05); } }
.mrow .ico { color: #c8c8ce; }
.mrow-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mrow-label small { font-size: 12.5px; color: var(--text-2); }
.mrow.danger, .mrow.danger .ico { color: var(--danger); }
.mrow.static.col { flex-direction: column; align-items: stretch; gap: 10px; }
.mrow.static .swatches { padding: 8px 0 0; }
.clabel { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); padding: 14px 18px 7px; }
.menu .clabel { padding-left: 2px; }

.toggle { position: relative; width: 48px; height: 29px; border-radius: 999px; background: #4a4a4e; flex: none; transition: background 0.18s; }
.toggle i { position: absolute; left: 2px; top: 2px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); transition: transform 0.18s; }
.toggle.on { background: var(--ok); }
.toggle.on i { transform: translateX(19px); }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: #1c1c1e; }
.seg button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.seg button.on { background: var(--panel-4); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }

.hs { display: block; width: 100%; }
.hs-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.hs-val { color: var(--text); font-variant-numeric: tabular-nums; }
.hs input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 0; touch-action: none; }
.hs input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), #4a4a4e var(--p, 50%)); }
.hs input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
.hs input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), #4a4a4e var(--p, 50%)); }
.hs input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; }

.blend-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.chip { padding: 9px 10px; border-radius: 10px; background: var(--panel-3); font-size: 13.5px; font-weight: 600; text-align: left; }
.chip.on { background: var(--accent); }

/* colours */
.colors { padding-bottom: 10px; width: 100%; }
.cswatches { display: flex; }
.cswatch { width: 30px; height: 30px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.cswatch.prev { border-radius: 8px 0 0 8px; }
.cswatch.cur { border-radius: 0 8px 8px 0; }
.cstage { display: grid; place-items: center; padding: 6px 0 8px; }
.disc { position: relative; touch-action: none; }
.disc canvas { position: absolute; left: 0; top: 0; }
.disc .disc-inner { left: 32px; top: 32px; }
.thumb {
  position: absolute; left: 0; top: 0;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}
.thumb.small { top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; }
.classic { touch-action: none; }
.classic .sq { position: relative; width: 248px; height: 180px; }
.classic .sq canvas { display: block; border-radius: 10px; }
.huebar { position: relative; height: 24px; margin-top: 16px; border-radius: 12px; background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); touch-action: none; }
.crow { display: flex; align-items: center; gap: 10px; padding: 4px 18px 0; }
.crow .clabel { padding: 0; }
.field {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1c1c1e;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.field:focus { border-color: var(--accent); }
.field.hex { width: 120px; height: 38px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; text-transform: lowercase; }
.swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 7px; padding: 0 18px; }
.sw { aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); }
.sw:active { transform: scale(0.9); }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px #fff; }
.swatches.people { grid-template-columns: repeat(10, 1fr); padding: 6px 0 0; gap: 8px; }
.swatches.people.big { gap: 10px; }
.ctabs { display: flex; justify-content: center; padding: 14px 0 4px; }

/* actions */
.atabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 12px 6px; }
.atab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.atab.on { background: var(--panel-3); color: #fff; }
.atab.on .ico { color: var(--accent-2); }
.help { padding: 2px 8px 8px; }
.gesture { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 6px; border-bottom: 1px solid var(--line); }
.gesture:last-child { border-bottom: 0; }
.gesture b { font-size: 14.5px; font-weight: 600; }
.gesture span { font-size: 13.5px; color: var(--text-2); text-align: right; }

.invite { padding: 0 18px 18px; }
.invite .pop-head { padding-left: 0; padding-right: 0; }
.invite p { margin: 0 0 14px; font-size: 14px; }
.row-btns { display: flex; gap: 10px; margin-top: 10px; }
.row-btns .btn { flex: 1; justify-content: center; }
.invite .clabel { padding-left: 0; }
.people-list { display: flex; flex-direction: column; gap: 10px; }
.person { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.person .avatar { box-shadow: none; }

/* bottom bar (selection / transform / adjustments) */
#bottombar {
  position: absolute;
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 20;
  max-width: calc(100vw - 20px);
}
#bottombar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.bb-inner {
  display: flex; align-items: center; gap: 4px;
  padding: 8px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
  scrollbar-width: none;
}
.bb-inner::-webkit-scrollbar { display: none; }
.bb-btn { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px; border-radius: 11px; font-size: 14px; font-weight: 600; white-space: nowrap; flex: none; }
.bb-btn:active { background: rgba(255, 255, 255, 0.08); }
.bb-btn.primary { background: var(--accent); padding: 0 18px; }
.bb-btn.dim { opacity: 0.38; pointer-events: none; }
.bb-sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; flex: none; }
.bb-grow { flex: 1; min-width: 10px; }
.bb-title { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 6px; font-weight: 700; white-space: nowrap; }
.bb-sliders { display: flex; gap: 20px; padding: 0 8px; }
.bb-sliders .hs { width: 190px; }

/* toast */
.toast {
  position: fixed;
  top: calc(60px + var(--safe-t));
  left: 50%;
  z-index: 400;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px 9px 14px;
  border-radius: 999px;
  background: rgba(50, 50, 54, 0.96);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .ico { color: var(--accent-2); }

/* modal */
.modal-wrap {
  position: fixed; inset: 0;
  z-index: 500;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.18s;
}
.modal-wrap.in { opacity: 1; }
.modal {
  width: min(430px, 100%);
  padding: 24px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transform: scale(0.97);
  transition: transform 0.18s;
}
.modal-wrap.in .modal { transform: none; }
.modal h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -0.02em; }
.modal p { margin: 0 0 16px; }
.modal .clabel { padding-left: 0; padding-right: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.welcome h2 { font-size: 26px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: 12px;
  background: var(--panel-3);
  font-size: 15px; font-weight: 600;
  white-space: nowrap;
}
.btn:active { filter: brightness(1.15); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { height: 34px; padding: 0 12px; font-size: 13.5px; }
.info { display: flex; flex-direction: column; }
.info-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.info-row span { color: var(--text-2); }

/* ---------- gallery ---------- */
#gallery { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #111113; overscroll-behavior: contain; }
.g-top {
  position: sticky; top: 0; z-index: 5;
  height: calc(58px + var(--safe-t));
  padding: var(--safe-t) calc(18px + var(--safe-r)) 0 calc(20px + var(--safe-l));
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(17, 17, 19, 0.82);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.g-brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.g-brand img { border-radius: 7px; }
.g-actions { display: flex; align-items: center; gap: 10px; }
.g-profile { display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 14px 0 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); font-size: 14px; font-weight: 600; }
.g-profile .avatar { box-shadow: none; }
.g-plus { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: #fff; }
.g-plus.open { background: var(--accent-2); }
.g-main { padding: 6px calc(clamp(16px, 4vw, 52px) + var(--safe-r)) calc(64px + var(--safe-b)) calc(clamp(16px, 4vw, 52px) + var(--safe-l)); }
.g-main h1 { margin: 18px 0 26px; font-size: 34px; letter-spacing: -0.03em; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 36px 28px; }
.g-card { cursor: pointer; outline: none; -webkit-user-select: none; user-select: none; }
.g-thumb { position: relative; height: 200px; display: flex; align-items: flex-end; justify-content: center; }
.g-frame { position: relative; width: 100%; max-height: 100%; border-radius: 5px; overflow: hidden; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06); background: #fff; transition: transform 0.18s ease; }
.g-frame.tall { width: auto; height: 100%; }
.g-card:active .g-frame { transform: scale(0.97); }
@media (hover: hover) { .g-card:hover .g-frame { transform: translateY(-3px); } }
.g-card:focus-visible .g-frame { box-shadow: 0 0 0 3px var(--accent); }
.g-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.g-blank { width: 100%; height: 100%; background: #fff; }
.g-live {
  position: absolute; left: 8px; top: 8px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.66);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 12px; font-weight: 600;
  color: #fff;
}
.g-live .avatar { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6); }
.g-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 13px 2px 0; }
.g-meta > div { min-width: 0; }
.g-meta h3 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-meta p { margin: 3px 0 0; font-size: 13px; color: var(--text-2); }
.g-more { width: 34px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: var(--text-2); flex: none; }
.g-more:active { background: rgba(255, 255, 255, 0.08); }
.g-empty { text-align: center; padding: 70px 20px; color: var(--text-2); }
.g-empty p { font-size: 17px; margin: 0 0 18px; }
.size-ico { width: 28px; height: 28px; display: grid; place-items: center; flex: none; color: #c8c8ce; }
.size-shape { border: 2px solid currentColor; border-radius: 3px; }

/* ---------- time-lapse ---------- */
.timelapse {
  position: fixed; inset: 0; z-index: 450;
  display: flex; flex-direction: column;
  background: #0c0c0d;
  opacity: 0;
  transition: opacity 0.2s;
}
.timelapse.in { opacity: 1; }
.tl-top { display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--safe-t)) 14px 6px 20px; }
.tl-top b { font-size: 17px; }
.tl-top .grow { flex: 1; }
.tl-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px 20px; }
.tl-stage canvas { box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6); border-radius: 3px; background: #fff; }
.tl-controls { display: flex; align-items: center; gap: 14px; padding: 12px 20px calc(18px + var(--safe-b)); }
.tl-bar { flex: 1; accent-color: var(--accent); }
.tl-who { min-width: 90px; color: var(--text-2); font-size: 13px; font-weight: 600; }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .tb-text { font-size: 15px; padding-right: 6px; }
  .tb-circ { width: 32px; height: 32px; margin: 0 1px; }
  .tb-tool { width: 38px; }
  .tb-color { width: 42px; }
  .presence .pres-label { display: none; }
  .presence { padding: 0 8px; }
  .lib-cols { grid-template-columns: 1fr; }
  .lib-cats { flex-direction: row; overflow-x: auto; padding: 0 12px 10px; }
  .lib-cat { flex: none; }
  .lib-right { border-radius: 0 0 var(--r) var(--r); border-left: 0; }
  .g-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 16px; }
  .g-thumb { height: 150px; }
  .g-profile span:last-child { display: none; }
  .g-profile { padding-right: 5px; }
}
@media (max-width: 520px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .tb-mid .presence { display: none; }
  .tb-left .tb-circ[data-act="adjust"] { display: none; }
  .tb-tool[data-tool="smudge"] { display: none; }
}
@media (max-width: 420px) {
  .topbar { display: flex; justify-content: space-between; }
  .tb-mid { display: none; }
}
