.worksheet-qr-box[hidden] { display: none !important; }

/* ==========================================================================
   모두매쓰 (Modoo-Math) 스타일 프리미엄 학습지 인터페이스 & 아이패드 필기 CSS
   ========================================================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --accent: #0ea5e9;

    /* 난이도 테마 */
    --basic-color: #059669;
    --basic-bg: #ecfdf5;
    --basic-border: #a7f3d0;

    --applied-color: #2563eb;
    --applied-bg: #eff6ff;
    --applied-border: #bfdbfe;

    --advanced-color: #7c3aed;
    --advanced-bg: #f5f3ff;
    --advanced-border: #ddd6fe;

    --neutral-dark: #0f172a;
    --neutral-body: #334155;
    --neutral-muted: #64748b;
    --bg-viewport: #e2e8f0; /* 용지가 돋보이는 시험지 데스크 배경 */
    --paper-bg: #ffffff;
    --border-subtle: #cbd5e1;

    --shadow-paper: 0 10px 30px -5px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-dock: 0 20px 25px -5px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background-color: var(--bg-viewport);
    color: var(--neutral-body);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   1. 상단 글로벌 네비게이션 바 (모두매쓰 시그니처)
   ========================================================================== */
.modoo-navbar {
    background: #1e293b;
    color: white;
    padding: 0.65rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo-badge {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.brand-sub-badge {
    font-size: 0.65rem;
    background: #0ea5e9;
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
}

.brand-desc {
    font-size: 0.7rem;
    color: #94a3b8;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-gemini-ai {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.35);
}

.btn-account {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}
.btn-account:hover {
    background: #e2e8f0;
}
.btn-gemini-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.5);
}

.btn-regen {
    background: #3b82f6;
    color: white;
}
.btn-regen:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-ipad {
    background: #8b5cf6;
    color: white;
}
.btn-ipad:hover {
    background: #7c3aed;
    transform: translateY(-1px);
}
.btn-ipad.active {
    background: #ec4899;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
}

.btn-print-main {
    background: #0f172a;
    color: white;
    border: 1px solid #475569;
}
.btn-print-main:hover {
    background: #334155;
    transform: translateY(-1px);
}

.btn-save {
    background: #10b981;
    color: white;
}
.btn-save:hover {
    background: #059669;
}

.btn-storage {
    background: #475569;
    color: white;
}
.btn-storage:hover {
    background: #64748b;
}

/* ==========================================================================
   2. 컨트롤 제어 툴바 (모두매쓰 서브 바)
   ========================================================================== */
.modoo-toolbar-bar {
    background: #ffffff;
    border-bottom: 1px solid #cbd5e1;
    padding: 0.65rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 54px;
    z-index: 90;
}

.toolbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.tool-group-grow {
    flex: 1;
    min-width: 220px;
}

.curriculum-coming-soon {
    margin: 4rem auto;
    max-width: 560px;
    padding: 2rem;
    text-align: center;
    border: 1px dashed #94a3b8;
    border-radius: 12px;
    color: #64748b;
    background: #f8fafc;
}

.curriculum-coming-soon strong {
    display: block;
    color: #334155;
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.tool-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
}

.modoo-select {
    padding: 0.45rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
    background: #ffffff;
    outline: none;
    cursor: pointer;
}

.unit-select {
    width: 100%;
}

