.main-tools {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-start;
  flex-wrap: wrap;
  background: color-mix(in srgb, var(--surface-elevated) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.45rem;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.main-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  flex: 1 1 clamp(104px, 11vw, 144px);
  justify-content: center;
  min-height: 2.55rem;
}

.main-tool-btn .main-tool-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.main-tool-btn .main-tool-label {
  white-space: nowrap;
}

.main-tool-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 64%, var(--accent-muted) 36%);
  border-color: color-mix(in srgb, var(--border) 35%, var(--accent) 65%);
  transform: translateY(-1px);
}

.main-tool-btn.active {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #fff 18%), var(--accent) 100%);
  color: #fff;
  border-color: color-mix(in srgb, var(--accent) 90%, #000 10%);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

.main-tool-btn.active .main-tool-icon {
  opacity: 1;
}

.main-tool-btn.active:hover {
  background: var(--accent-hover);
  color: #fff;
}

/* Easy mode: larger touch targets (≥44px) and clearer selection for kids */
.main-tools.easy-mode .main-tool-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.6rem 1rem;
}
.main-tools.easy-mode .main-tool-btn.active {
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.08)), var(--accent);
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.75), 0 10px 22px rgba(0, 0, 0, 0.22);
}
.main-tools.easy-mode .main-tool-btn.active:active {
  transform: scale(1);
}

@media (max-width: 560px) {
  .main-tools {
    gap: 0.3rem;
    padding: 0.35rem;
  }

  .main-tool-btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    padding: 0.55rem 0.65rem;
    gap: 0.4rem;
  }

  .main-tool-btn .main-tool-label {
    font-size: 0.82rem;
  }
}

.app.workspace.painting-active .main-tools {
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(238, 226, 212, 0.94));
  border-color: rgba(106, 84, 62, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 4px 18px rgba(45, 32, 22, 0.1);
}

body.theme-dark .app.workspace.painting-active .main-tools {
  background: linear-gradient(180deg, rgba(42, 38, 34, 0.96), rgba(22, 20, 18, 0.98));
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 4px 18px rgba(0, 0, 0, 0.35);
}
.tool-size-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
}

.tool-size-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.tool-size-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.tool-size-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  border-radius: 6px;
}
.tool-size-btn:hover:not(:disabled) {
  background: var(--accent-muted);
  color: var(--accent);
}

.tool-size-value {
  min-width: 2ch;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.simple-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-content: center;
  padding: 0.5rem 0;
  max-width: 100%;
  box-sizing: border-box;
}

.simple-swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  padding: 0;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.simple-swatch:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.simple-swatch:active {
  transform: scale(0.95);
}

.simple-palette.sensitive-press .simple-swatch,
.simple-palette.easy-mode .simple-swatch {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
}
.simple-palette.sensitive-press .simple-swatch:active,
.simple-palette.easy-mode .simple-swatch:active {
  transform: scale(0.92);
}

.simple-palette.easy-mode .simple-swatch.selected {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.75), 0 0 0 6px var(--accent);
}

@media (max-width: 600px) {
  .simple-palette {
    gap: 0.35rem;
    padding: 0.25rem 0;
  }

  .simple-palette.sensitive-press .simple-swatch,
  .simple-palette.easy-mode .simple-swatch {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  .simple-palette-mixer-add {
    min-height: 2.5rem;
    font-size: 0.85rem;
  }
}

.simple-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg);
}

.simple-swatch-check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  font-weight: 700;
  font-size: 0.95rem;
}

.simple-swatch-add {
  background: color-mix(in srgb, var(--surface-elevated) 85%, var(--accent-muted));
  color: var(--accent);
  border: 1px dashed color-mix(in srgb, var(--accent) 60%, var(--border));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.simple-palette-mixer {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.55rem;
  align-items: end;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-elevated) 90%, transparent);
}

.simple-palette-mixer-color,
.simple-palette-mixer-ratio {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.simple-palette-mixer-color input[type='color'] {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius-sm);
  padding: 0;
  border: 1px solid var(--border);
  background: transparent;
}

.simple-palette-mixer-ratio input[type='range'] {
  width: min(180px, 38vw);
}

.simple-palette-mixer-add {
  min-height: 2.1rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .simple-palette-mixer {
    grid-template-columns: 1fr;
    gap: 0.45rem;
    align-items: stretch;
  }

  .simple-palette-mixer-ratio input[type='range'] {
    width: 100%;
  }
}
.menu-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.menu-panel-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-elevated) 92%, transparent);
}

.menu-panel-card-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.menu-panel-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

@media (min-width: 560px) {
  .menu-panel-section:not(:has(select:nth-of-type(2))) {
    display: grid;
    grid-template-columns: minmax(5.5rem, auto) 1fr auto;
    align-items: center;
    flex-wrap: nowrap;
  }

  .menu-panel-section:not(:has(select:nth-of-type(2))) .menu-panel-label {
    min-width: 0;
  }
}

.menu-panel-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 6rem;
}

.menu-panel-section input[type="range"] {
  flex: 1;
  max-width: 140px;
}

.menu-panel-section select {
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
}

.menu-panel-value {
  min-width: 2.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.menu-panel-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 10.5rem), 1fr));
  gap: 0.5rem;
  align-items: stretch;
}

.menu-panel-actions--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.menu-panel-actions button {
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  min-height: 2.5rem;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
}

.menu-panel-special-box {
  gap: 0.55rem;
}

.menu-panel-special-head {
  font-size: 0.84rem;
}

.menu-panel-special-font {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.menu-panel-special-font > span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.menu-panel-symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.2rem, 1fr));
  gap: 0.35rem;
}

