:root {
  --edj-blue: #1e5bb8;
  --edj-blue-deep: #0f3d7a;
  --edj-blue-soft: #e8f1fc;
  --edj-yellow: #f5c542;
  --edj-orange: #f08a3a;
  --edj-cream: #fff8ef;
  --edj-ink: #1a2740;
  --edj-muted: #5a6b85;
  --edj-white: #ffffff;
  --edj-radius: 18px;
  --edj-shadow: 0 10px 28px rgba(15, 61, 122, 0.12);
  --tool-size: 52px;
  --swatch: 40px;
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--edj-ink);
  background: var(--edj-cream);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse at top, #dcecff 0%, transparent 55%),
    linear-gradient(180deg, #f3f8ff 0%, var(--edj-cream) 40%, #ffe9c8 100%);
}

body {
  min-height: 100dvh;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* —— Gallery —— */
.atelier-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.atelier-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--edj-yellow), var(--edj-orange));
  box-shadow: var(--edj-shadow);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  line-height: 1;
}

.brand-text h1 {
  margin: 0;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  color: var(--edj-blue-deep);
  letter-spacing: 0.01em;
}

.brand-text p {
  margin: 0.15rem 0 0;
  color: var(--edj-muted);
  font-size: 0.95rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:focus-visible {
  outline: 3px solid var(--edj-yellow);
  outline-offset: 3px;
}

.btn-primary {
  background: linear-gradient(180deg, var(--edj-yellow), #efb020);
  color: var(--edj-blue-deep);
  box-shadow: 0 6px 0 #d29a12;
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #d29a12;
}

.btn-ghost {
  background: var(--edj-white);
  color: var(--edj-blue);
  border: 2px solid #c9dbf5;
}

.btn-soft {
  background: var(--edj-blue-soft);
  color: var(--edj-blue-deep);
}

.hero-intro {
  background: var(--edj-white);
  border-radius: calc(var(--edj-radius) + 6px);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--edj-shadow);
  margin-bottom: 1.75rem;
  border: 2px solid #e4eefc;
}

.hero-intro h2 {
  margin: 0 0 0.35rem;
  font-family: "Fredoka", sans-serif;
  color: var(--edj-blue);
  font-size: 1.45rem;
}

.hero-intro p {
  margin: 0;
  color: var(--edj-muted);
  max-width: 52ch;
  line-height: 1.5;
}

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

.ill-card {
  background: var(--edj-white);
  border-radius: var(--edj-radius);
  overflow: hidden;
  box-shadow: var(--edj-shadow);
  border: 2px solid #e8f0fb;
  display: flex;
  flex-direction: column;
}

.ill-card__media {
  aspect-ratio: 4 / 3;
  background: #f7fbff;
  display: grid;
  place-items: center;
  padding: 0.75rem;
}

.ill-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ill-card__body {
  padding: 1rem 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}

.ill-card__body h3 {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: 1.15rem;
  color: var(--edj-blue-deep);
}

.ill-card__body p {
  margin: 0;
  color: var(--edj-muted);
  font-size: 0.9rem;
  flex: 1;
}

.ill-card .btn {
  width: 100%;
}

.atelier-note {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--edj-muted);
  text-align: center;
}

/* —— Editor layout —— */
.editor-body {
  background: linear-gradient(180deg, #e8f4ff 0%, var(--edj-cream) 55%);
}

.editor-app {
  display: grid;
  grid-template-columns: 92px 1fr 88px;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header header header"
    "tools canvas palette";
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

/* Compact institutional header (same brand language as site-rebuild) */
.editor-site-header {
  grid-area: header;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 64px;
  padding: 0.45rem 0.85rem;
  background: #fffffff8;
  box-shadow: 0 8px 24px #0b4a7a18;
  border-bottom: 1px solid #d7e8f8;
}

.editor-header-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 0 0 auto;
  min-width: 0;
}

.editor-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.editor-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transform: rotate(-3deg);
}

.editor-brand-text {
  font-family: "Fredoka", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 0.95;
  color: #0c4a6e;
  letter-spacing: -0.4px;
  -webkit-text-stroke: 2.5px white;
  paint-order: stroke fill;
  filter: drop-shadow(0 1px 0 #08265135);
}

.editor-brand-text strong {
  display: block;
  font-size: 1.05rem;
  text-align: center;
  color: #0054a6;
}

.editor-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 40px;
  padding: 0 0.75rem;
  border-radius: 999px;
  background: #eef7ff;
  color: #0c4a6e;
  border: 1.5px solid #cfe7fb;
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
}

.editor-back-btn:focus-visible {
  outline: 3px solid var(--edj-yellow);
  outline-offset: 2px;
}

.editor-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(0.95rem, 2.4vw, 1.25rem);
  color: #123a63;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-header-actions {
  flex: 0 0 auto;
}

.editor-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 40px;
  padding: 0 1rem;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--edj-yellow), #efb020);
  color: var(--edj-blue-deep);
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: 0 3px 0 #e0a80055;
  border: none;
}

.editor-download-btn:focus-visible {
  outline: 3px solid var(--edj-blue);
  outline-offset: 2px;
}

