/* v26 component rules — built up across phases 1-3.
   Phase 1 scope: icon base, focus rings, toast shell, settings dialog,
   theme/menu-size pickers. */

/* App chrome is a drawing surface, not selectable document text. Keep native
   editing/selection/callouts inside fields (including dynamically added ones).
   No pointer/touch cancellation: buttons, scrolling and layer dragging stay native. */
html, body, body * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body input, body textarea,
body [contenteditable]:not([contenteditable="false"]),
body [contenteditable]:not([contenteditable="false"]) * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.icon {
  width: 1em;
  height: 1em;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  vertical-align: -0.125em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Settings dialog ---------- */
#settings-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: var(--space-lg);
}
#settings-modal.open {
  display: flex;
}
#settings-modal .settings-dialog {
  width: min(560px, 100%);
  max-height: min(720px, 90vh);
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  color: var(--text-1);
  font-family: var(--font-ui);
}
#settings-modal .settings-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-1);
  background: var(--surface-1);
}
#settings-modal .settings-header h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
#settings-modal .settings-section {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-1);
}
#settings-modal .settings-section:last-child {
  border-bottom: none;
}
#settings-modal .settings-section h3 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-2);
  text-transform: none;
  letter-spacing: normal;
}
#settings-close {
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
#settings-close:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

/* Theme grid (id="theme-menu" for spec-compat, lives inside #settings-modal now) */
#theme-menu.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}
.theme-option {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  color: var(--text-1);
  font-family: var(--font-ui);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.theme-option:hover {
  background: var(--surface-3);
}
.theme-option[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.theme-option .theme-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.theme-option .theme-sub {
  font-size: var(--text-xs);
  color: var(--text-2);
}

/* Menu-size segmented control */
#menu-size-group {
  display: flex;
  gap: var(--space-xs);
  background: var(--surface-2);
  padding: var(--space-xs);
  border-radius: var(--radius-md);
  width: fit-content;
}
.menu-size-option {
  padding: var(--space-xs) var(--space-md);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  cursor: pointer;
}
.menu-size-option:hover {
  color: var(--text-1);
}
.menu-size-option.active {
  background: var(--surface-0);
  color: var(--text-1);
  font-weight: var(--weight-medium);
}

/* Settings toggle row (checkboxes) */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-xs) 0;
}
.settings-toggle-row label {
  font-size: var(--text-sm);
  color: var(--text-1);
}

.settings-info-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  padding: var(--space-xs) 0;
  color: var(--text-2);
}
.settings-info-row .info-value {
  color: var(--text-1);
  font-family: var(--font-mono);
}

.settings-action-btn {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.settings-action-btn:hover { background: var(--surface-3); }

/* ---------- Restore banner (v26.1 autosave) ---------- */
#restore-banner {
  position: fixed;
  top: calc(var(--topbar-h) + var(--space-sm));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  max-width: min(90vw, 480px);
}
#restore-banner .settings-action-btn { margin-top: 0; }

/* ---------- Startup splash ---------- */
#app-splash {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  background: var(--stage-bg);
  color: var(--text-1);
  font-family: var(--font-ui);
}
#app-splash[hidden] {
  display: none;
}
#app-splash img {
  opacity: 0.9;
}
#app-splash-text {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-2);
}
#app-splash-bar {
  width: 160px;
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  overflow: hidden;
}
#app-splash-bar-fill {
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  animation: jf-splash-indeterminate 1.2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  #app-splash-bar-fill {
    animation: none;
    width: 60%;
  }
}
@keyframes jf-splash-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
#app-splash-reload {
  padding: var(--space-sm) var(--space-lg);
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
}

/* ---------- Canvas HUD (zoom + grid) ---------- */
#canvas-hud {
  position: absolute;
  left: var(--space-md);
  bottom: var(--space-md);
  z-index: var(--z-hud);
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: 4px;
}
#canvas-hud button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
#canvas-hud button:hover {
  background: var(--surface-2);
  color: var(--text-1);
}
#canvas-hud button.active {
  background: var(--accent-soft);
  color: var(--accent);
}
#zoom-level {
  width: auto;
  padding: 0 var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  white-space: nowrap;
}
/* Menu opens upward from the HUD (which sits at the bottom of the canvas
   area) instead of downward like the top-bar's Speichern menu. */
