/* === RESET & BASE === */
@import url('https://fonts.googleapis.com/css2?family=Berkshire+Swash&family=Cherry+Bomb+One&family=Dekko&family=Lexend:wght@400;500;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === UI COLOR PALETTE (theme-neutral variables) === */
:root {
  /* Base backgrounds (fallback) */
  --bg-primary: #f4f4f4;
  --bg-canvas: #ffffff;
  --bg-dark: #111111;
  --bg-panel: #e4e4e4;

  /* UI icons, active, hover (used by all themes) */
  --ui-primary: #555555;
  --ui-dark: #222222;
  --ui-light: #888888;
  --ui-accent: #777777;
  --ui-shadow: #b5b5b5;

  /* Secondary accent (e.g. logo area) */
  --brand-primary: #666666;
  --brand-light: #999999;
  --brand-accent: #777777;
  
  /* Typography */
  --text-header: #222222;
  --text-body: #333333;
  --text-light: #f0f0f0;
  
  /* Borders & effects */
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.18);
  --border-strong: rgba(0, 0, 0, 0.35);

  /* Block + toolbar backgrounds (fallbacks) */
  --block-bg-light: #f4f4f4;
  --block-bg-dark: #e0e0e0;
  --bg-secondary: #e8e8e8;
  --toolbar-bg: #d0d0d0;

  /* Layout (viewport lock) */
  --sidebar-width: 9rem;
  --toolbar-height: 6.5rem;
  --footer-height: 2rem;
  --toolbar-bottom: 1.75rem;

  /* HPP: purple background, purple paw; white text on #36274f passes AAA */
  --pj-purple: #6a4bc4;
  --pj-purple-bg: #36274f;
  --pj-purple-paw: #4f2e92;
  --pj-purple-aaa: #4f3a9e;

  /* Reusable: checkerboard (transparency), popup control sizes */
  --checker-color: var(--border-medium, #ccc);
  --checker-bg-size: 6px 6px;
  --checker-bg-pos: 0 0, 0 3px, 3px -3px, -3px 0;
  --swatch-size: 2rem;
  --swatch-size-small: 1rem;
  --gap-row: 0.5rem;
  --gap-tight: 4px;
}

/* === THEMES (WCAG 2.1 AAA: 7:1 normal text, 4.5:1 large text, 3:1 UI) === */
/* a. Graphite – grayscale, pencil/sketch feel; "Lesson 1" / early stages (join Osbard from the start). WIP. */
body.theme-graphite {
  --bg-primary: #1a1a1a;
  --bg-canvas: #ffffff;
  --bg-dark: #0a0a0a;
  --bg-panel: #2d2d2d;

  --ui-primary: #e0e0e0;
  --ui-dark: #ffffff;
  --ui-light: #b8b8b8;   /* ≥7:1 on block-bg-dark #1f1f1f */
  --ui-accent: #c0c0c0;
  --ui-shadow: #404040;

  --brand-primary: #a0a0a0;
  --brand-light: #d0d0d0;
  --brand-accent: #b5b5b5;

  --text-header: #f5f5f5;
  --text-body: #e8e8e8;
  --text-light: #ffffff;

  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-medium: rgba(255, 255, 255, 0.25);
  --border-strong: rgba(255, 255, 255, 0.45);

  --block-bg-light: #2d2d2d;
  --block-bg-dark: #1f1f1f;
  --bg-secondary: #383838;
  --toolbar-bg: #0f0f0f;
  --toolbar-fg: #f0f0f0;
  --toolbar-arrow-bg: rgba(255, 255, 255, 0.1);
  --toolbar-arrow-hover: rgba(255, 255, 255, 0.2);
}

/* b. Bluesy-1 – blue shades, high-contrast */
body.theme-bluesy-1 {
  --bg-primary: #18324a;
  --bg-canvas: #b9f2f4;
  --bg-dark: #0b1624;
  --bg-panel: #224c63;

  --ui-primary: #7ee4f0;   /* ≥7:1 on block-bg #224c63 (AAA normal text) */
  --ui-dark: #e5f9ff;
  --ui-light: #9eeaf3;
  --ui-accent: #2f8fb0;
  --ui-shadow: #0f2435;

  --brand-primary: #244f65;
  --brand-light: #57c7d8;
  --brand-accent: #1d3a4f;

  --text-header: #e9fdff;
  --text-body: #d0f4ff;
  --text-light: #f5feff;

  --border-subtle: rgba(13, 41, 61, 0.3);
  --border-medium: rgba(13, 41, 61, 0.45);
  --border-strong: rgba(6, 18, 31, 0.6);

  --block-bg-light: #224c63;
  --block-bg-dark: #163549;
  --bg-secondary: #2a5f7a;
  --toolbar-bg: #0f2334;
  --toolbar-fg: #e5f9ff;
}

/* c. Bumblebee – high-contrast dark with gold accent */
body.theme-bumblebee {
  --bg-primary: #121212;
  --bg-canvas: #ffffff;
  --bg-dark: #000000;
  --bg-panel: #1e1e1e;

  --ui-primary: #e8c45c;
  --ui-dark: #ffffff;
  --ui-light: #f0d078;
  --ui-accent: #5a8bb5;   /* ≥7:1 on #1e1e1e for any text use */
  --ui-shadow: #2a1f28;

  --brand-primary: #ffffff;
  --brand-light: #f5f5f5;
  --brand-accent: #e8c45c;

  --text-header: #ffffff;
  --text-body: #f2f2f2;   /* ≥7:1 on #1e1e1e (AAA margin) */
  --text-light: #ffffff;

  --border-subtle: rgba(255, 255, 255, 0.2);
  --border-medium: rgba(255, 255, 255, 0.4);
  --border-strong: rgba(255, 255, 255, 0.65);

  --block-bg-light: #1e1e1e;
  --block-bg-dark: #000000;
  --bg-secondary: #2a2a2a;
  --toolbar-bg: #000000;
  --toolbar-fg: #ffffff;
}

/* d. Pawzr – custom UI theme from Pawzr 12-swatch palette (vars set by JS from localStorage) */
body.theme-pawzr {
  /* Derived from the 12 swatches set in JS; keep block/toolbar/brand in sync */
  --block-bg-light: var(--bg-panel);
  --block-bg-dark: var(--bg-dark);
  --bg-secondary: var(--bg-primary);
  --toolbar-fg: var(--text-header);
  --brand-light: var(--ui-light);
  --brand-primary: var(--toolbar-bg);
  --brand-accent: var(--ui-accent);
  --ui-shadow: var(--bg-dark);
  --toolbar-arrow-bg: rgba(255, 255, 255, 0.1);
  --toolbar-arrow-hover: rgba(255, 255, 255, 0.2);
}

body {
  font-family: 'Lexend', sans-serif;
  overflow: hidden;
  background: var(--bg-dark);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === LAYOUT (NO GRID, FIXED POSITIONING) === */
#app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* q100: Left Sidebar - FIXED. Alternating .sidebar-block (light/dark) shows; bg-panel is fallback. */
#q100 {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--toolbar-height) - var(--footer-height) - var(--toolbar-bottom));
  background: var(--bg-panel);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
  direction: rtl;
}

#q100 > * {
  direction: ltr;
}