.menu-panel-symbol-btn {
  min-height: 2.35rem;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

@media (max-width: 560px) {
  .menu-panel {
    gap: 0.9rem;
  }

  .menu-panel-card {
    padding: 0.6rem;
    gap: 0.6rem;
  }

  .menu-panel-section {
    gap: 0.55rem;
  }

  .menu-panel-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.color-palette {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.swatch:hover {
  transform: scale(1.06);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.swatch:active {
  transform: scale(0.96);
}

.color-palette.sensitive-press .swatches .swatch {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
}
.color-palette.sensitive-press .swatch:active {
  transform: scale(0.92);
}

.swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}

.swatch .check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  font-weight: 700;
  font-size: 0.9rem;
}

.swatch .remove-color {
  position: absolute;
  top: -3px;
  inset-inline-start: -3px;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swatch:hover .remove-color {
  opacity: 1;
}

.add-swatch {
  background: var(--surface-elevated) !important;
  border: 1px dashed var(--border) !important;
  color: var(--text-secondary) !important;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-swatch:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.spectrum-toggle-row {
  width: 100%;
  margin-top: 0.5rem;
}

.spectrum-toggle-btn {
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  color: var(--accent);
}

.spectrum-picker {
  width: 100%;
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.spectrum-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.25rem;
}

.spectrum-hue-strip-wrap {
  position: relative;
}

.spectrum-hue-slider {
  width: 100%;
  margin: 0.25rem 0;
  accent-color: var(--accent);
}

.spectrum-hue-bar {
  height: 10px;
  border-radius: 4px;
  margin-top: 0.25rem;
  pointer-events: none;
}

.spectrum-sl-box-wrap {
  position: relative;
  width: 100%;
  max-width: 200px;
  cursor: crosshair;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.spectrum-sl-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 140px;
  vertical-align: top;
}

.spectrum-sl-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.spectrum-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.spectrum-preview {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.spectrum-hex {
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
  color: var(--text-secondary);
}

.spectrum-use,
.spectrum-result .primary {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.mixer {
  background: var(--surface-elevated);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.mixer-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mixer-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.mixer-row input[type="color"] {
  width: 40px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}

.mixer-row input[type="range"] {
  width: 80px;
}

.mixer-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mixed-preview {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.mixed-hex {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: ui-monospace, monospace;
}

.current-color-display {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-right: auto;
  box-shadow: var(--shadow-sm);
}
.paint-style-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.paint-style-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.paint-style-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.paint-style-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.paint-style-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.1);
}

.paint-style-btn.active {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

.paint-style-icon {
  opacity: 0.85;
}

.paint-style-name {
  white-space: nowrap;
}

@media (max-width: 600px) {
  .paint-style-btn .paint-style-name {
    display: none;
  }
  .paint-style-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem;
  }
}

.app.workspace.painting-active .paint-style-bar {
  padding: 0.35rem 0.25rem;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.55), rgba(236, 224, 210, 0.45));
  border: 1px solid rgba(106, 84, 62, 0.15);
}

body.theme-dark .app.workspace.painting-active .paint-style-bar {
  background: linear-gradient(180deg, rgba(45, 40, 36, 0.9), rgba(28, 25, 22, 0.95));
  border-color: rgba(255, 255, 255, 0.08);
}
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.gallery-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.gallery-close {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.gallery-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.gallery-empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 2.5rem;
  margin: 0;
  font-size: 0.95rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.gallery-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
}

.gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.12);
}

.gallery-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.gallery-card-name {
  padding: 0.6rem 0.65rem;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0 0.5rem 0.6rem;
}

.gallery-btn {
  flex: 1;
  padding: 0.4rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.gallery-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.gallery-btn-delete:hover {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

.gallery-btn-edit {
  flex: 0 0 auto;
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

.gallery-btn-edit:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 101;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.gallery-lightbox img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.gallery-lightbox-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.gallery-lightbox-actions button {
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
}

.gallery-lightbox-actions .gallery-btn-delete {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.gallery-lightbox-actions .gallery-btn-delete:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.gallery-lightbox-actions .gallery-btn-edit {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.gallery-lightbox-actions .gallery-btn-edit:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.toast-container {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  padding-inline: max(0.75rem, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(420px, calc(100vw - 2rem));
  width: 100%;
  pointer-events: none;
}

.toast-container > * {
  pointer-events: auto;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md, 10px);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.16),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  animation: toast-in 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast-message {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  flex: 1;
}

.toast-info {
  background: var(--surface-elevated, #2a2a2e);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  color: var(--text, #f0f0f0);
}

.toast-success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.toast-close {
  flex-shrink: 0;
  padding: 0.2rem;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.75;
  cursor: pointer;
  border-radius: 4px;
}
.toast-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.toast-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.toast-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border, rgba(255,255,255,0.2));
  background: rgba(0, 0, 0, 0.2);
  color: var(--text, #f0f0f0);
}
.toast-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.toast-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.toast-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border, rgba(255,255,255,0.2));
  background: rgba(255, 255, 255, 0.08);
  color: var(--text, #f0f0f0);
  cursor: pointer;
}
.toast-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}
.toast-btn.primary {
  background: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
  color: #fff;
}
.toast-btn.primary:hover {
  filter: brightness(1.1);
}

.toast-prompt .toast-message,
.toast-confirm .toast-message {
  margin-bottom: 0;
}
.export-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.export-modal {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(720px, 96vw);
  max-width: 96vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.export-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.export-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.export-modal-close {
  padding: 0.35rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.export-modal-preview-wrap {
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 50vh;
  overflow: auto;
}

.export-modal-preview {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
}

.export-modal-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.export-modal-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
}

.export-modal-label span {
  min-width: 7rem;
}

.export-modal-select {
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.export-modal-slider {
  flex: 1;
  max-width: 200px;
  accent-color: var(--accent);
}

.export-modal-value {
  min-width: 2.5rem;
  font-variant-numeric: tabular-nums;
}

.export-modal-checkbox-row {
  min-height: 2.75rem;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 0.65rem;
}

.export-modal-checkbox-row input[type='checkbox'] {
  width: 1.2rem;
  height: 1.2rem;
  min-width: 1.2rem;
  accent-color: var(--accent);
}

.export-modal-checkbox-row span {
  min-width: 0 !important;
  flex: 1;
  width: auto !important;
}

.export-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.export-modal-actions .primary {
  margin-inline-start: auto;
}

@media (max-width: 560px) {
  .export-modal {
    width: 100%;
    max-height: 94vh;
  }

  .export-modal-label {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .export-modal-label span {
    min-width: 0;
    width: 100%;
  }

  .export-modal-slider {
    max-width: none;
    width: 100%;
  }

  .export-modal-actions .primary {
    margin-inline-start: 0;
  }

  .export-modal-actions button {
    flex: 1 1 calc(50% - 0.5rem);
  }
}
.flow-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

.flow-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 0;
}

.flow-editor-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: min(1080px, 100vw);
  max-height: 100dvh;
  margin: auto;
  display: flex;
  flex-direction: column;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

@media (min-width: 720px) {
  .flow-editor-shell {
    max-height: min(92vh, 920px);
    border-radius: var(--radius-lg);
    margin: 1rem auto;
    overflow: hidden;
  }
}

.flow-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
}

.flow-editor-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.flow-editor-close {
  flex-shrink: 0;
}

.flow-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.flow-editor-tool-btn {
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
}

.flow-editor-tool-btn:hover {
  border-color: var(--accent-muted);
  color: var(--accent);
}

.flow-editor-tool-btn.active {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent);
}

.flow-editor-tool-btn.danger {
  border-color: rgba(220, 38, 38, 0.35);
  color: #b91c1c;
}

.flow-editor-meta {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.flow-editor-meta select {
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
}

.flow-editor-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.flow-editor-canvas-wrap {
  flex: 1;
  min-height: 280px;
  overflow: auto;
  background: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 11px,
      rgba(15, 23, 42, 0.04) 11px,
      rgba(15, 23, 42, 0.04) 12px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 11px,
      rgba(15, 23, 42, 0.04) 11px,
      rgba(15, 23, 42, 0.04) 12px
    ),
    #f8fafc;
}

body.theme-dark .flow-editor-canvas-wrap {
  background: repeating-linear-gradient(0deg, transparent, transparent 11px, rgba(255, 255, 255, 0.03) 11px, rgba(255, 255, 255, 0.03) 12px),
    repeating-linear-gradient(90deg, transparent, transparent 11px, rgba(255, 255, 255, 0.03) 11px, rgba(255, 255, 255, 0.03) 12px),
    var(--surface);
}

.flow-editor-canvas {
  display: block;
  margin: 0 auto;
  touch-action: none;
  cursor: crosshair;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
}

.flow-editor-hint {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.flow-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.flow-editor-actions .primary {
  margin-inline-start: auto;
}

@media (max-width: 560px) {
  .flow-editor-meta {
    width: 100%;
    margin-inline-start: 0;
    justify-content: flex-start;
  }

  .flow-editor-actions .primary {
    margin-inline-start: 0;
    flex: 1 1 auto;
  }
}
.fun-panel {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

.fun-panel[open] {
  z-index: 4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.fun-panel-summary {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
  user-select: none;
}
.fun-panel-summary::-webkit-details-marker { display: none; }
.fun-panel-summary::before { content: '▸ '; opacity: 0.8; }
.fun-panel[open] .fun-panel-summary::before { content: '▾ '; }
.fun-panel-summary:hover { color: var(--accent); }

.fun-panel-body {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-sizing: border-box;
}

.fun-section-title {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.35;
}

/* גלילה אנכית + פס גלילה דק — אותם סטיקרים, רק אזור גלילה */
.fun-stickers-scroll-outer {
  position: relative;
  max-height: 6.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding-inline-end: 4px;
  margin-inline-end: 2px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 45%, var(--border)) color-mix(in srgb, var(--border) 35%, transparent);
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.fun-stickers-scroll-outer::-webkit-scrollbar {
  width: 6px;
}

.fun-stickers-scroll-outer::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--border) 25%, transparent);
  border-radius: 3px;
}

.fun-stickers-scroll-outer::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 40%, var(--border));
  border-radius: 3px;
}

.fun-stickers-scroll-outer::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.fun-stickers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  max-width: 100%;
}

@keyframes fun-sticker-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes fun-sticker-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1.08); }
}

.fun-sticker-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

@media (prefers-reduced-motion: no-preference) {
  .fun-sticker-btn {
    animation: fun-sticker-idle 2.8s ease-in-out infinite;
  }
  .fun-sticker-btn:nth-child(5n) { animation-delay: 0.2s; }
  .fun-sticker-btn:nth-child(5n + 1) { animation-delay: 0.5s; }
  .fun-sticker-btn:nth-child(5n + 2) { animation-delay: 0.1s; }
  .fun-sticker-btn:nth-child(5n + 3) { animation-delay: 0.7s; }
  .fun-sticker-btn:nth-child(5n + 4) { animation-delay: 0.35s; }
}

.fun-sticker-btn:hover {
  border-color: var(--accent-muted);
  transform: scale(1.08);
}
@media (prefers-reduced-motion: no-preference) {
  .fun-sticker-btn:hover {
    animation: fun-sticker-pop 0.45s ease-out both;
  }
}
.fun-sticker-btn.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
  transform: scale(1.05);
}
@media (prefers-reduced-motion: no-preference) {
  .fun-sticker-btn.selected {
    animation: none;
  }
}
.fun-sticker-btn:active {
  transform: scale(0.98);
}

.fun-sticker-hint {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--accent);
}

.fun-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fun-effect-btn {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.fun-effect-btn:hover {
  border-color: var(--accent-muted);
  transform: translateY(-1px);
}
.fun-effect-btn:active {
  transform: translateY(0) scale(0.98);
}
.geo-builder-modal {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.geo-builder-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.geo-builder-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.geo-builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.geo-builder-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.geo-builder-close {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.geo-builder-close:hover {
  background: var(--surface);
  color: var(--text);
}

.geo-builder-body {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  padding: 1rem 1.25rem 1.25rem;
}

.geo-builder-preview {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.geo-builder-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}
.geo-builder-preview-fallback {
  color: #555;
}

.geo-builder-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.geo-builder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--text);
}

.geo-builder-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  min-width: 90px;
}

.geo-builder-select {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  color: var(--text);
}

.geo-builder-range {
  flex: 1;
}

.geo-builder-create {
  margin-top: 0.25rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #0b1220;
  font-weight: 700;
}
.geo-builder-create:hover {
  filter: brightness(1.05);
}

@media (max-width: 520px) {
  .geo-builder-body {
    grid-template-columns: 1fr;
  }
  .geo-builder-preview {
    width: 100%;
    height: 200px;
  }
}

.confetti-burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
}

.confetti-particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: calc(var(--size) * 0.6);
  background: var(--color);
  border-radius: 1px;
  transform: rotate(var(--rot));
  animation: confetti-fall var(--duration) ease-out var(--delay) forwards;
  opacity: 0;
}

.confetti-particle:nth-child(odd) {
  border-radius: 50%;
  height: var(--size);
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(var(--rot));
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) rotate(calc(var(--rot) + 720deg));
  }
}
.sparkle-burst {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  pointer-events: none;
  z-index: 9998;
}

.sparkle-ray {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 35px;
  margin: -17px 0 0 -2px;
  background: linear-gradient(to top, rgba(255, 230, 100, 0.9), rgba(255, 200, 80, 0.4));
  border-radius: 2px;
  transform: rotate(var(--angle)) scale(0);
  animation: sparkle-pop 1s ease-out forwards;
}

@keyframes sparkle-pop {
  0% {
    transform: rotate(var(--angle)) scale(0);
    opacity: 1;
  }
  50% {
    transform: rotate(var(--angle)) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: rotate(var(--angle)) scale(0);
    opacity: 0;
  }
}

.sparkle-ray:nth-child(1) { animation-delay: 0ms; }
.sparkle-ray:nth-child(2) { animation-delay: 30ms; }
.sparkle-ray:nth-child(3) { animation-delay: 60ms; }
.sparkle-ray:nth-child(4) { animation-delay: 90ms; }
.sparkle-ray:nth-child(5) { animation-delay: 120ms; }
.sparkle-ray:nth-child(6) { animation-delay: 150ms; }
.sparkle-ray:nth-child(7) { animation-delay: 180ms; }
.sparkle-ray:nth-child(8) { animation-delay: 210ms; }
.sparkle-ray:nth-child(9) { animation-delay: 240ms; }
.sparkle-ray:nth-child(10) { animation-delay: 270ms; }
.sparkle-ray:nth-child(11) { animation-delay: 300ms; }
.sparkle-ray:nth-child(12) { animation-delay: 330ms; }
.paint-splash-burst {
  position: fixed;
  width: 0;
  height: 0;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 9998;
  transform: translate(-50%, -50%);
}

