/* style.css — Easel Lens */

/* ── Reset & Base ──────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  padding: 1rem;
}

/* ── Header ────────────────────────────────── */
header {
  text-align: center;
  padding: 1.5rem 0 1rem;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #f0f0f0;
}

.subtitle {
  color: #888;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ── Visually hidden (keyboard-accessible) ─── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Account ───────────────────────────────── */
.destructive-btn { border-color: #d96a6a !important; color: #ffd6d6 !important; }
.destructive-panel { border: 1px solid #8b3d4d; padding: 0.9rem; border-radius: 8px; }
.destructive-panel .checkbox-label { display: flex; align-items: flex-start; gap: 0.55rem; }
.destructive-panel .checkbox-label input { width: auto; margin-top: 0.2rem; }
.account-area {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
}
.account-toggle, .account-actions button, .account-actions a, .account-form button, .account-panel input {
  min-height: 44px;
}
.account-toggle, .account-actions button, .account-actions a, .link-btn {
  padding: 0.55rem 1rem;
  border: 1px solid #3a3a55;
  border-radius: 7px;
  background: #252540;
  color: #e0e0e0;
  cursor: pointer;
}
.account-actions a { display: inline-flex; align-items: center; justify-content: center; }
.account-toggle:hover, .account-actions button:hover, .account-actions a:hover, .link-btn:hover { border-color: #7c8aff; }
.account-panel {
  position: absolute;
  z-index: 10;
  top: 3rem;
  right: 0;
  width: min(25rem, 100%);
  padding: 1rem;
  background: #202038;
  border: 1px solid #3a3a55;
  border-radius: 10px;
  box-shadow: 0 0.5rem 2rem #0008;
}
.account-status { color: #ccc; margin-bottom: 0.5rem; }
.account-alert { min-height: 1.5rem; color: #e6a23c; margin-bottom: 0.5rem; }
.account-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.account-form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.account-form h2 { font-size: 1rem; color: #f0f0f0; }
.account-form input { width: 100%; padding: 0.5rem; border: 1px solid #555; border-radius: 6px; background: #151525; color: #fff; }
.account-form button { width: 100%; }

/* ── Projects ─────────────────────────────── */
.project-area {
  position: relative;
  max-width: 1100px;
  margin: 0.5rem auto 0;
  display: flex;
  justify-content: flex-end;
}
.project-panel {
  position: absolute;
  z-index: 10;
  top: 3rem;
  right: 0;
  width: min(30rem, 100%);
  padding: 1rem;
  background: #202038;
  border: 1px solid #3a3a55;
  border-radius: 10px;
  box-shadow: 0 0.5rem 2rem #0008;
}
.project-status { min-height: 1.5rem; color: #ccc; margin-bottom: 0.5rem; }
.project-create-form { display: grid; gap: 0.5rem; }
.project-create-form input { min-height: 44px; padding: 0.5rem; border: 1px solid #555; border-radius: 6px; background: #151525; color: #fff; }
.project-create-form button, .project-list button, .project-list input { min-height: 44px; }
.project-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.project-open-btn { min-height: 44px; padding: 0.55rem 1rem; border: 1px solid #3a3a55; border-radius: 7px; background: #252540; color: #e0e0e0; cursor: pointer; }
.project-open-btn.active, .project-open-btn:hover { border-color: #7c8aff; }
.project-list input { min-width: 10rem; padding: 0.5rem; border: 1px solid #555; border-radius: 6px; background: #151525; color: #fff; }
.project-image-area { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #3a3a55; }
.project-image-area h3 { margin-bottom: 0.5rem; font-size: 1rem; }
.project-image-area > input { width: 100%; min-height: 44px; margin: 0.35rem 0 0.6rem; padding: 0.5rem; border: 1px solid #555; border-radius: 6px; background: #151525; color: #fff; }
.project-image-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.project-image-actions button, .project-image-card button, .project-image-card input { min-height: 44px; }
.project-image-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.75rem; margin-top: 0.75rem; }
.project-image-card { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; padding: 0.6rem; border: 1px solid #3a3a55; border-radius: 8px; background: #18182b; }
.project-image-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 5px; background: #10101c; }
.project-image-name { overflow-wrap: anywhere; color: #f0f0f0; }
.project-image-card input { width: 100%; min-width: 0; padding: 0.4rem; border: 1px solid #555; border-radius: 5px; background: #151525; color: #fff; }

/* ── Drop Zone ─────────────────────────────── */
#upload-section {
  max-width: 600px;
  margin: 1rem auto 0;
}

#drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem 1rem;
  border: 2px dashed #555;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: #7c8aff;
  background: rgba(124, 138, 255, 0.08);
}

.drop-icon {
  font-size: 2.5rem;
}

.drop-hint {
  font-size: 0.8rem;
  color: #666;
}

/* ── Tab Bar ──────────────────────────────── */
#tab-bar {
  display: flex;
  gap: 0.25rem;
  max-width: 1100px;
  margin: 1.5rem auto 0;
  padding: 0 0.25rem;
  border-bottom: 1px solid #2a2a45;
}

.tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #888;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn:hover {
  background: #252540;
  color: #ccc;
}

.tab-btn.active {
  background: #252540;
  color: #f0f0f0;
  border-bottom-color: #7c8aff;
}

/* ── Tool Views ────────────────────────────── */
.hidden {
  display: none !important;
}

#tool-views {
  max-width: 1100px;
  margin: 1rem auto 0;
}

.tool-view {
  /* shown by .hidden removal */
}

.canvas-pair {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.canvas-box {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.canvas-box h3 {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.canvas-box canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  background: #111;
}

/* ── Controls ──────────────────────────────── */
.controls {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.control-label {
  font-size: 0.9rem;
  color: #aaa;
  min-width: 4rem;
}

#value-slider {
  flex: 1;
  max-width: 400px;
  accent-color: #7c8aff;
  height: 6px;
}

#value-label {
  color: #f0f0f0;
  font-size: 1.1rem;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  max-width: 400px;
  width: 100%;
  margin-left: 4.75rem;
  font-size: 0.7rem;
  color: #666;
}

/* Slider stacked directly above its tick labels. Prefer this over the
   bare .slider-ticks margin-left offset: alignment never depends on the
   control label's width or on the browser's default range width. */
.slider-stack {
  flex: 1;
  max-width: 400px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.slider-stack input[type="range"] {
  width: 100%;
  accent-color: #7c8aff;
  height: 6px;
}

.slider-stack .slider-ticks {
  margin-left: 0;
  max-width: none;
}

/* ── Mode Radio Buttons ────────────────────── */
.mode-row {
  gap: 0.5rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: #252540;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.radio-label:hover {
  background: #303055;
}

.radio-label input[type="radio"] {
  accent-color: #7c8aff;
}

.radio-label:has(input:checked) {
  background: #7c8aff22;
  outline: 1px solid #7c8aff55;
}

/* ── Histogram ─────────────────────────────── */
.histogram-section {
  margin-top: 1.25rem;
  text-align: center;
}

.histogram-section h3 {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#histogram-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  background: #111;
  cursor: pointer;
}

.histogram-hint {
  font-size: 0.78rem;
  color: #666;
  margin-top: 0.4rem;
}

.histogram-section .secondary-btn {
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

/* ── Sketch Section ───────────────────────── */
/* (sketch toggle styles removed — now uses tab bar) */

.sketch-canvas-box canvas,
.grid-canvas-box canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  background: #111;
}

#edge-blur,
#edge-threshold {
  flex: 1;
  max-width: 400px;
  accent-color: #7c8aff;
  height: 6px;
}

#edge-threshold-label {
  color: #f0f0f0;
  font-size: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: #252540;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.checkbox-label:hover {
  background: #303055;
}

.checkbox-label input[type="checkbox"] {
  accent-color: #7c8aff;
}

.checkbox-label:has(input:checked) {
  background: #7c8aff22;
  outline: 1px solid #7c8aff55;
}

/* ── Source Banner ──────────────────────────── */
.source-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  max-width: 1100px;
  margin: 0.75rem auto 0;
  padding: 0.5rem 1rem;
  background: #1f2a1f;
  border: 1px solid #3a5a3a;
  border-radius: 8px;
  font-size: 0.85rem;
}

.source-banner-label {
  color: #7bd88f;
}

.source-reset-btn {
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  border: 1px solid #3a5a3a;
  border-radius: 6px;
  background: #162016;
  color: #7bd88f;
  cursor: pointer;
  transition: background 0.2s;
}

.source-reset-btn:hover {
  background: #2a3a2a;
}

/* ── Promote Button ────────────────────────── */
.promote-btn {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  border: 1px solid #3a3a55;
  border-radius: 6px;
  background: #1f1f38;
  color: #ccc;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  margin-right: 0.5rem;
}

.promote-btn:hover {
  background: #2a2f48;
  border-color: #7c8aff;
}

/* ── Download ──────────────────────────────── */
.download-section {
  margin-top: 1rem;
  text-align: center;
}

.download-btn {
  padding: 0.6rem 1.5rem;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  background: #7c8aff;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.download-btn:hover {
  background: #5e6ee0;
}

/* ── Color Mixer Tool ──────────────────────── */
.color-pick-box {
  text-align: center;
}

.pick-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.pick-stage #color-canvas {
  display: block;
  cursor: crosshair;
}

.pick-stage #color-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  background: transparent;
}

.mix-result {
  margin-top: 1.25rem;
}

.mix-hint {
  color: #888;
  font-size: 0.9rem;
  text-align: center;
}

.swatch-pair {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.swatch {
  flex: 1;
  min-width: 8rem;
  max-width: 16rem;
  text-align: center;
}

.swatch-chip {
  height: 4.5rem;
  border-radius: 8px;
  border: 1px solid #333;
}

.swatch-label {
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.4rem;
}

.swatch-value {
  font-size: 0.85rem;
  color: #ccc;
  font-family: monospace;
}

.match-quality {
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.match-quality.reachable { color: #7bd88f; }
.match-quality.unreachable { color: #e6a23c; }
.match-quality.value-adjust { color: #5dade2; }

.delta-note {
  color: #666;
  font-size: 0.8rem;
}

.recipe-list {
  margin: 1rem auto 0;
  max-width: 28rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.recipe-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.recipe-swatch {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 3px;
  border: 1px solid #333;
  flex-shrink: 0;
}

.recipe-name { flex: 1; color: #ddd; font-size: 0.9rem; }
.recipe-percent { color: #f0f0f0; font-weight: 600; font-size: 0.95rem; }

.recipe-bar {
  flex: 1.4;
  height: 6px;
  background: #2a2a40;
  border-radius: 3px;
  overflow: hidden;
}
.recipe-bar > span {
  display: block;
  height: 100%;
  background: #7c8aff;
}

.mix-note {
  margin: 1.25rem auto 0;
  max-width: 38rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #888;
  border-left: 3px solid #3a3a55;
  padding: 0.5rem 0.9rem;
}
.mix-note strong { color: #aaa; }

.palette-editor {
  margin-top: 1.5rem;
  border-top: 1px solid #2a2a40;
  padding-top: 0.75rem;
}

.palette-editor summary {
  cursor: pointer;
  color: #aaa;
  font-size: 0.9rem;
}

#color-radius-label {
  display: inline-block;
  min-width: 3.4em;
  text-align: left;
}

.palette-list {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  gap: 0.4rem 0.6rem;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.palette-item input[type="color"] {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid #333;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.palette-item input[type="text"] {
  flex: 1;
  min-width: 0;
  background: #16162a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

.palette-strength {
  width: 3.2rem;
  background: #16162a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 0.4rem 0.3rem;
  font-size: 0.8rem;
  text-align: center;
  flex-shrink: 0;
}
.palette-strength::-webkit-inner-spin-button {
  opacity: 0.6;
}

.palette-remove {
  background: none;
  border: 1px solid #3a3a55;
  color: #999;
  border-radius: 6px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  flex-shrink: 0;
}
.palette-remove:hover { color: #e06c75; border-color: #e06c75; }

.palette-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.secondary-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border: 1px solid #3a3a55;
  border-radius: 6px;
  background: #1f1f38;
  color: #ccc;
  cursor: pointer;
}
.secondary-btn:hover { background: #2a2a48; }

/* ── Color Picker Modal ───────────────────── */
.color-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.color-picker-overlay[hidden] { display: none; }

.color-picker-panel {
  background: #1a1a2e;
  border: 1px solid #3a3a55;
  border-radius: 12px;
  width: min(640px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.color-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid #2a2a45;
}
.color-picker-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #e0e0e0;
}

.color-picker-close {
  background: none;
  border: 1px solid #3a3a55;
  color: #999;
  font-size: 1.3rem;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}
.color-picker-close:hover { color: #e06c75; border-color: #e06c75; }

.color-picker-search {
  margin: 0.75rem 1.1rem;
  padding: 0.5rem 0.75rem;
  background: #16162a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.9rem;
}
.color-picker-search::placeholder { color: #666; }

.color-picker-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.1rem 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.3rem;
  align-content: start;
}

.color-picker-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  background: none;
  border: 1px solid transparent;
  color: #ccc;
  font-size: 0.85rem;
  text-align: left;
  font-family: inherit;
  transition: background 0.1s;
}
.color-picker-item:hover {
  background: #252545;
  border-color: #3a3a55;
}

.color-picker-item .picker-swatch {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 4px;
  border: 1px solid #333;
  flex-shrink: 0;
}

.color-picker-footer {
  padding: 0.75rem 1.1rem;
  border-top: 1px solid #2a2a45;
}

/* ── Underpainting Check Tool: base styles ─────── */

.underpainting-upload-panel,
.underpainting-marking-panel {
  max-width: 600px;
  margin: 0 auto;
}

.underpainting-intro {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.underpainting-note {
  font-size: 0.85rem;
  color: #aaa;
  background: #252540;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  border-left: 3px solid #ffcc00;
}

.underpainting-file-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.underpainting-file-label {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  min-height: 44px;
  background: #3a3a5c;
  color: #e0e0e0;
  border: 1px solid #555;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, outline-color 0.15s;
  box-sizing: border-box;
}

.underpainting-file-label:hover {
  background: #4a4a6c;
}

/* The visually hidden file input receives keyboard focus; focus-within
   exposes that focus on the visible chooser label. */
.underpainting-file-row:focus-within .underpainting-file-label {
  outline: 2px solid #7c8aff;
  outline-offset: 2px;
}

.underpainting-status {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #ffaa44;
  min-height: 1.2em;
}

.underpainting-marking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

#underpainting-next-corner {
  font-weight: 600;
  color: #ffcc00;
  font-size: 0.95rem;
}

.underpainting-marking-actions {
  display: flex;
  gap: 0.4rem;
}

.underpainting-marking-actions .secondary-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.underpainting-stage {
  position: relative;
  display: inline-block;
  overflow: visible;
  /* Reserve 22 px on each side for the interaction surface that extends
     beyond the image canvas, so the 44 px boundary hit target does not
     cause horizontal page overflow at 320 CSS‑px viewports. */
  max-width: calc(100% - 44px);
  margin-left: 22px;
  margin-right: 22px;
}

/* ≥44 px touch/pointer target for opacity slider */
#underpainting-opacity {
  min-height: 44px;
}

.underpainting-stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

#underpainting-image-canvas {
  width: 100%;
  height: auto;
}

.underpainting-guide-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* The image canvas is the marking interaction surface; prevent browser
   pan/scroll gestures while dragging a corner. */
#underpainting-image-canvas {
  touch-action: none;
}

.underpainting-magnifier {
  position: fixed;
  z-index: 1000;
  width: 168px;
  height: 168px;
  border: 3px solid #ffcc00;
  border-radius: 50%;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
  background: #111;
  pointer-events: none;
  image-rendering: auto;
}

/* Comparison canvases */
.underpainting-comparison-panel {
  width: 100%;
  margin: 1.5rem auto 0;
}

.underpainting-comparison-viewport {
  width: 100%;
  max-width: 960px;
  max-height: 75vh;
  margin: 0 auto;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: none;
  cursor: grab;
  border-radius: 6px;
  background: #11111e;
}

.underpainting-comparison-viewport.is-panning {
  cursor: grabbing;
  user-select: none;
}

.underpainting-comparison-stage {
  position: relative;
  display: block;
  flex: none;
}

.underpainting-comparison-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.underpainting-overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.underpainting-comparison-controls {
  width: min(960px, 100%);
  margin: 0.9rem auto 0;
}

.underpainting-zoom-row {
  margin-top: 0.65rem;
}

.underpainting-zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.underpainting-zoom-controls .secondary-btn {
  min-width: 44px;
  min-height: 44px;
}

#underpainting-zoom {
  width: min(360px, 55vw);
  min-height: 44px;
}

/* ── Crop Tool ──────────────────────────── */
.crop-canvas-box canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  background: #111;
  cursor: crosshair;
  touch-action: none;
}

.crop-aspect-label {
  font-size: 0.85rem;
  color: #aaa;
  margin-left: 0.5rem;
}

#crop-rotate-btn {
  min-height: 36px;
}

.tool-state-conflict {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.75rem;
  border: 1px solid #ffb347;
  border-radius: 6px;
  color: #ffe0a3;
}
.tool-state-conflict-text { flex: 1 1 16rem; }

/* ── Responsive: Mobile ────────────────────── */
@media (max-width: 700px) {
  .canvas-pair {
    flex-direction: column;
  }

  header h1 {
    font-size: 1.3rem;
  }

  #value-slider {
    max-width: 100%;
  }

  .slider-ticks {
    display: none; /* too cramped on mobile */
  }

  #tab-bar {
    flex-wrap: wrap;
    gap: 0;
  }

  .tab-btn {
    font-size: 0.78rem;
    padding: 0.4rem 0.6rem;
  }

  .underpainting-marking-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .underpainting-comparison-viewport {
    max-height: 68vh;
  }

  .underpainting-zoom-controls {
    justify-content: flex-start;
  }

  #underpainting-zoom {
    width: min(100%, 240px);
  }

  .account-area, .project-area { width: 100%; justify-content: stretch; }
  .account-toggle { width: 100%; }
  .account-panel, .project-panel { position: static; width: 100%; margin-top: 0.5rem; }
  .account-actions button, .account-actions a, .account-form button, .project-create-form button, .project-list button { width: 100%; }
}