/* q300: Right Sidebar - FIXED */
#q300 {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--toolbar-height) - var(--footer-height) - var(--toolbar-bottom));
  background: var(--bg-panel);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
}

.layer-opacity {
  display: flex;
  align-items: center;
  gap: 0;
}
.layer-opacity + .layer-opacity {
  margin-top: 0.25rem;
}

.layer-number {
  font-size: 1.5rem;
  color: var(--text-body);
  cursor: pointer;
  transition: all 0.2s ease;
}

.layer-number:hover {
  color: var(--ui-light);
  filter: drop-shadow(0 0 8px var(--border-medium));
  transform: scale(1.1);
}

.layer-number.active {
  color: var(--ui-dark);
  filter: drop-shadow(0 0 4px var(--ui-primary))
          drop-shadow(0 0 12px var(--border-strong))
          drop-shadow(0 0 20px var(--ui-primary));
}

/* Active layer row: glow extends from number across the slider */
.layer-opacity.active .opacity-slider {
  box-shadow: 0 0 4px var(--ui-primary),
              0 0 12px var(--border-strong),
              0 0 20px var(--ui-primary);
}

/* Layer number wrap: circle number + lock replaces number when locked (double-tap) */
.layer-number-wrap {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}
.layer-lock-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem; /* same as .layer-number so lock fills the circle */
  color: var(--ui-primary);
  pointer-events: none;
  filter: drop-shadow(0 0 2px var(--bg-primary));
}
.layer-number-wrap.layer-locked .layer-number {
  visibility: hidden; /* hide number so lock is the only thing visible */
}
.layer-number-wrap.layer-locked .layer-lock-overlay {
  display: flex;
}

.layer-mask-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.layer-mask-row .icon-btn {
  flex-shrink: 0;
}
.layer-mask-label {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* q200: Canvas Area - FLEXIBLE CENTER */
#q200 {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: var(--sidebar-width);
  bottom: calc(var(--toolbar-bottom) + var(--toolbar-height));
  background-color: var(--bg-primary);
  background-image: url('img/bg-img-gs1.jpg');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  align-items: stretch;
  justify-content: center;
  z-index: 1;
}

/* Zoom/scroll: viewport is scroll container; zoom-wrap sized in JS */
.canvas-viewport {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* When zoomed in, align to top-left so the top of the canvas is reachable (no clipped top) */
.canvas-viewport.zoomed-in {
  justify-content: flex-start;
  align-items: flex-start;
}

.canvas-zoom-wrap {
  flex-shrink: 0;
}

.canvas-zoom-inner {
  transform-origin: 0 0;
}

/* q400: Bottom Toolbar */
#q400 {
  position: fixed;
  bottom: var(--toolbar-bottom);
  left: 0;
  right: 0;
  height: var(--toolbar-height);
  background: var(--toolbar-bg);
  color: var(--toolbar-fg, var(--text-header));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  z-index: 20;
  overflow-x: auto;
  overflow-y: hidden;
}

.toolbar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.toolbar-section h2 {
  font-size: 1rem;
  color: var(--toolbar-fg, var(--text-header));
  margin: 0;
  padding: 0;
  white-space: nowrap;
  text-align: center;
}

.logo-section {
  margin: 0;
  padding: 0 8px 0 8px;
}

#paw-logo {
  width: 6rem;
  height: 6rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  display: block;
  /* PJ colors applied in SVG */
  filter: drop-shadow(0 0 0 transparent);
}

#paw-logo:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px var(--border-medium));
}

.paw-logo-btn {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  display: block;
  line-height: 0;
}

.brush-tools,
.paint-section {
  display: flex;
  align-items: center;
}

.brush-tools {
  gap: 0;
}

.paint-section {
  gap: 0;
}

.color-wells {
  display: flex;
  align-items: center;
  gap: 0;
}

