:root{
  /* ===== Bright Kid Theme (Gold/Rainbow) ===== */
  --bg0:#fff7d1;
  --bg1:#ffe08a;

  /* Light UI surfaces */
  --card: rgba(255,255,255,.62);
  --card2: rgba(255,255,255,.78);
  --stroke: rgba(16,16,24,.16);

  /* Text (dark, because background is bright) */
  --text: rgba(16,16,24,.92);
  --muted: rgba(16,16,24,.70);

  /* Shadows + radii */
  --shadow: 0 18px 55px rgba(0,0,0,.16);
  --radius: 18px;
  --radius2: 26px;
  --gap: 14px;

  /* Punchy accents */
  --a1:#22c55e;   /* green */
  --a2:#06b6d4;   /* cyan */
  --a3:#6366f1;   /* indigo */
  --a4:#f59e0b;   /* gold */
  --a5:#ec4899;   /* pink */
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);

  /* ===== Gold + Rainbow glow background ===== */
  background:
    radial-gradient(1000px 650px at 12% 10%, rgba(236,72,153,.22), transparent 60%),
    radial-gradient(1000px 650px at 88% 16%, rgba(99,102,241,.20), transparent 62%),
    radial-gradient(900px 650px at 50% 92%, rgba(34,197,94,.16), transparent 64%),
    radial-gradient(900px 650px at 55% 40%, rgba(245,158,11,.22), transparent 65%),
    linear-gradient(135deg,
      #fff6cf 0%,
      #ffe08a 18%,
      #ffbf3f 40%,
      #ff9f1c 62%,
      #ffd36a 82%,
      #fff1b3 100%
    );
}

code{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ===== Top Bar ===== */
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;

  padding: 14px 14px calc(14px + env(safe-area-inset-top));
  backdrop-filter: blur(14px);
  background: rgba(255,255,255,.52);
  border-bottom: 1px solid var(--stroke);
  box-shadow: 0 10px 40px rgba(0,0,0,.12);
}

.brand{ display:flex; align-items:center; gap:12px; }

.logo{
  width:44px; height:44px;
  display:grid; place-items:center;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);

  background:
    radial-gradient(18px 18px at 30% 30%, rgba(255,255,255,.75), transparent 60%),
    linear-gradient(135deg, rgba(245,158,11,.65), rgba(236,72,153,.35), rgba(99,102,241,.28));
}

.brand-title{ font-weight: 900; letter-spacing:.2px; }
.brand-sub{ font-size: 13px; color: var(--muted); margin-top:2px; }

/* ===== Buttons ===== */
.pill{
  border: 0;
  color: #101018;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration:none;
  font-weight: 900;
  cursor:pointer;

  background: linear-gradient(135deg, #ffbf3f, #ff4fd8, #6c63ff);
  box-shadow:
    0 14px 34px rgba(0,0,0,.18),
    0 0 0 1px rgba(255,255,255,.35) inset;
}

.pill:hover{ filter: brightness(1.05); }
.pill:active{ transform: translateY(1px); }

.pill.ghost{
  background: rgba(255,255,255,.55);
  border: 1px solid var(--stroke);
  box-shadow: none;
}

/* ===== Layout ===== */
.container{
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 14px 30px;
}

/* ===== Hero ===== */
.hero{
  margin: 18px 0 18px;
  padding: 18px;
  border-radius: var(--radius2);
  background: linear-gradient(135deg, var(--card2), var(--card));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

.hero h1{
  margin: 0 0 8px;
  font-size: clamp(22px, 4vw, 34px);

  background: linear-gradient(90deg, #ff7a00, #ff4fd8, #6c63ff, #00c7be);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 10px 28px rgba(0,0,0,.12);
}

.hero p{
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

/* ===== Gallery Grid ===== */
.grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--gap);
  margin-top: 14px;
}

.card{
  display:block;
  border-radius: var(--radius2);
  overflow:hidden;
  text-decoration:none;
  border: 1px solid var(--stroke);
  background: linear-gradient(135deg, var(--card2), var(--card));
  box-shadow: var(--shadow);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}

.card:hover{
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow:
    0 22px 70px rgba(0,0,0,.20),
    0 0 0 1px rgba(255,255,255,.35) inset;
}

.card-preview{
  height: 180px;
  display:grid;
  place-items:center;

  background:
    radial-gradient(420px 280px at 20% 20%, rgba(0,199,190,.25), transparent 68%),
    radial-gradient(420px 280px at 85% 30%, rgba(255,79,216,.18), transparent 70%),
    radial-gradient(420px 280px at 55% 85%, rgba(255,191,63,.22), transparent 70%),
    rgba(255,255,255,.38);
}

.card-preview svg{
  width: 75%;
  height: 75%;
  opacity: 1;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.10));
}

.card-body{ padding: 14px; }
.card-title{ font-weight: 950; color: rgba(16,16,24,.92); }
.card-meta{ margin-top: 4px; color: var(--muted); font-size: 13px; }

.footer{
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  padding: 12px 4px;
}

/* ===== WORKSPACE ===== */
body.work .container{ max-width: 100%; }

.work-wrap{
  display:grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
}

