:root {
  --bg: #fff9ef;
  --surface: #ffffff;
  --surface-soft: #fff3d6;
  --text: #213547;
  --muted: #64748b;
  --primary: #ff8a1f;
  --primary-dark: #e86f00;
  --accent: #14b8a6;
  --accent-soft: #ccfbf1;
  --border: #eadfc9;
  --shadow: 0 16px 42px rgba(54, 64, 82, 0.12);
  --shadow-small: 0 8px 24px rgba(54, 64, 82, 0.09);
  --radius: 24px;
  --radius-small: 16px;
  --container: min(1180px, calc(100% - 2rem));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 209, 102, 0.28), transparent 28rem),
    radial-gradient(circle at 95% 10%, rgba(20, 184, 166, 0.15), transparent 25rem),
    var(--bg);
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

.container {
  width: var(--container);
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 1000;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(234, 223, 201, 0.88);
  background: rgba(255, 249, 239, 0.92);
  backdrop-filter: blur(14px);
}

.header-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  min-width: 0;
  gap: 0.55rem;
}

.brand img {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
}

.brand-text {
  font-size: 0.92rem;
}

.header-actions {
  margin-left: auto;
}

.header-actions .button {
  min-height: 38px;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: var(--shadow-small);
}

.brand-text {
  display: block;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-text small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-link {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.header-link:hover,
.header-link:focus-visible {
  background: var(--surface);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.78rem 1.1rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible,
.color-swatch:focus-visible,
.filter-chip:focus-visible,
.search-input:focus-visible {
  outline: 3px solid rgba(20, 184, 166, 0.4);
  outline-offset: 3px;
}

.button:disabled,
.icon-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.button--primary {
  color: #241300;
  background: linear-gradient(135deg, #ffb02e, var(--primary));
  box-shadow: 0 10px 20px rgba(255, 138, 31, 0.22);
}

.button--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffbe55, #ff7a00);
}

.button--secondary {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-small);
}

.button--small {
  min-height: 40px;
  padding: 0.65rem 0.95rem;
  font-size: 0.93rem;
}

.hero {
  padding: 4rem 0 2.4rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr);
  align-items: center;
  gap: 2rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 1rem;
  padding: 0.42rem 0.78rem;
  border: 1px solid #f0d28f;
  border-radius: 999px;
  background: #fff1c5;
  color: #7c4b00;
  font-size: 0.9rem;
  font-weight: 800;
}

.hero h1,
.color-heading h1 {
  margin: 0;
  max-width: 13ch;
  font-size: clamp(2.3rem, 7vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero p.lead,
.color-heading p {
  max-width: 64ch;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.hero-preview {
  position: relative;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  transform: rotate(1.2deg);
}

.hero-preview img {
  width: 100%;
  max-height: 480px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 23px;
}

.hero-preview::after {
  content: "Tap to fill";
  position: absolute;
  right: 1.5rem;
  bottom: 1.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(33, 53, 71, 0.9);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow-small);
}

.section {
  padding: 2rem 0 4rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.section-heading p {
  max-width: 52ch;
  margin: 0;
  color: var(--muted);
}

.gallery-tools {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.4rem;
}

.search-box {
  position: relative;
}

.search-box span {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 50px;
  padding: 0 1rem 0 3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-small);
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.2rem 0.2rem 0.45rem;
  scrollbar-width: thin;
}

.filter-chip {
  flex: 0 0 auto;
  padding: 0.68rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.filter-chip[aria-pressed="true"] {
  border-color: transparent;
  background: var(--text);
  color: #fff;
}

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

.gallery-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.gallery-card__image {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #fff;
}

.gallery-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.gallery-card:hover .gallery-card__image img {
  transform: scale(1.025);
}

.play-badge,
.progress-badge {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  box-shadow: var(--shadow-small);
}

.play-badge {
  right: 0.8rem;
  bottom: 0.8rem;
  width: 48px;
  height: 48px;
  background: var(--primary);
  font-size: 1.3rem;
}

.progress-badge {
  left: 0.8rem;
  top: 0.8rem;
  padding: 0.45rem 0.7rem;
  background: var(--accent);
  color: #042f2e;
  font-size: 0.82rem;
  font-weight: 900;
}

.gallery-card__body {
  padding: 1rem 1rem 1.15rem;
}

.category-label {
  color: #886300;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gallery-card h2 {
  margin: 0.3rem 0 0.45rem;
  font-size: 1.18rem;
  line-height: 1.25;
}

.gallery-card h2 a {
  text-decoration: none;
}

.gallery-card p {
  min-height: 3.1em;
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.94rem;
}

.empty-state {
  padding: 2rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  color: var(--muted);
}

/* Coloring workspace */
.color-page {
  padding: 1.4rem 0 3rem;
}

.color-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.color-heading h1 {
  max-width: 18ch;
  font-size: clamp(2rem, 5vw, 3.7rem);
}

.category-pill {
  display: inline-flex;
  margin-bottom: 0.6rem;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #115e59;
  font-size: 0.84rem;
  font-weight: 900;
}

.progress-card {
  min-width: 210px;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.progress-card__label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.87rem;
  font-weight: 800;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  transition: width 0.2s ease;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  gap: 1.2rem;
  align-items: start;
}

.canvas-card {
  position: relative;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: #e6f7ff;
  box-shadow: var(--shadow);
}

.canvas-shell {
  display: grid;
  place-items: center;
  min-height: 520px;
  overflow: auto;
  border-radius: 20px;
  background:
    linear-gradient(45deg, #eff8fb 25%, transparent 25%),
    linear-gradient(-45deg, #eff8fb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eff8fb 75%),
    linear-gradient(-45deg, transparent 75%, #eff8fb 75%),
    #fff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

#color-canvas {
  display: block;
  width: min(100%, 780px);
  height: auto;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.13);
  cursor: crosshair;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.loading-overlay {
  position: absolute;
  inset: 1rem;
  z-index: 10;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.8rem;
  border: 5px solid #dbeafe;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.tools-panel {
  position: sticky;
  top: 90px;
  display: grid;
  gap: 1rem;
}

.tool-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.tool-card h2 {
  margin: 0 0 0.3rem;
  font-size: 1.06rem;
}

.tool-card p {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.selected-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.selected-color {
  width: 42px;
  height: 42px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-small);
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.48rem;
}

.color-swatch {
  aspect-ratio: 1;
  min-width: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px #cbd5e1;
  cursor: pointer;
}

.color-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--text), 0 0 0 5px #fff;
  transform: scale(0.9);
}

.color-swatch--white {
  background: linear-gradient(135deg, #fff 0 45%, #ef4444 46% 54%, #fff 55%);
}

.custom-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.custom-color-row input {
  width: 52px;
  height: 38px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.icon-button {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.icon-button--wide {
  grid-column: 1 / -1;
}

.tip {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.85rem;
  border-radius: 14px;
  background: var(--surface-soft);
  color: #6b4700;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  z-index: 100;
  transform: translateX(-50%);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.example-dialog {
  width: min(720px, calc(100% - 2rem));
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.35);
}

.example-dialog::backdrop {
  background: rgba(15, 23, 42, 0.7);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.dialog-close {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 1.2rem;
}

.dialog-body {
  padding: 1rem;
}

.dialog-body img {
  width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 16px;
}

.simple-page {
  padding: 3rem 0 5rem;
}

.simple-card {
  max-width: 820px;
  margin-inline: auto;
  padding: clamp(1.2rem, 4vw, 2.4rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.site-footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.68);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 980px) {
  .hero-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-preview {
    max-width: 580px;
    margin-inline: auto;
  }

  .tools-panel {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-card:first-child {
    grid-row: span 2;
  }

  .canvas-shell {
    min-height: 430px;
  }
}

@media (max-width: 720px) {
  :root {
    --container: min(100% - 1rem, 1180px);
  }

  .header-inner {
    min-height: 66px;
  }

  .brand-text small,
  .header-link--secondary {
    display: none;
  }

  .hero {
    padding-top: 2.5rem;
  }

  .hero-grid {
    gap: 1.2rem;
  }

  .hero h1 {
    font-size: clamp(2.35rem, 14vw, 4rem);
  }

  .gallery-tools,
  .color-heading {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .gallery-card {
    border-radius: 18px;
  }

  .gallery-card__body {
    padding: 0.8rem;
  }

  .gallery-card h2 {
    font-size: 1rem;
  }

  .gallery-card p,
  .gallery-card .category-label {
    display: none;
  }

  .gallery-card .button {
    width: 100%;
    margin-top: 0.4rem;
  }

  .progress-card {
    min-width: 0;
  }

  .canvas-card {
    padding: 0.55rem;
    border-radius: 18px;
  }

  .canvas-shell {
    min-height: 0;
    border-radius: 14px;
  }

  #color-canvas {
    width: 100%;
    border-radius: 8px;
  }

  .loading-overlay {
    inset: 0.55rem;
    border-radius: 14px;
  }

  .tools-panel {
    grid-template-columns: 1fr;
  }

  .tool-card:first-child {
    grid-row: auto;
  }

  .palette {
    grid-template-columns: repeat(8, 1fr);
  }

  .color-swatch {
    min-height: 34px;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 410px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-card p,
  .gallery-card .category-label {
    display: block;
  }

  .palette {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
/* 404 error page */
.error-page {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
  padding: 3rem 1rem;
}

.error-card {
  width: min(680px, 100%);
  padding: 3rem 2rem;
  text-align: center;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e7ddc8);
  border-radius: var(--radius, 20px);
  box-shadow: var(--shadow, 0 12px 28px rgba(41, 53, 72, 0.08));
}

.error-code {
  margin: 0;
  font-size: clamp(5rem, 18vw, 10rem);
  font-weight: 900;
  line-height: 0.9;
  color: var(--primary, #ff9f1c);
}

.error-card h1 {
  margin: 1.5rem 0 0.75rem;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
}

.error-card p {
  max-width: 520px;
  margin: 0 auto;
  color: var(--muted, #5b6470);
  font-size: 1.05rem;
}

.error-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.error-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.8rem 1.25rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
}

.error-actions a:first-child {
  color: #1b1400;
  background: var(--primary, #ff9f1c);
}

.error-actions a:first-child:hover {
  background: var(--primary-dark, #e98700);
}

.error-actions a:not(:first-child) {
  color: var(--text, #213547);
  background: #ffffff;
  border: 1px solid var(--border, #e7ddc8);
}

@media (max-width: 600px) {
  .error-page {
    padding: 2rem 1rem;
  }

  .error-card {
    padding: 2.25rem 1.25rem;
  }

  .error-actions {
    flex-direction: column;
  }

  .error-actions a {
    width: 100%;
  }
}