/* === SCROLL ARROWS === */
.scroll-arrow {
  width: 3rem;
  height: 8rem;
  background: rgba(224, 224, 224, 0.9);
  border: none;
  color: var(--ui-primary);
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 25;
}

.scroll-arrow:hover {
  background: var(--bg-panel);
  color: var(--ui-dark);
  filter: drop-shadow(0 0 8px var(--border-medium));
}

/* When toolbar is dark (e.g. theme-graphite / theme-bumblebee), arrows use --toolbar-fg */
#q400 .scroll-arrow {
  color: var(--toolbar-fg, var(--ui-primary));
  background: var(--toolbar-arrow-bg, rgba(224, 224, 224, 0.9));
}

#q400 .scroll-arrow:hover {
  background: var(--toolbar-arrow-hover, var(--bg-panel));
  color: var(--toolbar-fg, var(--ui-dark));
  filter: drop-shadow(0 0 8px var(--border-medium));
}

.scroll-left {
  position: sticky;
  left: 0;
}

.scroll-right {
  position: sticky;
  right: 0;
}

.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.popup-overlay .popup-bubble {
  pointer-events: auto;
}

.popup-overlay.hidden {
  display: none;
}

.popup-bubble {
  background: var(--bg-panel);
  border: none;
  border-radius: 0;
  padding: 8px;
  width: fit-content;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  overflow: auto;
  box-shadow: 0 0 12px var(--border-strong);
}

.popup-bubble--lx {
  padding: 6px 8px;
  width: max-content;
  max-width: min-content;
}
.popup-bubble--lx .popup-content {
  width: max-content;
  display: block;
  gap: 0;
  min-width: 0;
}

.popup-bubble--lx .popup-header {
  margin-bottom: 6px;
}

/* LX · FX: shared styles; single-column when --lx-only or --fx-only */
.popup-bubble--lx-fx {
  padding: 0.75rem 1rem;
  width: max-content;
}
.popup-bubble--lx-fx .popup-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
  min-width: 0;
}
.popup-bubble--lx-only .popup-content,
.popup-bubble--fx-only .popup-content {
  grid-template-columns: 1fr;
}
.popup-bubble--lx-fx .popup-header {
  margin-bottom: 0.5rem;
}
.popup-bubble--lx-fx .lx-fx-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}
.popup-bubble--lx-fx .lx-fx-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-header);
  margin: 0 0 0.25rem 0;
}
.popup-bubble--lx-fx .fx-controls {
  grid-column: unset;
  min-width: 10rem;
}
.popup-bubble--lx-fx .fx-controls .fx-row {
  gap: 0.4rem;
}
.popup-bubble--lx-fx .fx-slider {
  flex: 0.5; /* roughly half-length inside LX · FX popup */
}
.popup-bubble--lx-fx .lx-controls {
  min-width: 10rem;
}
.popup-bubble--lx-fx .lx-reset-btn {
  margin-top: 0.25rem;
  align-self: flex-end;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-medium);
  background: transparent;
  color: var(--text-body);
  cursor: pointer;
}
.popup-bubble--lx-fx .lx-reset-btn:hover {
  background: var(--bg-secondary);
}
.popup-bubble--lx-fx .lx-blend-hint {
  margin: 0.4rem 0 0 0;
  font-size: 0.7rem;
  color: var(--text-muted, rgba(255,255,255,0.6));
  line-height: 1.3;
}
.popup-bubble--lx-fx .lx-brush-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#popup-title {
  color: var(--text-header);
}

#popup-title.popup-title-icon-only {
  font-size: 3rem;
  line-height: 1;
  margin: 0;
}

#popup-title.popup-title-icon-only .ph {
  font-size: inherit;
}

.popup-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-body);
  cursor: pointer;
}

.popup-content {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  color: var(--text-body);
}

/* All popup icons: 3rem × 3rem, NO outlines/borders/shadows — !important so global .icon-btn cannot override */
.popup-bubble .popup-content .icon-btn,
.popup-bubble .popup-content .canvas-surface-option,
.popup-bubble .popup-content .lx-brush-option,
.popup-bubble .popup-content .font-btn {
  color: var(--ui-primary) !important;
  width: 3rem !important;
  height: 3rem !important;
  min-width: 3rem !important;
  min-height: 3rem !important;
  padding: 0 !important;
  font-size: 1.75rem !important;
  border: none !important;
  border-radius: 0 !important;
  box-sizing: border-box !important;
  outline: none !important;
  box-shadow: none !important;
  filter: none !important;
  background: transparent !important;
}
.popup-bubble .popup-content .icon-btn:hover,
.popup-bubble .popup-content .canvas-surface-option:hover,
.popup-bubble .popup-content .lx-brush-option:hover,
.popup-bubble .popup-content .font-btn:hover {
  border: none !important;
  box-shadow: none !important;
  filter: none !important;
}
.popup-bubble .popup-content .icon-btn .ph,
.popup-bubble .popup-content .canvas-surface-option .ph,
.popup-bubble .popup-content .lx-brush-option .ph {
  font-size: inherit;
}
.popup-bubble .popup-content .canvas-surface-option.active,
.popup-bubble .popup-content .lx-brush-option.active {
  color: var(--text-header) !important;
  border: none !important;
  box-shadow: none !important;
  filter: none !important;
}
.popup-bubble .popup-content .ph {
  color: currentColor;
}
/* Popup icon grids: consistent gap */
.popup-bubble .popup-content .font-popup-grid,
.popup-bubble .popup-content .lx-brush-options,
.popup-bubble .popup-content .canvas-surface-options {
  gap: 0.35rem;
}

.brush-popup-section {
  grid-column: 1 / -1;
}