.paint-splash-drop {
  position: absolute;
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--splash-color, #3b82f6);
  box-shadow:
    0 0 10px var(--splash-color, #3b82f6),
    0 0 4px rgba(255, 255, 255, 0.5);
  opacity: 0;
  animation: paint-splash-fly 0.7s cubic-bezier(0.22, 0.82, 0.28, 1) forwards;
  animation-delay: var(--splash-delay, 0ms);
}

@keyframes paint-splash-fly {
  0% {
    transform: rotate(var(--splash-angle, 0deg)) translate(0, 0) scale(0.2);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  45% {
    transform: rotate(var(--splash-angle, 0deg)) translate(0, calc(-1 * var(--splash-dist, 48px))) scale(1.15);
    opacity: 0.95;
  }
  100% {
    transform: rotate(var(--splash-angle, 0deg)) translate(0, calc(-1 * var(--splash-dist, 48px) * 1.45)) scale(0.25);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .paint-splash-drop {
    animation-duration: 0.15s;
  }
}
.canvas-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.canvas-viewport-inner {
  display: inline-block;
  line-height: 0;
  max-width: 100%;
  will-change: transform;
  transition: transform 0.08s ease-out;
}

.canvas-viewport-inner.is-interacting {
  transition: none;
}

.canvas-zoom-controls {
  position: absolute;
  bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
  inset-inline-start: max(0.35rem, env(safe-area-inset-inline-start, 0px));
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.canvas-zoom-btn {
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.canvas-zoom-btn:hover:not(:disabled) {
  background: var(--accent-muted);
  color: var(--accent);
}

.canvas-zoom-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.canvas-zoom-reset {
  font-size: 0.75rem;
  margin-inline-start: 0.25rem;
}

.canvas-zoom-value {
  min-width: 2.25rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(0.75rem, 1.8vw, 1.25rem);
  padding-left: max(clamp(0.75rem, 1.8vw, 1.25rem), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(0.75rem, 1.8vw, 1.25rem), env(safe-area-inset-right, 0px));
  width: 100%;
  max-width: none;
  margin: 0;
  overflow-x: hidden;
}

@keyframes magic-float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}

@keyframes sparkle {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

@keyframes star-twinkle {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes kid-bg-shift {
  0% { background-position: 0% 0%, 100% 0%, 50% 100%, 0% 0%; }
  50% { background-position: 20% 10%, 80% 10%, 50% 90%, 0% 0%; }
  100% { background-position: 0% 0%, 100% 0%, 50% 100%, 0% 0%; }
}

@keyframes kid-noise-drift {
  0% { transform: translate3d(0, 0, 0); opacity: 0.22; }
  50% { transform: translate3d(-2%, 1%, 0); opacity: 0.26; }
  100% { transform: translate3d(0, 0, 0); opacity: 0.22; }
}

@keyframes kid-star-fly {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(0.9);
    opacity: 0;
  }
  12% { opacity: 1; }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1.1);
    opacity: 0;
  }
}

.kid-star-trail {
  position: fixed;
  width: 1px;
  height: 1px;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 999;
}

.kid-star {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--size);
  height: var(--size);
  transform: translate(0,0);
  animation: kid-star-fly 700ms cubic-bezier(.16,.84,.27,1) forwards;
  animation-delay: var(--delay);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.22));
}

.kid-star::before {
  content: "★";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--size) * 0.95);
  line-height: 1;
  color: var(--color);
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.22);
  opacity: 0.95;
}

@media (prefers-reduced-motion: reduce) {
  .kid-star-trail { display: none; }
  .welcome-menu-toggle-icon { animation: none; }
}

.app.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  text-align: center;
  padding: 2rem 1.5rem 5rem;
  min-height: 100vh;
  position: relative;
  background:
    radial-gradient(1000px 600px at 15% 15%, rgba(255, 182, 193, 0.2), transparent 50%),
    radial-gradient(800px 500px at 85% 25%, rgba(135, 206, 250, 0.18), transparent 50%),
    radial-gradient(700px 500px at 50% 95%, rgba(186, 255, 201, 0.12), transparent 55%),
    radial-gradient(600px 400px at 70% 60%, rgba(255, 218, 185, 0.1), transparent 45%);
}
.app.welcome:not(.child-mode) {
  background-color: var(--bg);
}

.welcome-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.welcome-app-logo {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: contain;
  animation: magic-float 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 16px rgba(244, 165, 116, 0.35)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
  position: relative;
}

.welcome-cover {
  display: block;
  width: min(520px, 92vw);
  height: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.28),
    0 8px 20px rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

.welcome-cover-wrap {
  position: relative;
  width: min(520px, 92vw);
  border-radius: 18px;
  overflow: hidden;
}

.welcome-cover-wrap .welcome-cover {
  width: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: block;
}

.welcome-cover-actions-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  box-sizing: border-box;
}

/* פאנל כפתורים בתחתית הכריכה — פחות התנגשות עם אמצע התמונה (מיוחד לכריכה ריבועית / צפופה) */
.welcome-cover-actions-center-start {
  place-items: end center;
  align-content: end;
  padding: 0.65rem;
  padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
}

.welcome-cover-actions-block {
  width: min(420px, 86%);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 20, 25, 0.55);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.welcome-source-grid-oncover {
  margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem;
}

.welcome-cover-actions-block .welcome-source-grid-oncover .welcome-source-btn {
  min-width: 0;
  min-height: 4.25rem;
  padding: 0.75rem 0.45rem;
}

.welcome-cover-actions-block .welcome-source-label {
  word-break: break-word;
  hyphens: auto;
}

.welcome-child-inline-oncover {
  margin-top: 0.35rem;
  max-width: none;
  width: 100%;
}

.app.welcome.child-mode .welcome-child-inline-oncover {
  max-width: none;
}

.welcome-child-inline-oncover .welcome-drawer-section {
  gap: 0.65rem;
}

.welcome-child-inline-oncover .welcome-drawer-section {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

@media (min-width: 720px) {
  .welcome-cover-wrap {
    width: min(680px, 92vw);
  }
  .welcome-cover-actions-block {
    width: min(520px, 94%);
    padding: 1rem;
  }
}

@media (max-width: 360px) {
  .welcome-cover-actions-block .welcome-source-grid-oncover {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 440px) {
  .welcome-source-grid {
    grid-template-columns: 1fr;
  }

  .welcome-source-btn {
    min-height: 3.8rem;
  }
}

.app.welcome .welcome-header-simple .welcome-hero {
  gap: 1rem;
}

.app.welcome .welcome-header-simple h1 {
  margin-top: 0.25rem;
}

.app.welcome .welcome-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4.5vw, 2rem);
  font-weight: 700;
  margin: 0;
  color: #b45309;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(180, 83, 9, 0.15);
  line-height: 1.2;
}
.app.welcome:not(.child-mode) .welcome-header h1,
.app.welcome.welcome-choose-mode .welcome-header h1 {
  color: var(--text);
  text-shadow: none;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.app.welcome.child-mode .welcome-header h1 {
  font-family: var(--font-display-playful);
}
body.theme-dark .app.welcome .welcome-header h1 {
  color: #fbbf24;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
body.theme-dark .app.welcome:not(.child-mode) .welcome-header h1,
body.theme-dark .app.welcome.welcome-choose-mode .welcome-header h1 {
  color: var(--text);
  text-shadow: none;
}

.app.welcome .welcome-header p {
  color: var(--text-secondary);
  max-width: 420px;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
}
.app.welcome .welcome-header p.welcome-tagline {
  color: #92400e;
}
body.theme-dark .app.welcome .welcome-header p.welcome-tagline {
  color: #fcd34d;
}

.welcome-header-simple {
  flex-direction: column;
  gap: 0.5rem;
}

.welcome-tagline {
  font-size: 0.95rem !important;
}

.welcome-choose-mode {
  justify-content: flex-start;
  padding-top: 3rem;
}

.welcome-choose-mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  max-width: 380px;
  margin-top: 2rem;
}

.welcome-language-gate {
  justify-content: center;
  background: var(--bg) !important;
}

.welcome-language-buttons {
  max-width: 460px;
}

@media (max-width: 680px) {
  .welcome-language-gate,
  .app.welcome.welcome-choose-mode {
    min-height: 100dvh;
    padding:
      max(14px, env(safe-area-inset-top, 0px))
      14px
      max(14px, env(safe-area-inset-bottom, 0px));
  }

  .welcome-language-buttons,
  .welcome-cover-actions-block {
    width: 100%;
    max-width: none;
    max-height: min(56dvh, 460px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .welcome-cover-actions-block .welcome-drawer-btn,
  .welcome-language-buttons .welcome-choose-mode-btn {
    min-height: 52px;
    width: 100%;
    font-size: 1rem;
    border-radius: 14px;
  }

  /* בחירת מצב (אחרי שפה): כמה כפתורים — בלי תיבת גלילה צרה */
  .app.welcome.welcome-choose-mode .welcome-cover-actions-block {
    max-height: none;
    overflow-y: visible;
  }

  .welcome-header .welcome-hero h1 {
    font-size: clamp(1.35rem, 5.5vw, 1.8rem);
  }
}

@media (max-width: 420px) {
  .app.welcome {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }

  .welcome-cover-actions-center-start {
    padding: 0.5rem;
  }

  .welcome-cover-actions-block {
    padding: 0.72rem;
    border-radius: 14px;
    width: min(100%, 360px);
  }

  .welcome-cover-actions-block .welcome-source-grid-oncover .welcome-source-btn,
  .welcome-cover-actions-block .welcome-drawer-btn {
    min-height: 48px;
    padding: 0.62rem 0.45rem;
    font-size: 0.94rem;
  }

  .welcome-source-grid-oncover {
    grid-template-columns: 1fr;
  }
}

/* Startup screen: remove banner/hero image and use a clean solid background */
.app.welcome.welcome-choose-mode {
  background: var(--bg) !important;
}

.app.welcome.welcome-choose-mode .welcome-cover-wrap {
  display: none;
}

/*
 * מסך "למי האפליקציה?" מגיע מיד אחרי בחירת שפה. הכריכה מוסתרת אבל .welcome-cover-actions-center
 * היה עם position:absolute + inset:0 ביחס ל-header — כך שהפריסה קרסה (גובה ה-hero לא כלל את הכפתורים,
 * והכפתורים נדבקו לפינות / חפפו את הכותרת).
 */
.app.welcome.welcome-choose-mode .welcome-cover-actions-center {
  position: relative;
  inset: auto;
  display: flex;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
  padding: 0 0.75rem;
  box-sizing: border-box;
}

.app.welcome.welcome-choose-mode .welcome-cover-actions-block {
  width: 100%;
  max-width: 100%;
}

.welcome-choose-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  text-align: center;
}

.welcome-choose-mode-btn:hover {
  border-color: var(--accent-muted);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.welcome-choose-mode-btn.child {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 50%, #fcd34d 100%);
  color: #92400e;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}
.welcome-choose-mode-btn.child:hover {
  border-color: #d97706;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

.welcome-choose-mode-btn.companion {
  border-color: #0ea5e9;
  background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 50%, #7dd3fc 100%);
  color: #0369a1;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.25);
}
.welcome-choose-mode-btn.companion:hover {
  border-color: #0284c7;
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.35);
}

.welcome-choose-mode-icon {
  font-size: 2.5rem;
}

.welcome-choose-mode-label {
  font-size: 1.25rem;
}

.welcome-choose-mode-desc {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.35;
}

.welcome-child-inline {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.welcome-child-inline .welcome-source-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.app.welcome.child-mode {
  position: relative;
  background:
    radial-gradient(1200px 700px at 20% 10%, rgba(255, 182, 193, 0.22), transparent 55%),
    radial-gradient(900px 600px at 90% 20%, rgba(135, 206, 250, 0.18), transparent 55%),
    radial-gradient(900px 600px at 50% 100%, rgba(186, 255, 201, 0.14), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.0));
  animation: kid-bg-shift 14s ease-in-out infinite;
  overflow: hidden;
}

.app.welcome.child-mode::before {
  content: '';
  position: absolute;
  inset: -18%;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.14), transparent 35%),
    radial-gradient(circle at 75% 20%, rgba(255, 255, 255, 0.10), transparent 30%),
    radial-gradient(circle at 50% 80%, rgba(255, 255, 255, 0.10), transparent 40%);
  filter: blur(18px);
  opacity: 0.5;
  animation: kid-noise-drift 10s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

/* subtle grain texture */
.app.welcome.child-mode::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.02) 0, rgba(0,0,0,0.02) 1px, transparent 1px, transparent 4px);
  opacity: 0.18;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 0;
}