.canvas-hud-menu {
  top: auto;
  bottom: 100%;
  right: auto;
  left: 0;
  margin-top: 0;
  margin-bottom: var(--space-xs);
}

/* ---------- Top bar dropdown menu (Speichern) ---------- */
.top-bar-menu-container {
  position: relative;
  display: inline-flex;
}
.top-bar-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-xs);
  min-width: 220px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: var(--space-xs);
  z-index: var(--z-topbar);
  flex-direction: column;
  gap: 2px;
}
.top-bar-menu.open {
  display: flex;
}
.top-bar-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.top-bar-menu-item:hover {
  background: var(--surface-2);
}

/* ---------- Toast shell (filled in further in Phase 3) ---------- */
#toast-region {
  position: fixed;
  left: 50%;
  bottom: var(--space-xl);
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}
/* Toasts are status messages without actions: they must never swallow taps on the
   controls underneath (they sit over the bottom colour panel on phones). */
.jf-toast {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  max-width: 360px;
}
.jf-toast--success { border-color: color-mix(in srgb, var(--success) 50%, var(--border-1)); }
.jf-toast--warning { border-color: color-mix(in srgb, var(--warning) 50%, var(--border-1)); }
.jf-toast--error { border-color: color-mix(in srgb, var(--danger) 50%, var(--border-1)); }

/* ---------- Recent colors (v26.1 phase 6) ---------- */
.recent-colors-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
  flex-wrap: wrap;
}
.recent-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-1);
  cursor: pointer;
  padding: 0;
  flex: none;
}
.recent-color-swatch:hover { border-color: var(--accent); }

/* ---------- Selection transform bar (v26.1 phase 6) ---------- */
#transform-bar {
  position: fixed;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
}
#transform-bar label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-2);
  white-space: nowrap;
}
#transform-bar input[type="number"] {
  width: 52px;
  padding: 2px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
#transform-bar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
}
#transform-bar button:hover { background: var(--surface-3); color: var(--text-1); }
#transform-bar button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
#transform-bar #tf-cancel { color: var(--danger); }

/* ---------- Zoom/pan (v26.1 phase 6) ---------- */
/* .canvas-container has `transition: transform .3s` (main inline <style>);
   suppress it while actively zooming via wheel/pinch so panning-toward-cursor
   doesn't lag behind the pointer. */
.canvas-container.is-zooming { transition: none !important; }

/* ---------- New Document dialog (v26.1 phase 6) — same modal pattern as
   #settings-modal, duplicated rather than shared to avoid coupling the two
   dialogs' styling together. ---------- */
#new-doc-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: var(--space-lg);
}
#new-doc-modal.open { display: flex; }
#new-doc-modal .new-doc-dialog {
  width: min(480px, 100%);
  max-height: min(720px, 90vh);
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  color: var(--text-1);
  font-family: var(--font-ui);
}
#new-doc-modal .new-doc-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-1);
  background: var(--surface-1);
}
#new-doc-modal .new-doc-header h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
#new-doc-close {
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
#new-doc-close:hover { background: var(--surface-2); color: var(--text-1); }
#new-doc-modal .new-doc-section,
#export-modal .new-doc-section {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-1);
}
#new-doc-modal .new-doc-section h3,
#export-modal .new-doc-section h3 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-2);
}
.new-doc-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}
.new-doc-preset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  text-align: left;
}
.new-doc-preset span { color: var(--text-2); font-size: var(--text-xs); font-weight: 400; }
.new-doc-preset:hover { background: var(--surface-3); }
.new-doc-preset.active { background: var(--accent-soft); border-color: var(--accent); }
.new-doc-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}
.new-doc-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--text-2);
}
.new-doc-fields input {
  width: 90px;
  padding: var(--space-xs) var(--space-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.new-doc-bg-group { display: flex; gap: var(--space-sm); }
.new-doc-bg-option {
  padding: var(--space-xs) var(--space-md);
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  cursor: pointer;
}
.new-doc-bg-option.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.new-doc-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-lg);
}

/* ---------- Work title (v26.1 phase 7, "Meine Werke") ---------- */
#work-title {
  margin-left: var(--space-sm);
  padding: 2px var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