.popup-section-head {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-header);
}

.popup-section-reset {
  cursor: pointer;
  user-select: none;
}

.popup-section-reset:hover {
  color: var(--ui-primary);
}

.lx-controls {
  width: fit-content;
}

.lx-brush-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
}

.lx-brush-option {
  padding: 0 !important;
  font-size: 1.75rem !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  filter: none !important;
  color: var(--text-body);
  cursor: pointer;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem !important;
  height: 3rem !important;
  box-sizing: border-box;
}

.lx-brush-option .ph {
  font-size: inherit;
}

.lx-brush-option:hover {
  color: var(--ui-primary);
}

.lx-brush-option.active {
  color: var(--text-header);
}

/* Outline & Fill (Palette) popup — fit to contents, 4px above q400 */
.popup-bubble .stroke-fill-controls {
  width: fit-content;
  min-width: 0;
}
.stroke-fill-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stroke-fill-row {
  display: flex;
  align-items: center;
  gap: var(--gap-row);
  flex-wrap: wrap;
}

.stroke-fill-label {
  min-width: 3.5rem;
  font-size: 0.9rem;
  color: var(--text-header);
}

.stroke-fill-swatch {
  width: var(--swatch-size);
  height: var(--swatch-size);
  border: none !important;
  border-radius: 0;
  box-shadow: none !important;
  flex-shrink: 0;
}

/* Swatch when current color is transparent (100%) */
.stroke-fill-swatch--transparent {
  background: transparent !important;
  background-image:
    linear-gradient(45deg, var(--checker-color) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-color) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-color) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-color) 75%) !important;
  background-size: var(--checker-bg-size);
  background-position: var(--checker-bg-pos);
}

/* Same-sized box to the right of picker: always checkerboard = set to transparent */
.stroke-fill-transparent-swatch {
  width: var(--swatch-size);
  height: var(--swatch-size);
  min-width: var(--swatch-size);
  min-height: var(--swatch-size);
  padding: 0;
  border: 1px solid var(--border-medium);
  border-radius: 0;
  flex-shrink: 0;
  cursor: pointer;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, var(--checker-color) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-color) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-color) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-color) 75%);
  background-size: var(--checker-bg-size);
  background-position: var(--checker-bg-pos);
  box-sizing: border-box;
}
.stroke-fill-transparent-swatch:hover {
  filter: brightness(0.95);
  box-shadow: 0 0 0 2px var(--ui-primary);
}
.stroke-fill-transparent-swatch:focus-visible {
  outline: 2px solid var(--ui-primary);
  outline-offset: 2px;
}

/* When outline or fill is transparent, the transparent box shows active 2px border */
.stroke-fill-transparent-swatch--active {
  border: 2px solid var(--ui-primary) !important;
  box-shadow: 0 0 0 1px var(--bg-primary);
}

.stroke-fill-hex {
  width: 5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-body);
}

.stroke-fill-picker {
  width: var(--swatch-size);
  height: var(--swatch-size);
  padding: 0;
  border: none !important;
  border-radius: 0;
  box-shadow: none !important;
  outline: none;
  cursor: pointer;
  background: transparent;
}

/* Custom Colors: 10 round swatches below Fill */
.stroke-fill-custom-row {
  display: flex;
  align-items: center;
  gap: var(--gap-row);
  flex-wrap: wrap;
}

.stroke-fill-keep-open-row {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
}
.stroke-fill-keep-open-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-header);
  cursor: pointer;
}
.stroke-fill-keep-open-label input[type="checkbox"] {
  cursor: pointer;
}
.stroke-fill-custom-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-tight);
}
.stroke-fill-custom-swatch {
  width: var(--swatch-size-small);
  height: var(--swatch-size-small);
  min-width: var(--swatch-size-small);
  min-height: var(--swatch-size-small);
  border-radius: 2px;
  padding: 0;
  border: 1px solid var(--border-medium);
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
}
.stroke-fill-custom-swatch:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 0 2px var(--ui-primary);
}
.stroke-fill-custom-swatch--locked {
  box-shadow: 0 0 0 2px var(--ui-primary);
  outline: 2px solid var(--text-body);
  outline-offset: -2px;
}

