
        body {
            font-family: 'Inter', sans-serif;
        }
        canvas {
            cursor: crosshair;
            touch-action: none;
        }
        .modal {
            display: none;
        }
        .modal.active {
            display: flex;
        }
        .sidebar-item-selected {
            background-color: #e0e7ff;
        }
        .tool-btn.active {
            background-color: #3b82f6;
            color: white;
        }
        ::-webkit-scrollbar {
            width: 8px;
        }
        ::-webkit-scrollbar-track {
            background: #f1f5f9;
        }
        ::-webkit-scrollbar-thumb {
            background: #94a3b8;
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: #64748b;
        }

        /* Drag and Drop Styles */
        .paper-item .drag-handle {
            cursor: grab;
        }
        .sortable-ghost {
            opacity: 0.4;
            background-color: #c7d2fe;
        }


        /* Print-specific styles */
        #print-area {
            display: none;
        }

        /* Scoring Overlay Mode */
        #template-canvas-container.overlay-mode {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 10;
            pointer-events: none; /* オーバーレイはクリックを透過 */
            opacity: 0.3;
        }

      /* ★ 修正: @page 設定は @media の外側に書くのが最も安全です */
    @page {
        size: auto;
        margin: 0mm;
    }

    @media print {
        /* デフォルト：すべての印刷用エリアを非表示 */
        #print-area,
        #report-print-area,
        #qr-code-print-area {
            display: none !important;
        }

        /* 印刷中は、まずbody直下のすべてのUIを非表示にする */
        body > * {
            display: none !important;
        }

        /* --- シナリオ1: 答案・レイアウト印刷 (.printing-layout) --- */
        body.printing-layout #print-area {
            display: block !important;
        }
        
        body.printing-layout {
            margin: 0;
        }

        body.printing-layout #print-area img {
            width: 100vw;
            height: 100vh;
            object-fit: contain;
            page-break-after: always;
        }
        body.printing-layout #print-area img:last-child {
            page-break-after: auto;
        }

        /* --- シナリオ2: レポート印刷 (.printing-report) --- */
        body.printing-report #report-print-area {
            display: block !important;
        }
        body.printing-report .report-page {
            width: 210mm;
            height: 296mm;
            padding: 15mm;
            margin: 0 auto;
            box-sizing: border-box;
            page-break-after: always;
        }

        /* --- シナリオ3: QR一覧印刷 (.printing-qr-list) --- */
        body.printing-qr-list #qr-code-modal {
            display: block !important;
            position: static !important;
            background: none !important;
            inset: auto !important;
            padding: 0 !important;
            overflow: visible !important;
        }
        body.printing-qr-list #qr-code-modal > div {
            box-shadow: none !important;
            padding: 0 !important;
            height: auto !important;
            max-width: 100% !important;
            width: 100% !important;
        }
        body.printing-qr-list #qr-code-modal #qr-code-print-area {
            display: grid !important;
            grid-template-columns: repeat(5, 1fr) !important;
            gap: 10px !important;
            page-break-inside: auto;
        }
        body.printing-qr-list .qr-code-item-print {
            padding: 5px;
            border: 1px solid #ccc;
            border-radius: 4px;
            text-align: center;
            page-break-inside: avoid;
        }
        body.printing-qr-list .qr-code-item-print img {
            width: 100% !important;
            height: auto !important;
            max-width: 100px;
            margin: 0 auto;
            page-break-inside: avoid;
        }
        body.printing-qr-list .qr-code-item-print p {
            font-size: 9pt;
            margin-top: 4px;
            word-wrap: break-word;
            page-break-inside: avoid;
        }
    }
  /* --- ダークモード用スタイル定義 --- */
    html.dark body {
        background-color: #0f172a; /* slate-900 */
        color: #e2e8f0; /* slate-200 */
    }
    html.dark .bg-white {
        background-color: #1e293b !important; /* slate-800 */
        color: #f1f5f9;
    }
    html.dark .bg-slate-50 {
        background-color: #334155 !important; /* slate-700 */
    }
    html.dark .bg-slate-100 {
        background-color: #1e293b !important; /* slate-800 */
    }
    html.dark .bg-slate-200 {
        background-color: #334155 !important; /* slate-700 */
    }
    html.dark .text-slate-500, html.dark .text-slate-600, html.dark .text-slate-700, html.dark .text-slate-800 {
        color: #cbd5e1 !important; /* slate-300 */
    }
    html.dark .border-slate-200, html.dark .border-slate-300 {
        border-color: #475569 !important; /* slate-600 */
    }
    html.dark header, html.dark aside, html.dark .modal > div {
        background-color: #1e293b;
        border-color: #334155;
    }
    html.dark input, html.dark select {
        background-color: #0f172a;
        border-color: #475569;
        color: #f8fafc;
    }
    /* ダークモード時のヒートマップ用調整 */
    html.dark .student-completed { background-color: rgba(22, 163, 74, 0.2) !important; }
    html.dark .student-progress { background-color: rgba(37, 99, 235, 0.2) !important; }
    html.dark .student-absent { background-color: rgba(100, 116, 139, 0.2) !important; } 
