.drawing-dialog { position:fixed; inset:0; margin:0; width:100vw; height:100dvh; max-width:none; max-height:none; padding:4px; border:0; color:var(--text); background:var(--surface); display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:44px minmax(0,1fr) auto; gap:4px; }
.drawing-dialog:not([open]) { display:none; }
.drawing-dialog::backdrop { background:#fff; }
.drawing-head { display:flex; gap:8px; align-items:center; min-width:0; }
.drawing-head #drawingStatus { flex:1; font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.drawing-head #drawingHud { font-size:14px; font-weight:800; }
.drawing-head .btn { min-width:44px; min-height:44px; }
#drawingChanged { position:absolute; top:48px; left:8px; z-index:5; margin:0; padding:var(--sp-2); background:var(--bad-soft); font-size:14px; pointer-events:none; }
.drawing-stage { position:relative; overflow:hidden; min-height:0; min-width:0; background:#e9edf5; border:1px solid var(--line); touch-action:none; }
.note-world { position:absolute; top:0; left:0; transform-origin:0 0; background:white; background-image:radial-gradient(#d9deea .7px,transparent .7px); background-size:20px 20px; pointer-events:none; }
.note-world .note-figure { position:absolute; color:#111; }
#drawingCanvas { position:absolute; inset:0; width:100%; height:100%; touch-action:none; -webkit-user-select:none; user-select:none; }
.drawing-tools { display:grid; grid-template-columns:1fr; gap:4px; }
.pen-widths, .pen-colors, .pen-actions { display:flex; gap:4px; flex-wrap:wrap; }
.drawing-tools .btn, .pen-color { min-height:44px; min-width:44px; padding:4px 6px; font-size:12px; }
.pen-widths .btn { flex:1; }
.pen-color { border:2px solid var(--line); border-radius:8px; background:white; display:grid; place-items:center; }
.pen-color span { width:24px; height:24px; border:1px solid #444; border-radius:50%; background:var(--pen-color); }
.drawing-tools [aria-pressed="true"] { outline:3px solid var(--primary); outline-offset:-3px; }
.pen-actions { display:grid; grid-template-columns:repeat(4,minmax(44px,1fr)); }
.pen-actions .btn { white-space:normal; }
@media (orientation:landscape) {
  .drawing-dialog { grid-template-columns:minmax(0,1fr) 200px; grid-template-rows:44px minmax(0,1fr); }
  .drawing-head { grid-column:1 / -1; }
  .drawing-stage { grid-column:1;grid-row:2; }
  .drawing-tools { grid-column:2;grid-row:2;overflow-y:auto;align-content:start; }
  .pen-widths, .pen-colors { display:grid; grid-template-columns:repeat(4,minmax(44px,1fr)); }
  .pen-actions { display:grid;grid-template-columns:repeat(2,minmax(44px,1fr)); }
  .pen-colors { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .pen-color { min-width:44px; }
}
.tv-mode .drawing-tools .btn { font-size:16px;min-height:48px; }
.tv-mode .pen-color { min-height:48px; }

/* 문항 위 투명 낙서와 엄지로 조작하는 학습 도구. 메뉴/하단 조작은 캔버스 밖이다. */
.question-layout { position:relative; }
.question-ink { position:absolute; inset:0; width:100%; height:100%; z-index:8; pointer-events:none; }
.ink-enabled .question-layout { touch-action:none; }
.ink-enabled .question-ink { pointer-events:auto; touch-action:none; }
.study-footer { display:flex; flex:none; align-items:center; gap:var(--sp-2); min-height:44px; }
.study-footer .after { flex:1; min-width:0; }
.study-controls { display:flex; gap:4px; position:relative; flex:none; z-index:10; }
.study-controls > .btn { min-height:44px; min-width:44px; padding:6px 10px; font-size:18px; }
.study-controls [aria-pressed=true] { outline:3px solid var(--primary); outline-offset:-3px; }
.ink-toolbar { position:fixed; z-index:30; inset:auto; width:270px; max-width:calc(100vw - 16px); max-height:calc(100dvh - 16px); box-sizing:border-box; overflow:auto; padding:8px; background:var(--surface); border:2px solid var(--line); border-radius:12px; box-shadow:var(--shadow); }
.ink-toolbar[hidden] { display:none; }
.ink-toolbar > div { margin-bottom:6px; }
.ink-toolbar .pen-color { min-width:44px; min-height:44px; }
.ink-toolbar .pen-colors, .ink-toolbar .pen-widths { display:flex; gap:4px; flex-wrap:wrap; }
.ink-toolbar .btn { min-height:44px; min-width:44px; padding:4px; }
.ink-toolbar .pen-actions { grid-template-columns:repeat(2,minmax(44px,1fr)); }
.ink-status { display:block; font-size:14px; }
.note-list-dialog { width:100vw; height:100dvh; max-width:none; max-height:none; margin:0; padding:16px; border:0; background:var(--surface); color:var(--text); overflow:auto; }
.note-list-dialog header { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.note-list-dialog .btn { min-width:44px; min-height:44px; }
.note-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:12px; margin-top:12px; }
.note-entry { border:1px solid var(--line); border-radius:12px; padding:8px; }
.note-open { display:flex; flex-direction:column; width:100%; gap:var(--sp-2); }
.note-open canvas { width:100%; height:140px; object-fit:contain; background:white; }
.note-open time { font-size:14px; }
.note-entry > .btn:not(.note-open) { margin-top:6px; }
.board-question { font-size:16px; line-height:1.4; max-height:70px; overflow:auto; padding:4px 8px; background:var(--surface); z-index:2; }
.board-question.has-stimulus { max-height:34vh; }
.board-question .stimulus-box { margin:6px auto 2px; max-height:none; cursor:default; }
.drawing-dialog { grid-template-rows:44px auto minmax(0,1fr) auto; padding:max(4px,var(--safe-area-top)) max(4px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(4px,env(safe-area-inset-left)); }
.drawing-head { font-size:14px; }
.drawing-head #drawingStatus { white-space:normal; font-size:12px; }
@media (orientation:landscape) {
  .drawing-dialog { grid-template-rows:44px auto minmax(0,1fr); }
  .board-question { grid-column:1 / -1; grid-row:2; }
  .drawing-stage, .drawing-tools { grid-row:3; }
}
@media (max-width:450px) {
  .study-controls > .btn { padding:4px 6px; font-size:16px; }
  .study-footer .question-actions .btn { padding:4px 6px; }
  .drawing-head { gap:4px; }
  #drawingZoom { display:none; }
}

/* 펜 켜기/끄기와 펜 설정을 분리한 버튼 구성(#54). 설정 창은 팝오버로만 열린다. */
.pen-toggle, .ink-toggle { white-space:nowrap; }
.pen-toggle[aria-pressed="true"], .ink-toggle[aria-pressed="true"] { background:var(--primary); color:#fff; border-color:var(--primary); outline:0; }
.drawing-tools .pen-toggle[aria-pressed="true"], .study-controls .ink-toggle[aria-pressed="true"] { outline:0; }
.pen-bar { display:flex; gap:4px; }
.pen-bar .pen-toggle { flex:1; }
.pen-settings, .ink-settings { display:grid; place-items:center; min-width:44px; min-height:44px; padding:0; }
.pen-dot { display:block; width:12px; height:12px; border-radius:50%; background:var(--pen-color,#111); border:2px solid #444; box-sizing:content-box; }
.is-eraser .pen-dot { background:transparent; border-style:dashed; }
.pen-popover { position:fixed; z-index:30; padding:8px; display:grid; gap:var(--sp-2); background:var(--surface); border:2px solid var(--line); border-radius:12px; box-shadow:var(--shadow); max-height:calc(100dvh - 8px); overflow:auto; }
.pen-popover[hidden] { display:none; }
.pen-popover .pen-actions { display:grid; grid-template-columns:1fr; }
.pen-popover .btn, .pen-popover .pen-color { min-height:44px; min-width:44px; }
.pen-popover [aria-pressed="true"] { outline:3px solid var(--primary); outline-offset:-3px; }

/* P3: 상단 노트 띠와 오른쪽 56px 6버튼. 모든 방향에 같은 보드 좌표를 사용한다. */
.drawing-dialog { grid-template-columns:minmax(0,1fr) 56px; grid-template-rows:44px auto minmax(0,1fr); gap:4px; }
.drawing-head { grid-column:1 / -1; grid-row:1; }
.board-context { grid-column:1 / -1; grid-row:2; min-width:0; }
.board-context .board-question { max-height:44px; font-size:14px; }
.note-strip { display:flex; gap:var(--sp-2); overflow-x:auto; overflow-y:hidden; height:84px; padding:2px; scrollbar-width:thin; }
.note-strip .btn { flex:0 0 116px; min-width:44px; min-height:44px; padding:2px 4px; font-size:12px; }
.note-strip .note-open { display:grid; grid-template-columns:1fr auto; grid-template-rows:44px 22px; gap:2px; border-radius:8px; }
.note-strip canvas { grid-column:1 / -1; width:100%; height:44px; background:white; object-fit:contain; }
.note-strip span { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-align:left; }
.note-strip time { font-size:var(--fs-caption); }
.note-strip [aria-pressed=true] { border-color:var(--primary); outline:2px solid var(--primary); outline-offset:-2px; }
.drawing-stage { grid-column:1; grid-row:3; }
.drawing-tools { grid-column:2; grid-row:3; display:grid; grid-template-rows:repeat(6,minmax(44px,1fr)); align-content:stretch; overflow:auto; gap:2px; }
.drawing-tools > .btn, .tv-mode .drawing-tools > .btn { display:flex; flex-direction:column; align-items:center; justify-content:center; width:56px; min-height:44px; padding:2px; font-size:var(--fs-caption); white-space:normal; line-height:1.2; }
.drawing-tools > .btn > span:first-child { font-size:20px; }
.drawing-tools [aria-pressed=true] { background:var(--primary); color:white; outline:0; }
.drawing-dialog .drawing-tools > .btn:focus-visible,
.drawing-dialog .note-strip .btn:focus-visible,
.study-controls .ink-toggle[aria-pressed]:focus-visible { outline:3px solid var(--accent); outline-offset:-3px; }
.board-materials { position:absolute; z-index:35; top:48px; left:4px; width:min(340px,calc(100vw - 12px)); max-height:calc(100dvh - 56px); overflow:auto; padding:12px; border:2px solid var(--line); border-radius:12px; background:var(--surface); box-shadow:var(--shadow); }
.board-materials[hidden] { display:none; }
.board-materials label { display:flex; align-items:center; gap:8px; }
.board-materials select { color:#111; background:white; min-height:44px; flex:1; font-size:16px; }
.board-materials .btn { min-width:44px; min-height:44px; margin:2px; }
.note-world { background-color:white; }
.board-sticker { position:absolute; background:white; color:#111; border:1px solid #bdc6d6; overflow:hidden; }
.board-sticker > svg, .board-sticker > .asset-content { width:100%; height:100%; }
.board-sticker svg { display:block; }
.board-sticker .stimulus-box { width:100%; height:100%; max-height:none; margin:0; pointer-events:none; cursor:default; overflow:hidden; }
.board-sticker .stimulus-expr { font-size:36px; }
.board-sticker .stimulus-passage { font-size:24px; line-height:1.7; }
.board-sticker.selected.editable { outline:3px solid #2563eb; }
.sticker-handle { display:none; position:absolute; right:0; bottom:0; width:32px; height:32px; text-align:center; color:white; background:#2563eb; font-size:24px; }
.board-sticker.editable .sticker-handle { display:block; }
.sticker-delete { position:absolute; z-index:3; top:4px; left:4px; min-height:44px; }
.sticker-delete[hidden] { display:none; }
.wrong-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:12px; margin-top:12px; }
.wrong-card { border:1px solid var(--line); padding:12px; border-radius:12px; }
.wrong-card p { margin:0 0 8px; }
.wrong-card .wrong-thumbnail { display:block; width:100%; height:120px; background:white; object-fit:contain; }
.wrong-card .btn { min-width:44px; min-height:44px; }
@media (max-height:500px) and (orientation:landscape) {
  .drawing-dialog { grid-template-rows:44px 54px minmax(0,1fr); }
  .board-context { display:grid; grid-template-columns:minmax(120px,1fr) minmax(0,2fr); gap:8px; }
  .board-context .board-question, .note-strip { max-height:54px; height:54px; }
  .note-strip .note-open { grid-template-rows:28px 20px; }
  .note-strip canvas { height:28px; }
  .board-context .board-question { grid-column:1; grid-row:1; }
  .board-context .note-strip { grid-column:2; grid-row:1; }
}

/* 펜 안내도 플로팅으로 표시한다. 가로 화면의 공통 토스트 공간 확보를 적용하지 않는다. */
@media (max-height:500px) and (orientation:landscape) {
  .quiz-screen:has(.toast.ink-notice:not([hidden])) #app { padding-top:max(4px,var(--safe-area-top)); }
}

.pen-opacities{display:flex;gap:var(--sp-2);flex-wrap:wrap}.pen-opacities .btn{min-height:44px;flex:1}.pen-opacities [aria-pressed="true"]{outline:2px solid var(--accent);outline-offset:-2px}

.note-list-dialog { padding-top:calc(16px + var(--safe-area-top)); }
/* 안내 본문은 입력을 통과시키고 복구 버튼만 44px 터치 영역을 가진다. */
#toast:has([data-toast-action]) { display:flex; width:max-content; align-items:center; justify-content:center; gap:8px; padding:var(--sp-2) var(--sp-3); border-radius:var(--r-pill); white-space:normal; overflow:visible; }
#toast[hidden] { display:none; }
#toast .toast-message { min-width:0; }
#toast [data-toast-action] { flex:0 0 auto; min-width:44px; min-height:44px; margin:0; padding:0 var(--sp-3); color:inherit; border:1px solid currentColor; border-radius:12px; background:transparent; font:inherit; white-space:nowrap; }
@media (max-width:360px) { #toast:has([data-toast-action]) { gap:var(--sp-2); padding-inline:var(--sp-3); max-width:calc(100vw - 20px); } }

/* 펜 영역 안의 스크롤/가장자리 시작 보호. 표시 여백은 만들지 않는다. */
.question-ink, #drawingCanvas { --ink-safe-left:env(safe-area-inset-left, 0px); --ink-safe-right:env(safe-area-inset-right, 0px); overscroll-behavior:none; }
.ink-enabled .question-layout, .drawing-stage { touch-action:none; overscroll-behavior:none; }