/* Stroke-fill popup: two columns — Outline & Fill | Saved Pawlettes */
.popup-bubble--stroke-fill {
  width: min(90vw, 624px);
  max-width: 624px;
}
.popup-bubble--stroke-fill .popup-content {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  box-sizing: border-box;
}
.stroke-fill-popup-title {
  margin: 0 0 0.35rem 0;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #fff);
}
/* Default palette row: mini oval wells (like q400) + lock + import */
.stroke-fill-default-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border-medium, rgba(255,255,255,0.12));
  box-sizing: border-box;
}
.stroke-fill-default-wells {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  justify-content: center;
}
.stroke-fill-default-well {
  width: 1.7rem;
  height: 2.3rem;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--bg-canvas, #333);
  box-sizing: border-box;
  cursor: default;
}
.stroke-fill-default-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.stroke-fill-default-lock,
.stroke-fill-default-import {
  background: none;
  border: none;
  color: var(--text-muted, rgba(255,255,255,0.5));
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}
.stroke-fill-default-lock:disabled {
  cursor: default;
  color: var(--accent, #8b6dd0);
}
.stroke-fill-default-import:hover {
  color: var(--text-primary, #fff);
  background: var(--bg-secondary, rgba(255,255,255,0.08));
}
.stroke-fill-default-lock i,
.stroke-fill-default-import i {
  font-size: 1rem;
}
.popup-header h3:empty {
  display: none;
}
.stroke-fill-two-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
}
.stroke-fill-header-row {
  display: flex;
  justify-content: space-between;
  padding: 0 0.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-header);
}
.stroke-fill-header-left { }
.stroke-fill-header-right { }
.stroke-fill-main-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  width: 100%;
  box-sizing: border-box;
}
.stroke-fill-left,
.stroke-fill-right {
  flex: 1 1 0;
  min-width: 0;
}
.stroke-fill-right {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 280px;
}
.saved-pawlettes-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.saved-pawlette-row {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid transparent;
}
.saved-pawlette-row:hover {
  background: var(--bg-secondary, rgba(255,255,255,0.08));
  border-color: var(--border-medium);
}
.saved-pawlette-swatches {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.saved-pawlette-swatches .saved-pawlette-swatch {
  flex-shrink: 0;
}
.saved-pawlette-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.saved-pawlette-lock,
.saved-pawlette-download {
  background: none;
  border: none;
  color: var(--text-muted, rgba(255,255,255,0.6));
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}
.saved-pawlette-lock:hover,
.saved-pawlette-download:hover {
  color: var(--text-primary, #fff);
  background: var(--bg-secondary, rgba(255,255,255,0.08));
}
.saved-pawlette-row .saved-pawlette-lock:has(.ph-lock-simple) {
  color: var(--accent, #8b6dd0);
}
.saved-pawlette-lock i,
.saved-pawlette-download i {
  font-size: 1rem;
}
.saved-pawlette-swatch {
  width: var(--swatch-size-small);
  height: var(--swatch-size-small);
  min-width: var(--swatch-size-small);
  min-height: var(--swatch-size-small);
  flex-shrink: 0;
  border-radius: 2px;
  box-sizing: border-box;
}
.stroke-fill-dropdown-row {
  margin-top: auto;
  padding-top: 0.5rem;
}
.stroke-fill-select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-body);
  cursor: pointer;
}
.stroke-fill-swatches-row {
  margin-top: 0.5rem;
}
.stroke-fill-swatches-row .stroke-fill-custom-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.stroke-fill-actions-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.stroke-fill-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-secondary, rgba(255,255,255,0.1));
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-body);
  cursor: pointer;
}
.stroke-fill-btn:hover {
  background: var(--ui-primary);
  color: var(--bg-primary);
}

/* Canvas Type popup — 6 icons in 2×3, fit width to content only */
.popup-bubble--canvas-type {
  width: max-content;
  max-width: min-content;
}
.popup-bubble--canvas-type .popup-content {
  width: max-content;
  display: block;
}

/* File menu popup — to the right of q100; 2 columns: New/Open | Recent Art */
.popup-bubble--file-menu {
  width: max-content;
  min-width: 12rem;
}
.popup-bubble--file-menu .popup-content {
  padding: 0.5rem 0;
  display: block;
}
.file-menu-columns {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.file-menu-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 0.5rem;
}
.file-menu-col:first-child {
  padding-left: 0.25rem;
}
.file-menu-col-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-header);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 0.15rem;
}
.file-menu-divider {
  width: 1px;
  background: var(--border-medium);
  flex-shrink: 0;
}
.file-menu-recent {
  min-width: 10rem;
  max-width: 14rem;
}
.recent-art-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 10rem;
  overflow-y: auto;
}
.recent-art-item {
  display: block;
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  text-align: left;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-body);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-art-item:hover {
  background: var(--border-subtle);
  color: var(--text-header);
}
.recent-art-empty {
  font-size: 0.8rem;
  color: var(--ui-light);
  padding: 0.35rem 0;
  margin: 0;
}
.popup-bubble--file-menu .popup-content .file-menu-option {
  color: var(--ui-primary) !important;
  width: 3rem !important;
}

.canvas-surface-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  width: fit-content;
}

.canvas-surface-options--six {
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}

.canvas-surface-options--four {
  grid-template-columns: repeat(2, 1fr);
  gap: 0.3rem;
}

.canvas-surface-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  font-size: 1.75rem !important;
  width: 3rem !important;
  height: 3rem !important;
  box-sizing: border-box;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  filter: none !important;
  cursor: pointer;
  color: inherit;
}

.canvas-surface-options--six .canvas-surface-option {
  width: 3rem;
  height: 3rem;
  font-size: 1.75rem;
  padding: 0;
}

.canvas-surface-option i,
.canvas-surface-option .ph {
  font-size: inherit;
}

.canvas-surface-option:hover {
  color: var(--ui-primary);
}

.canvas-surface-option.active {
  color: var(--text-header);
}

.lx-placeholder {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted, var(--text-body));
  opacity: 0.85;
}

/* HPP: the image IS the website (viewport = app). Centered, 90% vertically, width from image. Bubble = that rectangle only. */
.popup-bubble--hpp {
  padding: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
  border: none;
  border-radius: 0;
}

.popup-bubble--hpp .popup-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: transparent;
  color: #fff;
}

.popup-bubble--hpp .popup-header h3 {
  display: none;
}

.popup-bubble--hpp .popup-close {
  color: #fff;
}
.popup-bubble--hpp .popup-close:hover {
  color: #fff;
  opacity: 0.9;
}

