/* ColorKid online coloring editor (/_static/paint.html). Big targets for children, works on phones. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #eef2fb; color: #2b2d42;
  font: 16px/1.2 "Trebuchet MS", "Segoe UI", Arial, sans-serif; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
svg { fill: currentColor; }

#app { position: fixed; inset: 0; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto 1fr;
  grid-template-areas: "top top top" "tools stage pal"; }

/* top bar */
.top { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top));
  background: linear-gradient(90deg, #7b4dff, #c13cff 55%, #ff4f8b); color: #fff; box-shadow: 0 2px 8px rgba(60, 20, 120, .25); z-index: 3; }
.ttl { flex: 1; min-width: 0; font-weight: bold; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.tb { display: inline-flex; align-items: center; gap: 6px; height: 48px; min-width: 48px; padding: 0 12px; border-radius: 24px;
  background: rgba(255, 255, 255, .18); color: #fff; font-weight: bold; font-size: 15px; transition: background .15s, transform .1s; }
.tb:hover { background: rgba(255, 255, 255, .3); }
.tb:active { transform: scale(.94); }
.tb:disabled { opacity: .4; cursor: default; transform: none; }
.tb svg { width: 26px; height: 26px; flex: none; }
.tb i { font-style: normal; font-size: 24px; line-height: 1; }
.tb-close { background: rgba(0, 0, 0, .15); padding: 0; justify-content: center; }
.tb-save { background: #1e88e5; }
.tb-print { background: #ff7a00; }
.tb-magic { background: #ffd23f; color: #5a2d00; }
.tb-save:hover { background: #1e88e5; filter: brightness(1.1); }
.tb-print:hover { background: #ff7a00; filter: brightness(1.1); }
.tb-magic:hover { background: #ffd23f; filter: brightness(1.06); }

/* tools */
.tools { grid-area: tools; display: grid; grid-template-columns: 64px 64px; align-content: start; justify-items: center; gap: 6px; padding: 10px 8px;
  overflow-y: auto; background: #fff; box-shadow: 2px 0 8px rgba(0, 0, 0, .06); z-index: 2; scrollbar-width: thin; }
.tool { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 64px; min-height: 62px; padding: 5px 2px 4px; border-radius: 16px; background: #f3f0ff; border: 3px solid transparent;
  transition: transform .1s, background .15s; flex: none; }
.tool:active { transform: scale(.94); }
.tool.on { background: #fff; border-color: #7b4dff; box-shadow: 0 3px 10px rgba(123, 77, 255, .3); }
.tool i { font-style: normal; font-size: 30px; line-height: 34px; height: 34px; }
.tool svg { width: 34px; height: 34px; }
.tool b { font-size: 10.5px; font-weight: bold; line-height: 1.05; text-align: center; color: #5b5f7a; max-width: 62px;
  overflow: hidden; overflow-wrap: anywhere; hyphens: auto; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sep, .sizes, .inside { grid-column: 1 / -1; }
.sep { flex: none; width: 120px; height: 2px; background: #e6e2f5; border-radius: 2px; margin: 4px 0; }
.sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; flex: none; }
.size { width: 32px; height: 32px; border-radius: 12px; background: #f3f0ff; display: flex; align-items: center; justify-content: center;
  border: 3px solid transparent; }
.size.on { border-color: #7b4dff; background: #fff; }
.size span { display: block; border-radius: 50%; background: var(--c, #333); }
.inside { width: 134px; flex: none; display: flex; flex-direction: row; justify-content: center; align-items: center; gap: 3px; padding: 6px 2px;
  border-radius: 18px; background: #f1f1f4; border: 3px solid transparent; color: #8a8ca0; }
.inside.on { background: #e5f8e9; border-color: #2fbf55; color: #1d7a36; }
.inside svg { width: 26px; height: 26px; flex: none; }
.inside b { font-size: 12px; line-height: 1.1; text-align: start; }

/* palette */
.pal { grid-area: pal; display: grid; grid-template-columns: repeat(3, 46px); grid-auto-rows: 46px; gap: 8px; align-content: start;
  padding: 10px; overflow-y: auto; background: #fff; box-shadow: -2px 0 8px rgba(0, 0, 0, .06); z-index: 2; scrollbar-width: thin; }
.sw { width: 46px; height: 46px; border-radius: 50%; background: var(--c); border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .12), inset 0 -4px 0 rgba(0, 0, 0, .12); transition: transform .1s; position: relative; }
.sw:active { transform: scale(.9); }
.sw.on { box-shadow: 0 0 0 4px #2b2d42; transform: scale(1.06); }
.sw.on::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); }
.sw-custom { overflow: hidden; background: conic-gradient(#f44336, #ffeb3b, #4caf50, #00bcd4, #3f51b5, #e91e63, #f44336); }
.sw-custom input { position: absolute; inset: -10px; width: 70px; height: 70px; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.stamp { width: 46px; height: 46px; border-radius: 14px; background: #fff7e0; font-size: 28px; line-height: 46px; text-align: center;
  border: 3px solid transparent; }
.stamp.on { border-color: #ff9800; background: #fff; }

/* drawing area */
.stage { grid-area: stage; position: relative; overflow: hidden; touch-action: none; cursor: crosshair; min-height: 0;
  background: radial-gradient(circle at 20% 20%, #f7f3ff, #e8eefc 70%); }
.stage.t-fill, .stage.t-stamp { cursor: pointer; }
.board { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 6px 24px rgba(40, 30, 90, .18); background: #fff; }
.board canvas { position: absolute; left: 0; top: 0; display: block; }
#cLines { pointer-events: none; }
.zoom { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; z-index: 2; }
.zoom button { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: #5b4bb0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18); display: flex; align-items: center; justify-content: center; }
.zoom svg { width: 26px; height: 26px; }
.msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  font-size: 18px; font-weight: bold; color: #5b4bb0; background: rgba(238, 242, 251, .9); z-index: 4; text-align: center; padding: 20px; }
.msg[hidden] { display: none; }
.spin { width: 48px; height: 48px; border-radius: 50%; border: 6px solid #d9d0ff; border-top-color: #7b4dff; animation: spin 0.9s linear infinite; }
.msg.err .spin { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: absolute; left: 50%; top: 14px; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: #2b2d42; color: #fff; font-weight: bold; padding: 10px 18px; border-radius: 22px; transition: .25s; z-index: 5; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* labels in the top bar only on wide screens */
@media (max-width: 1180px) { .tb span { display: none; } .tb { padding: 0; justify-content: center; } }

/* phones and portrait tablets: tools and colours at the bottom */
@media (max-aspect-ratio: 5/4), (max-width: 700px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto auto; grid-template-areas: "top" "stage" "tools" "pal"; }
  .top { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .ttl { font-size: 15px; padding: 0 2px; }
  .tb { height: 44px; min-width: 44px; }
  .tools { display: flex; flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; padding: 6px 8px; gap: 6px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, .06); }
  .tool { width: 64px; min-height: 62px; }
  .tool i { font-size: 27px; }
  .sep { width: 2px; height: 50px; margin: 0 2px; }
  .sizes { grid-template-columns: 1fr 1fr; }
  .inside { width: 66px; flex-direction: column; }
  .inside b { font-size: 10px; text-align: center; }
  .pal { grid-template-columns: none; grid-auto-flow: column; grid-template-rows: repeat(2, 42px); grid-auto-columns: 42px;
    grid-auto-rows: unset; gap: 7px; overflow-x: auto; overflow-y: hidden; padding: 7px 10px;
    padding-bottom: max(7px, env(safe-area-inset-bottom)); box-shadow: none; }
  .sw, .stamp { width: 42px; height: 42px; }
  .stamp { line-height: 42px; font-size: 26px; }
  .zoom { right: 8px; bottom: 8px; }
  .zoom button { width: 42px; height: 42px; }
}
@media (max-width: 380px) { .tb { min-width: 40px; height: 40px; } .tb svg { width: 23px; height: 23px; } .tb i { font-size: 21px; } }

/* print: only the finished picture */
#printSheet { display: none; }
@media print {
  html, body { overflow: visible; height: auto; background: #fff; }
  #app { display: none !important; }
  #printSheet { display: block; }
  #printImg { display: block; width: 100%; height: auto; max-height: 96vh; object-fit: contain; margin: 0 auto; }
}