.app.welcome.child-mode > * {
  position: relative;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .app.welcome.child-mode { animation: none; }
  .app.welcome.child-mode::before { animation: none; }
}

.app.welcome.child-mode .welcome-header {
  padding: 0.25rem 0 0.25rem;
}

.app.welcome.child-mode .welcome-app-logo {
  filter: drop-shadow(0 8px 24px rgba(244, 165, 116, 0.35)) drop-shadow(0 10px 40px rgba(107, 159, 255, 0.18));
}

.app.welcome.child-mode .welcome-tagline {
  font-size: 1rem !important;
}

.app.welcome.child-mode .welcome-child-inline {
  max-width: 460px;
}

.app.welcome.child-mode .welcome-child-inline .welcome-drawer-section {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  box-shadow: 0 10px 30px rgba(0,0,0,0.16);
  padding: 0.9rem;
}

.app.welcome.child-mode .welcome-child-inline .welcome-source-grid {
  gap: 0.85rem;
}

.app.welcome.child-mode .welcome-source-btn {
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.16);
  min-height: 4.4rem;
  padding: 0.95rem 0.65rem;
  transform: translateY(0);
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(1) {
  border: 2px solid #60a5fa;
  background: linear-gradient(180deg, #93c5fd 0%, #60a5fa 100%);
  color: #1e3a8a;
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(2) {
  border: 2px solid #34d399;
  background: linear-gradient(180deg, #6ee7b7 0%, #34d399 100%);
  color: #064e3b;
}
.app.welcome.child-mode .welcome-source-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(1):hover {
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
  border-color: #2563eb;
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(2):hover {
  background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
  border-color: #059669;
}
.app.welcome.child-mode .welcome-source-btn:active {
  transform: translateY(0) scale(0.98);
}

.app.welcome.child-mode .welcome-source-icon {
  font-size: 1.9rem;
}

.app.welcome.child-mode .welcome-source-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.app.welcome.child-mode .welcome-child-inline .welcome-drawer-btn {
  border-radius: 18px;
  border: 2px solid;
  box-shadow: 0 10px 22px rgba(0,0,0,0.14);
  font-weight: 800;
  letter-spacing: -0.01em;
  min-height: 2.9rem;
}
.app.welcome.child-mode .welcome-child-inline .welcome-drawer-section .welcome-drawer-btn:nth-child(1) { background: linear-gradient(180deg, #fef08a 0%, #fde047 100%); border-color: #facc15; color: #a16207; }
.app.welcome.child-mode .welcome-child-inline .welcome-drawer-section .welcome-drawer-btn:nth-child(2) { background: linear-gradient(180deg, #fbcfe8 0%, #f9a8d4 100%); border-color: #f472b6; color: #9d174d; }
.app.welcome.child-mode .welcome-child-inline .welcome-drawer-section .welcome-drawer-btn:nth-child(3) { background: linear-gradient(180deg, #a7f3d0 0%, #6ee7b7 100%); border-color: #34d399; color: #047857; }
.app.welcome.child-mode .welcome-child-inline .welcome-drawer-section .welcome-drawer-btn:nth-child(4) { background: linear-gradient(180deg, #c4b5fd 0%, #a78bfa 100%); border-color: #8b5cf6; color: #4c1d95; }
.app.welcome.child-mode .welcome-child-inline .welcome-drawer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
}
.app.welcome.child-mode .welcome-child-inline .welcome-drawer-btn:active {
  transform: translateY(0) scale(0.99);
}

.app.welcome.child-mode .welcome-footer-audit {
  background: rgba(15, 20, 25, 0.62);
}

.welcome-child-inline .welcome-drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.welcome-child-inline .welcome-drawer-btn {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
}

.main-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding:
    max(2rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(4rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
  overflow-y: auto;
}

@media (min-width: 768px) {
  .main-menu-overlay {
    align-items: center;
    padding: 1.5rem 1.25rem;
  }
}

.main-menu-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.main-menu-overlay-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: min(85vh, 85dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: calc(var(--radius-lg) + 2px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg, 0 12px 40px rgba(0, 0, 0, 0.35));
}

@media (max-width: 420px) {
  .main-menu-overlay {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  }

  .main-menu-overlay-panel {
    max-height: min(92dvh, 92vh);
    border-radius: 14px;
  }
}

@media (min-width: 768px) {
  .main-menu-overlay-panel {
    max-width: min(480px, 92vw);
    max-height: min(88vh, 88dvh);
  }
}

.main-menu-overlay-panel > .drawer-panel-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-radius: calc(var(--radius-lg) + 2px) calc(var(--radius-lg) + 2px) 0 0;
}

@keyframes bear-flag-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.05); }
}

.welcome-menu-toggle {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem 0 0.6rem;
  height: 48px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fde047 0%, #facc15 50%, #eab308 100%);
  border: 2px solid #f59e0b;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: #78350f;
  font-size: 1.05rem;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.welcome-menu-toggle:hover {
  border-color: #d97706;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: scale(1.03);
}
.welcome-menu-toggle:active {
  transform: scale(0.98);
}
.welcome-menu-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: bear-flag-bounce 1.8s ease-in-out infinite;
}
.welcome-menu-toggle:hover .welcome-menu-toggle-icon {
  animation-duration: 1s;
}
.welcome-menu-toggle-label {
  letter-spacing: 0.02em;
}

.welcome-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 98;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.welcome-drawer-overlay[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

.welcome-drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 99;
  max-height: min(90vh, 90dvh);
  overflow-y: auto;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 12%, #fff 30%, var(--surface) 100%);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 0 1.25rem 1.5rem;
  transform: translateY(-100%);
  transition: transform 0.3s ease-out;
  border: 1px solid var(--border);
  border-top: none;
}
body.theme-dark .welcome-drawer-panel {
  background: linear-gradient(180deg, #422006 0%, #1c1917 25%, var(--surface) 100%);
}

.welcome-drawer-panel[data-open="true"] {
  transform: translateY(0);
}

.welcome-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 2px solid rgba(251, 191, 36, 0.4);
  background: linear-gradient(90deg, rgba(254, 243, 199, 0.9), rgba(253, 230, 138, 0.5));
  position: sticky;
  top: 0;
  z-index: 2;
}
body.theme-dark .welcome-drawer-header {
  border-bottom-color: rgba(251, 191, 36, 0.3);
  background: linear-gradient(90deg, rgba(120, 53, 15, 0.5), rgba(68, 36, 10, 0.3));
}

.welcome-drawer-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #b45309;
}
body.theme-dark .welcome-drawer-header h2 {
  color: #fbbf24;
}

.welcome-drawer-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 0;
}

.welcome-drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.welcome-drawer-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 0.25rem;
}
body.theme-dark .welcome-drawer-section-title {
  color: #fcd34d;
}

.welcome-drawer-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
  line-height: 1.35;
}

.welcome-source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.welcome-source-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 4.2rem;
  gap: 0.35rem;
  padding: 0.8rem 0.55rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
/* מבוגרים / מלווה — כפתורי פעולה אחידים */
.app.welcome:not(.child-mode) .welcome-source-btn,
.app.workspace:not(.child-mode) .welcome-source-btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.app.welcome:not(.child-mode) .welcome-source-btn:hover,
.app.workspace:not(.child-mode) .welcome-source-btn:hover {
  background: color-mix(in srgb, var(--surface) 70%, var(--accent-muted) 30%);
  border-color: color-mix(in srgb, var(--border) 40%, var(--accent) 60%);
  color: var(--accent-dark);
}
.app.welcome:not(.child-mode) .welcome-cover-actions-block,
.app.welcome.welcome-choose-mode .welcome-cover-actions-block {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-color: var(--border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}

/* צבעים לילדים – כל כפתור בגוון אחר */
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(1),
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn:nth-child(1) {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: #93c5fd;
  color: #1e40af;
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(2),
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn:nth-child(2) {
  background: linear-gradient(180deg, #d1fae5 0%, #a7f3d0 100%);
  border-color: #6ee7b7;
  color: #047857;
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(3),
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn:nth-child(3) {
  background: linear-gradient(180deg, #ede9fe 0%, #ddd6fe 100%);
  border-color: #c4b5fd;
  color: #5b21b6;
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(4),
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn.welcome-source-search,
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn:nth-child(4),
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn.welcome-source-search {
  background: linear-gradient(180deg, #ffedd5 0%, #fed7aa 100%);
  border-color: #fdba74;
  color: #c2410c;
}
.welcome-source-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(1):hover,
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn:nth-child(1):hover {
  background: linear-gradient(180deg, #bfdbfe 0%, #93c5fd 100%);
  border-color: #60a5fa;
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(2):hover,
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn:nth-child(2):hover {
  background: linear-gradient(180deg, #a7f3d0 0%, #6ee7b7 100%);
  border-color: #34d399;
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(3):hover,
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn:nth-child(3):hover {
  background: linear-gradient(180deg, #ddd6fe 0%, #c4b5fd 100%);
  border-color: #a78bfa;
}
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn:nth-child(4):hover,
.app.welcome.child-mode .welcome-source-grid .welcome-source-btn.welcome-source-search:hover,
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn:nth-child(4):hover,
.app.workspace.child-mode .welcome-source-grid .welcome-source-btn.welcome-source-search:hover {
  background: linear-gradient(180deg, #fed7aa 0%, #fdba74 100%);
  border-color: #fb923c;
}

.welcome-source-icon {
  font-size: 1.5rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.welcome-source-icon i {
  display: inline-block;
}
.welcome-drawer-btn i {
  display: inline-block;
  margin-left: 0.4rem;
}
.welcome-drawer-btn i:first-child {
  margin-left: 0;
  margin-right: 0.4rem;
}
.welcome-drawer-btn i:only-child {
  margin: 0;
}

.welcome-source-label {
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.welcome-drawer-section-search {
  margin-top: 0.25rem;
}

.welcome-blank-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.welcome-size-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.welcome-size-btn:hover {
  border-color: var(--accent-muted);
  color: var(--text);
}
.welcome-size-btn.selected {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent);
}

.welcome-abc-one-page {
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
  border-radius: var(--radius-btn);
}
.welcome-abc-one-page:hover {
  background: var(--accent-muted);
  border-color: var(--accent-hover);
}

.welcome-compose-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.35rem;
  line-height: 1.35;
}

.welcome-compose-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.welcome-compose-input {
  flex: 1;
  min-width: 140px;
  padding: 0.6rem 0.85rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
}

.welcome-compose-input:focus {
  outline: none;
  border-color: var(--accent);
}

.welcome-compose-btn {
  padding: 0.7rem 1.2rem;
  white-space: nowrap;
  border-radius: var(--radius-btn);
  font-weight: 600;
}

.welcome-drawer-btn {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 1rem;
  text-align: center;
  border-radius: var(--radius-btn);
  font-weight: 600;
  background: color-mix(in srgb, var(--surface-elevated) 88%, var(--accent-muted) 12%);
  border: 1px solid color-mix(in srgb, var(--border) 52%, var(--accent) 48%);
  color: var(--text);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
}
.welcome-drawer-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  background: color-mix(in srgb, var(--surface-elevated) 72%, var(--accent-muted) 28%);
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
}

.welcome-drawer-btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.welcome-drawer-chars {
  max-height: 8rem;
  overflow-y: auto;
}

.welcome-search {
  width: 100%;
  max-width: 420px;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.welcome-search-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.welcome-search-source-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.25rem;
  line-height: 1.4;
}

.welcome-search-primary {
  white-space: nowrap;
}

.welcome-search-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.welcome-search-input {
  flex: 1;
  min-width: 140px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
}

.welcome-search-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
}

.welcome-search-suggestions-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-inline-end: 0.35rem;
}

.welcome-search-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}

.welcome-search-secondary-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.welcome-search-secondary-btn {
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
}

.welcome-search-error {
  font-size: 0.85rem;
  color: #ffb3b3;
}

.welcome-search-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.welcome-search-result {
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  aspect-ratio: 1 / 1;
}

.welcome-search-result:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.welcome-search-result img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-search-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.image-search-modal {
  width: min(860px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1rem;
  text-align: right;
}

.image-search-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.image-search-modal-title {
  font-weight: 700;
  color: var(--text);
}

.image-search-modal-close {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-search-modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.image-search-modal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

@media (max-width: 680px) {
  .image-search-modal-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.image-search-modal-item {
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  aspect-ratio: 1 / 1;
}

.image-search-modal-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.image-search-modal-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-search-modal-hint {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.image-search-modal-google {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.welcome-suggestion-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.welcome-suggestion-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.welcome-default-pages {
  width: 100%;
  max-width: 520px;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.welcome-default-pages-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.welcome-default-pages-row {
  margin-bottom: 0.75rem;
}

.welcome-default-pages-row:last-child {
  margin-bottom: 0;
}

.welcome-default-pages-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.welcome-default-pages-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.welcome-default-char-btn {
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.welcome-default-char-btn:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

.welcome-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.welcome-btn,
.upload-actions button {
  padding: 0.7rem 1.25rem;
  font-weight: 500;
  border-radius: var(--radius-md);
}

.upload-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.welcome-btn-room {
  border: 1px solid var(--accent);
  color: var(--accent);
}

.room-invite-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.room-invite-modal {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.25rem;
  text-align: right;
}

.room-invite-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.room-invite-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.room-invite-close {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.room-invite-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.room-invite-hint {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0 0 1rem;
  line-height: 1.4;
}

.room-invite-name-row {
  margin-bottom: 1rem;
}

.room-invite-name-row label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.room-invite-name-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.room-invite-link-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.room-invite-copy {
  white-space: nowrap;
}

.room-invite-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
}

.drawer-room-block {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.drawer-room-block strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text);
  font-size: 0.9rem;
}

.drawer-room-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.drawer-room-name-row {
  margin-bottom: 0.5rem;
}

.drawer-room-name-row label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.drawer-room-name-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
}

.drawer-room-link-row {
  display: flex;
  gap: 0.4rem;
}

.drawer-room-input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--text);
}

.drawer-room-copy {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.room-live-bar {
  margin-top: 0.5rem;
  padding: 0 0.25rem;
  font-size: 0.8rem;
}

.room-live-details {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.room-live-summary {
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  color: var(--text-secondary);
  list-style: none;
  user-select: none;
}
.room-live-summary::-webkit-details-marker { display: none; }
.room-live-summary::before { content: '▸ '; opacity: 0.7; }
.room-live-details[open] .room-live-summary::before { content: '▾ '; }
.room-live-summary:hover { color: var(--text); }

.room-live-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0.75rem 0.6rem;
  max-height: 140px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.room-live-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.room-live-item:last-child { border-bottom: none; }
.room-live-who { color: var(--text); font-weight: 500; }
.room-live-when { color: var(--text-secondary); white-space: nowrap; }

.undo-redo-bar {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  margin-top: 0.5rem;
  margin-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  z-index: 30;
}

/* Paint-first fullscreen mode: keep canvas dominant and float controls above palette. */
.app.workspace.painting-active .undo-redo-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--bottom-colors-height) + 0.35rem + env(safe-area-inset-bottom, 0px));
  margin: 0;
  z-index: 45;
}

.undo-redo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.undo-redo-btn:hover:not(:disabled) {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}
.undo-redo-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .undo-redo-bar {
    gap: 0.5rem;
    padding: 0.45rem 0.7rem;
    margin-top: 0.3rem;
    margin-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .app.workspace.painting-active .undo-redo-bar {
    bottom: calc(var(--bottom-colors-height) + 0.25rem + env(safe-area-inset-bottom, 0px));
  }

  .workspace-header-actions {
    gap: 0.35rem;
  }

  .workspace-top-btn,
  .workspace-mode-btn,
  .workspace-expand-mode-btn {
    min-height: 42px;
  }

  .workspace-tools-edge-tab,
  .colors-drawer-tab {
    min-height: 42px;
    min-width: 42px;
  }
}

.live-update-toast {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  animation: live-toast-in 0.25s ease-out;
}

.live-update-toast-bottom {
  margin-top: 0.5rem;
  text-align: center;
  align-self: center;
}

.live-update-toast-text {
  font-weight: 500;
}

.video-stop-fab {
  position: fixed;
  right: max(0.9rem, env(safe-area-inset-right, 0px));
  bottom: calc(var(--bottom-colors-height) + 0.85rem + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  border-radius: 999px;
  border: 1px solid #dc2626;
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(220, 38, 38, 0.35);
}

.video-stop-fab:hover {
  background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
  border-color: #ef4444;
}

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

.app.workspace:not(.welcome) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  max-height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  --bottom-colors-height: clamp(92px, 15dvh, 142px);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 0;
}

.workspace-header-start {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding:
    max(0.35rem, env(safe-area-inset-top, 0px))
    max(0.5rem, env(safe-area-inset-right, 0px))
    0.35rem
    max(0.5rem, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(var(--header-blur));
  -webkit-backdrop-filter: blur(var(--header-blur));
}

@media (min-width: 768px) {
  .workspace-header {
    gap: 0.75rem;
    padding:
      max(0.5rem, env(safe-area-inset-top, 0px))
      max(1rem, env(safe-area-inset-right, 0px))
      0.5rem
      max(1rem, env(safe-area-inset-left, 0px));
  }
}

@media (max-width: 480px) {
  .workspace-header {
    flex-wrap: wrap;
    align-items: flex-start;
    row-gap: 0.5rem;
  }

  .workspace-header-start {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  .workspace-header-actions {
    flex: 1 1 auto;
    justify-content: flex-end;
    margin-inline-start: 0;
    gap: 0.4rem;
    width: 100%;
  }

  .workspace-header-actions > * {
    flex: 1 1 auto;
    min-width: 0;
  }

  .workspace-current-color--header {
    width: 100%;
    justify-content: flex-start;
  }
}

body.theme-dark .workspace-header {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.workspace-back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.workspace-back-home:hover {
  color: var(--accent);
}

.workspace-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-inline-start: auto;
}

.workspace-top-btn {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 500;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.workspace-top-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--border) 50%, var(--accent) 50%);
  background: color-mix(in srgb, var(--surface) 75%, var(--accent-muted) 25%);
}
.app.workspace.child-mode .workspace-back-home {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e3a8a;
  border-color: #93c5fd;
}
.app.workspace.child-mode .workspace-name-btn {
  background: linear-gradient(180deg, #fce7f3 0%, #fbcfe8 100%);
  color: #9d174d;
  border-color: #f9a8d4;
}
.app.workspace.child-mode .drawer-toggle {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
  color: #166534;
  border-color: #86efac;
}

.workspace-mode-btn {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
}
.workspace-mode-btn:hover {
  border-color: var(--accent-muted);
  color: var(--text);
}
.workspace-mode-btn.active {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent);
}
.workspace-mode-btn.expert.active {
  background: var(--accent-muted);
  color: var(--accent);
}

.workspace-expand-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
}
.workspace-expand-mode-btn:hover {
  border-color: var(--accent-muted);
  color: var(--accent);
}
.workspace-expand-mode-btn .icon-svg {
  opacity: 0.9;
}

.workspace-main-bar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 0;
}

.workspace-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  flex: 1;
  min-height: 0;
  position: relative;
}

@media (min-width: 1100px) {
  .workspace-body {
    max-width: min(1700px, 100%);
    margin-inline: auto;
    width: 100%;
  }

  .workspace-body--editor-layout.workspace-body {
    max-width: none;
    margin-inline: 0;
    width: 100%;
  }
}

.app.workspace.colors-drawer-open .workspace-body {
  padding-bottom: 220px;
}

.workspace-body .canvas-area {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: clamp(240px, 50dvh, 760px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0;
  border: none;
  border-radius: 0;
  background: var(--surface);
  position: relative;
  z-index: 0;
  /* מונע גלילה על ה-main — אחרת הקנבס “נדבק” לראש ולא נראה ממורכז ב-web */
  overflow: hidden;
}

@media (max-width: 600px) {
  .workspace-body .canvas-area {
    min-height: clamp(210px, 42dvh, 560px);
    padding: 0;
  }
}

.workspace-body .canvas-area.split-mode {
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
}

.workspace-body .canvas-area .canvas-viewport {
  flex: 1;
  width: 100%;
  min-height: 0;
  min-width: 0;
}

.workspace-body .canvas-area.split-mode .canvas-viewport {
  flex: 0 1 50%;
  min-width: 0;
}

/* עורך: כלים במגירה מהצד, קנבס ממוסגר — לא רצועה על כל רוחב המסך */
.workspace-body--editor-layout {
  gap: 0;
}

.workspace-body--editor-layout .workspace-editor-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  width: 100%;
  position: relative;
  padding-bottom: 0;
}

.workspace-tools-backdrop {
  display: none;
  appearance: none;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  pointer-events: none;
}

@media (max-width: 899px) {
  .workspace-tools-backdrop.is-visible {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 18;
    background: rgba(0, 0, 0, 0.38);
    pointer-events: auto;
    cursor: pointer;
  }
}

@media (min-width: 900px) {
  .workspace-tools-backdrop {
    display: none !important;
  }
}

.workspace-tools-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 0 0 auto;
  min-height: 0;
  max-height: 100%;
  position: relative;
  z-index: 22;
  isolation: isolate;
}

.workspace-tools-shell.no-pointer {
  pointer-events: none;
}

.workspace-tools-edge-tab {
  flex-shrink: 0;
  width: 2.65rem;
  min-height: 5.5rem;
  margin: 0;
  padding: 0.35rem 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-elevated) 94%, var(--accent-muted));
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  line-height: 1.2;
  box-shadow: var(--shadow-sm);
  align-self: center;
}

.workspace-tools-edge-tab:hover {
  background: var(--surface);
}

.workspace-tools-edge-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.workspace-body--editor-layout .workspace-tools-panel.drawer-panel-tools.open {
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: clamp(250px, 22vw, 380px);
  border-top: none;
  border-bottom: none;
  border-inline: 1px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow-sm);
}

.workspace-tools-shell:not(.is-open) .workspace-tools-panel {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0;
  margin: 0;
  border: none;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  flex: 0 0 0 !important;
}

@media (max-width: 899px) {
  .workspace-body--editor-layout .workspace-tools-panel.drawer-panel-tools.open {
    width: min(320px, 88vw);
  }
}

.workspace-body--editor-layout .workspace-tools-panel-inner {
  max-width: none;
  margin-inline: 0;
  padding: 0.5rem 0.45rem;
}

.workspace-canvas-column {
  flex: 1 1 auto;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
  align-self: stretch;
}

/* מקסימום שטח לציור: ללא תקרת רוחב/גובה, מילוי עד כותרת + פס צבעים */
.workspace-body--editor-layout .workspace-canvas-column .canvas-area {
  flex: 1 1 auto;
  min-height: 0;
  align-self: stretch;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.workspace-body--editor-layout .workspace-canvas-column .canvas-area--workspace-frame {
  margin-inline: 0;
  width: 100%;
  max-width: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: var(--surface);
  padding: 0;
  min-height: 0;
  flex: 1 1 auto;
}

.workspace-body--editor-layout .workspace-canvas-column .canvas-area .canvas-viewport {
  max-height: none;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  width: 100%;
}

.workspace-body--editor-layout .workspace-canvas-column .canvas-area.split-mode .canvas-viewport {
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
}

.canvas-placeholder {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.workspace-top-tools,
.workspace-bottom-colors-fixed {
  width: 100%;
  flex: 0 0 auto;
  min-height: 0;
  flex-shrink: 0;
  pointer-events: auto;
  position: relative;
  z-index: 24;
  isolation: isolate;
}

/* מקל על הצמדות למטה (notch / home indicator) */
.workspace-bottom-colors-fixed {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface-elevated) 95%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}

.workspace-top-tools.no-pointer,
.workspace-bottom-colors-fixed.no-pointer {
  pointer-events: none;
}

.workspace-current-color {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.25rem 0.35rem;
  margin-bottom: 0.15rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 88%, var(--accent-muted));
  border: 1px solid var(--border);
}

button.workspace-current-color {
  font: inherit;
  color: inherit;
  margin: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: start;
}

.workspace-current-color-swatch {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.workspace-current-color-hex {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* בכותרת ליד בית — קומפקטי */
.workspace-current-color--header {
  margin-bottom: 0;
  padding: 0.2rem 0.4rem;
  gap: 0.35rem;
  flex-shrink: 1;
  min-width: 0;
}

.workspace-current-color--header .workspace-current-color-swatch {
  width: 1.45rem;
  height: 1.45rem;
}

.workspace-current-color--header .workspace-current-color-hex {
  font-size: 0.65rem;
  max-width: 4.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.3rem;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-elevated) 90%, transparent);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  backdrop-filter: blur(5px);
}

.drawer-tab:hover {
  background: var(--surface);
  color: var(--text);
}

.drawer-tab.open {
  background: var(--accent-muted);
  color: var(--accent);
}

.drawer-tab:focus-visible,
.colors-drawer-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.drawer-tab-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.drawer-panel-tools,
.drawer-panel-colors {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  transition: max-height 0.2s ease-out;
  background: var(--surface-elevated);
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-inline: none;
  border-radius: 0;
  box-shadow: none;
  pointer-events: auto;
}

/*
 * בלנדסקייפ: גובה המסך (vh) קטן — vmin נותן גובה סביר לפאנלים.
 * overflow: hidden כאן + גלילה ב-.drawer-panel-inner — סטיקרים לא נחతכים חלקית.
 */
.drawer-panel-tools.open,
.drawer-panel-colors.open {
  overflow: hidden;
  min-height: 0;
}

/* Tools panel should feel anchored to the top. */
.drawer-panel-tools.open {
  justify-content: flex-start;
  /* גובה מספיק לסטיקרים / הנפשות / אפקטים בלי לחתוך מתחת לקנבס */
  max-height: clamp(190px, 36dvh, 420px);
}

/* Colors panel should feel anchored to the bottom. */
.drawer-panel-colors.open {
  justify-content: flex-end;
  max-height: var(--bottom-colors-height);
}

@media (orientation: landscape) and (max-height: 520px) {
  .drawer-panel-tools.open {
    max-height: clamp(140px, 42dvh, 300px);
  }
  .drawer-panel-colors.open {
    max-height: clamp(96px, 24dvh, 160px);
  }
}

@media (max-width: 899px) {
  .app.workspace:not(.welcome) {
    --bottom-colors-height: clamp(88px, 18dvh, 130px);
  }
}

.drawer-panel-inner {
  padding: 0.45rem max(0.5rem, env(safe-area-inset-left, 0px)) 0.45rem max(0.5rem, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: min(56rem, 100%);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
  .drawer-panel-inner {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    gap: 0.35rem;
  }
}

/* מגירת צבעים מלמטה למעלה – נשארת פתוחה כברירת מחדל */
.workspace-bottom-colors {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.workspace-bottom-colors > * {
  pointer-events: auto;
}

.colors-drawer-tab {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.colors-drawer-tab:hover {
  background: var(--surface);
  color: var(--text);
}

.colors-drawer-tab.open {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-muted);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}

.colors-drawer-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.colors-drawer-panel.open {
  max-height: 220px;
}

@media (max-height: 520px) {
  .colors-drawer-panel.open {
    max-height: 160px;
  }
  .app.workspace.colors-drawer-open .workspace-body {
    padding-bottom: 160px;
  }
}

.colors-drawer-inner {
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.accessibility-toggle {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.workspace-name-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.workspace-name-btn:hover {
  filter: brightness(0.98);
}

.workspace-name-btn-label {
  max-width: 6em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.drawer-toggle-icon {
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.9;
}

.drawer-overlay {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 98;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-overlay[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

.effect-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 99;
  max-height: min(88vh, 88dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding:
    0
    max(1.25rem, env(safe-area-inset-right, 0px))
    max(1.5rem, env(safe-area-inset-bottom, 0px))
    max(1.25rem, env(safe-area-inset-left, 0px));
  padding-top: max(0.35rem, env(safe-area-inset-top, 0px));
  transform: translateY(-100%);
  transition: transform 0.32s var(--ease-smooth, cubic-bezier(0.4, 0, 0.2, 1));
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border: 1px solid var(--border);
  border-top: none;
}

body.theme-dark .drawer-panel {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.drawer-panel[data-open="true"] {
  transform: translateY(0);
}

/* מסכים רחבים: מגירת תפריט מצד (RTL — מימין) במקום מלמעלה */
@media (min-width: 900px) {
  .drawer-panel {
    left: auto;
    width: min(420px, 38vw);
    max-width: 440px;
    height: 100%;
    min-height: 100dvh;
    max-height: none;
    top: 0;
    bottom: 0;
    right: 0;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    border-top: 1px solid var(--border);
    border-right: none;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.14);
    transform: translateX(108%);
    transition: transform 0.32s var(--ease-smooth, cubic-bezier(0.4, 0, 0.2, 1));
  }

  .drawer-panel[data-open="true"] {
    transform: translateX(0);
  }

  .welcome-drawer-panel {
    left: auto;
    width: min(420px, 38vw);
    max-width: 440px;
    height: 100%;
    min-height: 100dvh;
    max-height: none;
    top: 0;
    bottom: 0;
    right: 0;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    border-top: 1px solid var(--border);
    border-right: none;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.14);
    transform: translateX(108%);
    transition: transform 0.3s var(--ease-smooth, ease-out);
    padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
  }

  .welcome-drawer-panel[data-open="true"] {
    transform: translateX(0);
  }
}

.drawer-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.drawer-panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.drawer-close {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
}

.drawer-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.drawer-panel-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.drawer-mode-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.drawer-mode-btn {
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.drawer-mode-btn:hover {
  border-color: var(--accent-muted);
  color: var(--text);
}

.drawer-mode-btn.active {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent);
}

.drawer-admin-link {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  text-align: right;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.drawer-admin-link:hover {
  border-color: var(--accent-muted);
  color: var(--accent);
}

.drawer-canvas-measure {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.drawer-canvas-measure-label { color: var(--text-secondary); }
.drawer-canvas-measure-value { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

.canvas-measure-badge {
  position: absolute;
  bottom: 0.35rem;
  right: 0.35rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 5;
  pointer-events: none;
}

.drawer-option-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.drawer-option-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
}
.drawer-option-label input { accent-color: var(--accent); }
.drawer-option-desc {
  margin: 0.25rem 0 0 1.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.canvas-area {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  min-height: 380px;
  border: 1px solid var(--border);
}

.canvas-area.split-mode {
  flex-direction: row;
  gap: 1rem;
  align-items: flex-start;
  justify-content: center;
}

.split-reference {
  flex: 0 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.split-reference-inner {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-elevated);
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid var(--border);
}

.split-reference-img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
}

.split-reference-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.split-ref-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.split-ref-btn:hover {
  border-color: var(--accent-muted);
  background: var(--accent-muted);
}

.split-reference-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}
.split-reference-placeholder p {
  margin: 0;
  font-size: 0.95rem;
}
.split-ref-paste,
.split-ref-upload {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.split-ref-upload:hover {
  border-color: var(--accent-muted);
}

.split-drawing {
  flex: 0 1 50%;
  min-width: 0;
  position: relative;
  display: inline-block;
  line-height: 0;
}

.layers-underlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: 1;
}

.split-drawing .coloring-canvas,
.split-drawing .outline-overlay {
  max-width: 100%;
  height: auto;
}
.split-drawing .outline-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  object-fit: fill;
  /* מעל שכבת הצביעה — אחרת קנבס לבן מכסה את הקווים */
  z-index: 3;
  pointer-events: none;
}
.split-drawing .coloring-canvas {
  display: block;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 2;
}

/* Visually hidden but still "clickable" for input.click() — pointer-events:none and 0×0 break file pickers in Android WebView */
.hidden-input {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
}

.canvas-stack {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.canvas-stack .coloring-canvas {
  display: block;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-width: 100%;
  height: auto;
  position: relative;
  z-index: 2;
}

.canvas-stack .outline-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  max-width: 100%;
  object-fit: fill;
  /* חייב להיות מעל .coloring-canvas (z-index: 2) — אחרת קווים נעלמים */
  z-index: 3;
  pointer-events: none;
}

/* תבנית מהגלריה: התמונה המקורית מעל הצבע — לבן נשאר שקוף ויזואלית, בלי להמיר לקווים */
.canvas-grid-overlay {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  z-index: 4;
}

.canvas-triangle-overlay {
  display: block;
}

.drawer-grid-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0;
}

.layers-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-elevated) 92%, transparent);
}

.layers-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.layers-panel-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 180px;
  overflow-y: auto;
}

.layers-panel-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
}

.layers-panel-select,
.layers-panel-toggle {
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.layers-panel-item.active .layers-panel-select {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 700;
}

.layers-panel-toggle.is-hidden {
  opacity: 0.78;
}

.drawer-ready-pages .drawer-ready-page-btn {
  width: 100%;
  box-sizing: border-box;
  justify-content: flex-start;
  text-align: start;
}

.drawer-ready-pages-hint {
  margin: 0 0 0.35rem;
}

.drawer-compose-row {
  width: 100%;
}

.welcome-cover-canvas-hint {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

.drawer-canvas-custom-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.drawer-canvas-custom-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.drawer-canvas-custom-label input[type="number"] {
  width: 4.75rem;
  max-width: 100%;
  padding: 0.35rem 0.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

.drawer-canvas-custom-apply {
  flex: 1 1 6rem;
  min-width: min(100%, 6rem);
}

.drawer-pdf-promo-btn {
  width: 100%;
  justify-content: center;
  gap: 0.35rem;
  display: inline-flex;
  align-items: center;
}

.drawer-pdf-promo-hint {
  margin-top: 0.35rem;
}

.drawer-grid-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.drawer-grid-btns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.75rem), 1fr));
  gap: 0.4rem;
}

.drawer-grid-btn {
  min-height: 2.7rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  transition:
    background var(--transition, 0.2s ease),
    border-color var(--transition, 0.2s ease),
    color var(--transition, 0.2s ease),
    box-shadow var(--transition, 0.2s ease),
    transform 0.15s var(--ease-smooth, ease);
}

.drawer-grid-btn:focus-visible,
.welcome-source-btn:focus-visible,
.welcome-drawer-btn:focus-visible,
.welcome-source-btn:focus,
.welcome-drawer-btn:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}

.drawer-grid-btn:hover {
  border-color: color-mix(in srgb, var(--border) 45%, var(--accent) 55%);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.drawer-grid-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.drawer-grid-btn.active {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* תרשים זרימה (Excalidraw-style) */
.flow-shape-picker {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.15rem 0.15rem;
  border-top: 1px solid var(--border);
  margin-top: 0.35rem;
}

.flow-shape-picker-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.flow-shape-picker-btns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 5.5rem), 1fr));
  gap: 0.35rem;
}

.flow-shape-option {
  min-height: 2.35rem;
  font-size: 0.8rem;
}

.flow-shape-picker-label-sub {
  margin-top: 0.35rem;
  padding-top: 0.25rem;
  border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
}

.flow-shape-picker-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.flow-shape-pdf-btn {
  width: 100%;
  margin-top: 0.15rem;
  min-height: 2.5rem;
  font-weight: 600;
}

.drawer-paper-threshold {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.15rem 0 0.25rem;
}

.drawer-paper-threshold-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.drawer-paper-threshold-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.drawer-paper-threshold-row input[type="range"] {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.drawer-paper-threshold-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  min-width: 2rem;
  text-align: center;
}

.drawer-paper-fill-hint {
  margin-top: 0.35rem !important;
  margin-bottom: 0.35rem !important;
}

.drawer-paper-fill-btn {
  width: 100%;
  margin-top: 0.15rem;
  padding: 0.55rem 0.85rem;
  font-weight: 600;
}

.accessibility-on .canvas-area {
  border-width: 3px;
  border-color: rgba(37, 99, 235, 0.4);
}
.accessibility-on .main-tool-btn,
.accessibility-on .welcome-drawer-btn {
  min-height: 44px;
}
.accessibility-toggle[aria-pressed="true"] {
  background: var(--accent-muted) !important;
  border-color: var(--accent) !important;
  color: var(--accent);
  font-weight: 600;
}
.accessibility-toggle[aria-pressed="true"]::before {
  content: '✓ ';
}
.app-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.app.workspace.painting-active .app-footer {
  display: none;
}

.app-footer-audit {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.app-footer-audit-icon {
  display: inline-flex;
  color: var(--accent);
  opacity: 0.9;
}

.app-footer-audit-count {
  font-weight: 700;
  color: var(--text);
}

.welcome-footer-audit {
  position: fixed;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
}
.welcome-footer-audit .app-footer-audit-icon { color: var(--accent); opacity: 0.9; }
.welcome-footer-audit .app-footer-audit-count { font-weight: 800; color: #fff; }

.welcome-side-brand {
  position: fixed;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 150px;
  height: auto;
  opacity: 0.92;
  pointer-events: none;
  filter: drop-shadow(0 12px 30px rgba(0,0,0,0.22));
  z-index: 4;
}

@media (max-width: 900px) {
  .welcome-side-brand { width: 120px; opacity: 0.88; }
}

@media (max-width: 520px) {
  .welcome-side-brand { display: none; }
}

.app-footer-about-toggle {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.app-footer-about-content {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: right;
  max-width: 520px;
}

.app-footer-version {
  display: block;
  width: 100%;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}

.app-footer-brand {
  font-weight: 500;
  letter-spacing: 0.08em;
}

.app-footer-site-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.app-footer-site-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.app-footer-share-qr-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
}
.app-footer-share-qr-btn:hover {
  border-color: var(--accent-muted);
  color: var(--accent);
}

.qr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2.5rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

.qr-modal-box {
  position: relative;
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}

.qr-modal-close {
  position: absolute;
  top: 0.5rem;
  inset-inline-start: 0.5rem;
  padding: 0.25rem;
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.qr-modal-close:hover {
  color: var(--text);
  background: var(--surface);
}

.qr-modal-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.qr-modal-image {
  display: block;
  width: 140px;
  height: 140px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.app-footer-story,
.app-footer-guide {
  font-size: 0.88rem;
  line-height: 1.5;
}

.app-footer-story strong,
.app-footer-guide strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.app-footer-story p,
.app-footer-guide ul {
  margin: 0;
  padding-right: 0;
}

.app-footer-guide ul {
  list-style: none;
  padding-right: 0;
}

.app-footer-guide li {
  margin-bottom: 0.35rem;
  padding-right: 1rem;
  position: relative;
}

.app-footer-guide li::before {
  content: '•';
  position: absolute;
  right: 0;
  color: var(--accent);
}

.app-footer-donate {
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 500;
}

.app-footer-donate:hover {
  color: var(--accent-hover);
}

.app-footer-admin-btn {
  background: none;
  border: none;
  padding: 0.35rem 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: underline;
}
.app-footer-admin-btn:hover {
  color: var(--accent);
}

.app-footer-heart {
  font-size: 0.9rem;
}

.app-footer-disclaimer-box {
  flex-basis: 100%;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
}

.app-footer-disclaimer-title {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.app-footer-disclaimer-box p {
  margin: 0 0 0.5rem;
  line-height: 1.45;
}

.app-footer-disclaimer-box p:last-child {
  margin-bottom: 0;
}

.app.workspace.adult-mode .workspace-header {
  border-bottom-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}

.adult-pro-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-elevated) 92%, transparent);
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.adult-pro-panel-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.adult-pro-panel-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.adult-pro-presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.adult-measure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.adult-measure-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.adult-measure-grid input {
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.adult-measure-result {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
}

.adult-notes {
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem;
  font: inherit;
}

.paintify-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.paintify-preview-modal {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 0.9rem;
}

.paintify-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.paintify-preview-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.paintify-preview-loading {
  padding: 1rem;
  text-align: center;
  color: var(--text-secondary);
}

/* טעינה: המרת צילום / טעינת תמונה לדף */
.app-image-apply-overlay {
  position: fixed;
  inset: 0;
  z-index: 100002;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: rgba(15, 18, 28, 0.42);
  backdrop-filter: blur(4px);
  pointer-events: all;
}

.app-image-apply-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 1.15rem 1.35rem;
  border-radius: var(--radius-lg, 12px);
  background: var(--surface, #fff);
  color: var(--text, #1a1d26);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  box-shadow: var(--shadow-md, 0 12px 40px rgba(0, 0, 0, 0.18));
  max-width: min(22rem, 92vw);
  text-align: center;
}

.app-image-apply-spinner {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 3px solid var(--border, rgba(0, 0, 0, 0.12));
  border-top-color: var(--accent, #5b7cff);
  animation: app-image-apply-spin 0.75s linear infinite;
}

.app-image-apply-msg {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text-secondary, #5c6370);
}

@keyframes app-image-apply-spin {
  to {
    transform: rotate(360deg);
  }
}

.paintify-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.paintify-preview-option {
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.paintify-preview-option img,
.paintify-preview-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  object-fit: cover;
}

.paintify-preview-placeholder {
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.paintify-preview-option.selected {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

@media (max-width: 760px) {
  .paintify-preview-grid {
    grid-template-columns: 1fr;
  }

  .paintify-preview-modal {
    width: 100%;
    max-height: min(92dvh, 92vh);
    padding: 0.7rem;
    border-radius: 12px;
  }

  .paintify-preview-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    padding-bottom: 0.35rem;
    margin-bottom: 0.55rem;
  }

  .paintify-preview-option {
    padding: 0.35rem;
  }
}

/* --- סטודיו ציור: נייר, מסגרת עץ, צל (כשיש דף פעיל) --- */
.welcome-inline-ico {
  display: inline-block;
  margin-inline-end: 0.35rem;
  font-size: 1.05em;
  line-height: 1;
  vertical-align: -0.1em;
}

.app.workspace.painting-active .canvas-area,
.app.workspace.painting-active .canvas-area--workspace-frame,
.app.workspace.painting-active .workspace-body--editor-layout .workspace-canvas-column .canvas-area--workspace-frame {
  background:
    radial-gradient(ellipse 85% 60% at 50% -8%, rgba(255, 252, 246, 0.55) 0%, transparent 52%),
    repeating-linear-gradient(
      -8deg,
      rgba(210, 192, 168, 0.14) 0 1px,
      transparent 1px 14px
    ),
    linear-gradient(168deg, #e4d9cc 0%, #d1c2b2 38%, #c8b6a4 52%, #d8cec2 100%);
  border-color: rgba(93, 71, 54, 0.2);
}

.app.workspace.painting-active .canvas-viewport-inner {
  position: relative;
  padding: clamp(10px, 2vmin, 18px);
  background: linear-gradient(145deg, #3d3025 0%, #5c4836 12%, #4a3b2d 100%);
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.12),
    0 18px 44px rgba(35, 24, 16, 0.32);
}

.app.workspace.painting-active .canvas-stack,
.app.workspace.painting-active .split-drawing {
  background: #faf7f0;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.65),
    inset 0 -2px 12px rgba(120, 90, 60, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.08),
    0 10px 28px rgba(0, 0, 0, 0.14);
  border-radius: 1px;
}

.app.workspace.painting-active .canvas-measure-badge {
  background: rgba(250, 247, 240, 0.92);
  border-color: rgba(106, 84, 62, 0.22);
  color: #5a4a3a;
}

.app.workspace.painting-active .canvas-zoom-controls {
  background: rgba(250, 247, 240, 0.96);
  border-color: rgba(106, 84, 62, 0.22);
}

body.theme-dark .app.workspace.painting-active .canvas-area,
body.theme-dark .app.workspace.painting-active .canvas-area--workspace-frame,
body.theme-dark .app.workspace.painting-active .workspace-body--editor-layout .workspace-canvas-column .canvas-area--workspace-frame {
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(70, 60, 50, 0.45) 0%, transparent 50%),
    linear-gradient(168deg, #222018 0%, #12100e 100%);
  border-color: rgba(255, 255, 255, 0.07);
}

body.theme-dark .app.workspace.painting-active .canvas-viewport-inner {
  background: linear-gradient(145deg, #0e0c0b 0%, #242019 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 16px 40px rgba(0, 0, 0, 0.55);
}

body.theme-dark .app.workspace.painting-active .canvas-stack,
body.theme-dark .app.workspace.painting-active .split-drawing {
  background: #f7f2ea;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.45);
}

body.theme-dark .app.workspace.painting-active .canvas-measure-badge {
  background: rgba(30, 26, 22, 0.9);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e8dfd5;
}

body.theme-dark .app.workspace.painting-active .canvas-zoom-controls {
  background: rgba(30, 26, 22, 0.92);
  border-color: rgba(255, 255, 255, 0.1);
}
* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  /* Light theme (default) — מערכת צבע עקבית, ניגודיות קריאה */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-elevated: #eef2fa;
  --surface-glass: color-mix(in srgb, var(--surface) 88%, transparent);
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-muted: rgba(37, 99, 235, 0.14);
  --text: #0f172a;
  --text-secondary: #455368;
  --text-muted: #64748b;
  --border: rgba(15, 23, 42, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-btn: 12px;
  --accent-dark: #1e40af;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 22px 56px rgba(15, 23, 42, 0.12);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 34%, transparent);
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --transition: 0.2s ease;
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Heebo', system-ui, sans-serif;
  --font-display-playful: 'Fredoka', 'Varela Round', 'Heebo', system-ui, sans-serif;
  --header-blur: 14px;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body.theme-dark {
  color-scheme: dark;
  --bg: #0c1016;
  --surface: #161d2a;
  --surface-elevated: #1f2938;
  --surface-glass: color-mix(in srgb, var(--surface) 86%, transparent);
  --accent: #7aa8ff;
  --accent-hover: #93b9ff;
  --accent-muted: rgba(122, 168, 255, 0.18);
  --text: #f1f5f9;
  --text-secondary: #b8c5d9;
  --text-muted: #8b9bb0;
  --border: rgba(255, 255, 255, 0.1);
  --accent-dark: #3b82f6;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 26px 64px rgba(0, 0, 0, 0.28);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent);
}

body {
  margin: 0;
  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: clamp(15px, 0.18vw + 14px, 17px);
  line-height: 1.55;
}

/* מצב נגישות - הגדלת פונט וריווח */
body.accessibility-mode-on {
  font-size: 18px;
  line-height: 1.6;
}
body.accessibility-mode-on button {
  font-size: 1.05rem;
  padding: 0.65rem 1.2rem;
}
body.accessibility-mode-on input,
body.accessibility-mode-on select {
  font-size: 1.05rem;
  padding: 0.5rem 0.75rem;
}
body.accessibility-mode-on .workspace-header h1,
body.accessibility-mode-on .welcome-header h1 {
  font-size: 1.5em;
}
body.accessibility-mode-on .drawer-panel-body,
body.accessibility-mode-on .welcome-drawer-body {
  font-size: 1.05rem;
}

#root {
  min-height: 100vh;
}

select {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 2.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}

select:hover {
  border-color: color-mix(in srgb, var(--border) 50%, var(--accent) 50%);
}

select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}

button {
  font-family: inherit;
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  min-height: 2.65rem;
  padding: 0.6rem 1.1rem;
  background: var(--surface-elevated);
  color: var(--text);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition),
    transform 0.15s var(--ease-smooth);
}

button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--surface-elevated) 70%, var(--accent-muted) 30%);
  border-color: color-mix(in srgb, var(--border) 40%, var(--accent) 60%);
  box-shadow: var(--shadow-sm);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled),
  button:hover:not(:disabled) {
    transform: none;
    transition-duration: 0.01ms;
  }
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}

button.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent);
  color: #fff;
  box-shadow:
    0 2px 10px rgba(37, 99, 235, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

body.theme-dark button.primary {
  box-shadow:
    0 2px 16px rgba(59, 130, 246, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
  border-color: var(--accent-hover);
  box-shadow:
    0 4px 18px rgba(37, 99, 235, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

input[type="file"] {
  display: none;
}

input[type="range"] {
  accent-color: var(--accent);
}

input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
textarea {
  min-height: 2.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* אייקוני SVG - מרוכזים ולא מתכווצים */
.icon-svg {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-svg svg {
  display: block;
}