.popup-bubble--hpp .popup-content {
  padding: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.popup-bubble--hpp .hpp-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

/* HPP Legal: single document with TOC + anchors (footer "Do Not Share" | "Legal" open this) */
.hpp-legal-print-row {
  margin-bottom: 1rem;
}
.hpp-legal-print-btn {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--panel, #252a34);
  border: 1px solid var(--border-medium, rgba(255,255,255,0.2));
  border-radius: 6px;
  color: var(--text-primary, #fff);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.hpp-legal-print-btn:hover {
  background: var(--accent, #8b6dd0);
  border-color: var(--accent, #8b6dd0);
}
.popup-bubble--hpp-legal {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-primary, #1a1a2e);
  color: var(--text-body, #e4e2df);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  border: 1px solid var(--border-medium, rgba(255,255,255,0.1));
}
.popup-bubble--hpp-legal .popup-header h3 {
  display: block;
  font-size: 1.1rem;
  margin: 0 0 0.75rem 0;
  color: var(--text-primary, #fff);
}
.popup-bubble--hpp-legal .popup-content {
  padding: 0;
  height: auto;
  min-height: 0;
}
.hpp-legal-toc {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-medium, rgba(255,255,255,0.12));
}
.hpp-legal-toc-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text-header, #ccc);
}
.hpp-legal-toc ul {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
}
.hpp-legal-toc a {
  color: var(--ui-primary, #8b6dd0);
  text-decoration: none;
}
.hpp-legal-toc a:hover {
  text-decoration: underline;
}
.hpp-legal-body section {
  margin-bottom: 1.25rem;
}
.hpp-legal-body h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.35rem 0;
  color: var(--text-primary, #fff);
}
.hpp-legal-body p {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  line-height: 1.45;
}
.hpp-legal-body a {
  color: var(--ui-primary, #8b6dd0);
  text-decoration: none;
}
.hpp-legal-body a:hover {
  text-decoration: underline;
}

.hpp-paw-svg {
  width: 100%;
  max-width: min(20rem, 45vh);
  height: auto;
  fill: var(--pj-purple-paw);
  opacity: 0.98;
}

.hpp-stage-content {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
}

.hpp-tip-block--stage {
  border-left-color: rgba(255, 255, 255, 0.5);
  padding-left: 0.75rem;
  margin: 0;
  text-align: left;
}

.hpp-tip-text--stage {
  font-size: 1.125rem;
  line-height: 1.45;
  color: #fff;
  font-weight: 500;
}

.hpp-coming--stage p {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.9);
}

.hpp-download-cta {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.4);
}

.hpp-download-label {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

.hpp-download-placeholder {
  display: block;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 0.25rem;
}

/* HPP 2-column: Left = TOC + thumbnails/announcements, Right = page content (e.g. Privacy Policy) */
.hpp-two-col {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 12rem;
  flex: 0 0 auto;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}

.hpp-toc {
  flex: 0 0 auto;
  width: 12rem;
  padding: 0 0.75rem 0.5rem 0;
}

.hpp-toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.9);
  margin: 0 0 0.5rem 0;
}

.hpp-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hpp-toc-item {
  display: block;
  width: 100%;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.15rem;
  text-align: left;
  background: none;
  border: none;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  cursor: pointer;
}

.hpp-toc-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.hpp-toc-item.active {
  background: rgba(255, 255, 255, 0.18);
  font-weight: 500;
}

.hpp-toc-note {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  margin: 0.5rem 0 0 0;
}

.hpp-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.hpp-content-pane {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 0 0.5rem 0.75rem;
  overflow-y: auto;
}

.hpp-content-placeholder {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

/* HPP when used in small tooltip-style popups (unchanged) */
.hpp-tip-block {
  grid-column: 1 / -1;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--ui-primary);
  padding-left: 0.75rem;
  min-width: 16rem;
  max-width: 22rem;
}

.hpp-tip-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-body);
}

.hpp-coming {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted, var(--text-body));
  opacity: 0.8;
}

.hpp-coming p {
  margin: 0;
}

.fx-controls {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 12rem;
}

.fx-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-body);
}

.fx-row > span:first-child {
  min-width: 5rem;
}

.fx-slider {
  flex: 1;
  height: 0.5rem;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-medium);
  border-radius: 0.25rem;
}

.fx-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  background: var(--ui-primary);
  border-radius: 50%;
  cursor: pointer;
}

.fx-slider::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  background: var(--ui-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.fx-value {
  min-width: 2rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-header);
}

.fx-reset-btn {
  margin-top: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-body);
}

.fx-reset-btn:hover {
  border-color: var(--ui-primary);
  background: var(--bg-secondary);
}

/* Font buttons: in popup use uniform rules above (2rem, no border); base for sidebar only */
.font-btn {
  width: 4rem;
  height: 4rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-body);
  font-size: 2rem;
  transition: all 0.2s ease;
  border-radius: 6px;
}
/* Popup font buttons must have no border/shadow (overrides base when inside popup) */
.popup-bubble .popup-content .font-btn,
.popup-bubble .popup-content .font-btn:hover {
  border: none !important;
  box-shadow: none !important;
  filter: none !important;
  transform: none;
}
.font-btn:hover {
  border-color: var(--ui-primary);
  filter: drop-shadow(0 0 8px var(--border-medium));
  transform: scale(1.1);
}

/* Active font: visible at a glance (outline + color) */
.font-btn.active,
.popup-bubble .popup-content .font-btn.active {
  outline: 2px solid var(--ui-primary);
  outline-offset: 2px;
  color: var(--ui-primary);
  font-weight: 600;
}
.popup-bubble .popup-content .font-btn.active:hover {
  color: var(--ui-primary);
}