#work-title.saved { color: var(--text-2); }

/* ---------- Meine Werke / Export / Shortcuts modals (v26.1 phase 7) —
   same modal shell pattern as #settings-modal / #new-doc-modal. ---------- */
#works-modal, #export-modal, #shortcuts-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: var(--space-lg);
}
#works-modal.open, #export-modal.open, #shortcuts-modal.open { display: flex; }

.works-dialog, .export-modal-dialog {
  width: min(640px, 100%);
  max-height: min(720px, 90vh);
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  color: var(--text-1);
  font-family: var(--font-ui);
}
.export-modal-dialog { width: min(400px, 100%); }
.works-header, .export-modal-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-1);
  background: var(--surface-1);
}
.works-header h2, .export-modal-header h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
#works-close, #export-modal-close, #shortcuts-close {
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
#works-close:hover, #export-modal-close:hover, #shortcuts-close:hover { background: var(--surface-2); color: var(--text-1); }

.works-empty {
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-2);
  font-size: var(--text-sm);
}
/* Shown in place of the grid when listWorks() fails. Deliberately distinct
   from .works-empty: "you have no works" and "we could not read your works"
   must never look the same. */
.works-error {
  padding: var(--space-xl);
  margin: 0;
  text-align: center;
  color: var(--danger);
  font-size: var(--text-sm);
}
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-md);
  padding: var(--space-lg);
}
.work-card {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.work-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--surface-3);
  display: block;
}
.work-card-body { padding: var(--space-sm); }
.work-card-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.work-card-date { font-size: var(--text-xs); color: var(--text-2); }
.work-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 var(--space-sm) var(--space-sm);
}
.work-card-actions button {
  flex: 1;
  min-width: 60px;
  padding: 4px 6px;
  background: var(--surface-3);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 10px;
  cursor: pointer;
}
.work-card-actions button:hover { background: var(--accent-soft); color: var(--accent); }

#export-modal-quality { width: 100%; }
#export-modal-quality-value { font-size: var(--text-xs); color: var(--text-2); }

.shortcuts-group { padding: var(--space-lg); border-bottom: 1px solid var(--border-1); }
.shortcuts-group:last-child { border-bottom: none; }
.shortcuts-group h3 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-2);
}
.shortcuts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: var(--text-sm);
}
.shortcuts-row kbd {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  margin-left: 4px;
}

/* Moved from joe/joe.css (v26.9): LIGHT ships without joe.css, the rule must live in a shared stylesheet. */
/* v26: the right panel's "Werkzeuge" section duplicates the left panel's
   tools 1:1 (same 10 tools, "-right" id suffix), and "Power Controls"
   duplicates the dock's size/intensity/opacity sliders — both were always
   visible, doubling the same controls. Hidden by default; Experten-Modus
   (same toggle as the legacy AI menus) brings them back for anyone who
   preferred having tools in both panels. */
body:not(.joe-expert) #mini-tools-section,
body:not(.joe-expert) #power-controls-section {
    display: none !important;
}

/* v26.9 mobile bottom-right corner: the help button (#app-info-btn) sat exactly on the
   "Panel wiederherstellen" button (.control-restore-btn, bottom-right on phones). On narrow
   screens the help button moves above that stack. Token = restore button height + its gap. */
:root { --bottom-stack-h: 72px; }
@media (max-width: 768px) {
  html body #app-info-btn {
    bottom: calc(var(--bottom-stack-h) + 12px + env(safe-area-inset-bottom, 0px));
    right: calc(15px + env(safe-area-inset-right, 0px));
  }
}

/* v26.10 Mandala controls inside the canvas HUD (shown only while mandala is on). */
#mandala-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border-left: 1px solid var(--border-1);
  color: var(--text-1);
  font-size: var(--text-sm, 13px);
}
#mandala-controls[hidden] { display: none; }
#mandala-controls input[type="range"] { width: 96px; min-height: 44px; }
#mandala-controls #mandala-segments-value { min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
#mandala-controls button[aria-pressed="true"] { background: var(--accent-soft, rgba(43, 181, 173, 0.2)); }