/* --- モバイル用サイドバー（ドロワー）設定 --- */
    @media (max-width: 768px) {
        #sidebar {
            position: absolute !important;
            top: 0;
            left: 0;
            height: 100% !important;
            z-index: 50; /* ヘッダーより上に表示 */
            transform: translateX(-100%); /* デフォルトは画面外へ隠す */
        }
        #sidebar.active {
            transform: translateX(0) !important; /* activeクラスがつくと表示 */
        }
        /* サイドバーが開いている時の背景を暗くする */
        #mobile-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 40;
        }
        #mobile-overlay.active {
            display: block;
        }
    }
/* --- 追加機能: フローティングツールバー用スタイル --- */
    #toolbar-container {
        position: fixed;
        bottom: 30px; /* 初期位置：画面下部 */
        left: 50%;
        transform: translateX(-50%);
        z-index: 1000; /* 最前面に表示 */
        width: auto !important;
        max-width: 95vw !important;
        transition: transform 0.1s; /* ドラッグ時の追従性 */
        background: transparent;
    }
    
    /* ツールバーがドラッグ移動された後（transform解除） */
    #toolbar-container.moved {
        transform: none !important;
        bottom: auto !important;
    }

    /* ツールバーのウィンドウ枠 */
    .toolbar-window {
        background-color: white;
        border-radius: 8px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.2);
        border: 1px solid #cbd5e1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* ドラッグ用ハンドル（ヘッダー） */
    .toolbar-handle {
        background-color: #f1f5f9;
        padding: 6px 12px;
        cursor: grab;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #e2e8f0;
        user-select: none;
    }
    .toolbar-handle:active {
        cursor: grabbing;
        background-color: #e2e8f0;
    }

    /* 最小化時のスタイル */
    #toolbar-container.minimized .toolbar-content {
        display: none;
    }
    #toolbar-container.minimized {
        width: auto !important;
    }

    /* --- 追加機能: モード別ヘッダー色 --- */
    /* 準備モード */
    body.mode-preparation header {
        background-color: #ecfdf5 !important; /* emerald-50 */
        border-bottom-color: #10b981;
    }
    /* 設定モード */
    body.mode-setting header {
        background-color: #e0e7ff !important; /* indigo-50 */
        border-bottom-color: #6366f1;
    }
    /* 採点モード */
    body.mode-scoring header {
        background-color: #fff1f2 !important; /* rose-50 */
        border-bottom-color: #f43f5e;
    }
/* --- 追加修正: タブレット向けナビゲーションボタン配置 --- */
    #prev-paper-btn, #next-paper-btn {
        position: fixed !important;
        top: auto !important;
        bottom: 20px !important; /* 画面下部へ */
        transform: none !important;
        width: 64px !important; /* タップしやすいサイズに拡大 */
        height: 64px !important;
        background-color: rgba(255, 255, 255, 0.9) !important;
        border: 2px solid #cbd5e1 !important;
    }
    #prev-paper-btn {
        left: 20px !important; /* 左下 */
    }
    #next-paper-btn {
        right: 20px !important; /* 右下 */
    }
    /* スマホの場合はツールバーと被らないよう少し上に */
    @media (max-width: 768px) {
        #prev-paper-btn, #next-paper-btn {
            bottom: 90px !important;
            width: 50px !important;
            height: 50px !important;
        }
    }
/* --- グルーピングモード用スタイル --- */
    .grouping-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 16px;
        padding: 10px;
        overflow-y: auto;
        height: 100%;
        align-content: start;
    }
    .grouping-item {
        border: 2px solid #e2e8f0;
        border-radius: 8px;
        overflow: hidden;
        cursor: pointer;
        transition: all 0.2s;
        position: relative;
        background-color: white;
        display: flex;
        flex-direction: column;
    }
    .grouping-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }
    .grouping-item.selected {
        border-color: #3b82f6;
        background-color: #eff6ff;
        box-shadow: 0 0 0 2px #3b82f6;
    }
    .grouping-item img {
        width: var(--grouping-image-width, auto);
        height: var(--grouping-image-height, 100px);
        object-fit: contain; /* アスペクト比を維持して全体を表示 */
        background-color: #f8fafc;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .grouping-item .info {
        padding: 8px;
        font-size: 0.75rem;
        text-align: center;
        color: #475569;
    }
    .grouping-check {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 20px;
        height: 20px;
        background: white;
        border: 2px solid #cbd5e1;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
    }
    .grouping-item.selected .grouping-check {
        background: #3b82f6;
        border-color: #3b82f6;
    }
    .grouping-section-title {
        grid-column: 1 / -1;
        padding: 10px 0 5px 0;
        font-weight: bold;
        color: #64748b;
        border-bottom: 2px solid #e2e8f0;
        margin-top: 10px;
    }
    #point-palette {
    position: fixed !important; /* 絶対位置から固定位置に変更 */
    z-index: 10000 !important;
    background-color: white !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3) !important;
}