        /* ===== カラー変数（ライト／ダーク共通） ===== */
        :root {
            --bg-app:            #f0f2f5;
            --bg-sidebar:        #ffffff;
            --bg-main:           #e9ebee;
            --border:            #ddd;
            --border-light:      #eee;
            --text-primary:      #333;
            --text-secondary:    #666;
            --text-muted:        #999;
            --bg-select:         #f8f9fa;
            --text-select:       #333;
            --bg-history:        #f9f9f9;
            --bg-history-hover:  #f0f0f0;
            --bg-history-active: #e3f2fd;
            --border-history:    #e0e0e0;
            --border-history-active: #90caf9;
            --summary-bg:        rgba(255,255,255,0.88);
            --summary-color:     #1565c0;
            --modal-bg:          #ffffff;
            --modal-input-bg:    #f8f9fa;
            --modal-input-focus-bg: #fff;
            --empty-color:       #999;
            --arrow-color:       #535353;
        }
        @media (prefers-color-scheme: dark) {
            :root {
                --bg-app:            #1a1b1e;
                --bg-sidebar:        #25262b;
                --bg-main:           #1a1b1e;
                --border:            #3a3b40;
                --border-light:      #2e2f35;
                --text-primary:      #e0e0e0;
                --text-secondary:    #aaa;
                --text-muted:        #555;
                --bg-select:         #2e2f35;
                --text-select:       #e0e0e0;
                --bg-history:        #2e2f35;
                --bg-history-hover:  #35363d;
                --bg-history-active: #1a2e45;
                --border-history:    #3a3b40;
                --border-history-active: #1565c0;
                --summary-bg:        rgba(30,31,36,0.92);
                --summary-color:     #90caf9;
                --modal-bg:          #25262b;
                --modal-input-bg:    #2e2f35;
                --modal-input-focus-bg: #35363d;
                --empty-color:       #555;
                --arrow-color:       #aaa;
            }
        }

        body { background: var(--bg-app); margin: 0; padding: 0; height: 100vh; overflow: hidden; font-family: "BIZ UDPGothic", sans-serif; color: var(--text-primary); }
       a{text-decoration:none;}
        .app-container { display: flex; height: 100%; width: 100%; }
#progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    overflow: hidden;
    z-index: 99999;
    display: none;
    margin: 0;
    padding: 0;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4f46e5, #6366f1);
    transition: width 0.2s ease;
}