/* Font popup: 2 rows — row1 two columns (fonts + line spacing | B I U), row2 full width (size) */
.popup-bubble--font .popup-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 14rem;
}
.popup-bubble--font .font-popup-row1 {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: start;
}
.popup-bubble--font .font-popup-col1 .font-popup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.popup-bubble--font .font-line-spacing-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary, rgba(255,255,255,0.06));
  border-radius: 6px;
  min-height: 2.5rem;
}
.popup-bubble--font .font-line-spacing-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted, rgba(255,255,255,0.6));
}
.popup-bubble--font .font-line-spacing-btns {
  display: flex;
  gap: 4px;
}
.popup-bubble--font .font-format-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 6px;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-body);
  cursor: pointer;
}
.popup-bubble--font .font-format-btn:hover {
  border-color: var(--ui-primary);
  color: var(--ui-primary);
}
.popup-bubble--font .font-format-btn.active {
  background: var(--ui-primary);
  color: var(--bg-primary);
  border-color: var(--ui-primary);
}
.popup-bubble--font .font-format-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.popup-bubble--font .font-align-row {
  margin-top: 4px;
}
.popup-bubble--font .font-align-btn .ph {
  font-size: 1.1rem;
}
.popup-bubble--font .font-popup-divider {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border-medium);
}
.popup-bubble--font .font-popup-row2 {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.popup-bubble--font .font-points-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.popup-bubble--font .font-points-row input {
  width: 4rem;
  padding: 4px;
}

/* q000: Footer */
#q000 {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-height);
  background: var(--bg-dark);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 1rem;
  color: var(--text-light);
  font-size: 0.9rem;
  z-index: 20;
}

#q000 span:first-child {
  justify-self: start;
}

#q000 .copyright {
  justify-self: center;
  font-family: 'Cherry Bomb One', cursive;
  color: var(--bg-canvas);
}

#q000 span:last-child {
  justify-self: end;
  align-self: center;
  display: flex;
  align-items: center;
}

#q000 span:first-child,
#q000 span:last-child {
  color: var(--ui-light);
}
#q000 .footer-left-legal {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
#q000 .footer-legal-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
#q000 .footer-legal-link:hover {
  text-decoration: underline;
}

#q000 .footer-theme-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 0 0.25rem;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font-size: inherit;
}
#q000 .footer-theme-btn:hover {
  color: var(--bg-canvas);
}
#q000 .footer-theme-btn i {
  font-size: 1rem;
}

#q000 .footer-right {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem; /* spaced for easy tap without overlap (WCAG touch targets) */
  line-height: 1;
}
#q000 .footer-right .footer-zoom,
#q000 .footer-right .footer-zoom-reset-btn,
#q000 .footer-right .footer-theme-btn {
  line-height: 1;
}

#q000 .footer-zoom {
  color: #f0c000;
  font-weight: 500;
  min-width: 3.5rem;
}

/* Zoom in/out/Reset: same font size as footer for clean alignment */
#q000 .footer-zoom-btn,
#q000 .footer-zoom-reset-btn {
  padding: 0.2rem 0.4rem;
  background: none;
  border: 1px solid var(--ui-light);
  border-radius: 4px;
  color: inherit;
  cursor: pointer;
  font-size: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#q000 .footer-zoom-btn i {
  font-size: 1em;
}
#q000 .footer-zoom-btn:hover,
#q000 .footer-zoom-reset-btn:hover {
  color: var(--bg-canvas);
  border-color: var(--bg-canvas);
}
#q000 .footer-zoom-reset-btn {
  font-size: 0.85em;
}

/* === SCROLLBAR === */
#q100::-webkit-scrollbar,
#q300::-webkit-scrollbar {
  width: 1rem;
}

#q100::-webkit-scrollbar-track,
#q300::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

#q100::-webkit-scrollbar-thumb,
#q300::-webkit-scrollbar-thumb {
  background: var(--ui-primary);
  border-radius: 0.5rem;
  transition: background 0.2s ease;
}

#q100::-webkit-scrollbar-thumb:hover,
#q300::-webkit-scrollbar-thumb:hover {
  background: var(--ui-dark);
}

/* === SIDEBAR BLOCKS === */
.sidebar-block {
  padding-bottom: 0.75rem; /* gap between blocks = this block’s color */
}
.sidebar-block:first-child {
  padding-top: 0.75rem; /* top of first block = block color */
}

/* Start Making Art! – h1 at 1.25rem, doubles as theme switcher (piratey PJ🐶) */
.sidebar-block h1.start-art-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-header);
  padding: 0.5rem;
  text-align: center;
  margin: 0;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  transition: color 0.2s ease, filter 0.2s ease;
}
.sidebar-block h1.start-art-heading:hover {
  color: var(--ui-light);
  filter: drop-shadow(0 0 6px var(--border-medium));
}
.sidebar-block h1.start-art-heading:focus {
  outline: 2px solid var(--ui-primary);
  outline-offset: 2px;
}

.block-header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 0.5rem 0 0.5rem;
}
.block-header-row h2 {
  margin: 0;
}
.block-lock-btn {
  flex-shrink: 0;
  padding: 0.25rem;
}
.block-lock-btn .block-lock-icon {
  font-size: 1rem;
}
.block-lock-btn.locked .block-lock-icon {
  color: var(--ui-primary, #0a7ea4);
}

.sidebar-block h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-header);
  padding: 0.5rem;
  text-align: center;
}

.sidebar-block h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-header);
  padding: 0.25rem 0.5rem;
  text-align: center;
}

/* Alternating block backgrounds per theme (all assets in block share bg) */
#q100 .sidebar-block,
#q300 .sidebar-block {
  background: var(--block-bg-light);
}
#q100 .sidebar-block {
  width: 100%;
  box-sizing: border-box;
}
/* q100 & q300: alternating block backgrounds (e.g. Bumblebee #1e1e1e / #000000) */
#q100 .sidebar-block:nth-of-type(even),
#q300 .sidebar-block:nth-of-type(even) {
  background: var(--block-bg-dark);
}