/* v26.10 Tagesidee chip over the canvas (LIGHT) */
.canvas-container { position: relative; }
.daily-idea {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-hud, 20);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92%, 640px);
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  box-shadow: var(--shadow-2);
  color: var(--text-1);
  font-size: var(--text-sm, 13px);
}
.daily-idea[hidden] { display: none; }
.daily-idea .daily-idea-label { font-weight: 600; white-space: nowrap; }
.daily-idea #daily-idea-text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.daily-idea button { min-height: 44px; min-width: 44px; border-radius: 999px; border: 1px solid var(--border-1); background: transparent; color: inherit; cursor: pointer; padding: 0 12px; white-space: nowrap; }
@media (max-width: 520px) {
  /* v26.10: on phones the chip becomes a small card: full idea text, buttons below without
     overlapping rings (the text was cut off and the round borders overlapped). */
  .daily-idea { flex-wrap: wrap; border-radius: 16px; padding: 10px 12px 6px; gap: 4px 8px; width: min(92%, 360px); }
  .daily-idea .daily-idea-label { display: none; }
  .daily-idea #daily-idea-text { flex: 1 1 100%; display: block; overflow: visible; }
  .daily-idea button { border: 0; box-shadow: none; padding: 0 10px; }
  .daily-idea #daily-idea-next { margin-left: auto; color: var(--accent, #2bb5ad); font-weight: 600; }
}

/* v26.10 Ausmalvorlagen in the new-document dialog */
.new-doc-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.new-doc-template { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; padding: 8px 4px; border-radius: var(--radius-md, 10px); border: 1px solid var(--border-1); background: #fff; color: #1c1d20; cursor: pointer; font-size: var(--text-xs, 12px); }
.new-doc-template:focus-visible { outline: 3px solid var(--accent, #2bb5ad); outline-offset: 2px; }
.new-doc-template img { width: 72px; height: 72px; }

/* v26.10: toasts and the status line sit above the bottom tool bar (they used to shine
   through the "Pinsel" button and cover it on phones). */
#toast-region,
#status-indicator {
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

/* v26.10: on phones the mandala controls ran under the "?" help button. They wrap into their
   own row and the HUD keeps clear of the bottom-right corner. */
@media (max-width: 600px) {
  #canvas-hud {
    flex-wrap: wrap;
    max-width: calc(100% - 2 * var(--space-md, 12px) - 64px);
  }
  #mandala-controls {
    order: 10; /* zoom + grid stay together in the first row */
    flex: 1 1 100%;
    border-left: 0;
    border-top: 1px solid var(--border-1);
  }
  #mandala-controls input[type="range"] { flex: 1 1 auto; width: auto; min-width: 72px; }
}

/* v26.10: a closed right panel peeked 8px into the screen on phones (right: 8px + translateX(100%)). */
html[data-edition="light"] .floating-panel-right:not(.active) {
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0s linear 0.3s; /* hide after sliding out */
}

/* v26.11 tool context controls in the canvas HUD: gradient stop bar + fill tolerance
   (same pattern as #mandala-controls: shown only while the tool is active). */
#gradient-controls,
#fill-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border-left: 1px solid var(--border-1);
  color: var(--text-1);
  font-size: var(--text-sm, 13px);
}
#gradient-controls[hidden],
#fill-controls[hidden] { display: none; }
#gradient-controls .gc-label { font-weight: 600; white-space: nowrap; }
#canvas-hud #gradient-type { width: auto; padding: 0 10px; font-size: var(--text-xs, 12px); font-weight: 600; color: var(--text-1); border: 1px solid var(--border-1); }
#canvas-hud #gradient-type[aria-pressed="true"] { background: var(--accent-soft, rgba(43, 181, 173, 0.2)); }
#canvas-hud button:disabled { opacity: 0.4; cursor: default; }
.gradient-stops, .gradient-presets { display: flex; align-items: center; gap: 4px; }
#canvas-hud .gradient-stop {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--border-1);
}
#canvas-hud .gradient-stop.is-transparent {
  background-image: linear-gradient(45deg, #c9c9c9 25%, transparent 25%, transparent 75%, #c9c9c9 75%), linear-gradient(45deg, #c9c9c9 25%, #ffffff 25%, #ffffff 75%, #c9c9c9 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
}
#canvas-hud .gradient-stop:hover { box-shadow: 0 0 0 2px var(--accent, #2bb5ad); }
.gradient-presets { padding-left: 6px; border-left: 1px solid var(--border-1); }
#canvas-hud .gradient-preset {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border-1);
}
#canvas-hud .gradient-preset[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent, #2bb5ad); }
#fill-controls input[type="range"] { width: 110px; min-height: 44px; }
#fill-controls #fill-tolerance-value { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 600px) {
  #gradient-controls,
  #fill-controls {
    order: 11;
    flex: 1 1 100%;
    flex-wrap: wrap;
    border-left: 0;
    border-top: 1px solid var(--border-1);
    padding: 4px 6px;
  }
  #gradient-controls .gc-label { display: none; }
  .gradient-presets { flex: 1 1 100%; border-left: 0; padding-left: 0; }
  #canvas-hud .gradient-stop, #canvas-hud .gradient-preset { width: 32px; height: 32px; }
  #fill-controls input[type="range"] { flex: 1 1 auto; width: auto; min-width: 72px; }
}

