/* ReaderNook Online Coloring Studio Stylesheet */
:root {
  --studio-bg: #f3f5ef;
  --studio-header-h: 60px;
  --studio-panel-bg: rgba(255, 255, 255, 0.94);
  --studio-border: #dde3d7;
  --studio-active: #29624c;
  --studio-forest: #29624c;
  --studio-ink: #243e34;
  --studio-cream: #f9f8f3;
  --shadow-sm: 0 2px 8px rgba(36, 62, 52, 0.06);
  --shadow-md: 0 6px 20px rgba(36, 62, 52, 0.09);
  --shadow-lg: 0 12px 36px rgba(36, 62, 52, 0.14);
}

html, body.studio-body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--studio-bg);
  color: var(--studio-ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

.studio-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Header */
.studio-header {
  height: var(--studio-header-h);
  background: #ffffff;
  border-bottom: 1px solid var(--studio-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 30;
  flex-shrink: 0;
  gap: 12px;
}

.studio-header-left, .studio-header-center, .studio-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.studio-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--studio-ink);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--studio-cream);
  border: 1px solid var(--studio-border);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.studio-back-link:hover {
  background: #edf2e8;
  color: var(--studio-active);
}
.studio-back-link svg {
  width: 16px;
  height: 16px;
  transform: rotate(180deg);
}

.studio-title-box {
  display: flex;
  flex-direction: column;
}
.studio-title-box h1 {
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: var(--studio-ink);
  line-height: 1.2;
}
.studio-title-box span {
  font-size: 11px;
  color: #707e74;
}

/* Header Action Buttons */
.studio-btn-group {
  display: flex;
  align-items: center;
  background: var(--studio-cream);
  border: 1px solid var(--studio-border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.studio-icon-btn {
  background: transparent;
  border: none;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--studio-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.studio-icon-btn:hover:not(:disabled) {
  background: #ffffff;
  color: var(--studio-active);
}
.studio-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.studio-icon-btn svg {
  width: 17px;
  height: 17px;
}

.zoom-level-text {
  font-size: 11px;
  font-weight: 600;
  min-width: 42px;
  text-align: center;
  color: #556359;
}

.studio-cta-btn {
  background: var(--studio-active);
  color: #ffffff;
  border: 1px solid var(--studio-active);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: background 0.15s ease;
  box-shadow: 0 2px 6px rgba(41, 98, 76, 0.2);
}
.studio-cta-btn:hover {
  background: #204d3c;
}
.studio-cta-btn svg {
  width: 16px;
  height: 16px;
}

/* Main Workspace */
.studio-workspace {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Left Tools Bar */
.studio-tools-bar {
  width: 72px;
  background: var(--studio-panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--studio-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 6px;
  gap: 8px;
  z-index: 20;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.tool-btn {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #506155;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.tool-btn span {
  font-size: 9px;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.3px;
}
.tool-btn svg {
  width: 20px;
  height: 20px;
}
.tool-btn:hover {
  background: #edf2e8;
  color: var(--studio-active);
}
.tool-btn.active {
  background: var(--studio-active);
  color: #ffffff;
  border-color: var(--studio-active);
  box-shadow: 0 3px 10px rgba(41, 98, 76, 0.25);
}

.tool-divider {
  width: 40px;
  height: 1px;
  background: var(--studio-border);
  margin: 4px 0;
}

/* Active Color Indicator on Tools Bar */
.active-color-preview-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 1px var(--studio-border), var(--shadow-sm);
  cursor: pointer;
  position: relative;
  margin-top: auto;
  transition: transform 0.15s ease;
}
.active-color-preview-btn:hover {
  transform: scale(1.08);
}
.active-color-preview-btn input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Tool Settings Bar (floating top center or sidebar) */
.tool-props-bar {
  position: absolute;
  top: 14px;
  left: 90px;
  background: var(--studio-panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--studio-border);
  border-radius: 10px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-md);
  z-index: 15;
  font-size: 12px;
}
.shape-options-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.shape-sub-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--studio-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--studio-ink);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.shape-sub-btn:hover {
  background: #ffffff;
  border-color: #a4b5a8;
}
.shape-sub-btn.active {
  background: var(--studio-forest);
  color: #ffffff;
  border-color: var(--studio-forest);
  box-shadow: 0 1px 4px rgba(45, 90, 39, 0.25);
}
.shape-fill-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--studio-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--studio-ink);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.shape-fill-btn:hover {
  background: #ffffff;
  border-color: #a4b5a8;
}
.shape-fill-btn.solid {
  background: #395443;
  color: #ffffff;
  border-color: #395443;
}
.shape-black-btn {
  background: #ffffff;
  border: 1.5px solid #111111;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #111111;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.shape-black-btn:hover {
  background: #111111;
  color: #ffffff;
}
.prop-separator {
  width: 1px;
  height: 18px;
  background: var(--studio-border);
  margin: 0 4px;
}
.easel-viewport.tool-shape {
  cursor: crosshair !important;
}
.prop-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.prop-label {
  font-weight: 600;
  color: #5d6d62;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.prop-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: #d4ded0;
  outline: none;
  width: 90px;
}
.prop-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--studio-active);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.prop-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--studio-active);
  cursor: pointer;
  border: none;
}
.size-preview-dot {
  display: inline-block;
  background: var(--studio-ink);
  border-radius: 50%;
  transition: width 0.1s ease, height 0.1s ease;
}

