    /* Import Google Fonts: Atkinson Hyperlegible (Latin) + Zen Maru Gothic (Japanese) */
    @import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=Zen+Maru+Gothic:wght@500;700&display=swap');

    :root {
        --primary-color: #2196F3;
        /* Everest Blue */
        --primary-dark: #1976D2;
        /* Darker Blue */
        --accent-color: #002D58;
        /* Everest Navy */
        --highlight-color: #FFCA28;
        /* Warm Yellow Accent */
        --bg-color: #E3F2FD;
        /* Very Light Blue */
        --card-bg: #FFFFFF;
        --text-color: #002D58;
        /* Navy Text */
        --border-color: #BBDEFB;
        --radius: 16px;
        /* Friendly Rounded Corners */
    }

    body {
        font-family: 'Atkinson Hyperlegible', 'Zen Maru Gothic', sans-serif;
        background-color: var(--bg-color);
        color: var(--text-color);
        margin: 0;
        padding: 10px 10px 8px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        min-height: 100vh;
        line-height: 1.6;
        gap: 6px;
        overflow-x: hidden;
    }

    html {
        overflow-x: hidden;
    }

    body.page-loading {
        overflow: hidden;
    }

    /* 出力モード: 中学生以上はふりがなを非表示 */
    .furigana {
        white-space: nowrap;
        font-weight: 600;
        opacity: 0.9;
    }

    body.mode-junior .furigana {
        display: none;
    }

    .page-loading-overlay {
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, 0.85);
        display: none;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 14px;
        z-index: 9999;
        color: #ffffff;
        font-weight: 600;
    }

    .page-loading-overlay.active {
        display: flex;
    }

    .page-loading-spinner {
        width: 48px;
        height: 48px;
        border: 5px solid rgba(255, 255, 255, 0.3);
        border-top-color: #ffffff;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    /* ボタン内ローディング（提出中…） */
    .btn-spinner {
        display: inline-block;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        border: 3px solid rgba(255, 255, 255, 0.55);
        border-top-color: #ffffff;
        margin-right: 8px;
        vertical-align: -3px;
        animation: spin 1s linear infinite;
    }

    .btn-loading {
        opacity: 0.9;
    }

    #student-navbar {
        width: 100%;
        align-self: stretch;
    }

    .student-navbar {
        position: relative;
        background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
        color: white;
        padding: 0 14px 8px;
        margin: -20px -20px 12px -20px;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
        border-radius: 0;
        min-height: auto;
    }

    .navbar-top {
        background: #ffffff;
        padding: 8px 14px;
        margin: 0 -14px 10px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid rgba(2, 6, 23, 0.08);
    }

    .navbar-top-inner {
        max-width: 680px;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .navbar-inner {
        max-width: 680px;
        margin: 0 auto;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        align-items: center;
        justify-content: space-between;
    }

    .navbar-name {
        display: flex;
        flex-direction: column;
        gap: 2px;
        font-weight: 700;
        font-size: 1.05em;
        letter-spacing: 0.04em;
        align-items: flex-end;
    }

    .navbar-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        justify-content: flex-end;
    }

    .navbar-logo {
        width: auto;
        height: auto;
        max-height: 40px;
        object-fit: contain;
        background: transparent;
        padding: 0;
        box-shadow: none;
    }

    .greeting-line {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 4px;
        line-height: 1.3;
    }

    .greeting-prefix {
        color: #fff7d1;
        font-size: 0.95em;
        font-weight: 700;
    }

    .streak-cards {
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
        width: 100%;
    }

    .streak-column {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }

    .streak-card {
        padding: 8px 14px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 12px;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
        min-width: 150px;
        text-align: center;
        flex: 1;
        transition: box-shadow 0.3s ease, border 0.3s ease;
        position: relative;
        overflow: hidden;
    }

    .streak-card .streak-label {
        font-size: 0.85em;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        margin-bottom: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: #ffffff;
    }

    .streak-label-icon {
        display: inline-flex;
        font-size: 1.1em;
    }

    .streak-card .streak-value {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }

    .streak-value-main {
        display: flex;
        flex-direction: row;
        align-items: baseline;
        gap: 8px;
        font-size: 1.1em;
        font-weight: 700;
        letter-spacing: 0.02em;
        color: #fff;
    }

    .streak-number {
        font-size: 1.8em;
        line-height: 1;
    }

    .streak-badge {
        position: relative;
        font-size: 0.5em;
        font-weight: 800;
        background: linear-gradient(135deg, #ffd54f 0%, #ffb300 55%, #ffe082 100%);
        color: #1f2a44;
        border-radius: 999px;
        padding: 2px 8px;
        margin-left: 10px;
        display: none;
        letter-spacing: 0.12em;
        border: 1px solid rgba(255, 255, 255, 0.95);
        box-shadow:
            0 1px 2px rgba(0, 0, 0, 0.18),
            inset 0 1px 0 rgba(255, 255, 255, 0.65);
        overflow: hidden;
        transform: translateY(0);
        white-space: nowrap;
        line-height: 1;
        align-self: center;
    }

    .streak-badge.current {
        background: linear-gradient(135deg, #f5f5f5 0%, #d9d9d9 60%, #c0c0c0 100%);
        color: #0e7490;
        border: 1px solid rgba(14, 116, 144, 0.25);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
        letter-spacing: 0.1em;
        text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
    }

    .streak-badge::before {
        content: '✦';
        font-size: 0.9em;
        margin-right: 4px;
        color: rgba(255, 255, 255, 0.95);
        text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
    }

    .streak-badge::after {
        content: '';
        position: absolute;
        inset: -2px;
        background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.55) 45%, transparent 70%);
        transform: translateX(-120%);
        animation: badgeShimmer 4.2s ease-in-out infinite;
        pointer-events: none;
        opacity: 0.35;
    }

    @keyframes badgeShimmer {

        0%,
        55% {
            transform: translateX(-120%);
        }

        75% {
            transform: translateX(120%);
        }

        100% {
            transform: translateX(120%);
        }
    }

    .streak-card.active {
        border: 2px solid #ffd54f;
        background: rgba(255, 255, 255, 0.12);
        box-shadow:
            0 0 0 1px rgba(255, 213, 79, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }

    .streak-card.active::after {
        content: '';
        position: absolute;
        inset: -30% -20%;
        background: radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.18), transparent 42%),
            radial-gradient(circle at 85% 25%, rgba(255, 244, 193, 0.12), transparent 48%);
        pointer-events: none;
        opacity: 0.6;
    }

    .streak-card.active .streak-badge {
        display: inline-flex;
    }

    .streak-unit {
        font-size: 0.8em;
        line-height: 1;
    }

    .streak-card.streak-current {
        background: rgba(255, 255, 255, 0.25);
    }

    .container {
        background-color: var(--card-bg);
        width: 100%;
        max-width: 640px;
        padding: 18px 26px 24px;
        border-radius: var(--radius);
        box-shadow: 0 10px 30px rgba(33, 150, 243, 0.15);
        /* Soft floating shadow */
        border: 3px solid #FFFFFF;
        margin-top: 2px;
    }

    h1 {
        text-align: center;
        color: var(--primary-color);
        font-size: 28px;
        font-weight: 700;
        margin: 0 0 18px;
        letter-spacing: 0.05em;
    }

    h2 {
        color: var(--accent-color);
        border-bottom: 2px dashed var(--border-color);
        padding-bottom: 10px;
        text-align: center;
        font-size: 22px;
        font-weight: 700;
        margin-top: 0;
        margin-bottom: 18px;
    }

    .form-group {
        margin-bottom: 18px;
        position: relative;
    }

    label {
        display: block;
        margin-bottom: 8px;
        font-weight: 700;
        color: var(--accent-color);
        font-size: 1.05rem;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    input[type="text"],
    input[type="number"],
    select,
    textarea {
        width: 100%;
        padding: 12px;
        border: 2px solid var(--border-color);
        border-radius: 12px;
        font-size: 17px;
        box-sizing: border-box;
        font-family: inherit;
        transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        background-color: #F8FDFF;
        color: var(--text-color);
    }

    input:focus,
    select:focus,
    textarea:focus {
        border-color: var(--primary-color);
        outline: none;
        background-color: #FFFFFF;
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
        transform: translateY(-2px);
    }

    textarea {
        resize: vertical;
        min-height: 140px;
    }

    button {
        width: 100%;
        padding: 14px;
        background-color: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50px;
        font-size: 18px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        font-family: inherit;
        box-shadow: 0 4px 0 var(--primary-dark);
        margin-top: 8px;
    }

    button:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 0 var(--primary-dark);
        filter: brightness(1.05);
    }

    /* 画像が選ばれて押せる状態の「ノート画像の提出」ボタンを少し強調 */
    #resubmit-btn.ready:hover {
        transform: translateY(-2px);
        filter: brightness(1.08);
    }

    #submit-btn.ready:hover {
        transform: translateY(-2px);
        filter: brightness(1.08);
    }

    button:active {
        transform: translateY(2px);
        box-shadow: 0 2px 0 var(--primary-dark);
    }

    button:disabled {
        background-color: #CFD8DC;
        box-shadow: none;
        color: #90A4AE;
        cursor: not-allowed;
        transform: none;
    }

    /* Preview Box */
    #problem-preview {
        background: #E1F5FE !important;
        border: 2px dashed var(--primary-color) !important;
        border-radius: 16px !important;
    }

    #preview-topic {
        color: var(--accent-color) !important;
    }

    /* Results */
    .result-card {
        background: #fff;
        border: 2px solid var(--border-color);
        padding: 20px;
        margin-bottom: 18px;
        border-radius: 16px;
        position: relative;
        overflow: hidden;
    }

    .result-label {
        background: var(--primary-color);
        color: #FFFFFF;
        padding: 6px 14px;
        border-radius: 20px;
        font-size: 0.9em;
        font-weight: 700;
        display: inline-block;
        margin-bottom: 14px;
    }

    .correction-box {
        background-color: #F1F8E9;
        border-color: #AED581;
    }

    .correction-box .result-label {
        background: #689F38;
    }

    .result-content {
        font-size: 1.1rem;
        line-height: 1.8;
    }

    /* 修正箇所のスタイル */
    .result-content span[style*="color: red"] {
        color: #d32f2f !important;
        font-weight: bold !important;
        background-color: #ffebee;
        padding: 2px 4px;
        border-radius: 3px;
    }

    /* 不足箇所の空白部分のスタイル */
    .result-content span[style*="border-bottom: 3px solid red"] {
        border-bottom: 3px solid #d32f2f !important;
        background-color: #ffebee !important;
        padding: 2px 4px;
        border-radius: 3px;
        display: inline-block;
        min-width: 20px;
    }

    ul {
        padding-left: 24px;
        margin-top: 5px;
    }

    li {
        margin-bottom: 8px;
        list-style-type: disc;
        color: var(--text-color);
    }

    .loader {
        display: none;
        border: 4px solid #E1F5FE;
        border-top: 4px solid var(--highlight-color);
        border-radius: 50%;
        width: 32px;
        height: 32px;
        animation: spin 1s linear infinite;
        margin: 20px auto;
    }

    /* ノート画像の提出（リライティング）用：ボタン直下の小さめスピナー */
    .loader.resubmit-loader {
        width: 22px;
        height: 22px;
        border-width: 3px;
        margin: 10px auto 0;
    }

    @keyframes spin {
        0% {
            transform: rotate(0deg);
        }

        100% {
            transform: rotate(360deg);
        }
    }

    .hidden {
        display: none;
    }

    /* 出力モード切り替えスイッチ */
    .mode-switch-container {
        margin-bottom: 20px;
    }

    .mode-switch-label {
        display: block;
        font-weight: 700;
        color: var(--accent-color);
        font-size: 0.9rem;
        margin-bottom: 10px;
        text-align: center;
        letter-spacing: 0.05em;
    }

    .mode-switch {
        display: flex;
        gap: 0;
        background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
        border-radius: 12px;
        padding: 4px;
        box-shadow:
            inset 0 2px 4px rgba(0, 0, 0, 0.06),
            0 2px 8px rgba(0, 0, 0, 0.08);
        position: relative;
    }

    .mode-switch input[type="radio"] {
        display: none;
    }

    .mode-switch .mode-option {
        flex: 1;
        padding: 12px 20px;
        text-align: center;
        border-radius: 10px;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        font-size: 0.95rem;
        font-weight: 600;
        color: #64748b;
        background: transparent;
        margin: 0;
        position: relative;
        z-index: 1;
    }

    .mode-switch input[type="radio"]:checked+.mode-option {
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
        color: #FFFFFF;
        font-weight: 700;
        box-shadow:
            0 4px 12px rgba(33, 150, 243, 0.4),
            0 2px 4px rgba(33, 150, 243, 0.2);
        transform: translateY(-1px);
    }

    .mode-switch .mode-option:hover {
        color: var(--primary-color);
        background: rgba(33, 150, 243, 0.08);
    }

    .mode-switch input[type="radio"]:checked+.mode-option:hover {
        background: linear-gradient(135deg, var(--primary-dark) 0%, #1565C0 100%);
        color: #FFFFFF;
        box-shadow:
            0 6px 16px rgba(33, 150, 243, 0.5),
            0 2px 6px rgba(33, 150, 243, 0.3);
        transform: translateY(-2px);
    }

    /* ヒントトグルボタン */
    .hint-toggle-btn {
        background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
        border: 1.5px solid #0284c7;
        border-radius: 8px;
        cursor: pointer;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.1em;
        height: 1.1em;
        flex-shrink: 0;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 2px 4px rgba(2, 132, 199, 0.15);
        position: relative;
        align-self: center;
        line-height: 1;
    }

    .hint-toggle-btn::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 8px;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, transparent 100%);
        opacity: 0;
        transition: opacity 0.25s;
    }

    .hint-toggle-btn:hover {
        background: linear-gradient(135deg, #bae6fd 0%, #7dd3fc 100%);
        border-color: #0369a1;
        box-shadow: 0 4px 8px rgba(2, 132, 199, 0.25);
        transform: translateY(-2px);
    }

    .hint-toggle-btn:hover::before {
        opacity: 1;
    }

    .hint-toggle-btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(2, 132, 199, 0.15);
    }

    .hint-icon {
        color: #0284c7;
        font-size: 0.75em;
        font-weight: bold;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
        display: inline-block;
        line-height: 1;
        position: relative;
        z-index: 1;
    }

    /* ヒントワードコンテナのアニメーション */
    .hint-words-container {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        padding: 0 12px;
        background: #f0f9ff;
        border: 2px solid #bae6fd;
        border-radius: 8px;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
            padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
            margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        margin-top: 0;
    }

    .hint-words-container.expanded {
        max-height: 1000px;
        opacity: 1;
        padding: 12px;
        margin-top: 10px;
    }

    /* ヒントワードグリッド（2列表示） */
    .hint-words-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 16px;
        color: #0e7490;
        line-height: 1.8;
    }

    .hint-word-item {
        padding: 4px 0;
        font-size: 0.95em;
    }

    /* 生徒画面タブ */
    .student-tabs {
        display: flex;
        gap: 10px;
        margin: 0 0 16px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .student-tab-btn {
        width: auto;
        padding: 10px 14px;
        border-radius: 999px;
        border: 2px solid #bae6fd;
        background: #f0f9ff;
        color: #0e7490;
        font-weight: 800;
        font-size: 0.95rem;
        box-shadow: 0 3px 0 #bae6fd;
        cursor: pointer;
        transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
        margin-top: 0;
    }

    .student-tab-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 0 #7dd3fc;
        background: #e0f2fe;
    }

    .student-tab-btn:active {
        transform: translateY(1px);
        box-shadow: 0 2px 0 #bae6fd;
    }

    .student-tab-btn.active {
        background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
        color: #ffffff;
        border-color: rgba(255, 255, 255, 0.35);
        box-shadow: 0 4px 0 rgba(7, 89, 133, 0.9);
    }

    .history-section.hidden {
        display: none;
    }

    /* モーダル（ノート画像の提出 完了） */
    .modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, 0.65);
        display: none;
        align-items: center;
        justify-content: center;
        padding: 18px;
        z-index: 10000;
    }

    .modal-overlay.active {
        display: flex;
    }

    .modal-card {
        width: min(520px, 92vw);
        background: #ffffff;
        border-radius: 18px;
        border: 2px solid rgba(186, 230, 253, 0.95);
        box-shadow: 0 18px 60px rgba(2, 6, 23, 0.35);
        padding: 18px 16px 16px;
        position: relative;
        color: #0f172a;
    }

    .modal-close {
        position: absolute;
        right: 10px;
        top: 10px;
        width: 34px;
        height: 34px;
        border-radius: 10px;
        border: 2px solid rgba(186, 230, 253, 0.95);
        background: #f0f9ff;
        color: #0e7490;
        font-weight: 900;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
        font-size: 20px;
        padding: 0;
    }

    .modal-title {
        font-size: 1.15rem;
        font-weight: 900;
        margin-bottom: 10px;
        color: #0e7490;
    }

    .modal-message {
        font-size: 1.02rem;
        font-weight: 800;
        line-height: 1.65;
        white-space: pre-line;
        margin-bottom: 14px;
    }

    .modal-actions {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .modal-btn {
        width: auto;
        padding: 10px 14px;
        border-radius: 12px;
        border: 2px solid rgba(186, 230, 253, 0.95);
        background: #f0f9ff;
        color: #0e7490;
        font-weight: 900;
        cursor: pointer;
        box-shadow: 0 3px 0 #bae6fd;
    }

    .modal-btn.primary {
        background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
        color: #ffffff;
        border-color: rgba(255, 255, 255, 0.35);
        box-shadow: 0 4px 0 rgba(7, 89, 133, 0.9);
    }

    /* 提出チェッカー内のLevelタブ */
    .history-level-tabs {
        display: flex;
        gap: 10px;
        justify-content: center;
        flex-wrap: wrap;
        margin: 10px 0 12px;
    }

    .history-level-tab-btn {
        width: auto;
        padding: 10px 14px;
        border-radius: 999px;
        border: 2px solid #bae6fd;
        background: #f0f9ff;
        color: #0e7490;
        font-weight: 900;
        font-size: 0.95rem;
        box-shadow: 0 3px 0 #bae6fd;
        cursor: pointer;
        transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
        margin-top: 0;
    }

    .history-level-tab-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 0 #7dd3fc;
        background: #e0f2fe;
    }

    .history-level-tab-btn:active {
        transform: translateY(1px);
        box-shadow: 0 2px 0 #bae6fd;
    }

    .history-level-tab-btn.active {
        background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
        color: #ffffff;
        border-color: rgba(255, 255, 255, 0.35);
        box-shadow: 0 4px 0 rgba(7, 89, 133, 0.9);
    }

    .history-level-panel {
        display: none;
    }

    .history-level-panel.active {
        display: block;
    }

    /* 提出チェッカー */
    .history-header {
        text-align: center;
        margin-bottom: 12px;
    }

    .history-subtitle {
        color: #64748b;
        font-weight: 700;
        font-size: 0.95rem;
        margin-top: -8px;
        margin-bottom: 10px;
    }

    .history-level-block {
        background: #f8fdff;
        border: 2px solid #bae6fd;
        border-radius: 16px;
        padding: 14px 14px 16px;
        margin: 14px 0;
        position: relative;
        overflow: hidden;
    }

    .history-level-block::after {
        content: '';
        position: absolute;
        inset: -40% -25%;
        background:
            radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.7), transparent 42%),
            radial-gradient(circle at 85% 25%, rgba(186, 230, 253, 0.35), transparent 55%);
        pointer-events: none;
        opacity: 0.9;
    }

    .history-level-title {
        font-weight: 900;
        color: #0e7490;
        font-size: 1.05rem;
        letter-spacing: 0.04em;
        text-align: center;
        position: relative;
        z-index: 1;
    }

    .history-meta {
        text-align: center;
        color: #475569;
        font-weight: 800;
        margin: 6px 0 10px;
        position: relative;
        z-index: 1;
    }

    .history-grid {
        display: grid;
        grid-template-columns: repeat(10, 1fr);
        gap: 8px;
        position: relative;
        z-index: 1;
    }

    .day-cell {
        width: 100%;
        aspect-ratio: 1 / 1;
        border-radius: 14px;
        border: 2px solid #e2e8f0;
        background: #ffffff;
        box-shadow: 0 3px 0 #e2e8f0;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        cursor: pointer;
        user-select: none;
        font-weight: 900;
        color: #0f172a;
        font-size: 0.95rem;
        transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
        padding: 0;
        margin-top: 0;
    }

    .day-cell:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 0 #cbd5e1;
        background: #f8fafc;
    }

    .day-cell:active {
        transform: translateY(1px);
        box-shadow: 0 2px 0 #e2e8f0;
    }

    .day-cell.done {
        /* 提出済み = 銀 */
        border-color: rgba(148, 163, 184, 0.55);
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 40%, #cbd5e1 100%);
        box-shadow: 0 3px 0 rgba(148, 163, 184, 0.7);
    }

    .day-cell.done.gold {
        /* 画像投稿あり = 金 */
        border-color: rgba(234, 179, 8, 0.45);
        background: linear-gradient(135deg, #fff7d1 0%, #fde68a 45%, #fbbf24 100%);
        box-shadow: 0 3px 0 rgba(234, 179, 8, 0.55);
    }

    .day-cell.done::after {
        content: '';
        position: absolute;
        inset: -2px;
        border-radius: 14px;
        background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.75) 45%, transparent 70%);
        transform: translateX(-120%);
        animation: dayShimmer 3.8s ease-in-out infinite;
        opacity: 0.35;
        pointer-events: none;
    }

    @keyframes dayShimmer {

        0%,
        60% {
            transform: translateX(-120%);
        }

        80% {
            transform: translateX(120%);
        }

        100% {
            transform: translateX(120%);
        }
    }

    .day-badges {
        position: absolute;
        right: 6px;
        bottom: 6px;
        display: flex;
        gap: 4px;
        align-items: center;
    }

    .day-badge {
        font-size: 0.7rem;
        line-height: 1;
        background: rgba(15, 23, 42, 0.08);
        border: 1px solid rgba(15, 23, 42, 0.12);
        border-radius: 999px;
        padding: 1px 6px;
        font-weight: 900;
        color: #0f172a;
        backdrop-filter: blur(6px);
    }

    .day-badge.image {
        /* 色は付けない（銀/金の2色だけ） */
    }

    .day-badge.resubmit {
        /* 色は付けない（銀/金の2色だけ） */
    }

    .day-count {
        position: absolute;
        left: 6px;
        top: 6px;
        font-size: 0.7rem;
        line-height: 1;
        background: rgba(2, 132, 199, 0.16);
        border: 1px solid rgba(2, 132, 199, 0.25);
        color: #0369a1;
        border-radius: 999px;
        padding: 1px 6px;
        font-weight: 900;
    }

    .history-legend {
        display: flex;
        gap: 10px;
        justify-content: center;
        flex-wrap: wrap;
        margin-top: 10px;
        margin-bottom: 8px;
        color: #334155;
        font-weight: 800;
        font-size: 0.9rem;
    }

    .legend-item {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .legend-chip {
        width: 18px;
        height: 18px;
        border-radius: 6px;
        border: 2px solid #e2e8f0;
        background: #ffffff;
        display: inline-block;
    }

    .legend-chip.silver {
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 60%, #cbd5e1 100%);
        border-color: rgba(148, 163, 184, 0.75);
    }

    .legend-chip.gold {
        background: linear-gradient(135deg, #fff7d1 0%, #fde68a 60%, #fbbf24 100%);
        border-color: rgba(234, 179, 8, 0.55);
    }

    .history-detail {
        margin-top: 14px;
        background: #ffffff;
        border: 2px solid #bae6fd;
        border-radius: 16px;
        padding: 14px 16px;
    }

    .history-all {
        margin-top: 14px;
        background: #ffffff;
        border: 2px solid #e2e8f0;
        border-radius: 16px;
        padding: 14px 16px;
    }

    .history-detail-title {
        font-weight: 900;
        color: #0e7490;
        margin-bottom: 10px;
        text-align: center;
    }

    .history-detail-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
        font-weight: 700;
        color: #0f172a;
    }

    .history-item {
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        padding: 10px 12px;
        background: #f8fafc;
        display: flex;
        justify-content: space-between;
        gap: 10px;
        flex-wrap: wrap;
    }

    .history-item .meta {
        color: #475569;
        font-weight: 800;
        font-size: 0.9rem;
    }

    .history-item .tags {
        display: inline-flex;
        gap: 6px;
        flex-wrap: wrap;
    }

    .tag {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border-radius: 999px;
        padding: 2px 10px;
        border: 1px solid rgba(15, 23, 42, 0.12);
        background: rgba(15, 23, 42, 0.06);
        font-weight: 900;
        font-size: 0.85rem;
        color: #0f172a;
        line-height: 1.2;
    }

    .tag.silver {
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 60%, #cbd5e1 100%);
        border-color: rgba(148, 163, 184, 0.65);
    }

    .tag.gold {
        background: linear-gradient(135deg, #fff7d1 0%, #fde68a 60%, #fbbf24 100%);
        border-color: rgba(234, 179, 8, 0.55);
    }

    /* コピー制限用のクラス */
    .unselectable {
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        /* 右クリックメニューを制限する場合に備えて pointer-events を使うことも可能ですが、
           ボタンやトグルまで効かなくなるのを避けるため user-select のみ適用します */
    }

    /* Responsive layouts */
    @media (min-width: 1024px) {
        body {
            padding: 16px 16px 12px;
        }

        .container {
            max-width: 720px;
        }

        .navbar-inner {
            max-width: 720px;
        }
    }

    @media (min-width: 768px) and (max-width: 1023px) {
        body {
            padding: 12px 12px 10px;
        }

        .student-navbar {
            margin: -16px -16px 12px -16px;
            padding: 0 14px 10px;
        }

        .navbar-top {
            padding: 8px 14px;
            margin: 0 -14px 10px;
        }

        .navbar-top-inner {
            max-width: 680px;
        }

        .container {
            max-width: 680px;
            padding: 18px 22px 22px;
        }

        .navbar-inner {
            max-width: 680px;
        }

        .streak-card {
            min-width: 140px;
        }

        .admin-container {
            padding: 28px;
        }

        .section {
            padding: 24px;
        }

        .cache-button {
            min-width: 180px;
        }
    }

    @media (max-width: 767px) {
        body {
            padding: 8px 8px 6px;
        }

        .student-navbar {
            margin: -12px -12px 10px -12px;
            padding: 0 12px 8px;
        }

        .navbar-top {
            padding: 6px 12px;
            margin: 0 -12px 8px;
        }

        .navbar-top-inner {
            max-width: 100%;
        }

        .navbar-inner {
            gap: 8px;
        }

        .container {
            padding: 14px 14px 18px;
            border-radius: 14px;
        }

        h1 {
            font-size: 22px;
            margin-bottom: 14px;
        }

        h2 {
            font-size: 18px;
            margin-bottom: 14px;
        }

        label {
            font-size: 0.95rem;
        }

        input[type="text"],
        input[type="number"],
        select,
        textarea {
            font-size: 16px;
            padding: 10px;
        }

        textarea {
            min-height: 120px;
        }

        button {
            font-size: 16px;
            padding: 12px;
        }

        .form-row {
            flex-direction: column;
            gap: 12px;
            margin-bottom: 16px !important;
        }

        .streak-cards {
            flex-direction: column;
            gap: 8px;
        }

        .streak-card {
            min-width: 0;
        }

        .streak-value-main {
            font-size: 1rem;
        }

        .streak-number {
            font-size: 1.6em;
        }

        .result-content {
            font-size: 1rem;
        }

        .mode-switch .mode-option {
            padding: 10px 8px;
            font-size: 0.9rem;
        }

        .student-tabs,
        .history-level-tabs {
            gap: 8px;
        }

        .student-tab-btn,
        .history-level-tab-btn {
            font-size: 0.85rem;
            padding: 8px 12px;
        }

        .history-grid {
            grid-template-columns: repeat(10, 1fr);
            gap: 6px;
        }

        .day-cell {
            border-radius: 10px;
            font-size: 0.8rem;
        }

        .day-badge,
        .day-count {
            font-size: 0.6rem;
        }

        .history-level-block {
            padding: 12px 12px 14px;
        }

        .history-legend {
            font-size: 0.85rem;
        }

        #problem-preview {
            overflow-wrap: anywhere;
        }

        #preview-topic {
            white-space: normal !important;
            word-break: break-word;
            overflow-wrap: anywhere;
        }

        .admin-container {
            padding: 16px;
            margin: 10px auto;
        }

        .section {
            padding: 18px;
        }

        .cache-button-group {
            gap: 10px;
        }

        .cache-button {
            width: 100%;
            min-width: 0;
        }

        .modal-card {
            padding: 16px 14px;
        }
    }
    
