/* ===== 그림 놀이터 — 색칠하기 (우드톤 디자인) ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  user-select: none; -webkit-user-select: none;
  font-family: 'Jua', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  color: #4a3f3a;
}

.app {
  width: 100vw; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: linear-gradient(165deg, #fff6e9, #fdeede);
  overflow: hidden;
}

/* ===== 상단 액션 바 ===== */
.topbar { display: flex; gap: 6px; padding: 12px 13px 7px; align-items: stretch; }
.tbtn {
  flex: 1; min-width: 0; border: none; border-radius: 15px; background: #fff;
  padding: 7px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  box-shadow: 0 4px 0 rgba(120,80,50,.14), inset 0 2px 2px rgba(255,255,255,.8);
  cursor: pointer; position: relative;
}
.tbtn:active { transform: translateY(2px); }
.tbtn .bi { font-size: 22px; line-height: 1; }
.tbtn .bl { font-size: 11px; color: #7a6a5a; white-space: nowrap; }
.tbtn:disabled { opacity: .4; }
.tbtn.danger .bl { color: #e0674a; }
.badge {
  position: absolute; top: -7px; right: 0; background: #ff3f6a; color: #fff;
  font-size: 9px; font-family: 'Noto Sans KR', sans-serif; font-weight: 700;
  padding: 2px 6px; border-radius: 9px; box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

/* ===== 무대: 왼쪽 도구열 + 캔버스 ===== */
.stage { flex: 1; display: flex; padding: 6px 16px 16px; min-height: 0; }
.toolL { display: flex; flex-direction: column; gap: 9px; padding-right: 13px; overflow-y: auto; }
.tool {
  width: 84px; flex: none; border: none; border-radius: 22px; background: #fff;
  padding: 9px 4px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  box-shadow: 0 5px 0 rgba(120,80,50,.13), inset 0 2px 2px rgba(255,255,255,.8);
  cursor: pointer;
}
.tool:active { transform: translateY(2px); }
.tool .bi { font-size: 29px; line-height: 1; }
.tool .bl { font-size: 12.5px; color: #7a6a5a; }
.bi.ic { display: flex; align-items: center; justify-content: center; }
.bi.gl { font-size: 28px; font-weight: 700; color: #7a6a5a; }
.pal-btn .bi { font-size: 30px; }
.pal-btn.act-open { background: #efe7ff; box-shadow: 0 5px 0 #a26bff; }
.tool.on { background: #ffe6c2; box-shadow: 0 5px 0 #e8993e; }
/* 페인트: 평소엔 다른 도구와 동일한 흰 배경, 선택 시에만 강조(.on과 동일) */
.paint.sel { background: #ffe6c2; box-shadow: 0 5px 0 #e8993e; }

/* ===== 캔버스 ===== */
.canvas {
  flex: 1; border-radius: 28px; position: relative; overflow: hidden;
  border: 3px solid #f0dcc0; background: #fffaf1;
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.canvas-stack { position: relative; background: #fffaf1; overflow: hidden; }
.c-paint, .c-outline, .c-sticker { position: absolute; top: 0; left: 0; pointer-events: none; }
.c-outline { mix-blend-mode: multiply; }
.brush-cursor {
  position: absolute; pointer-events: none; z-index: 5;
  transform: translate(-50%, -50%); border-radius: 50%;
  border: 2px solid rgba(232,153,62,.8); box-shadow: 0 0 0 1px rgba(255,255,255,.9);
}
.brush-cursor.eraser { border: 2px dashed #555; background: rgba(255,255,255,.2); }

/* ===== 팔레트 팝업 ===== */
.palettepop {
  position: absolute; top: 12px; left: 12px; width: 330px; max-width: calc(100% - 24px);
  background: #fff; border-radius: 24px; padding: 15px 17px; display: flex; flex-direction: column; gap: 13px;
  box-shadow: 0 16px 36px rgba(80,50,30,.24); z-index: 12; border: 2px solid #f3ead9;
}
.pop-t { font-size: 15px; color: #8a7a6a; margin: -2px 0 -4px 2px; }
.crow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2); flex: none; cursor: pointer; padding: 0;
}
.swatch:active { transform: scale(.92); }
.swatch.sel { box-shadow: 0 0 0 4px #e8993e, 0 2px 6px rgba(0,0,0,.2); }
.swatch.wht { border-color: #e2e2e2; }
.custom {
  display: flex; align-items: center; justify-content: center; font-size: 17px; border-color: #fff;
  background: conic-gradient(#ff5a5f,#ffd23f,#3ec46d,#4d96ff,#a26bff,#ff5a5f); overflow: hidden; position: relative;
}
.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sizerow2 { display: flex; align-items: center; gap: 13px; padding: 2px 2px 0; }
.sizerow2 .lbl { font-size: 15px; color: #8a7a6a; flex: none; }
.sizedot { background: #7a6a5a; border-radius: 50%; flex: none; }
.rng { flex: 1; -webkit-appearance: none; appearance: none; height: 14px; border-radius: 8px; background: #efe6da; outline: none; }
.rng::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 4px solid #e8993e; box-shadow: 0 2px 5px rgba(0,0,0,.2); cursor: pointer; }
.rng::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 4px solid #e8993e; cursor: pointer; }

/* ===== 선택된(움직이는) 스티커 ===== */
.astk { position: absolute; transform: translate(-50%,-50%); z-index: 14; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.astk-box { position: relative; display: flex; align-items: center; justify-content: center; cursor: move; }
.astk-box .sel-ring { position: absolute; inset: -10px; border: 3px dashed #4d96ff; border-radius: 14px; pointer-events: none; }
.astk-emoji { line-height: 1; user-select: none; }
.astk-img { display: block; object-fit: contain; }
.handle { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid #4d96ff; box-shadow: 0 2px 5px rgba(0,0,0,.25); }
.h-br { bottom: -16px; right: -16px; cursor: nwse-resize; }
.astk-pill { display: flex; align-items: center; gap: 9px; background: #fff; border-radius: 18px; padding: 7px 10px; box-shadow: 0 8px 20px rgba(0,0,0,.2); }
.pbtn { width: 40px; height: 40px; border: none; border-radius: 14px; background: #f3ead9; font-size: 21px; display: flex; align-items: center; justify-content: center; flex: none; box-shadow: 0 3px 0 rgba(120,80,50,.15); cursor: pointer; }
.pbtn:active { transform: translateY(2px); }
.pbtn.ok { background: #4fb974; color: #fff; box-shadow: 0 3px 0 #379a5b; padding: 0 16px; width: auto; height: 40px; font-family: 'Jua', sans-serif; font-size: 16px; gap: 5px; }

/* ===== 시트(하단) ===== */
.sheet-ov { position: fixed; inset: 0; background: rgba(60,40,30,.4); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 820px; max-height: 84vh; border-radius: 30px 30px 0 0; padding: 16px 18px 26px; overflow-y: auto; box-shadow: 0 -10px 34px rgba(60,40,30,.3); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; position: sticky; top: 0; background: #fff; z-index: 2; padding-bottom: 4px; }
.sheet-title { font-size: 23px; }
.sheet-close { border: none; background: #f2ece4; border-radius: 50%; width: 46px; height: 46px; font-size: 20px; cursor: pointer; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; }
.sheet-grid.stickers { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
.tcell { border: 3px solid #eee; border-radius: 18px; background: #fff; cursor: pointer; aspect-ratio: 1/1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 7px; overflow: hidden; }
.tcell:active { transform: scale(.95); }
.tcell img { width: 100%; height: 76%; object-fit: contain; }
.tcell-label { font-size: 13px; margin-top: 3px; color: #6a5a4a; }
.tcell .blank { font-size: 44px; opacity: .4; }
.tcell.add { border-style: dashed; border-color: #f0b46a; color: #e0893a; }
.tcell .add-in { font-size: 15px; text-align: center; line-height: 1.3; }
.tabs { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 12px; position: sticky; top: 52px; background: #fff; padding-bottom: 5px; z-index: 2; }
.tab { flex: 0 0 auto; border: none; border-radius: 22px; background: #f2ece4; padding: 9px 16px; font-family: 'Jua', sans-serif; font-size: 15px; color: #7a6a5a; cursor: pointer; }
.tab.active { background: #ffe6c2; color: #c9762a; }
.scell { border: 2px solid #eee; border-radius: 16px; background: #fff; cursor: pointer; aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; font-size: 36px; padding: 5px; position: relative; }
.scell:active { transform: scale(.93); }
.scell img { width: 100%; height: 100%; object-fit: contain; }
.scell.mine { border-color: #f0c060; }
.scell-del { position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; background: #ff5a5f; color: #fff; border-radius: 50%; font-size: 14px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.import-bar { background: #fff7ea; border: 2px solid #ffe0a3; border-radius: 18px; padding: 12px; margin-bottom: 14px; }
.import-guide { font-size: 13px; font-family: 'Noto Sans KR', sans-serif; line-height: 1.5; color: #8a6a3a; margin-bottom: 10px; }
.import-row { display: flex; gap: 9px; flex-wrap: wrap; }
.import-btn { flex: 1 1 140px; border: none; border-radius: 14px; background: #fff; color: #e0893a; box-shadow: 0 4px 0 #f0d3a3; font-family: 'Jua', sans-serif; font-weight: 400; padding: 13px 12px; font-size: 15px; cursor: pointer; }
.import-btn:active { transform: translateY(2px); }
.import-btn.primary { background: #e8993e; color: #fff; box-shadow: 0 4px 0 #c9762a; }
.cutout-overlay { position: fixed; inset: 0; background: rgba(255,251,244,.94); z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.cut-spin { width: 56px; height: 56px; border: 6px solid #ffe0a3; border-top-color: #e8993e; border-radius: 50%; animation: cs .9s linear infinite; }
@keyframes cs { to { transform: rotate(360deg); } }
.cut-text { font-size: 19px; }
.cut-pct { font-size: 16px; color: #e0893a; min-height: 20px; }

.tcell.gal { position: relative; overflow: visible; }
.gal-empty { font-size: 17px; color: #8a7a6a; text-align: center; padding: 44px 12px; font-family: 'Noto Sans KR', sans-serif; line-height: 1.7; }

/* ===== 확인 모달 ===== */
.confirm-ov { position: fixed; inset: 0; background: rgba(60,40,30,.42); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.confirm-box { background: #fff; border-radius: 28px; padding: 28px 30px; box-shadow: 0 18px 44px rgba(60,40,30,.32); max-width: 400px; text-align: center; display: flex; flex-direction: column; gap: 22px; }
.confirm-msg { font-size: 23px; color: #4a3f3a; line-height: 1.4; }
.confirm-btns { display: flex; gap: 14px; justify-content: center; }
.cf-btn { border: none; border-radius: 18px; padding: 14px 34px; font-family: 'Jua', sans-serif; font-size: 20px; cursor: pointer; box-shadow: 0 5px 0 rgba(0,0,0,.14); }
.cf-btn:active { transform: translateY(2px); }
.cf-btn.yes { background: #e8993e; color: #fff; box-shadow: 0 5px 0 #c9762a; }
.cf-btn.no { background: #f2ece4; color: #7a6a5a; box-shadow: 0 5px 0 #ddd3c6; }

/* ===== 토스트 ===== */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(16px);
  background: rgba(50,36,28,.95); color: #fff; padding: 13px 22px; border-radius: 24px;
  font-size: 16px; z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