.work-title{ text-align:center; line-height:1.1; }
.strong{ font-weight: 950; }
.muted{ color: var(--muted); font-size: 12px; }

.stage{
  display:flex;
  justify-content:center;
}

/* Paper looks like a real page */
.paper{
  width: min(92vw, 520px);
  aspect-ratio: 4 / 5;
  border-radius: var(--radius2);
  position: relative;
  overflow:hidden;
  touch-action: none; /* drawing */

  background:
    radial-gradient(2px 2px at 20px 20px, rgba(0,0,0,.035), transparent 55%),
    #ffffff;
  background-size: 40px 40px, auto;

  border: 1px solid rgba(0,0,0,.10);
  box-shadow: 0 24px 80px rgba(0,0,0,.22);
}

#paint{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
}

.outline{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  pointer-events:none;
}
.outline svg{
  width: 100%;
  height: 100%;
}

.outline canvas{
  width: 100%;
  height: 100%;
}


/* Toolbar */
.toolbar{
  border-radius: var(--radius2);
  border: 1px solid var(--stroke);
  background: linear-gradient(135deg, var(--card2), var(--card));
  box-shadow: var(--shadow);
  padding: 12px;
}

.tool-row{
  display:flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items:center;
}

.tool-row.split{
  margin-top: 12px;
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Tool buttons */
.tool{
  appearance:none;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.55);
  color: rgba(16,16,24,.92);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 950;
  cursor:pointer;
  min-height: 44px;
}

.tool:hover{ filter: brightness(1.03); }
.tool:active{ transform: translateY(1px); }

.tool.active{
  border: 0;
  color: #101018;
  background: linear-gradient(135deg, #00c7be, #6c63ff);
  box-shadow:
    0 10px 30px rgba(0,0,0,.16),
    0 0 0 1px rgba(255,255,255,.35) inset;
}

.tool.danger{
  border: 0;
  color: #101018;
  background: linear-gradient(135deg, #fb7185, #ef4444);
}

/* Slider */
.slider .slider-line{
  display:flex;
  gap: 10px;
  align-items:center;
  margin-top: 8px;
}
input[type="range"]{ width: 100%; }

.badge{
  min-width: 44px;
  text-align:center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.55);
  font-weight: 950;
  color: rgba(16,16,24,.92);
}

/* Palette */
.palette{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.swatch{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,.75);
  box-shadow:
    0 10px 24px rgba(0,0,0,.18),
    0 0 0 1px rgba(0,0,0,.08) inset;
  cursor:pointer;
}

.swatch.active{
  outline: 4px solid rgba(16,16,24,.85);
  outline-offset: 3px;
  box-shadow:
    0 12px 30px rgba(0,0,0,.22),
    0 0 18px rgba(0,0,0,.12);
}

.picker-row{
  margin-top: 10px;
  display:flex;
  gap: 10px;
  align-items:center;
}

#colorPick{
  width: 58px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.10);
  padding: 0;
  background: rgba(255,255,255,.55);
  cursor:pointer;
}

.mini{
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.55);
  color: rgba(16,16,24,.92);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 950;
  cursor:pointer;
  min-height: 44px;
}

.hint{
  margin-top: 10px;
  display:flex;
  align-items:center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.dot{
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(16,16,24,.35);
}

/* Focus (nice + accessible) */
.tool:focus-visible, .pill:focus-visible, .mini:focus-visible, .swatch:focus-visible{
  outline: 3px solid rgba(0,199,190,.85);
  outline-offset: 3px;
}

/* Desktop layout */
@media (min-width: 860px){
  .work-wrap{
    grid-template-columns: 1fr 420px;
    align-items:start;
  }
  .stage{ justify-content:flex-end; }
  .tool-row.split{
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Cursor ring + cursor modes (Desktop) ===== */
.cursor-ring{
  position:absolute;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  pointer-events:none;
  transform: translate(-9999px, -9999px);
  border: 2px solid rgba(0,0,0,.35);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  background: rgba(255,255,255,.12);
  mix-blend-mode: multiply;
}

/* Eraser ring style */
.paper.cursor-eraser .cursor-ring{
  border-style: dashed;
  border-color: rgba(255,60,60,.55);
}

/* Cursor fallback (you can swap to image cursors later) */
.paper.cursor-brush{ cursor: crosshair; }
.paper.cursor-eraser{ cursor: crosshair; }

/* Hide ring on small/touch-first devices (optional but nice) */
@media (hover: none){
  .cursor-ring{ display:none; }
}

/* Fun cursors (desktop only) — MUST be small images */
.paper.cursor-brush{
  cursor: url("./assets/cursor-brush-64.png") 22 38, crosshair;
}
.paper.cursor-eraser{
  cursor: url("./assets/cursor-eraser-64.png") 21 40, crosshair;
}
/* allow file picker to open on Safari (do NOT use [hidden] / display:none) */
.visually-hidden{
  position:absolute !important;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* ensure outline overlay doesn't block drawing */
#outline, #outline *{
  pointer-events:none;
}
#outline canvas{
  width:100%;
  height:100%;
  display:block;
}
/* allow file picker to open reliably (Safari/iOS) */
.visually-hidden{
  position:absolute !important;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}