/* Center Easel (Canvas Viewport) */
.easel-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  background: radial-gradient(#e0e7dc 1px, transparent 1px);
  background-size: 24px 24px;
  touch-action: none;
}
.easel-viewport.panning {
  cursor: grab;
}
.easel-viewport.panning:active {
  cursor: grabbing;
}

.easel-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  box-shadow: 0 16px 45px rgba(27, 46, 36, 0.15);
  background: #ffffff;
  border-radius: 4px;
  transition: box-shadow 0.2s ease;
}

.canvas-stack {
  position: relative;
  display: block;
}
.canvas-layer {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 100%;
  height: 100%;
}
#bg-canvas {
  position: relative;
  z-index: 1;
  background: #ffffff;
}
#paint-canvas {
  z-index: 2;
}
#outline-canvas {
  z-index: 3;
  mix-blend-mode: multiply;
  pointer-events: none;
}
#cursor-canvas {
  z-index: 4;
  pointer-events: none;
}
.brush-cursor {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  border: 1.5px solid var(--studio-active);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
  pointer-events: none;
  display: none;
  z-index: 35;
  will-change: transform;
}
.brush-cursor.eraser {
  border-color: #d9534f;
}

/* Bottom Palette Tray */
.studio-palette-dock {
  background: var(--studio-panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--studio-border);
  padding: 10px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 20;
  box-shadow: 0 -4px 18px rgba(36, 62, 52, 0.05);
  flex-shrink: 0;
}

.palette-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.palette-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.palette-tabs::-webkit-scrollbar {
  display: none;
}

.palette-tab-btn {
  background: var(--studio-cream);
  border: 1px solid var(--studio-border);
  border-radius: 16px;
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 600;
  color: #5b6b60;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.palette-tab-btn:hover {
  background: #edf2e8;
  color: var(--studio-active);
}
.palette-tab-btn.active {
  background: var(--studio-active);
  color: #ffffff;
  border-color: var(--studio-active);
}

.palette-swatches-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.swatches-scroll-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px;
  flex: 1;
  scrollbar-width: thin;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15), var(--shadow-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}
.color-swatch:hover {
  transform: scale(1.18);
  z-index: 2;
}
.color-swatch.active {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px var(--studio-active), 0 3px 8px rgba(0,0,0,0.25);
  z-index: 3;
}

/* Custom & Recent */
.palette-extras {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid var(--studio-border);
  padding-left: 12px;
}

.custom-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid var(--studio-border);
  font-size: 11px;
  font-weight: 600;
  color: var(--studio-ink);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.custom-picker-btn:hover {
  background: var(--studio-cream);
}
.custom-picker-btn input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.custom-picker-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  display: inline-block;
}

.recent-colors-strip {
  display: flex;
  align-items: center;
  gap: 5px;
}
.recent-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s ease;
}
.recent-swatch:hover {
  transform: scale(1.15);
}

/* Modals */
.studio-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 48, 38, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.studio-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.studio-modal {
  background: #ffffff;
  border-radius: 14px;
  width: 90%;
  max-width: 440px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}
