/* 초코블록 화면. ui.css · type.css 다음에 붙는다. */
:root {
  --ink: #2B211C;
  --muted: #6B625C;
  --line: #E6E1DC;
  --site: #FFF3DF; --site-ink: #E0702A;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); background: #FBF8F4; background-image: none;
  font-family: 'Pretendard Variable', Pretendard, 'Malgun Gothic', sans-serif; font-size: 16px;
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; cursor: pointer; }

/* 머리 */
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); flex: none; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); margin-right: 8px; }
.logo img { width: 34px; height: 34px; }
.logo b { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.logo span { font-size: 13px; color: var(--muted); }
.go, .stopbtn { border: 2.5px solid var(--ink); border-radius: 999px; padding: 7px 20px; font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 var(--ink); }
.go { background: #2FA84F; color: #fff; }
.go:disabled { background: #BFC7BF; box-shadow: none; cursor: wait; }
.stopbtn { background: #EF5350; color: #fff; }
.go:active, .stopbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.status { font-size: 14px; color: var(--muted); }
.spacer { flex: 1; }
.ghostbtn { background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 14px; color: var(--ink); }
.ghostbtn.sm { padding: 3px 10px; font-size: 13px; }
.ghostbtn:hover { border-color: var(--ink); }

/* 본문: 왼쪽 무대 · 오른쪽 블록판 */
.app { flex: 1; display: grid; grid-template-columns: minmax(300px, 420px) 1fr; min-height: 0; }
.left { padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow: auto; border-right: 1px solid var(--line); }
.stage-wrap { position: relative; border: 2.5px solid var(--ink); border-radius: 16px; overflow: hidden; background: #fff; flex: none; }
#stage { display: block; width: 100%; aspect-ratio: 4 / 3; touch-action: none; }
.ask { position: absolute; left: 8px; right: 8px; bottom: 8px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 10px; }
.ask p { margin: 0 0 6px; font-weight: 700; font-size: 15px; }
.ask form { display: flex; gap: 6px; }
.ask input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 16px; }
.ask button { border: 0; border-radius: 10px; background: #E457DC; color: #fff; font-weight: 700; padding: 6px 14px; }
.ask .yn { display: flex; gap: 8px; }
.ask .yn button { flex: 1; padding: 8px; font-size: 16px; }
.ask .yn button + button { background: #6B625C; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.objs { display: flex; flex-wrap: wrap; gap: 8px; }
.obj { position: relative; width: 84px; border: 2px solid var(--line); border-radius: 12px; padding: 4px 4px 2px; text-align: center; background: #fff; cursor: pointer; }
.obj.on { border-color: var(--site-ink); background: #FFF6EA; }
.obj canvas { width: 72px; height: 54px; display: block; margin: 0 auto; }
.obj span { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obj .x { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #EF5350; color: #fff; font-size: 12px; line-height: 20px; padding: 0; display: none; }
.obj:hover .x { display: block; }
.bgpick { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.bgpick select { border: 1.5px solid var(--line); border-radius: 8px; padding: 3px 6px; }
.tip { font-size: 13px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }

.right { display: grid; grid-template-columns: 76px 300px 1fr; min-height: 0; }
.cats { display: flex; flex-direction: column; gap: 4px; padding: 10px 6px; background: #fff; border-right: 1px solid var(--line); overflow: auto; }
.cat { border: 0; background: none; padding: 8px 2px; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cat::before { content: ''; width: 20px; height: 20px; border-radius: 50%; background: var(--c); border: 2px solid var(--ink); }
.cat.on { background: #F4EDE4; }
.pal { overflow: auto; padding: 10px 12px 40px; background: #fff; border-right: 1px solid var(--line); }
.pal-title { font-weight: 800; font-size: 18px; margin: 2px 0 8px; }
.pal-row { margin: 0 0 12px; }
.pal-btn { width: 100%; border: 2px dashed #E457DC; background: #FFF4FE; border-radius: 12px; padding: 7px; font-weight: 700; margin-bottom: 12px; }
.pal-empty { font-size: 14px; color: var(--muted); line-height: 1.55; }
.pal input, .pal select { pointer-events: none; }
.pal .b { cursor: grab; }
.ws { overflow: auto; background: #F7F8FA; background-image: radial-gradient(#D7DCE4 1.3px, transparent 1.3px); background-size: 20px 20px; position: relative; }
.ws-canvas { position: relative; width: 2400px; height: 1800px; }
.ws-empty { position: absolute; left: 30px; top: 30px; color: var(--muted); }
.script { position: absolute; }
.script .b, .ghost .b { cursor: grab; }

/* 블록 */
.list { display: flex; flex-direction: column; align-items: flex-start; }
.blk { display: flex; align-items: center; gap: 6px; width: max-content; color: #fff; font-weight: 700; font-size: 15px;
       background: var(--c); border: 2px solid rgba(0,0,0,.18); border-radius: 12px; padding: 6px 12px; margin: 3px 0;
       box-shadow: 0 3px 0 rgba(0,0,0,.18); user-select: none; white-space: nowrap; }
.blk.hat { border-radius: 26px 26px 12px 12px; padding-top: 12px; margin-bottom: 4px; }
.blk.word { background: none; border: 0; box-shadow: none; padding: 0; margin: 0 0 0 -8px; }
.blk.unknown { --c: #9A9087; }
.rep { display: inline-flex; align-items: center; gap: 5px; color: #fff; font-weight: 700; font-size: 14px; background: var(--c);
       padding: 3px 10px; margin: 0 1px; white-space: nowrap; user-select: none; box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.rep.val { border-radius: 999px; border: 2px solid rgba(0,0,0,.18); }
.rep.cond { clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%); padding: 4px 18px; }
.t { pointer-events: none; }
.in { border: 0; border-radius: 999px; background: #fff; color: var(--ink); font: inherit; font-weight: 700; font-size: 14px;
      padding: 2px 6px; text-align: center; min-width: 1.6em; outline: none; }
.in:focus { box-shadow: 0 0 0 2px var(--ink); }
.pick { border: 0; border-radius: 999px; background: rgba(255,255,255,.95); color: var(--ink); font: inherit; font-weight: 700; font-size: 14px; padding: 2px 4px; }
.hole { display: inline-block; width: 46px; height: 24px; background: rgba(0,0,0,.18);
        clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%); }
.slot-hot { outline: 3px solid #FFD400; outline-offset: 1px; background: #FFF6B8 !important; }

/* 글자 블록 (입): 낱말 첫 글자 줄기가 등뼈·아래턱 (letters.js 가 그림) */
.jaw { position: relative; width: max-content; padding-right: 30px; margin: 2px 0; --c: transparent; }
.jaw > svg.art { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 0; }
.jaw > .head, .jaw > .inside, .jaw > .foot { position: relative; z-index: 1; }
.jaw > .head { display: flex; align-items: center; gap: 5px; }
.jaw > .head > .wsp { flex: none; }
.jaw > .head.mid > .wsp { margin-left: var(--spine); }
.jaw > .head > .t { color: var(--ink); font-weight: 800; font-size: 15px; margin-top: 8px; }
.jaw > .head > .in, .jaw > .head > .pick, .jaw > .head > .hole, .jaw > .head > .rep { margin-top: 8px; }
.jaw > .head > .in { border: 2.5px solid var(--ink); }
.jaw > .head > .hole { background: #E9E1D7; }
.jaw > .head .colon { margin: 6px 0 0 -10px; display: inline-flex; }
.jaw > .inside { padding: 0 0 2px calc(var(--spine) + 10px); min-height: 40px; }
.jaw > .foot { height: 30px; }
.sticker { display: block; overflow: visible; }

/* 끌기 */
.ghost { position: fixed; z-index: 50; pointer-events: none; opacity: .9; filter: drop-shadow(0 8px 12px rgba(0,0,0,.25)); }
.marker { position: fixed; z-index: 49; width: 120px; height: 6px; border-radius: 3px; background: #FFD400; border: 1.5px solid var(--ink); pointer-events: none; display: none; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px;
         border-radius: 12px; font-size: 15px; z-index: 60; max-width: min(90vw, 640px); white-space: pre-line; }
.toast.err { background: #C2412D; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; overflow: auto; }
  body { overflow: auto; }
  .left { border-right: 0; }
  .right { min-height: 640px; grid-template-columns: 64px 240px 1fr; }
}