/* v26.11: the gradient stop bar gets its own HUD row (presets wrap below the stops), so the HUD
   stays compact and never runs under the bottom control panel on desktop. */
#canvas-hud:has(#gradient-controls:not([hidden])) { flex-wrap: wrap; max-width: min(400px, calc(100% - 2 * var(--space-md, 12px) - 64px)); }
#canvas-hud #gradient-controls { order: 10; flex: 1 1 100%; flex-wrap: wrap; border-left: 0; border-top: 1px solid var(--border-1); padding: 4px 6px; }
#canvas-hud #gradient-controls .gradient-presets { flex: 1 1 100%; border-left: 0; padding-left: 0; }

/* v26.11: on phones the HUD grows to two rows while a tool context bar (mandala, gradient, fill)
   is open; toasts and the status line move above it instead of covering it. */
@media (max-width: 600px) {
  body:has(#gradient-controls:not([hidden])) #toast-region,
  body:has(#gradient-controls:not([hidden])) #status-indicator,
  body:has(#fill-controls:not([hidden])) #toast-region,
  body:has(#fill-controls:not([hidden])) #status-indicator,
  body:has(#mandala-controls:not([hidden])) #toast-region,
  body:has(#mandala-controls:not([hidden])) #status-indicator {
    bottom: calc(236px + env(safe-area-inset-bottom, 0px));
  }
}
/* v26.11: the stop row never wraps (up to 5 stops + add/remove on a 390px phone): swatches shrink. */
#canvas-hud .gradient-stops { flex: 1 1 0; min-width: 0; }
#canvas-hud .gradient-stop { flex: 0 1 32px; min-width: 22px; height: auto; aspect-ratio: 1 / 1; }
@media (max-width: 600px) {
  #canvas-hud #gradient-type { padding: 0 8px; }
  #canvas-hud #add-gradient-stop, #canvas-hud #remove-gradient-stop { width: 28px; flex: 0 0 28px; }
}

/* v26.11 vector stickers: category tabs + grid in the left panel, sticker and smudge bars in the HUD. */
.sticker-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.sticker-tab {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-1);
  background: transparent;
  color: var(--text-2);
  font-size: var(--text-xs, 12px);
  font-weight: 600;
  cursor: pointer;
}
.sticker-tab[aria-selected="true"] { background: var(--accent-soft, rgba(43, 181, 173, 0.2)); color: var(--text-1); border-color: var(--accent, #2bb5ad); }
.sticker-tab:focus-visible { outline: 3px solid var(--accent, #2bb5ad); outline-offset: 2px; }
#stickers-section .sticker-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
#stickers-section .sticker-btn { width: auto; height: auto; aspect-ratio: 1 / 1; min-height: 44px; padding: 6px; color: var(--text-1); border-width: 1px; }
#stickers-section .sticker-btn[hidden] { display: none !important; }
#stickers-section .sticker-btn .icon { width: 70%; height: 70%; max-width: 32px; max-height: 32px; }
#stickers-section .sticker-btn.active { transform: none; color: var(--text-1); }
.sticker-hint { margin: 8px 0 0; font-size: var(--text-xs, 12px); color: var(--text-2); }

#sticker-controls,
#smudge-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 4px 6px;
  color: var(--text-1);
  font-size: var(--text-sm, 13px);
}
#sticker-controls[hidden],
#smudge-controls[hidden] { display: none; }
#canvas-hud:has(#sticker-controls:not([hidden])),
#canvas-hud:has(#smudge-controls:not([hidden])) { flex-wrap: wrap; max-width: min(560px, calc(100% - 2 * var(--space-md, 12px) - 64px)); }
#canvas-hud #sticker-controls,
#canvas-hud #smudge-controls { order: 10; flex: 1 1 100%; border-top: 1px solid var(--border-1); }
#sticker-controls input[type="range"] { width: 96px; min-height: 44px; }
#sticker-controls .sc-field { display: inline-flex; align-items: center; gap: 6px; }
#sticker-controls .sc-val { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.sc-seg { display: inline-flex; border: 1px solid var(--border-1); border-radius: var(--radius-sm, 8px); overflow: hidden; }
#canvas-hud .sc-seg button { width: auto; padding: 0 10px; gap: 4px; border-radius: 0; font-size: var(--text-xs, 12px); font-weight: 600; color: var(--text-1); }
#canvas-hud .sc-seg button + button { border-left: 1px solid var(--border-1); }
#canvas-hud .sc-seg button[aria-pressed="true"],
#canvas-hud #sticker-controls > button[aria-pressed="true"] { background: var(--accent-soft, rgba(43, 181, 173, 0.2)); color: var(--text-1); box-shadow: inset 0 -2px 0 var(--accent, #2bb5ad); }
@media (max-width: 600px) {
  #sticker-controls .sc-field { flex: 1 1 100%; }
  #sticker-controls .sc-field + .sc-field { flex: 1 1 0; min-width: 0; } /* rotation shares its row with the 3 toggles */
  #sticker-controls .sc-field label { min-width: 7ch; }
  #sticker-controls input[type="range"] { flex: 1 1 auto; width: auto; min-width: 64px; }
  .sc-seg { flex: 1 1 100%; }
  #canvas-hud .sc-seg button { flex: 1 1 0; padding: 0 4px; }
  body:has(#smudge-controls:not([hidden])) #toast-region,
  body:has(#smudge-controls:not([hidden])) #status-indicator {
    bottom: calc(236px + env(safe-area-inset-bottom, 0px));
  }
}
@media (max-width: 600px) {
  /* the sticker bar is three rows high on phones: status + toasts sit above it */
  body:has(#sticker-controls:not([hidden])) #toast-region,
  body:has(#sticker-controls:not([hidden])) #status-indicator {
    bottom: calc(300px + env(safe-area-inset-bottom, 0px));
  }
}

/* v26.11 HUD pill: active tool + effects with their status (JF_COMPAT). Active = accent, rests =
   yellow dashed + the word "ruht", Kombi = second chip after "+". Never colour alone (WCAG 1.4.1). */
.jf-tool-pill {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  min-height: 44px;
  padding: 0 8px 0 6px;
  border-right: 1px solid var(--border-1);
  color: var(--text-1);
  font-size: var(--text-sm, 13px);
}
.jf-tool-pill .hud-tool { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.jf-tool-pill .hud-tool .icon { width: 18px; height: 18px; }
#canvas-hud .hud-chip {
  width: auto;
  height: auto;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-1);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
}
#canvas-hud .hud-chip:hover { background: var(--accent-soft); color: var(--text-1); text-decoration: line-through; }
#canvas-hud .hud-chip.secondary { border-style: double; border-width: 4px; padding: 0 10px; }
#canvas-hud .hud-chip.dormant {
  border: 2px dashed var(--warning);
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  color: var(--text-1);
}
#canvas-hud .hud-chip.basic:not(.dormant) { border-color: color-mix(in srgb, var(--accent) 60%, var(--text-2)); }
.jf-tool-pill .hud-plus { font-weight: 700; color: var(--accent); }
.jf-tool-pill .hud-rest { font-weight: 700; color: var(--warning); font-size: var(--text-xs, 12px); text-transform: uppercase; letter-spacing: 0.04em; }

/* effect cards / basic buttons that stay selected but rest with the current tool, Kombi partner */
.effects-grid .effect-card.active.dormant {
  background: color-mix(in srgb, var(--warning) 16%, var(--surface-1, #1b1d22)) !important;
  border: 2px dashed var(--warning) !important;
  color: var(--text-1) !important;
  box-shadow: none !important;
  transform: none;
}
.effects-grid .effect-card.active.secondary:not(.dormant) {
  background: var(--accent-soft) !important;
  border: 4px double var(--accent) !important;
  color: var(--text-1) !important;
  box-shadow: none !important;
  transform: none;
}
.effects-grid .effect-card.active.dormant,
.effects-grid .effect-card.active.secondary { position: relative; }
.effects-grid .effect-card.active.dormant::after,
.effects-grid .effect-card.active.secondary::after {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.effects-grid .effect-card.active.dormant::after { content: "ruht"; color: var(--warning); }
.effects-grid .effect-card.active.secondary:not(.dormant)::after { content: "+ Kombi"; color: var(--accent); }
.basic-effects-grid .effect-btn.active.dormant {
  border: 2px dashed var(--warning);
  background: color-mix(in srgb, var(--warning) 14%, transparent);
}
@media (prefers-reduced-motion: reduce) {
  #canvas-hud .hud-chip, .effects-grid .effect-card { transition: none !important; }
}
@media (max-width: 600px) {
  .jf-tool-pill {
    order: -1;
    flex: 1 1 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border-1);
    padding-bottom: 2px;
  }
}
#mandala-controls.dormant { outline: 2px dashed var(--warning); outline-offset: -2px; border-radius: var(--radius-sm, 6px); }
/* v26.11: on phones the HUD pill adds a row above the zoom controls; toasts move above it
   (the sticker-controls rule above stays stronger and keeps its 300px). */
@media (max-width: 600px) {
  body:has(#jf-tool-pill) #toast-region,
  body:has(#jf-tool-pill) #status-indicator {
    bottom: calc(170px + env(safe-area-inset-bottom, 0px));
  }
}
/* v26.11 critic round 1: in Kombi, cards that cannot join the active effect are dimmed with a lock
   (title says why; a tap replaces the active effect with a clear message). */
.effects-grid .effect-card.locked { position: relative; opacity: 0.55; border-style: dashed; }
.effects-grid .effect-card.locked::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 14px;
  height: 14px;
  background: var(--text-2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1zm2 0h6V7a3 3 0 0 0-6 0v3z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1zm2 0h6V7a3 3 0 0 0-6 0v3z'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}
/* v26.11 critic round 1: one tool display (the HUD pill), no debug stamp for users, toasts above
   the bottom stack on phones (--jf-toast-bottom is measured by the dock script in index.html). */
#tool-status-indicator { display: none !important; }
#version-indicator { display: none !important; }
.control-restore-btn .icon { width: 18px; height: 18px; }
@media (max-width: 768px) {
  #toast-region,
  #status-indicator { bottom: var(--jf-toast-bottom, calc(170px + env(safe-area-inset-bottom, 0px))) !important; }
}
/* the left/right tabs move beside an open panel (dock script); keep their slide smooth */
.panel-toggle { transition: left 0.3s ease, right 0.3s ease, background var(--transition-fast), border-color var(--transition-fast); }
/* v26.11 critic round 1: title + work title fit the 43px top bar (the title was cut at the top at 1366). */
.top-bar-center .app-title { line-height: 1.15; }
.top-bar-center #work-title { display: inline-block; line-height: 1.15; padding-top: 0; padding-bottom: 0; vertical-align: top; }
/* v26.11 critic round 1: 44px hit areas (WCAG 2.5.8 / Apple HIG). HUD buttons are 44px; the top bar
   buttons keep their compact look and get an invisible vertical extension. */
.top-bar-center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; }
.top-bar-center #work-title { margin-left: 0; }
#canvas-hud > button,
#canvas-hud #zoom-level { min-width: 44px; height: 44px; }
#canvas-hud .sc-seg button,
#canvas-hud #sticker-controls > button { min-height: 44px; }
.top-bar-btn { position: relative; }
.top-bar-btn::after { content: ""; position: absolute; left: 0; right: 0; top: -7px; bottom: -7px; }
/* v26.11 critic round 1: effect cards never get wider than the panel (phones cut "…lektrisch",
   "Feue" and scrolled the section sideways). Columns may shrink, long names wrap. */
.effects-grid,
.basic-effects-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.effects-grid .effect-card,
.basic-effects-grid .effect-btn { min-width: 0; }
.effects-grid .effect-title,
.effects-grid .effect-description,
.basic-effects-grid .effect-label { overflow-wrap: anywhere; hyphens: auto; }
@media (max-width: 768px) {
  .effects-grid .effect-card { padding: 10px 6px; }
  .effects-grid .effect-title { font-size: var(--text-sm, 13px); }
}
#layer-panel-section .layer-controls-header,
#layer-panel-section .layer-actions,
#layer-panel-section .layer-blend-mode { flex-wrap: wrap; row-gap: 6px; min-width: 0; }
#layer-panel-section #blend-mode-select { max-width: 100%; min-width: 0; }
/* v26.11 critic round 1: an open side panel on phones rests without a 3D transform. WebKit painted a
   black square at the panel's top-left corner while the composited translate3d(0,0,0) layer stayed. */
@media (max-width: 768px) {
  #left-panel.floating-panel-left.active,
  #right-panel.floating-panel-right.active { transform: none; }
}
/* v26.11 critic round 1: on phones the idea of the day is one compact line on the canvas edge
   (it covered the top third of the canvas); "mehr" opens the full text. */
#daily-idea-more { display: none; }
@media (max-width: 520px) {
  .daily-idea:not(.expanded) { flex-wrap: nowrap; top: auto; bottom: calc(100% + 6px); padding: 0 4px 0 12px; border-radius: 999px; gap: 2px; width: min(94%, 380px); }
  .daily-idea:not(.expanded) #daily-idea-text { flex: 1 1 auto; min-width: 0; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .daily-idea #daily-idea-more { display: inline-flex; align-items: center; color: var(--accent, #2bb5ad); font-weight: 600; padding: 0 8px; }
  .daily-idea:not(.expanded) #daily-idea-next { margin-left: 0; padding: 0 8px; }
}
/* effect-previews:start (generated by scripts/build-effect-previews.mjs) */
.effects-grid .effect-card[id^="effect-"]::before { content: ""; display: block; height: 28px; margin: -4px -2px 6px; border-radius: 6px; background: var(--fx-preview, none) center / 100% 100% no-repeat; }
.effects-grid #effect-none::before { display: none; }
#effect-cosmic { --fx-preview: url("../assets/effect-previews/cosmic.webp"); }
#effect-lightning { --fx-preview: url("../assets/effect-previews/lightning.webp"); }
#effect-neon { --fx-preview: url("../assets/effect-previews/neon.webp"); }
#effect-rainbow { --fx-preview: url("../assets/effect-previews/rainbow.webp"); }
#effect-plasma { --fx-preview: url("../assets/effect-previews/plasma.webp"); }
#effect-explosion { --fx-preview: url("../assets/effect-previews/explosion.webp"); }
#effect-crystal { --fx-preview: url("../assets/effect-previews/crystal.webp"); }
#effect-matrix { --fx-preview: url("../assets/effect-previews/matrix.webp"); }
#effect-quantum { --fx-preview: url("../assets/effect-previews/quantum.webp"); }
#effect-dead-city { --fx-preview: url("../assets/effect-previews/dead-city.webp"); }
#effect-lines { --fx-preview: url("../assets/effect-previews/lines.webp"); }
#effect-aurora { --fx-preview: url("../assets/effect-previews/aurora.webp"); }
#effect-fire { --fx-preview: url("../assets/effect-previews/fire.webp"); }
#effect-galaxy { --fx-preview: url("../assets/effect-previews/galaxy.webp"); }
#effect-fireflies { --fx-preview: url("../assets/effect-previews/fireflies.webp"); }
#effect-cyber { --fx-preview: url("../assets/effect-previews/cyber.webp"); }
#effect-ice { --fx-preview: url("../assets/effect-previews/ice.webp"); }
#effect-bleed { --fx-preview: url("../assets/effect-previews/bleed.webp"); }
#effect-drip { --fx-preview: url("../assets/effect-previews/drip.webp"); }
#effect-mosaic { --fx-preview: url("../assets/effect-previews/mosaic.webp"); }
#effect-chalk { --fx-preview: url("../assets/effect-previews/chalk.webp"); }
/* effect-previews:end */