.level-btn-group,
.col-toggle-group {
    display: flex;
    background: #f1f5f9;
    padding: 0.2rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.level-chip,
.col-chip {
    border: none;
    background: transparent;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.level-chip.active,
.col-chip.active {
    background: #ffffff;
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.level-chip-olympiad {
    color: #c2410c;
}

.level-chip-olympiad.active {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fdba74;
}

.level-chip.disabled-chip,
.level-chip:disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    background: #f1f5f9 !important;
    color: #94a3b8 !important;
    border-color: #e2e8f0 !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

.tool-toggles {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-left: auto;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}

.checkbox-inline input {
    accent-color: var(--primary);
    width: 15px;
    height: 15px;
}

/* ==========================================================================
   3. 아이패드 / 태블릿 필기 툴바 (플로팅 독)
   ========================================================================== */
.ipad-drawing-dock {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    box-shadow: var(--shadow-dock);
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: white;
    user-select: none;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translate(-50%, 30px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.dock-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #38bdf8;
    white-space: nowrap;
}

.dock-separator {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
}

.tool-btn {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.35rem 0.65rem;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.tool-btn.active {
    background: #38bdf8;
    color: #0f172a;
    font-weight: 700;
}

.color-palette {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s;
}

.color-dot.active {
    border-color: white;
    transform: scale(1.2);
}

.dock-select {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    outline: none;
}

.dock-select option {
    background: #0f172a;
    color: white;
}

.dock-action-btn {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    padding: 0.35rem 0.6rem;
    border-radius: 14px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}
.dock-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 손글씨 도구별 전역 커서 스타일 (JS DOM 순회 없는 초고속 CSS 전환) */
body[data-handwriting-tool="eraser"] .scratchpad-canvas {
    cursor: cell !important;
}
body[data-handwriting-tool="highlighter"] .scratchpad-canvas {
    cursor: crosshair !important;
}
body[data-handwriting-tool="pen"] .scratchpad-canvas {
    cursor: crosshair !important;
}

.ipad-drawing-dock.dock-pos-top {
    bottom: auto !important;
    top: 60px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
}

.dock-pos-btn {
    background: rgba(56, 189, 248, 0.2) !important;
    color: #38bdf8 !important;
    font-weight: 700 !important;
}
.dock-pos-btn:hover {
    background: rgba(56, 189, 248, 0.35) !important;
}

.dock-fold-btn {
    background: rgba(245, 158, 11, 0.22) !important;
    color: #fde047 !important;
    font-weight: 700 !important;
}
.dock-fold-btn:hover {
    background: rgba(245, 158, 11, 0.38) !important;
}

/* 도구함이 내려갔을 때 화면 중앙에 뜨는 콤팩트 미니 올리기 탭 */
.dock-minimized-tab {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #38bdf8;
    border: 1.5px solid rgba(56, 189, 248, 0.5);
    border-radius: 30px;
    padding: 6px 16px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    animation: tabBounce 0.25s ease-out;
}

.dock-minimized-tab:hover,
.dock-minimized-tab:active {
    transform: translateX(-50%) translateY(-2px);
    background: #0284c7;
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
}

.dock-minimized-tab.dock-pos-top {
    bottom: auto !important;
    top: 60px !important;
}

@keyframes tabBounce {
    from { transform: translate(-50%, 15px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* ==========================================================================
   4. 메인 뷰포트 & 실제 A4 시험지 용지
   ========================================================================== */
.page-viewport {
    flex: 1;
    padding: 1.5rem 1rem 4rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.print-sub-bar {
    width: 100%;
    max-width: 880px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.5rem;
}

.print-guide-text {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

.print-sub-right {
    display: flex;
    gap: 0.5rem;
}

.btn-sub-action {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-sub-action:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-score-check {
    background: #059669;
    color: white;
    border-color: #059669;
}
.btn-score-check:hover {
    background: #047857;
}

/* 실제 A4 용지 규격 (210mm x 297mm 비율) */
.a4-sheet-wrapper {
    background: var(--paper-bg);
    width: 100%;
    max-width: 880px;
    min-height: 1180px;
    padding: 3rem 3rem 4rem 3rem;
    border-radius: 4px;
    box-shadow: var(--shadow-paper);
    position: relative;
    border: 1px solid #d1d5db;
}

.solution-sheet-wrapper {
    background: #fafaf9;
}

/* 시험지 상단 타이틀 영역 */
.worksheet-header {
    border-bottom: 2px solid #0f172a;
    padding-bottom: 1.25rem;
    margin-bottom: 2rem;
}

.worksheet-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.worksheet-brand h2 {
    font-size: 1.65rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.5px;
}

.badge-accent {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-solution {
    background: #fef3c7;
    color: #92400e;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.student-info-box {
    display: flex;
    gap: 1.25rem;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.info-field {
    color: #1e293b;
    font-weight: 600;
}

.score-field {
    color: #dc2626;
    font-weight: 700;
}

.worksheet-meta-sub {
    margin-top: 0.65rem;
    display: flex;
    gap: 1.25rem;
    font-size: 0.78rem;
    color: #64748b;
}

/* ==========================================================================
   문제 리스트 및 1단/2단 그리드
   ========================================================================== */
.questions-grid.grid-col-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem 3rem;
}

.questions-grid.grid-col-1 {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.question-card {
    border-bottom: 1px dashed #cbd5e1;
    padding-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 220px;
    position: relative;
}

.q-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.q-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #0f172a;
    color: white;
    border-radius: 50%;
    font-size: 0.88rem;
    font-weight: 800;
}

.q-level-tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.badge-basic {
    background: var(--basic-bg);
    color: var(--basic-color);
    border: 1px solid var(--basic-border);
}

.badge-applied {
    background: var(--applied-bg);
    color: var(--applied-color);
    border: 1px solid var(--applied-border);
}

.badge-advanced {
    background: var(--advanced-bg);
    color: var(--advanced-color);
    border: 1px solid var(--advanced-border);
}

.badge-mix {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* 🏆 영재·올림피아드 */
.badge-olympiad {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fdba74;
}

.q-unit-tag {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-left: auto;
}

.q-body {
    font-size: 1.05rem;
    color: #0f172a;
    line-height: 1.7;
    margin-bottom: 0.85rem;
}

.visual-objects {
    display: inline-block;
    font-size: 1.25rem;
    line-height: 1.5;
    letter-spacing: 0.06rem;
    word-break: break-word;
}

.quality-question .q-body {
    font-size: 1rem;
    line-height: 1.65;
}

.visual-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin: 1rem 0 0.5rem;
    min-height: 70px;
    flex-wrap: nowrap;
}

.visual-group {
    min-width: 74px;
    min-height: 58px;
    max-width: 132px;
    padding: 0.45rem 0.55rem;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.visual-items {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    line-height: 1;
}

.visual-item {
    display: inline-flex;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
}

.visual-group small {
    margin-top: 0.3rem;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 700;
}

.visual-zero {
    font-size: 1.4rem;
    font-weight: 800;
    color: #64748b;
}

.visual-operator {
    display: inline-flex;
    width: 34px;
    height: 42px;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    font-size: 30px;
    line-height: 1;
    font-weight: 800;
    color: #1e293b;
}

.visual-answer-box {
    width: 44px;
    height: 44px;
    border: 2px solid #475569;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    background: white;
}

.visual-choice-row {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 0.55rem;
    margin-top: 0.8rem;
    flex-wrap: wrap;
}

.visual-choice {
    min-width: 56px;
    min-height: 44px;
    padding: 0.35rem 0.55rem;
    border: 1.5px solid #94a3b8;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: white;
}

.visual-choice .visual-group {
    border: 0;
    padding: 0.15rem;
    min-width: auto;
    min-height: auto;
}

.covered-items, .removed-note {
    display: inline-block;
    margin: 0.4rem;
    padding: 0.35rem 0.55rem;
    border-radius: 7px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.78rem;
}

.draw-zone {
    min-width: 88px;
    min-height: 58px;
    border: 2px dashed #94a3b8;
    border-radius: 10px;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
}

.number-line {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin: 1rem auto 0.5rem;
    max-width: 430px;
}

.number-tick { flex: 1; text-align: center; position: relative; border-top: 3px solid #475569; }
.number-tick i { display: block; width: 2px; height: 9px; background: #475569; margin: -3px auto 3px; }
.number-tick b { font-size: 0.8rem; }
.number-tick.active b { display: inline-flex; width: 25px; height: 25px; border-radius: 50%; align-items: center; justify-content: center; background: #2563eb; color: white; }

.pattern-strip, .position-board {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.65rem;
    margin: 0.9rem 0;
}
.pattern-strip span, .position-board span { font-size: 1.45rem; }

.length-compare { display: flex; flex-direction: column; gap: 0.65rem; margin: 0.8rem auto; max-width: 320px; }
.length-compare span { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; }
.length-compare span::after { content: ''; width: calc(var(--bar-width) * 22px); height: 13px; border-radius: 7px; background: #3b82f6; }

.balance-scale { display: flex; justify-content: center; align-items: center; gap: 1rem; font-size: 1.5rem; margin: 0.8rem; }
.balance-scale i { width: 70px; border-top: 3px solid #475569; position: relative; }
.balance-scale i::after { content: ''; position: absolute; left: 33px; top: 0; height: 28px; border-left: 3px solid #475569; }

.reasoning-source {
    margin: 0.7rem 0;
    padding: 0.7rem 0.85rem;
    border-left: 4px solid #60a5fa;
    border-radius: 0 8px 8px 0;
    background: #eff6ff;
}

.reasoning-choice-row {
    display: flex;
    gap: 0.65rem;
    justify-content: center;
    margin: 0.75rem 0;
    flex-wrap: wrap;
}

.reasoning-choice-row span {
    min-width: 90px;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid #94a3b8;
    border-radius: 8px;
    background: white;
    text-align: center;
}

.reasoning-choice-row b {
    display: inline-flex;
    width: 21px;
    height: 21px;
    margin-right: 0.4rem;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e2e8f0;
    font-size: 0.72rem;
}

.worked-solution {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin: 0.7rem 0;
    padding: 0.75rem;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    background: #fafafa;
}

.clock-diagram { display: block; width: 118px; height: 118px; margin: 0.7rem auto; }
.clock-diagram circle { fill: white; stroke: #334155; stroke-width: 3; }
.clock-diagram line { stroke: #0f172a; stroke-linecap: round; }
.clock-diagram .minute-hand { stroke-width: 2.5; }
.clock-diagram .hour-hand { stroke-width: 4; }

@media print {
    .visual-objects {
        font-size: 12pt;
        color: #000 !important;
    }
    .visual-item { font-size: 16pt; width: 18pt; height: 18pt; }
    .visual-operator { font-size: 20pt; }
    .visual-group { border-color: #555; }
}

/* ==========================================================================
   아이패드 터치 캔버스 영역 (풀이 공간)
   ========================================================================== */
.scratchpad-box {
    margin-top: auto;
    position: relative;
    border: 1.5px dashed #a5b4fc;
    border-radius: 8px;
    height: 140px;
    min-height: 140px;
    background: #fafafa;
    overflow: hidden;
    touch-action: none !important;
    transition: all 0.2s ease;
}

body.handwriting-mode-active .scratchpad-box {
    border: 2px dashed #8b5cf6;
    background: #faf5ff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.12);
}

.scratchpad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: rgba(241, 245, 249, 0.8);
    border-bottom: 1px solid #e2e8f0;
}

.scratchpad-label {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 600;
}

.scratchpad-tools {
    display: flex;
    gap: 0.25rem;
}

.btn-scratch-tool {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}
.btn-scratch-tool:hover {
    background: #e2e8f0;
}

.scratchpad-canvas {
    display: block;
    background: #ffffff;
    position: absolute;
    top: 24px;
    left: 0;
    width: 100%;
    height: calc(100% - 24px);
    cursor: crosshair;
    touch-action: none !important;
    pointer-events: auto !important;
}

.btn-scratch-status {
    background: #e0e7ff;
    color: #4338ca;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    border: 1px solid #c7d2fe;
}
.btn-scratch-status:hover {
    background: #c7d2fe;
}

/* 화면 풀기 모드 스타일 */
.choices-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin: 0.65rem 0;
}

.choice-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

.choice-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e2e8f0;
    font-size: 0.7rem;
    font-weight: 700;
}

.input-answer-container {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0.65rem 0;
    flex-wrap: wrap;
}

.input-answer-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ans-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #475569;
}

.input-answer {
    padding: 0.45rem 0.75rem;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    width: 170px;
    background: #ffffff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-answer:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.ans-unit {
    display: inline-flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-left: 1px;
    user-select: none;
}

/* 원클릭 퀵 선택 칩 (예/아니요, 기호, 부등호 등) */
.quick-chip-group {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.btn-quick-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #334155;
    background: #f1f5f9;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 36px;
}

.btn-quick-chip:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.btn-quick-chip:active {
    transform: translateY(0);
}

.btn-quick-chip.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.q-result-feedback {
    margin-top: 0.45rem;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
}
.q-result-feedback.correct {
    background: #ecfdf5;
    color: #065f46;
}
.q-result-feedback.incorrect {
    background: #fef2f2;
    color: #991b1b;
}

/* ==========================================================================
   해설집 스타일
   ========================================================================== */
.answer-quick-table {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.85rem;
    margin-top: 1rem;
}

.quick-table-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.quick-table-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
}

.quick-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.quick-item .num {
    font-weight: 700;
    color: #64748b;
}

.quick-item .ans {
    font-weight: 800;
    color: #0f172a;
}

.solutions-list {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.solution-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    background: white;
}

.sol-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.5rem;
    margin-bottom: 0.65rem;
}

.sol-number {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
}

.sol-ans-badge {
    margin-left: auto;
    background: #fee2e2;
    color: #991b1b;
    padding: 0.2rem 0.6rem;
    border-radius: 14px;
    font-size: 0.8rem;
}

.solution-steps {
    padding-left: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #334155;
}

.concept-tip-box {
    background: #fefce8;
    border: 1px solid #fef08a;
    border-radius: 6px;
    padding: 0.5rem 0.85rem;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: #854d0e;
    margin-top: 0.5rem;
}

/* ==========================================================================
   5. 보관함 및 재미나이 모달 창
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-card {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 580px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-card-large {
    max-width: 720px;
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: #0f172a;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

.modal-intro {
    font-size: 0.82rem;
    color: #64748b;
    margin-bottom: 1rem;
}

.saved-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.saved-empty {
    text-align: center;
    color: #64748b;
    padding: 2rem;
}

.saved-error {
    color: #b91c1c;
}

.auth-modal-card {
    max-width: 760px;
}

.auth-forms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.auth-panel {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 10px;
    padding: 1rem;
}

.auth-panel h4 {
    margin-bottom: 0.75rem;
    color: #0f172a;
}

.auth-panel label {
    display: block;
    margin-bottom: 0.65rem;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
}

.auth-panel input {
    width: 100%;
    margin-top: 0.25rem;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 0.65rem 0.7rem;
    background: white;
    color: #0f172a;
    font: inherit;
}

.auth-submit,
.auth-logout {
    width: 100%;
    border: 0;
    border-radius: 7px;
    padding: 0.7rem;
    background: #2563eb;
    color: white;
    font-weight: 800;
    cursor: pointer;
}

.auth-register { background: #059669; }
.auth-logout { background: #dc2626; max-width: 200px; margin-top: 0.75rem; }
.auth-admin { border: 0; border-radius: 7px; padding: 0.7rem; background: #4f46e5; color: white; font-weight: 800; cursor: pointer; margin: 0.75rem 0.5rem 0 0; }
.account-request-panel p, .setup-admin-panel p { color: #64748b; font-size: 0.82rem; line-height: 1.6; }
.setup-admin-panel { margin-top: 1rem; border-color: #c4b5fd; background: #faf5ff; }
.admin-create-form { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; align-items: end; margin-bottom: 1rem; }
.admin-create-form h4 { grid-column: 1 / -1; }
.admin-create-form input, .admin-create-form select { min-width: 0; border: 1px solid #cbd5e1; border-radius: 7px; padding: 0.6rem; }
.admin-user-list { display: flex; flex-direction: column; gap: 0.5rem; }
.admin-user-item { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: center; border: 1px solid #e2e8f0; border-radius: 8px; padding: 0.75rem; }
.admin-user-meta strong { color: #0f172a; }
.admin-user-meta small { display: block; color: #64748b; margin-top: 0.2rem; }
.admin-user-actions { display: flex; gap: 0.4rem; }
.admin-user-actions button { border: 0; border-radius: 6px; padding: 0.4rem 0.6rem; cursor: pointer; font-size: 0.75rem; }
.btn-admin-password { background: #dbeafe; color: #1d4ed8; }
.btn-admin-delete { background: #fee2e2; color: #b91c1c; }

.auth-error {
    margin-bottom: 0.8rem;
    border: 1px solid #fecaca;
    border-radius: 7px;
    padding: 0.65rem;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.82rem;
}

.signed-in-panel {
    border: 1px solid #bbf7d0;
    border-radius: 9px;
    padding: 1rem;
    background: #f0fdf4;
}

.auth-security-note {
    margin-top: 1rem;
    color: #64748b;
    font-size: 0.72rem;
}

@media (max-width: 700px) {
    .auth-forms { grid-template-columns: 1fr; }
    .admin-create-form { grid-template-columns: 1fr; }
    .admin-user-item { grid-template-columns: 1fr; }
}

.saved-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.saved-item-info .title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e293b;
}

.saved-item-info .date {
    font-size: 0.72rem;
    color: #94a3b8;
}

.saved-item-actions {
    display: flex;
    gap: 0.4rem;
}

.btn-open-saved {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-del-saved {
    background: #fee2e2;
    color: #991b1b;
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    cursor: pointer;
}

/* 재미나이 모달 세부 스타일 */
.gemini-step-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.gemini-step-box h4 {
    font-size: 0.92rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.gemini-meta-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge-gemini-info {
    background: #e0e7ff;
    color: #4338ca;
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-gemini-note {
    background: #fef3c7;
    color: #92400e;
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.gemini-textarea {
    width: 100%;
    height: 110px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.6rem;
    font-size: 0.8rem;
    font-family: monospace;
    background: #ffffff;
    color: #334155;
    resize: vertical;
    margin-bottom: 0.65rem;
}

.gemini-btn-row {
    display: flex;
    gap: 0.65rem;
}

.btn-copy-prompt {
    flex: 1;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.55rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-copy-prompt:hover {
    background: #4338ca;
}

.btn-launch-gemini {
    flex: 1;
    background: #0284c7;
    color: white;
    border-radius: 6px;
    padding: 0.55rem;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-launch-gemini:hover {
    background: #0369a1;
}

.gemini-subtext {
    font-size: 0.78rem;
    color: #64748b;
    margin-bottom: 0.4rem;
}

.gemini-textarea-input {
    width: 100%;
    height: 120px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
    background: #ffffff;
    color: #0f172a;
    resize: vertical;
    margin-bottom: 0.65rem;
}

.btn-import-gemini {
    width: 100%;
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
.btn-import-gemini:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.45);
}

/* ==========================================================================
   A4 프린터 인쇄 스타일 (@media print)
   ========================================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm 15mm;
    }

    body {
        background: white !important;
        color: black !important;
        font-size: 11pt;
    }

    .no-print,
    .modoo-navbar,
    .modoo-toolbar-bar,
    .print-sub-bar,
    .ipad-drawing-dock,
    .modal-overlay,
    .scratchpad-header {
        display: none !important;
    }

    .page-viewport {
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }

    .a4-sheet-wrapper {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        min-height: auto !important;
    }

    .question-card {
        page-break-inside: avoid;
        border-bottom: 1px dashed #64748b !important;
    }

    .print-page-break {
        page-break-before: always !important;
    }

    body.print-only-questions #solutionSheetContainer {
        display: none !important;
    }

    body.print-only-solutions #questionSheetContainer {
        display: none !important;
    }

    .scratchpad-box {
        border: 1px dotted #94a3b8 !important;
        background: transparent !important;
    }

    .scratchpad-canvas {
        display: block !important;
    }

    .worksheet-qr-box {
        display: inline-flex !important;
        border: 1px solid #64748b !important;
        background: transparent !important;
        padding: 3px 5px !important;
    }
    .worksheet-qr-box .qr-canvas-holder img,
    .worksheet-qr-box .qr-canvas-holder canvas {
        width: 65px !important;
        height: 65px !important;
    }
    .worksheet-qr-code {
        color: #000 !important;
        font-weight: bold !important;
    }
}

/* 신규 네비게이션 버튼 */
.btn-code-load {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}
.btn-code-load:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.btn-parent-reg {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.btn-parent-reg:hover {
    background: #dbeafe;
    color: #1e40af;
}

/* 시험지 우측 상단 QR코드 박스 */
.worksheet-qr-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 4px 6px;
    min-width: 74px;
}
.worksheet-qr-box .qr-canvas-holder {
    width: 70px;
    height: 70px;
}
.worksheet-qr-box .qr-canvas-holder img,
.worksheet-qr-box .qr-canvas-holder canvas {
    width: 70px !important;
    height: 70px !important;
    display: block;
}

/* 문제집 출처 시그니처 뱃지 스타일 */
.q-source-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: -0.3px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

/* 최상위수학S / 디딤돌 최상위 (퍼플 톤) */
.q-source-badge.badge-choisang {
    background: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ddd6fe;
}

/* 쎈 초등수학 B/C단계 (오렌지/레드 톤) */
.q-source-badge.badge-ssen {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

/* 올림피아드 왕수학 경시 (골드/앰버 톤) */
.q-source-badge.badge-wang {
    background: #fefce8;
    color: #b45309;
    border: 1px solid #fde68a;
}

.q-source-badge.badge-default {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

@media print {
    .q-source-badge {
        border: 1px solid #000 !important;
        background: transparent !important;
        color: #000 !important;
        font-weight: bold !important;
    }
}

/* 📚 에듀왕 왕수학 전용 UI 스타일 */
.nav-btn.btn-eduwang {
    background: linear-gradient(135deg, #4338ca, #3730a3);
    color: #fff;
    border: 1px solid #312e81;
}
.nav-btn.btn-eduwang:hover {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.35);
}

/* ==========================================================================
   버전 뱃지 및 푸터 스타일
   ========================================================================== */
.version-tag {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 12px;
    vertical-align: middle;
    margin-left: 6px;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
    letter-spacing: 0.5px;
}

.app-footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 20px 24px;
    margin-top: 50px;
    border-top: 1px solid #1e293b;
    font-size: 13px;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.footer-logo {
    font-weight: 800;
    color: #f8fafc;
}

.footer-ver-badge {
    background: #334155;
    color: #38bdf8;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.footer-desc {
    color: #64748b;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 12px;
}

.footer-sep {
    color: #334155;
}

/* ==========================================================================
   📱 모바일 & 아이패드(태블릿) 최적화 반응형 미디어 쿼리
   ========================================================================== */

/* 1. 태블릿 / 아이패드 최적화 (화면 폭 1024px 이하) */
@media screen and (max-width: 1024px) {
    .nav-container {
        flex-wrap: wrap;
        padding: 10px 16px;
        height: auto;
        gap: 10px;
    }

    .nav-actions {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        gap: 6px;
        scrollbar-width: none;
    }
    .nav-actions::-webkit-scrollbar {
        display: none;
    }

    .modoo-toolbar-bar {
        padding: 10px 16px;
    }

    .toolbar-inner {
        flex-wrap: wrap;
        gap: 10px;
    }

    .tool-group-grow {
        flex: 1 1 200px;
    }

    .a4-sheet-wrapper {
        max-width: 96%;
        padding: 24px 20px;
        border-radius: 12px;
    }

    /* 아이패드 손글씨 도크 최적화 */
    .ipad-drawing-dock {
        max-width: 90%;
        bottom: 20px;
        padding: 8px 14px;
    }
}

/* 2. 스마트폰 / 모바일 최적화 (화면 폭 768px 이하) */
@media screen and (max-width: 768px) {
    body {
        overflow-x: hidden;
        -webkit-tap-highlight-color: transparent;
    }

    /* 헤더 컴팩트화 */
    .nav-container {
        padding: 8px 12px;
    }

    .brand-title {
        font-size: 18px;
    }

    .brand-desc {
        display: none; /* 모바일에서 슬로건 숨김으로 깔끔한 공간 확보 */
    }

    .nav-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-height: 38px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* 툴바 세로 스택 & 모바일 최적화 */
    .modoo-toolbar-bar {
        padding: 10px 12px;
    }

    .toolbar-inner {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .tool-group {
        width: 100%;
    }

    .tool-group:nth-child(3),
    .tool-group:nth-child(4) {
        grid-column: span 2;
    }

    .tool-group:nth-child(5) {
        grid-column: span 2;
    }

    .modoo-select {
        width: 100%;
        height: 44px; /* 손가락 터치 최적 높이 */
        font-size: 14px;
        padding: 8px 12px;
        border-radius: 8px;
    }

    .level-btn-group {
        display: flex;
        overflow-x: auto;
        gap: 6px;
        width: 100%;
        -webkit-overflow-scrolling: touch;
        padding: 2px 0 4px 0;
        scrollbar-width: none;
    }
    .level-btn-group::-webkit-scrollbar {
        display: none;
    }

    .level-chip {
        min-height: 40px;
        padding: 0 14px;
        font-size: 14px;
        white-space: nowrap;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 인쇄 서브바 모바일 정리 */
    .print-sub-bar {
        padding: 8px 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .print-sub-bar .sub-bar-left,
    .print-sub-bar .sub-bar-right {
        justify-content: space-between;
        width: 100%;
    }

    /* 학습지 컨테이너 스마트폰 전용 1열 자동 전환 */
    .page-viewport {
        padding: 12px 8px;
    }

    .a4-sheet-wrapper {
        padding: 16px 12px;
        border-radius: 10px;
        max-width: 100%;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }

    .worksheet-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .worksheet-header-right {
        width: 100%;
        justify-content: space-between;
    }

    .student-info-box {
        font-size: 12px;
        gap: 8px;
    }

    /* 문제 그리드 스마트폰 1열 강제 전환 */
    .questions-grid,
    .questions-grid.grid-col-2,
    .questions-grid.grid-col-1 {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .question-card {
        padding: 16px 14px;
        border-radius: 10px;
    }

    .q-number {
        font-size: 15px;
    }

    .q-body {
        font-size: 15px !important;
        line-height: 1.65 !important;
        margin-top: 8px;
        word-break: keep-all;
    }

    /* 객관식 보기 1열/2열 터치 확장 */
    .choices-container {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        margin-top: 12px;
    }

    .choice-label {
        min-height: 48px;
        padding: 10px 14px;
        font-size: 15px;
        border-radius: 8px;
    }

    /* 주관식 정답 입력창 터치 확대 (iOS 확대 방지 16px) */
    .input-answer-container {
        margin-top: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .input-answer-row {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .input-answer {
        flex: 1;
        width: 100% !important;
        height: 46px;
        font-size: 16px !important;
        padding: 8px 14px;
        border-radius: 8px;
    }

    .quick-chip-group {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .btn-quick-chip {
        flex: 1;
        min-width: 60px;
        height: 44px;
        font-size: 0.95rem;
        border-radius: 10px;
    }

    /* 손글씨 캔버스 영역 스마트폰 대응 */
    .scratchpad-box {
        height: 180px !important;
        min-height: 180px !important;
        margin-top: 10px;
        touch-action: none !important;
    }

    /* 필기 모드 활성화 시 풀이 공간 확대 & 보라색 하이라이트 */
    body.handwriting-mode-active .scratchpad-box {
        height: 220px !important;
        min-height: 220px !important;
        border: 2px dashed #8b5cf6 !important;
        background: #faf5ff !important;
        touch-action: none !important;
    }

    /* 플로팅 필기 도크 스마트폰 콤팩트 알약 바 */
    .ipad-drawing-dock {
        width: calc(100% - 24px) !important;
        max-width: 380px !important;
        bottom: 12px !important;
        padding: 6px 10px !important;
        border-radius: 24px !important;
        gap: 4px !important;
        justify-content: space-between !important;
        background: rgba(15, 23, 42, 0.94) !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
    }

    .ipad-drawing-dock .dock-label,
    .ipad-drawing-dock .dock-separator,
    .ipad-drawing-dock #drawWidthSelect {
        display: none !important;
    }

    .ipad-drawing-dock .tool-btn {
        padding: 5px 8px !important;
        font-size: 12px !important;
        border-radius: 12px !important;
    }

    .ipad-drawing-dock .color-dot {
        width: 18px !important;
        height: 18px !important;
    }

    .ipad-drawing-dock .dock-action-btn {
        padding: 5px 8px !important;
        font-size: 11px !important;
    }

    /* 모달창 반응형 풀스크린/바텀시트화 */
    .modal-card {
        width: 95vw !important;
        max-height: 90vh !important;
        border-radius: 16px !important;
        padding: 0;
    }

    .modal-header {
        padding: 14px 18px;
    }

    .modal-body {
        padding: 14px;
    }

    .auth-forms {
        grid-template-columns: 1fr;
    }

    /* 푸터 모바일 */
    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* 3. 초소형 스마트폰 (화면 폭 480px 이하) */
@media screen and (max-width: 480px) {
    .brand-title {
        font-size: 16px;
    }

    .version-tag {
        font-size: 10px;
        padding: 1px 5px;
    }

    .nav-btn .btn-text {
        font-size: 11px;
    }

    .toolbar-inner {
        grid-template-columns: 1fr;
    }

    .tool-group:nth-child(3),
    .tool-group:nth-child(4),
    .tool-group:nth-child(5) {
        grid-column: span 1;
    }
}

/* ==========================================================================
   상단 정보/설정 접기/펼치기 슬림 바 (모바일 및 태블릿 최적화)
   ========================================================================== */
.toolbar-toggle-bar {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 56px;
    z-index: 90;
}

.toggle-summary-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.summary-badge {
    background: #3b82f6;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.summary-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toggle-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-quick-ipad {
    background: #7c3aed;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(124,58,237,0.3);
}

.btn-quick-ipad:hover {
    background: #6d28d9;
}

.btn-quick-ipad.active {
    background: #4c1d95;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.btn-quick-regen {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(37,99,235,0.3);
}

.btn-quick-regen:hover {
    background: #1d4ed8;
}

.btn-toggle-toolbar {
    background: #e2e8f0;
    color: #334155;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.btn-toggle-toolbar:hover {
    background: #cbd5e1;
}

/* 툴바 접힘 상태 트랜지션 */
.modoo-toolbar-bar {
    transition: max-height 0.28s ease, opacity 0.22s ease, padding 0.28s ease;
    max-height: 500px;
    overflow: hidden;
    opacity: 1;
}

.modoo-toolbar-bar.collapsed {
    max-height: 0 !important;
    opacity: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-bottom: none !important;
    pointer-events: none !important;
}

/* 모바일 및 태블릿 화면에서 오른쪽 깨짐(가로 오버플로우) 100% 방지 및 컴팩트 레이아웃 */
@media screen and (max-width: 860px) {
    /* 네비게이션 바 & 컨테이너 가로 제한 */
    .modoo-navbar {
        padding: 6px 8px !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    .nav-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 6px !important;
        box-sizing: border-box !important;
    }

    .nav-brand {
        width: 100% !important;
        justify-content: flex-start !important;
    }

    .nav-actions {
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        padding-bottom: 4px !important;
        -webkit-overflow-scrolling: touch;
        gap: 6px !important;
        box-sizing: border-box !important;
    }
    .nav-actions::-webkit-scrollbar {
        display: none;
    }
    .nav-btn {
        flex-shrink: 0 !important;
        padding: 5px 8px !important;
        font-size: 11px !important;
        white-space: nowrap !important;
    }

    /* 슬림 상단 제어 바 */
    .toolbar-toggle-bar {
        padding: 6px 10px !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        top: 48px;
    }

    .summary-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .summary-title {
        font-size: 12px;
        max-width: 140px;
    }

    .btn-quick-regen,
    .btn-toggle-toolbar {
        padding: 5px 9px;
        font-size: 11px;
    }

    /* 툴바 내부 */
    .modoo-toolbar-bar {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        padding: 8px 10px !important;
    }
    .toolbar-inner {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .tool-group-grow {
        min-width: 0 !important;
        width: 100% !important;
    }
    .level-btn-group,
    .col-toggle-group {
        overflow-x: auto !important;
        max-width: 100% !important;
        -webkit-overflow-scrolling: touch;
    }

    /* 메인 뷰포트 & 인쇄 바 */
    .page-viewport {
        padding: 8px 4px 80px 4px !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    .print-sub-bar {
        width: 100% !important;
        max-width: 100% !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 4px 6px !important;
        box-sizing: border-box !important;
    }
    .print-sub-right {
        flex-wrap: wrap !important;
        gap: 4px !important;
    }

    /* A4 용지 규격을 스마트폰/태블릿 화면에 맞춤 (가로 깨짐 완전 방지) */
    .a4-sheet-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px 10px !important;
        box-shadow: none !important;
        border: none !important;
        min-height: auto !important;
        box-sizing: border-box !important;
    }

    .worksheet-header {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 1rem !important;
        padding-bottom: 0.75rem !important;
        box-sizing: border-box !important;
    }
    .worksheet-title-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    .worksheet-brand h2 {
        font-size: 1.25rem !important;
    }
    .student-info-box {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 3px 6px !important;
        font-size: 11px !important;
    }
    .worksheet-meta-sub {
        flex-wrap: wrap !important;
        gap: 8px !important;
        font-size: 11px !important;
    }

    /* ★ 2열 그리드를 1열로 강제 변환하여 화면 우측 잘림 원천 차단 */
    .questions-grid.grid-col-2 {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .questions-grid.grid-col-1 {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .question-card {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* 플로팅 드로잉 독 모바일 최적화 */
    .ipad-drawing-dock {
        max-width: calc(100vw - 16px) !important;
        width: max-content !important;
        padding: 4px 8px !important;
        border-radius: 20px !important;
        font-size: 11px !important;
        gap: 4px !important;
        bottom: 0.8rem !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box !important;
    }
    .dock-label {
        display: none !important;
    }
    .dock-separator {
        height: 14px !important;
        margin: 0 2px !important;
    }
    .color-dot {
        width: 16px !important;
        height: 16px !important;
    }
    .tool-btn {
        padding: 4px 6px !important;
        font-size: 11px !important;
    }
    .dock-action-btn {
        padding: 4px 6px !important;
        font-size: 11px !important;
    }
}

/* v3.7 풀이 일시 및 수정 뱃지, 하단 저장 액션 스타일 */
.badge-modified-header {
    display: inline-flex;
    align-items: center;
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
}

.badge-modified-chip {
    display: inline-flex;
    align-items: center;
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.saved-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.saved-mod-time {
    color: #ea580c;
    font-size: 11px;
    font-weight: 600;
}

.meta-modified-time {
    color: #c2410c;
}

.btn-save-action {
    background: #0284c7 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border: 1px solid #0369a1 !important;
}

.btn-save-action:hover {
    background: #0369a1 !important;
}

.btn-resume {
    background: #059669 !important;
    color: #ffffff !important;
    border: 1px solid #047857 !important;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.2);
}

.btn-resume:hover {
    background: #047857 !important;
}

.btn-resume-action {
    background: #10b981 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border: 1px solid #059669 !important;
}

.btn-resume-action:hover {
    background: #059669 !important;
}

/* v3.9 무인 자동 저장(Auto-Save) 인디케이터 스타일 */
.auto-save-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    user-select: none;
    transition: all 0.25s ease;
}

.auto-save-pill.saving {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.auto-save-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.auto-save-pill.saving .auto-save-dot {
    background: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

.saved-questions-preview {
    margin-top: 4px;
    font-size: 11px;
    color: #475569;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    padding: 4px 8px;
    line-height: 1.4;
}

/* ==========================================================================
   대한민국 4대 초등 명문 사고력 학원 & 정밀 문제유형(problemType) 전용 뱃지
   ========================================================================== */
.badge-academy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 6px;
    letter-spacing: -0.3px;
    white-space: nowrap;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 1. 생각하는 황소 킬러 (골드/엠버) */
.badge-academy-hwangso {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #f59e0b;
}

/* 2. 소마 프리미어 (코발트/사파이어 블루) */
.badge-academy-soma {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0369a1;
    border: 1px solid #0284c7;
}

/* 3. CMS 영재관 (바이올렛/퍼플) */
.badge-academy-cms {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    color: #6d28d9;
    border: 1px solid #8b5cf6;
}

/* 4. 필즈 더 클래식 (에메랄드/포레스트 그린) */
.badge-academy-fields {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #10b981;
}

/* 5. 미국 AMC 8 / Math Kangaroo (성조기 테마 네이비/인디고) */
.badge-academy-usa {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #1e1b4b;
    border: 1px solid #6366f1;
}

/* 6. 영국 UKMT / Bebras 창의수학 (유니언잭 테마 로열블루/크림슨) */
.badge-academy-uk {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    color: #831843;
    border: 1px solid #ec4899;
}

/* 🎯 오답 극복 / 취약 유형 집중 클리닉 뱃지 */
.badge-weakness {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 6px;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #ef4444;
    box-shadow: 0 1px 4px rgba(239, 68, 68, 0.25);
    animation: weaknessGlow 2.5s infinite;
    letter-spacing: -0.3px;
    white-space: nowrap;
    user-select: none;
}

@keyframes weaknessGlow {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* 정밀 문제유형 뱃지 (Problem Type Tag) */
.badge-problem-type {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    letter-spacing: -0.3px;
    white-space: nowrap;
    user-select: none;
}

.badge-problem-type:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

@media print {
    .badge-academy, .badge-problem-type, .badge-weakness {
        border-width: 1px !important;
        box-shadow: none !important;
        animation: none !important;
    }
}

/* ==========================================================================
   최근 자동 저장 문제지 (최대 5개 롤링 보존) 모달 스타일
   ========================================================================== */
.recent-worksheets-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
}

.recent-ws-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.recent-ws-card:hover {
    border-color: #3b82f6;
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.12);
}

.recent-ws-main {
    flex: 1;
    min-width: 0;
}

.recent-ws-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.recent-ws-slot-badge {
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.recent-ws-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-ws-meta {
    font-size: 12px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.recent-ws-status-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.recent-ws-status-badge.in-progress {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.recent-ws-status-badge.graded {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.recent-ws-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

.btn-recent-load {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.btn-recent-load:hover {
    background: #1d4ed8;
}

.btn-recent-del {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-recent-del:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.recent-empty-box {
    text-align: center;
    padding: 30px 10px;
    color: #94a3b8;
    font-size: 13px;
}

/* 🎯 보관함 고정(체크) 스타일 */
.recent-ws-card.is-pinned-card {
    border-color: #f59e0b;
    background: #fffbeb;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
}

.recent-ws-pin-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}

.recent-ws-pin-label:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.recent-ws-pin-checkbox {
    cursor: pointer;
    accent-color: #d97706;
}

.recent-ws-pin-badge {
    font-size: 11px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* 🎯 부모님 전용 빠른 정오답 표 (학생 답, 정답, ⭕/❌) */
.parent-quick-grade-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #166534;
    font-weight: 700;
    flex-wrap: wrap;
    gap: 8px;
}

.parent-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.parent-quick-item {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.15s ease;
}

.parent-quick-item.is-correct {
    border-color: #86efac;
    background: #f0fdf4;
}

.parent-quick-item.is-incorrect {
    border-color: #fca5a5;
    background: #fef2f2;
}

.parent-quick-item.is-empty {
    border-color: #e2e8f0;
    background: #f8fafc;
}

.pq-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 800;
    font-size: 12.5px;
}

.pq-mark {
    font-size: 13px;
    font-weight: 900;
}
.pq-mark.correct { color: #16a34a; }
.pq-mark.incorrect { color: #dc2626; }
.pq-mark.empty { color: #94a3b8; }

.pq-row {
    font-size: 11.5px;
    display: flex;
    justify-content: space-between;
    color: #475569;
}

.pq-row strong {
    font-weight: 700;
    color: #0f172a;
}

.pq-row.ans-user strong.wrong {
    color: #dc2626;
    text-decoration: line-through;
}

.pq-row.ans-real strong {
    color: #16a34a;
}

/* 🎯 제미나이 눈높이 설명 연결 버튼 */
.btn-gemini-explain {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
    transition: all 0.2s ease;
}

.btn-gemini-explain:hover {
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.35);
}

.gemini-explain-modal-content {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 14px;
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: #1e293b;
}

/* ⚡ 인앱 제미나이 눈높이 설명 생성기 (페이지 이탈 없음) */
.btn-gemini-inapp {
    background: linear-gradient(135deg, #0284c7, #6366f1, #8b5cf6);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    transition: all 0.2s ease;
    flex: 1;
}

.btn-gemini-inapp:hover {
    background: linear-gradient(135deg, #0369a1, #4f46e5, #7c3aed);
    transform: translateY(-1.5px);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}

.btn-gemini-inapp:active {
    transform: translateY(0);
}

.btn-gemini-key-toggle {
    background: #f1f5f9;
    border: 1.5px solid #cbd5e1;
    color: #475569;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-gemini-key-toggle:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.gemini-key-panel {
    background: #f8fafc;
    border: 1.5px dashed #94a3b8;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 10px;
    font-size: 12px;
}

.gemini-key-input-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.gemini-key-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
}

.btn-gemini-save-key {
    background: #2563eb;
    color: white;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.gemini-inline-result-card {
    background: #ffffff;
    border: 1.5px solid #c7d2fe;
    border-radius: 12px;
    padding: 16px;
    margin-top: 14px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.1);
}

.gemini-inline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1.5px solid #e0e7ff;
    padding-bottom: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.gemini-badge-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eef2ff;
    color: #4338ca;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
}

.gemini-inline-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    gap: 12px;
    color: #4f46e5;
    font-size: 13.5px;
    font-weight: 700;
    text-align: center;
}

.gemini-spinner {
    width: 32px;
    height: 32px;
    border: 3.5px solid #e0e7ff;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: geminiSpin 0.8s linear infinite;
}

@keyframes geminiSpin {
    to { transform: rotate(360deg); }
}

.gemini-inline-content {
    font-size: 13.5px;
    line-height: 1.7;
    color: #1e293b;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

.gemini-inline-content h3, .gemini-inline-content h4 {
    color: #1e1b4b;
    margin: 12px 0 6px;
    font-size: 14.5px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gemini-inline-content p {
    margin-bottom: 10px;
}

.gemini-inline-content ul, .gemini-inline-content ol {
    margin: 6px 0 10px 18px;
}

.gemini-inline-content li {
    margin-bottom: 4px;
}

.gemini-inline-content strong {
    color: #0f172a;
    font-weight: 800;
    background: #fef08a40;
    padding: 0 2px;
    border-radius: 2px;
}

.gemini-restore-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    margin-top: 12px;
}

/* ⚙️ [방장님 특명] Gemini API 키 설정 전용 다크 테마 카드 및 액션 버튼 */
.btn-gemini-settings {
    background: #1e1b4b;
    color: #a5b4fc;
    border: 1px solid #4338ca;
}
.btn-gemini-settings:hover {
    background: #312e81;
    color: #e0e7ff;
}
.gemini-settings-card {
    border-radius: 20px !important;
    background: #111827 !important;
    color: #f8fafc !important;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.7) !important;
    border: 1px solid #1f2937 !important;
}
.gemini-dark-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
}
.gemini-dark-input {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 12px 14px;
    color: #f8fafc;
    font-size: 13px;
    box-sizing: border-box;
    font-family: monospace;
    transition: border-color 0.2s;
}
.gemini-dark-input:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}
.gemini-actions-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.btn-dark-action {
    flex: 1;
    background: #334155;
    color: #e2e8f0;
    border: none;
    border-radius: 8px;
    padding: 9px 0;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-dark-action:hover {
    background: #475569;
    color: #ffffff;
}
.btn-dark-action:active {
    transform: scale(0.98);
}
.btn-dark-action.btn-save-action {
    background: #2563eb;
    color: #ffffff;
}
.btn-dark-action.btn-save-action:hover {
    background: #1d4ed8;
}
.btn-dark-action.btn-danger-action {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-dark-action.btn-danger-action:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}










/* Only the canvas owns drawing gestures. Contacts outside it can scroll normally. */
html.handwriting-screen-locked {
    overscroll-behavior: none;
}
html.handwriting-screen-locked body { user-select: none; -webkit-user-select: none; }
.scratchpad-box, body.handwriting-mode-active .scratchpad-box {touch-action:pan-y !important;}
body[data-handwriting-input="move"] .scratchpad-box,
body[data-handwriting-input="move"] .scratchpad-canvas { touch-action: pan-y !important; }
.ink-input-control { display:flex; flex-direction:column; gap:4px; color:white; font-size:12px; }
.ink-input-control select { max-width:240px; min-height:44px; font:inherit; padding:8px; border-radius:10px; }
.ink-movement-toggle {position:fixed;right:12px;top:calc(env(safe-area-inset-top,0px) + 12px);z-index:11000;min-height:48px;min-width:108px;padding:10px 14px;border:2px solid #fff;border-radius:24px;background:#005fcc;color:white;font-weight:700;box-shadow:0 3px 14px #0004;touch-action:manipulation;}
.ink-movement-toggle[hidden] {display:none !important;}
@media print { html.handwriting-screen-locked, html.handwriting-screen-locked body {overflow:visible !important;} }

.ipad-drawing-dock { flex-wrap:wrap; overflow:visible !important; }
@media screen and (max-width:768px) {
    .ipad-drawing-dock {width:calc(100vw - 24px) !important;max-height:45dvh;}
    .ink-input-control {flex-basis:100%;}
    .ink-input-control select {max-width:100%;width:100%;}
}

/* Paper layout uses physical A4 units; it does not reuse screen card sizing. */
.print-sub-left {display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
.print-setting-label {display:flex;align-items:center;gap:6px;font-size:13px;}
.print-setting-label select {min-height:40px;max-width:100%;font:inherit;padding:6px;border:1px solid #cbd5e1;border-radius:8px;background:white;}
@media print {
 @page {size:A4 portrait;margin:12mm;}
 html,body {width:auto!important;height:auto!important;min-height:0!important;overflow:visible!important;background:white!important;font-size:11pt!important;}
 .page-viewport,.a4-sheet-wrapper {width:auto!important;max-width:none!important;min-width:0!important;min-height:0!important;height:auto!important;margin:0!important;padding:0!important;box-shadow:none!important;border:0!important;}
 .a4-sheet-wrapper {border-radius:0!important;background:white!important;}
 .questions-grid.grid-col-1,.questions-grid.grid-col-2 {display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:2mm 7mm!important;align-items:start!important;}
 body[data-print-layout="1col"] .questions-grid {display:block!important;}
 .question-card {min-height:0!important;height:auto!important;padding:0 0 2mm!important;margin:0!important;box-shadow:none!important;border:0!important;border-bottom:0.3mm solid #b8b8b8!important;border-radius:0!important;break-inside:avoid;page-break-inside:avoid;display:block!important;}
 body[data-print-layout="1col"] .question-card {margin-bottom:4mm!important;}
 .q-header {margin:0 0 2mm!important;padding:0!important;gap:2mm!important;flex-wrap:wrap!important;}
 .q-number {width:6mm!important;height:6mm!important;font-size:10pt!important;}
 .q-unit-tag,.q-level-tag,.q-source-badge,.badge-problem-type {font-size:8pt!important;line-height:1.25!important;}
 .q-body {font-size:11pt!important;line-height:1.45!important;margin:0 0 2mm!important;overflow-wrap:anywhere!important;}
 .worksheet-header {padding-bottom:3mm!important;margin-bottom:5mm!important;break-inside:avoid;}
 .worksheet-title-row {gap:3mm!important;flex-wrap:wrap!important;}
 .worksheet-brand h2 {font-size:15pt!important;line-height:1.3!important;margin:1mm 0 2mm!important;}
 .worksheet-meta-sub {font-size:8pt!important;gap:4mm!important;margin-top:2mm!important;flex-wrap:wrap!important;}
 .student-info-box {font-size:9pt!important;padding:2mm!important;gap:4mm!important;}
 .worksheet-qr-box .qr-canvas-holder,.worksheet-qr-box .qr-canvas-holder img,.worksheet-qr-box .qr-canvas-holder canvas {width:16mm!important;height:16mm!important;}
 .worksheet-qr-box {min-width:18mm!important;}
 .input-answer-container {padding:1mm 0!important;margin:0 0 2mm!important;background:white!important;border:0!important;box-shadow:none!important;}
 .input-answer,.input-answer-row {font-size:10pt!important;min-height:0!important;padding:0!important;}
 .input-answer {height:6mm!important;width:30mm!important;border:0!important;border-bottom:0.3mm solid black!important;border-radius:0!important;background:white!important;}
 .input-answer::placeholder {color:transparent!important;}
 .quick-chip-group,.grading-mark {display:none!important;}
 .answer-line {margin:2mm 0!important;font-size:10pt!important;}
 .choices-container {margin:2mm 0!important;gap:2mm!important;font-size:10pt!important;}
 .scratchpad-box {height:8mm!important;min-height:8mm!important;margin:2mm 0 0!important;padding:0!important;border:0.25mm dotted #aaa!important;border-radius:0!important;background:white!important;box-shadow:none!important;transition:none!important;}
 body[data-print-density="standard"] .scratchpad-box {height:24mm!important;min-height:24mm!important;}
 body[data-print-density="wide"] .scratchpad-box {height:40mm!important;min-height:40mm!important;}
 /* Preserve the aspect ratio of real handwriting; compact only empty paper. */
 .scratchpad-box:has(canvas[data-has-ink="true"]) {height:auto!important;min-height:0!important;aspect-ratio:var(--ink-aspect-ratio);}
 .scratchpad-canvas {width:100%!important;height:100%!important;}
 .solution-list,.solutions-grid {gap:3mm!important;}
 .solution-card,.solution-item,.worked-solution {break-inside:avoid;font-size:10pt!important;line-height:1.45!important;min-height:0!important;padding:2mm!important;margin:2mm 0!important;}
 .solution-sheet-wrapper {break-before:page;}
 body.print-only-solutions .solution-sheet-wrapper {break-before:auto;}
}

@media print { #appToast {display:none!important;} .q-body .katex-display {margin:2mm 0!important;} }