#progress-text {
    display: none; /* YouTube風なら非表示 */
}
        @media (prefers-color-scheme: dark) {
            #progress-container { background: #374151; }
            #progress-text { color: #818cf8; }
        }
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent; 
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2); 
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.4); 
}
        .sidebar {
            width: 320px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
            display: flex; flex-direction: column; padding: 30px 20px 0 20px;
            box-sizing: border-box; box-shadow: 2px 0 8px rgba(0,0,0,0.1); z-index: 10;
        }
        .sidebar h1 { font-size: 18px; margin: 0 0 20px 0; color: var(--text-primary); text-align: center; }
        .selectbox-5 { display: inline-flex; align-items: center; position: relative; width: 100%; }
        .selectbox-5::after {
            position: absolute; right: 15px; width: 10px; height: 7px;
            background-color: var(--arrow-color); clip-path: polygon(0 0, 100% 0, 50% 100%);
            content: ''; pointer-events: none;
        }
        .selectbox-5 select {
            appearance: none; min-width: 230px; width: 100%; height: 2.8em;
            padding: .4em 35px .4em .8em; border: none; background-color: var(--bg-select);
            color: var(--text-select); font-size: 13px; cursor: pointer; border-radius: 50px;
        }
        .selectbox-5 select:focus { outline: none; }
        .selectbox-container { margin-bottom: 15px; }
        .selectbox-container label { font-size: 12px; font-weight: bold; color: var(--text-secondary); display: block; margin-bottom: 5px; }
        .actions { margin-bottom: 20px; }
        .btn {
            display: flex; align-items: center; justify-content: center; gap: 6px;
            width: 100%; padding: 10px; box-sizing: border-box;
            border: none; border-radius: 20px; cursor: pointer; font-size: 14px; font-weight: bold;
            text-align: center; transition: background 0.2s, transform 0.1s; margin-bottom: 10px; color: #fff;
        }
        .btn:active { transform: scale(0.97); }
        .btn svg { flex-shrink: 0; }
        .btn-add { background: #2196f3; }
        .btn-add:hover { background: #005aa2; }
        .btn-pdf-all { background: #ff9800; }
        .btn-pdf-all:hover { background: #e68a00; }
        .btn-config { background: transparent; }
        .btn-offline { background: #00897b; }
        .btn-offline:hover { background: #005f56; }

        /* ===== 履歴リスト ===== */
        .history-list { flex: 1; overflow-y: auto; border-top: 2px solid var(--border-light); padding-top: 15px; min-height: 50px;}
        .history-list h3 { font-size: 11px; font-weight: bold; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 10px 4px; color: var(--text-secondary); }
        .history-item {
            display: flex; align-items: center; gap: 8px;
            padding: 9px 14px; background: var(--bg-history);
            border: 1px solid var(--border-history);
            margin-bottom: 6px; border-radius: 50px; cursor: pointer;
            transition: background 0.15s, box-shadow 0.15s;
        }
        .history-item:hover { background: var(--bg-history-hover); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
        .history-item.active {
            background: var(--bg-history-active);
            border-color: var(--border-history-active);
            box-shadow: 0 0 0 2px rgba(33,150,243,0.2);
        }
        .history-icon { font-size: 13px; flex-shrink: 0; opacity: 0.55; }
        .history-title { font-size: 12px; font-weight: bold; flex: 1; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .btn-delete {
            background: transparent; color: #f44336; border: 1px solid #f44336;
            padding: 3px 10px; font-size: 11px; border-radius: 50px; cursor: pointer;
            flex-shrink: 0; transition: background 0.15s, color 0.15s; font-weight: bold;
        }
        .btn-delete:hover { background: #f44336; color: #fff; }
        .info-list { border-top: 2px solid var(--border-light); padding-top: 10px; padding-bottom: 14px; }
        .info-list h3 { font-size: 10px; margin: 0 0 4px 0; color: var(--text-muted); }

        .main-content { flex: 1; padding: 20px; overflow-y: auto; box-sizing: border-box; background: var(--bg-main); }
        #summary-box {
            display: none; background: var(--summary-bg);
            justify-content: center; align-items: center;
            position: fixed; left: 50%; transform: translateX(-15%);
            z-index: 2000; width: auto; max-width: 94vw;
            gap: clamp(2px, 2vw, 15px); padding: 8px clamp(10px, 3vw, 20px);
            backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
            border-radius: 40px; border: 1px solid rgba(128,128,128,0.2);
            box-shadow: 0 8px 32px rgba(0,0,0,0.2);
        }
        #summary-text { font-size: 15px; font-weight: bold; color: var(--summary-color); }
        .empty-state { text-align: center; color: var(--empty-color); margin-top: 100px; font-size: 16px; }

        /* ===== エラーバナー ===== */
        .error-banner {
            background: #fff3e0; border: 2px solid #ff9800; border-radius: 16px;
            padding: 16px 20px; margin-bottom: 20px; display: flex;
            align-items: flex-start; gap: 12px;
        }
        @media (prefers-color-scheme: dark) {
            .error-banner { background: #2a1f0a; border-color: #ff9800; }
            .error-banner p, .error-banner ul { color: #ccc; }
        }
        .error-banner .error-icon { font-size: 24px; flex-shrink: 0; margin-top: 2px; }
        .error-banner .error-body { flex: 1; }
        .error-banner h3 { margin: 0 0 6px 0; font-size: 15px; color: #e65100; }
        .error-banner p { margin: 0 0 6px 0; font-size: 13px; color: #555; }
        .error-banner ul { margin: 4px 0 10px 0; padding-left: 18px; font-size: 13px; color: #555; }
        .error-banner .btn-open-config {
            background: #9c27b0; color: #fff; border: none; border-radius: 20px;
            padding: 7px 18px; font-size: 13px; font-weight: bold; cursor: pointer;
        }
        .error-banner .btn-open-config:hover { background: #6a0080; }

        /* ===== モーダル ===== */
        .modal-overlay {
            display: none; position: fixed; inset: 0;
            background: rgba(0,0,0,0.55); z-index: 9000;
            justify-content: center; align-items: center;
        }
        .modal-overlay.open { display: flex; }
        .modal-box {
            background: var(--modal-bg); border-radius: 18px; padding: 28px 30px;
            width: 520px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
            box-shadow: 0 24px 64px rgba(0,0,0,0.35); border: 1px solid var(--border);
        }
        .modal-box h2 { margin: 0 0 6px 0; font-size: 18px; color: var(--text-primary); }
        .modal-box .modal-desc { font-size: 12px; color: var(--text-secondary); margin: 0 0 20px 0; }
        .modal-section { margin-bottom: 18px; }
        .modal-section h3 { font-size: 13px; font-weight: bold; color: var(--text-secondary); margin: 0 0 10px 0; border-bottom: 1px solid var(--border-light); padding-bottom: 4px; }
        .modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
        .modal-field label { font-size: 11px; color: var(--text-secondary); display: block; margin-bottom: 3px; }
        .modal-field input {
            width: 100%; box-sizing: border-box; padding: 7px 10px;
            border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
            font-family: monospace; background: var(--modal-input-bg); color: var(--text-primary);
        }
        .modal-field input:focus { outline: none; border-color: #616bff

; background: var(--modal-input-focus-bg); }
        .modal-field input.error { border-color: #f44336; }
        @media (prefers-color-scheme: dark) {
            .modal-field input.error { background: #2a0a0a; }
        }
        .modal-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
        .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
        .modal-actions .btn-cancel {
            background: var(--bg-select); color: var(--text-secondary); border: none; border-radius: 20px;
            padding: 9px 22px; font-size: 14px; font-weight: bold; cursor: pointer;
        }
        .modal-actions .btn-apply {
            background: #3496f3; color: #fff; border: none; border-radius: 20px;
            padding: 9px 22px; font-size: 14px; font-weight: bold; cursor: pointer;
        }
        .modal-actions .btn-reset {
            background: transparent; color: #3496f3; border: 2px solid #3496f3; border-radius: 20px;
            padding: 9px 22px; font-size: 14px; font-weight: bold; cursor: pointer; margin-right: auto;
        }
        .validation-msg { font-size: 12px; color: #f44336; margin-top: 10px; min-height: 16px; }

        /* ===== 印刷 ===== */
        @media print {
            body, html { height: auto !important; overflow: visible !important; background: white !important; margin: 0; padding: 0; }
            .app-container { display: block; }
            .sidebar, .no-print { display: none !important; }
            .main-content { padding: 0 !important; background: white !important; }
            .student-page {
                width: 100% !important; margin: 0 !important; box-shadow: none !important;
                border: none !important; page-break-after: always; page-break-inside: avoid;
                height: 209mm; overflow: hidden;
            }
            .layout-portrait .student-page { height: 296mm; }
            .student-page:last-child { page-break-after: auto !important; }
            #print-temp-container { display: block !important; }
            #report-content, #summary-box { display: none !important; }
        }

.student-page {
    background: white; 
    color: #111; 
    width: 297mm; min-height: 209mm; height: auto;
    margin: 0 auto 20px auto; padding: 10mm; box-sizing: border-box;
    display: flex; flex-direction: column; box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.layout-portrait .student-page { width: 210mm; min-height: 296mm; height: auto; padding: 7mm 10mm; }
        .report-header { text-align: center; margin-bottom: 10px; }
        .report-header h2 { margin: 0; font-size: 22px; }
        .info-row { display: flex; justify-content: space-between; border: 2px solid #000; padding: 6px 15px; margin-bottom: 10px; font-weight: bold; font-size: 14px; }

        .tables-container { display: flex; gap: 10px; align-items: flex-start; width: 100%; }
        .layout-portrait .tables-container { flex-wrap: wrap; }

        table { border-collapse: collapse; flex: 1; table-layout: fixed; margin-bottom: 5px; width: 100%; }
        th, td { border: 1px solid #000; padding: 3px 2px; text-align: center; word-wrap: break-word; overflow: hidden; vertical-align: top; }
        th { background: #eee; font-size: 12px; }
        .col-no { width: 38px; }
        .col-val { width: 30px; }
        .td-title { text-align: left; padding-left: 6px;  text-overflow: ellipsis; overflow: hidden; }

        .footer-section { margin-top: auto; border-top: 2px double #000; padding-top: 8px; width: 100%; }
        .wrong-title { font-weight: bold; font-size: 13px; margin-bottom: 4px; color: #d32f2f; }
        .wrong-tables-container { display: flex; gap: 10px; width: 100%; }
        .wrong-table { flex: 1; border-collapse: collapse; table-layout: fixed; width: 100%; }
        .col-judge { width: 35px; }

        .theme-modern .report-header h2 { color: #2c3e50; border-bottom: 3px solid #3498db; display: inline-block; }
        .theme-modern .info-row { border: 1px solid #bdc3c7; background: #ecf0f1; border-radius: 6px; }
        .theme-modern th { background: #d4e6f1; color: #154360; border-color: #a9cce3; }
        .theme-modern .footer-section { border-top: 2px solid #3498db; }
        .theme-formal .info-row { border: 3px double #000; }
        .theme-natural .report-header h2 { color: #2e7d32; border-bottom: 3px solid #81c784; display: inline-block; }
        .theme-natural .info-row { border: 1px solid #a5d6a7; background: #f1f8e9; border-radius: 6px; }
        .theme-natural th { background: #c8e6c9; color: #1b5e20; border-color: #a5d6a7; }
        .theme-pop .info-row { border: 2px solid #ffb74d; background: #fff3e0; border-radius: 10px; }
        .theme-pop th { background: #ffe0b2; color: #e65100; border-color: #ffb74d; }