/* === ICON BUTTONS === */
.icon-row {
  display: flex;
  width: 100%;
}

.icon-btn {
  width: 4rem;
  height: 4rem;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-primary);
  font-size: 3rem;
  transition: all 0.2s ease;
}

/* Toolbar Paint Tools: normal = brighter (like former active); active = color-well inactive outline (white/light) */
#q400 .icon-btn {
  color: var(--text-light);
}
#q400 .icon-btn.active {
  color: var(--bg-canvas);
  filter: none;
  box-shadow: 0 0 0 2px var(--bg-canvas);
}
#q400 .icon-btn:hover {
  color: var(--bg-canvas);
}
#q400 .icon-btn i {
  color: inherit;
}

.icon-btn i {
  font-size: 3rem;
  color: var(--ui-primary);
}

.icon-btn img {
  width: 3rem;
  height: 3rem;
  object-fit: contain;
}

.icon-btn:hover {
  color: var(--ui-light);
  filter: drop-shadow(0 0 8px var(--border-medium));
  transform: scale(1.25);
}

.icon-btn:hover i {
  color: var(--ui-light);
}

.icon-btn.active {
  color: var(--ui-dark);
  filter: drop-shadow(0 0 12px var(--border-strong));
}

.icon-btn.active i {
  color: var(--ui-dark);
}

/* === CANVAS PREVIEW === */
/* Mini canvases are square; main canvas remains portrait by default */
.preview-box {
  width: 7rem;
  height: 7rem;
  background: var(--bg-canvas);
  margin: 0.5rem auto;
  border: 1px solid var(--border-medium);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.storyboard-icons {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
  font-size: 1.1rem;
  color: var(--ui-primary);
}

.storyboard-icons .ph {
  font-size: 1.1rem;
}

.preview-row {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.preview-small {
  width: 3.4rem;
  height: 3.4rem;
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
}

/* === OPACITY SLIDERS === */
.opacity-slider {
  width: calc(100% - 1rem);
  margin: 0.5rem 0.5rem;
  height: 0.5rem;
  background: var(--border-medium);
  outline: none;
  border-radius: 0.25rem;
  -webkit-appearance: none;
}

.opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  background: var(--ui-primary);
  border-radius: 50%;
  cursor: pointer;
}

.opacity-slider::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  background: var(--ui-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* === CANVAS === */
/* Wrap size is set by JS (updateCanvasWrapSize) so canvas fills 90% of q200 height first, then width by aspect ratio */
.canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#canvas {
  background: var(--bg-canvas);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: none; /* so pen/stylus and touch get pointer events, not browser pan/zoom */
}

.text-edit-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.text-edit-overlay:not(.hidden) {
  pointer-events: auto;
}
.text-edit-overlay .text-edit-input {
  position: absolute;
  margin: 0;
  padding: 4px 8px;
  border: 2px solid var(--ui-primary);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-body);
  outline: none;
  min-width: 80px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.text-edit-overlay .text-edit-textarea {
  min-height: 2.5em;
  resize: vertical;
  white-space: pre-wrap;
}

/* === COLOR WELLS === */
.color-wells {
  display: flex;
  width: 100%;
  gap: 0;
  justify-content: center;
}

.color-btn {
  width: 3rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: transform 0.2s ease;
}

.color-btn:hover {
  transform: scale(1.15);
}

.color-well {
  width: 2.15rem;
  height: 3rem;
  border-radius: 50%;
  border: 4px solid var(--bg-canvas);
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-well:hover {
  transform: scale(1.15);
  border-color: var(--ui-primary);
  box-shadow: 0 0 12px var(--border-medium);
}

.color-well.active {
  border-color: var(--ui-dark);
  box-shadow: 0 0 16px var(--border-strong);
}

/* === STARTUP TIP (one-time FX reset hint) === */
.startup-tip {
  position: fixed;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 28rem);
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--border-strong);
  z-index: 1000;
  font-size: 0.9rem;
  color: var(--text-body);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.startup-tip.hidden {
  display: none;
}

.startup-tip p {
  margin: 0;
}

.startup-tip strong {
  color: var(--text-header);
}

.startup-tip-dismiss {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-body);
  cursor: pointer;
  border-radius: 4px;
}

.startup-tip-dismiss:hover {
  background: var(--bg-secondary);
  color: var(--text-header);
}

/* Print: when printing Legal, show only the legal document (user can Save as PDF) */
@media print {
  body.printing-legal * {
    visibility: hidden;
  }
  body.printing-legal #popup-overlay,
  body.printing-legal #popup-overlay .popup-bubble--hpp-legal,
  body.printing-legal #popup-overlay .popup-bubble--hpp-legal * {
    visibility: visible;
  }
  body.printing-legal #popup-overlay {
    position: static;
    inset: 0;
    background: #fff;
    padding: 0;
  }
  body.printing-legal #popup-overlay .popup-bubble--hpp-legal {
    position: static;
    width: 100%;
    max-width: none;
    max-height: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: #fff;
    color: #111;
    padding: 1rem 1.5rem;
  }
  body.printing-legal .popup-close,
  body.printing-legal .hpp-legal-print-row {
    display: none;
  }
  body.printing-legal #popup-overlay .popup-header h3 {
    color: #111;
  }
  body.printing-legal .hpp-legal-toc a,
  body.printing-legal .hpp-legal-body a {
    color: #333;
  }
}