/* Elemenop Kids — Coloring Studio */

.studio {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column;
  background: #f6f2ff;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  user-select: none; -webkit-user-select: none;
}
.st-top { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fff; box-shadow: 0 2px 0 rgba(124, 77, 255, 0.08); z-index: 2; }
.st-title { flex: 1; min-width: 0; font-weight: 600; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-top-actions { display: flex; gap: 6px; align-items: center; }
.st-zoom { display: flex; gap: 6px; padding: 0 4px; }
.st-done { min-height: 48px; padding: 8px 18px; }
.st-top .icon-btn { background: #f4f0ff; box-shadow: none; }
.st-top .icon-btn[disabled] { opacity: 0.35; pointer-events: none; }
.more-btn { font-family: var(--font) !important; font-weight: 700; }

.st-body {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 330px; grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "tools canvas panel";
}
.st-tools { grid-area: tools; display: flex; flex-direction: column; gap: 8px; padding: 10px 8px; overflow-y: auto; background: #fff; }
.st-tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 70px; padding: 6px 4px; border: 0; border-radius: 18px;
  background: #f4f0ff; color: var(--ink-soft); font-weight: 500; font-size: 0.8rem;
  transition: transform 0.08s, background 0.15s;
}
.st-tool .e { font: 1.8rem/1 var(--emoji); }
.st-tool.on { background: var(--purple); color: #fff; box-shadow: 0 4px 0 var(--purple-d); }
.st-tool:active { transform: translateY(2px); }

.st-canvas {
  grid-area: canvas; position: relative; overflow: hidden; touch-action: none;
  background: radial-gradient(#ddd3f7 1.2px, transparent 1.3px) 0 0 / 22px 22px, #efe9fb;
}
.st-canvas[data-tool='move'] { cursor: grab; }
.st-canvas[data-tool='fill'], .st-canvas[data-tool='picker'] { cursor: pointer; }
.st-canvas[data-tool='brush'], .st-canvas[data-tool='eraser'], .st-canvas[data-tool='stamp'] { cursor: crosshair; }
.st-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 30px rgba(60, 40, 140, 0.2); background: #fff; will-change: transform; }
.st-paper, .st-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.st-layer { display: block; }
.st-lines { pointer-events: none; }
.st-loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; background: rgba(239, 233, 251, 0.6); }

.st-panel { grid-area: panel; display: flex; flex-direction: column; gap: 12px; padding: 14px; overflow-y: auto; background: #fff; }
.st-color-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.st-current {
  flex: 0 0 auto; width: 66px; height: 66px; border-radius: 50%; border: 4px solid #fff;
  display: grid; place-items: center; font: 700 1.6rem/1 var(--font);
  box-shadow: 0 0 0 3px #e2dcf5, 0 5px 12px rgba(0, 0, 0, 0.14);
}
.st-current .plus { opacity: 0.85; }
.st-color-info { flex: 1; min-width: 0; }
.st-color-info b { display: block; font-size: 1.15rem; font-weight: 600; line-height: 1.2; }
.st-color-info small { color: var(--ink-faint); font-size: 0.82rem; }
.st-shades { display: flex; gap: 5px; width: 100%; }
.st-shades .swatch { flex: 1; width: auto; height: 32px; border-radius: 10px; }

.swatch {
  flex: 0 0 auto; width: 46px; height: 46px; padding: 0; border: 3px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(43, 45, 66, 0.1); transition: transform 0.1s;
}
.swatch:active { transform: scale(0.92); }
.swatch.small { width: 34px; height: 34px; border-width: 2px; }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.1); }
.swatch.on2 { box-shadow: 0 0 0 3px var(--purple); }
.swatch.add { background: #f4f0ff; color: var(--purple); font: 700 1.5rem/1 var(--font); }
.st-tabs { padding-bottom: 4px; }
.st-tabs .chip { min-height: 40px; padding: 4px 12px; font-size: 0.92rem; }
.st-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 9px; justify-items: center; }
.st-recent { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-height: 0; }
.st-label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.st-hint { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

.st-options { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 2px dashed #ebe5fa; }
.st-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fill-chip, .brush-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 62px;
  padding: 6px 4px; border: 2px solid transparent; border-radius: 14px; background: #f6f3ff;
  color: var(--ink-soft); font-size: 0.75rem; font-weight: 500;
}
.fill-chip img { width: 40px; height: 40px; border-radius: 10px; display: block; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); background: #fff; }
.brush-chip .e { font: 1.5rem/1.2 var(--emoji); }
.fill-chip.on, .brush-chip.on { border-color: var(--purple); background: #ece4ff; color: var(--purple-d); }
.st-mix .chip.small { min-height: 36px; }
.sticker { width: 54px; height: 54px; padding: 0; border: 2px solid transparent; border-radius: 14px; background: #f6f3ff; font: 1.9rem/1 var(--emoji); }
.sticker.on { border-color: var(--purple); background: #ece4ff; }
.st-slider { display: flex; align-items: center; gap: 10px; }
.st-range { flex: 1; min-width: 80px; height: 34px; accent-color: var(--purple); }
.size-dot { display: inline-block; flex: 0 0 auto; border-radius: 50%; box-shadow: 0 0 0 2px #ddd5f3; }
.chip.small { min-height: 38px; padding: 4px 12px; font-size: 0.9rem; }
.toggle-chip.on { background: #dff5ea; color: #136b43; }

/* Dialog contents used by the studio */
.menu-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.menu-list .list-item { align-items: center; cursor: pointer; background: #f7f4ff; }
.paper-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 10px; }
.paper { min-height: 74px; border: 3px solid #e7e1f7; border-radius: 16px; font-weight: 600; }
.paper.on { border-color: var(--purple); }
.help-list { text-align: left; }
.help-list p { margin: 8px 0; }
.help-list .e { font-family: var(--emoji); }
.finish { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: center; margin-top: 6px; }
.finish-preview { width: 100%; border-radius: 18px; box-shadow: 0 0 0 8px #ffd23f, 0 10px 30px rgba(0, 0, 0, 0.15); background: #fff; }
.finish-actions { display: flex; flex-direction: column; gap: 10px; }
.finish-actions .btn { justify-content: flex-start; }
@media (max-width: 560px) { .finish { grid-template-columns: 1fr; } .finish-preview { width: 70%; margin: 6px auto; } }

/* Phones and portrait tablets: tools and colors below the picture */
@media (max-width: 860px), (max-aspect-ratio: 1/1) {
  .st-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas: "canvas" "tools" "panel";
  }
  .st-tools { flex-direction: row; gap: 6px; padding: 6px 8px; overflow-x: auto; overflow-y: hidden; box-shadow: 0 -2px 0 rgba(124, 77, 255, 0.06); }
  .st-tool { flex: 1 0 62px; min-height: 58px; font-size: 0.72rem; }
  .st-tool .e { font-size: 1.45rem; }
  .st-panel { max-height: 42vh; gap: 8px; padding: 8px 10px 10px; }
  .st-color-row { flex-wrap: nowrap; }
  .st-color-info { display: none; }
  .st-current { width: 54px; height: 54px; }
  .st-shades { width: auto; flex: 1; }
  .st-swatches { display: flex; flex-wrap: nowrap; overflow-x: auto; justify-items: start; padding: 3px 2px 6px; scrollbar-width: none; }
  .st-swatches::-webkit-scrollbar, .st-chips::-webkit-scrollbar { display: none; }
  .st-recent { flex-wrap: nowrap; overflow-x: auto; }
  .st-options { padding-top: 8px; gap: 8px; }
  .st-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .st-slider { min-width: 0; }
}
@media (max-width: 600px) {
  .st-zoom { display: none; }
  .st-done { padding: 8px 14px; }
  .st-done .lbl { display: none; }
  .st-title { font-size: 1rem; }
  .st-top { gap: 6px; padding: 6px 8px; }
  .st-top .icon-btn { width: 42px; height: 42px; flex-basis: 42px; font-size: 1.15rem; }
}
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .st-tool { min-height: 52px; }
  .st-tool .lbl { display: none; }
  .st-body { grid-template-columns: 70px minmax(0, 1fr) 300px; }
}