.studio-modal-backdrop.open .studio-modal {
  transform: translateY(0) scale(1);
}
.studio-modal h2 {
  font-family: Georgia, serif;
  font-size: 24px;
  margin: 0 0 10px;
  color: var(--studio-ink);
}
.studio-modal p {
  color: #617066;
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 22px;
}
.studio-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-btn {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.modal-btn-cancel {
  background: var(--studio-cream);
  color: var(--studio-ink);
  border: 1px solid var(--studio-border);
}
.modal-btn-cancel:hover {
  background: #edf2e8;
}
.modal-btn-danger {
  background: #c94436;
  color: #ffffff;
}
.modal-btn-danger:hover {
  background: #a83327;
}

/* Toast Notifications */
.studio-toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(36, 62, 52, 0.94);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.studio-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Loading Overlay */
.studio-loading-overlay {
  position: absolute;
  inset: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
  transition: opacity 0.3s ease;
}
.studio-loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}
.studio-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e1e7dc;
  border-top-color: var(--studio-active);
  border-radius: 50%;
  animation: studio-spin 0.8s linear infinite;
}
@keyframes studio-spin {
  to { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .tool-props-bar {
    top: auto;
    bottom: 85px;
    left: 12px;
    right: 12px;
    justify-content: space-around;
    padding: 7px 12px;
  }
}

@media (max-width: 680px) {
  .studio-header {
    height: 54px;
    padding: 0 10px;
    gap: 8px;
  }
  .studio-back-link span {
    display: none;
  }
  .studio-title-box h1 {
    font-size: 14px;
  }
  .studio-title-box span {
    display: none;
  }
  .studio-tools-bar {
    width: 58px;
    padding: 8px 4px;
    gap: 5px;
  }
  .tool-btn {
    width: 44px;
    height: 44px;
  }
  .tool-btn span {
    font-size: 8px;
  }
  .tool-btn svg {
    width: 17px;
    height: 17px;
  }
  .palette-tabs {
    max-width: 100%;
  }
  .palette-extras {
    display: none;
  }
  .studio-cta-btn span {
    display: none;
  }
  .zoom-level-text {
    display: none;
  }
}

/* Contest Modal in Studio */
.studio-contest-modal {
  max-width: 520px;
  text-align: left;
  position: relative;
  max-height: 92vh;
  overflow-y: auto;
  padding: 24px 28px;
}
.studio-contest-modal .kicker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--studio-forest);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.studio-contest-modal .kicker svg {
  width: 14px;
  height: 14px;
}
.studio-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--studio-cream);
  color: var(--studio-ink);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.studio-modal-close:hover {
  background: #e2e8dc;
}
.contest-modal-header {
  text-align: center;
  margin-bottom: 16px;
}
.contest-modal-header h2 {
  font-size: 22px;
  margin: 4px 0 6px;
}
.contest-modal-header p {
  font-size: 13px;
  color: #617066;
  margin: 0;
}
.modal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.studio-contest-form .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.studio-contest-form .field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--studio-ink);
}
.studio-contest-form .field input,
.studio-contest-form .field select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--studio-border);
  font-size: 13px;
  font-family: inherit;
  background: #ffffff;
  color: var(--studio-ink);
}
.studio-contest-form .field input:focus,
.studio-contest-form .field select:focus {
  outline: none;
  border-color: var(--studio-forest);
  box-shadow: 0 0 0 2px rgba(41, 98, 76, 0.15);
}
.modal-btn-primary {
  background: #29624c;
  background: var(--studio-forest, #29624c);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(41, 98, 76, 0.25);
  transition: all 0.15s ease;
}
.modal-btn-primary:hover {
  background: #1e4a38;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(41, 98, 76, 0.32);
}
.modal-btn-primary svg {
  width: 15px;
  height: 15px;
}
.modal-ad-slot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--studio-border);
  text-align: center;
}

/* Print formatting */
@media print {
  body.studio-body {
    background: #ffffff;
    overflow: visible;
    height: auto;
  }
  .studio-header,
  .studio-tools-bar,
  .tool-props-bar,
  .studio-palette-dock,
  .studio-modal-backdrop,
  .studio-toast {
    display: none !important;
  }
  .studio-container {
    height: auto;
    display: block;
  }
  .studio-workspace, .easel-viewport {
    overflow: visible;
    background: none;
    display: block;
  }
  .easel-stage {
    position: static;
    transform: none !important;
    box-shadow: none;
    margin: 0 auto;
    page-break-inside: avoid;
  }
}