.editor-tools {
  grid-area: tools;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.4rem;
  background: rgba(255, 255, 255, 0.97);
  border-right: 2px solid #e2ecf8;
  overflow-y: auto;
  z-index: 5;
}

.editor-palette {
  grid-area: palette;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.35rem;
  background: rgba(255, 255, 255, 0.97);
  border-left: 2px solid #e2ecf8;
  overflow: hidden;
  z-index: 5;
}

.palette-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--edj-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.tool-sep {
  width: 60%;
  border: none;
  border-top: 2px solid #e2ecf8;
  margin: 0.2rem 0;
}

.brush-sizes-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.atelier-viewport {
  grid-area: canvas;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(45deg, #eef3fa 25%, transparent 25%),
    linear-gradient(-45deg, #eef3fa 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef3fa 75%),
    linear-gradient(-45deg, transparent 75%, #eef3fa 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-color: #f8fbff;
  touch-action: none;
  user-select: none;
  overscroll-behavior: none;
}

.atelier-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  box-shadow: 0 12px 40px rgba(15, 61, 122, 0.18);
  border-radius: 4px;
  overflow: hidden;
}

.atelier-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.layer-hit {
  z-index: 10;
  /* Fully transparent pixels, but opacity 1 so hit-testing & a11y tools see the layer */
  opacity: 1;
  background: transparent;
  cursor: crosshair;
}

.layer-hit[data-tool="bucket"] {
  cursor: cell;
}

.layer-hit[data-tool="pan"] {
  cursor: grab;
}

.layer-hit[data-tool="pan"]:active {
  cursor: grabbing;
}

.layer-hit[data-tool="eraser"] {
  cursor: cell;
}

.icon-btn--fit {
  min-width: 100%;
}

.icon-btn {
  width: var(--tool-size);
  min-height: var(--tool-size);
  height: auto;
  padding: 0.35rem 0.2rem;
  border-radius: 16px;
  background: var(--edj-blue-soft);
  color: var(--edj-blue-deep);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 2px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.icon-btn svg {
  display: block;
  flex-shrink: 0;
}

.icon-btn span {
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
}

.icon-btn.is-active {
  background: var(--edj-yellow);
  border-color: #e0a918;
  transform: translateY(-1px);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn:focus-visible {
  outline: 3px solid var(--edj-blue);
  outline-offset: 2px;
}

.palette {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  flex: 1;
  padding: 0.15rem 0.1rem 0.5rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.swatch {
  width: var(--swatch);
  height: var(--swatch);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #c5d5ea;
  flex: 0 0 auto;
  position: relative;
}

.swatch.is-active {
  box-shadow: 0 0 0 3px var(--edj-blue), 0 4px 10px rgba(0, 0, 0, 0.15);
  transform: scale(1.08);
}

.swatch.is-active::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.brush-sizes {
  display: inline-flex;
  flex-direction: column;
  gap: 0.3rem;
  background: var(--edj-blue-soft);
  padding: 0.25rem;
  border-radius: 16px;
}

.brush-sizes button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.brush-sizes button.is-active {
  background: var(--edj-white);
  box-shadow: 0 2px 6px rgba(15, 61, 122, 0.15);
}

.brush-dot {
  display: block;
  border-radius: 50%;
  background: var(--edj-blue-deep);
}

.status-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: var(--edj-blue-deep);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
}

.status-toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 40, 80, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--edj-white);
  border-radius: 22px;
  padding: 1.4rem 1.35rem;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--edj-shadow);
  text-align: center;
}

.modal h2 {
  margin: 0 0 0.5rem;
  font-family: "Fredoka", sans-serif;
  color: var(--edj-blue-deep);
}

.modal p {
  margin: 0 0 1.1rem;
  color: var(--edj-muted);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.loading-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(248, 251, 255, 0.85);
  z-index: 20;
  font-weight: 800;
  color: var(--edj-blue);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 900px) {
  .editor-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas:
      "header"
      "canvas"
      "tools"
      "palette";
  }

  .editor-tools {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    border-right: none;
    border-top: 2px solid #e2ecf8;
    padding: 0.45rem 0.5rem;
    gap: 0.35rem;
    max-height: none;
    overflow-x: auto;
  }

  .tool-group {
    flex-direction: row;
    width: auto;
  }

  .tool-sep {
    width: 2px;
    height: 44px;
    border: none;
    border-left: 2px solid #e2ecf8;
    margin: 0 0.15rem;
  }

  .brush-sizes {
    flex-direction: row;
  }

  .editor-palette {
    border-left: none;
    border-top: 2px solid #e2ecf8;
    flex-direction: row;
    align-items: center;
    padding: 0.4rem 0.55rem;
    gap: 0.5rem;
  }

  .palette-label {
    flex-shrink: 0;
  }

  .palette {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.15rem 0;
  }

  .icon-btn--fit {
    min-width: var(--tool-size);
  }

  .editor-brand-text {
    display: none;
  }

  .editor-download-btn span {
    display: none;
  }

  .editor-back-btn span {
    display: none;
  }
}

@media (max-width: 480px) {
  :root {
    --tool-size: 46px;
    --swatch: 36px;
  }

  .editor-site-header {
    padding: 0.4rem 0.45rem;
    gap: 0.4rem;
  }

  .btn {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
