* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f4f7fb;
    color: #1f2937;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-header {
    background: #1e3a8a;
    color: #fff;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title a {
    font-size: 20px;
    font-weight: 700;
}

.app-nav {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 14px;
}

.app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px;
}

.app-footer {
    text-align: center;
    padding: 24px;
    color: #6b7280;
}

.card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    margin-bottom: 20px;
}

.card h1,
.card h2,
.card h3 {
    margin-top: 0;
}

.login-wrap {
    max-width: 420px;
    margin: 60px auto;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
}

textarea {
    line-height: 1.7;
}

button,
.btn {
    display: inline-block;
    border: none;
    background: #2563eb;
    color: #fff;
    padding: 11px 18px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
}

button:hover,
.btn:hover {
    background: #1d4ed8;
}

.btn-sub {
    background: #64748b;
}

.btn-sub:hover {
    background: #475569;
}

.btn-danger {
    background: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-disabled {
    background: #94a3b8 !important;
    cursor: not-allowed;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.menu-card {
    background: #fff;
    border-radius: 16px;
    padding: 22px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.menu-card h3 {
    margin: 0 0 8px;
}

.menu-card p {
    color: #64748b;
    font-size: 14px;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-admin {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-teacher {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-student {
    background: #dcfce7;
    color: #166534;
}

.badge-soft {
    display: inline-block;
    background: #f1f5f9;
    color: #334155;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 5px;
}

.muted {
    color: #64748b;
    font-size: 14px;
}

/* table common */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px;
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    white-space: nowrap;
}

td input,
td select {
    min-width: 120px;
}

.action-cell {
    white-space: nowrap;
}

.action-cell button {
    margin-right: 6px;
    margin-bottom: 4px;
}

/* curriculum */

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 120px 120px 140px;
    gap: 12px;
    align-items: end;
}

.form-row .small {
    max-width: 140px;
}

.button-group {
    display: flex;
    align-items: end;
}

/* criteria */

.criteria-note {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.criteria-note div {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
}

.criteria-table {
    min-width: 1400px;
}

.criteria-table th,
.criteria-table td {
    font-size: 13px;
}

.criteria-table select {
    min-width: 90px;
}

.target-label {
    min-width: 260px;
    font-weight: 700;
    color: #1e293b;
}

.input-mini {
    width: 90px;
    min-width: 90px;
}

.current-value {
    margin-top: 4px;
    font-size: 11px;
    color: #475569;
    line-height: 1.4;
}

.current-value span {
    display: block;
    color: #94a3b8;
}

/* old question management */

.question-table {
    min-width: 1100px;
}

.question-list-text {
    min-width: 260px;
}

.question-thumb {
    margin-top: 8px;
}

.question-thumb img {
    max-width: 140px;
    max-height: 90px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.inline-delete-form {
    display: inline-block;
    margin-top: 6px;
}

.time-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.checkbox-label {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    font-weight: 700;
}

.checkbox-label input {
    width: auto;
}

.image-preview-box {
    margin-top: 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    padding: 12px;
    border-radius: 12px;
}

.image-preview-box img {
    display: block;
    max-width: 360px;
    max-height: 240px;
    width: auto;
    height: auto;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

/* step question management */

.step-question-table {
    min-width: 1000px;
}

.default-setting-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
}

.question-form-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
}

.formula-help {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 18px;
    line-height: 1.8;
}

.formula-help code {
    background: #eef2ff;
    padding: 2px 6px;
    border-radius: 6px;
}

.choice-area {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px;
    margin: 18px 0;
}

.choice-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.choice-check {
    font-weight: 700;
    margin: 0;
}

.image-token-area {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px;
    margin: 18px 0;
}

.image-row {
    display: grid;
    grid-template-columns: 180px 1fr 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.btn-mini {
    display: inline-block;
    border: none;
    background: #475569;
    color: #fff;
    padding: 5px 9px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 6px;
}

.step-question-list {
    display: grid;
    gap: 18px;
}

.registered-question-card {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 18px;
    background: #fff;
}

.registered-question-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.stage-badge-try {
    background: #dbeafe;
    color: #1d4ed8;
}

.stage-badge-survival {
    background: #fee2e2;
    color: #991b1b;
}

.registered-question-body {
    line-height: 1.9;
    font-size: 16px;
    margin-bottom: 12px;
}

.inline-question-image {
    margin: 14px 0;
}

.inline-question-image img {
    max-width: 100%;
    max-height: 420px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

.image-caption {
    color: #64748b;
    font-size: 13px;
    margin-top: 4px;
}

.token-list {
    margin: 8px 0;
}

.token-list span {
    display: inline-block;
    background: #ecfeff;
    color: #155e75;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    margin-right: 6px;
}

.registered-choices {
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px;
    margin-top: 12px;
}

.choice-correct {
    color: #166534;
    font-weight: 700;
}

.answer-box,
.explanation-box {
    background: #f8fafc;
    border-left: 4px solid #2563eb;
    padding: 12px;
    border-radius: 10px;
    margin-top: 12px;
}

/* student management */

.student-form-grid,
.student-course-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.student-table {
    min-width: 1300px;
}

.student-setting-table {
    min-width: 1000px;
}

.select-student-form {
    max-width: 420px;
}

.selected-student-box {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin: 14px 0 20px;
}

.course-setting-form {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 24px;
}

.lock-badge {
    display: inline-block;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

.ok-badge {
    display: inline-block;
    background: #dcfce7;
    color: #166534;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

/* student dashboard */

.student-hero {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #fff;
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-end;
    box-shadow: 0 12px 30px rgba(30, 58, 138, 0.24);
}

.student-hero h1 {
    margin: 0 0 8px;
    font-size: 30px;
}

.student-hero p {
    margin: 0;
    color: #dbeafe;
}

.student-hero-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.student-hero-meta span {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
}

.student-dashboard-grid {
    display: grid;
    gap: 22px;
}

.student-course-card {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    border: 1px solid #e5e7eb;
}

.student-course-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 18px;
    margin-bottom: 18px;
}

.course-path {
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.student-course-head h2 {
    margin: 0;
    color: #0f172a;
}

.course-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.level-badge,
.status-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
}

.level-badge {
    background: #ede9fe;
    color: #5b21b6;
}

.status-badge {
    background: #dcfce7;
    color: #166534;
}

.review-alert {
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 700;
}

.review-alert.warning {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde68a;
}

.review-alert.danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.locked-box {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 16px;
}

.current-step-box,
.survival-box {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 18px;
    margin-top: 16px;
}

.step-label {
    display: inline-block;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 10px;
}

.survival-label {
    background: #fee2e2;
    color: #991b1b;
}

.current-step-box h3 {
    margin: 4px 0 16px;
    color: #0f172a;
}

.step-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.step-info-grid div {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px;
}

.step-info-grid span {
    display: block;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.step-info-grid strong {
    font-size: 18px;
}

.status-passed {
    color: #166534;
}

.status-review-ok {
    color: #854d0e;
}

.status-review {
    color: #991b1b;
}

.status-progress {
    color: #1d4ed8;
}

.status-not-started {
    color: #64748b;
}

.try-btn {
    background: #2563eb;
}

.try-btn:hover {
    background: #1d4ed8;
}

.survival-btn {
    background: #dc2626;
}

.survival-btn:hover {
    background: #b91c1c;
}

.current-survival-note {
    margin-top: 14px;
    color: #64748b;
    font-size: 14px;
    line-height: 1.7;
}

.survival-list {
    display: grid;
    gap: 12px;
}

.survival-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

/* responsive */

@media (max-width: 1100px) {
    .default-setting-grid,
    .question-form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .form-row,
    .default-setting-grid,
    .question-form-grid,
    .student-form-grid,
    .student-course-grid,
    .criteria-note {
        grid-template-columns: 1fr;
    }

    .form-row .small {
        max-width: none;
    }

    .choice-row,
    .image-row {
        grid-template-columns: 1fr;
    }

    .image-preview-box img {
        max-width: 100%;
    }

    .registered-question-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .student-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .student-hero-meta {
        justify-content: flex-start;
    }

    .student-course-head {
        flex-direction: column;
    }

    .course-badges {
        justify-content: flex-start;
    }

    .step-info-grid {
        grid-template-columns: 1fr;
    }

    .survival-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .app-main {
        padding: 24px 14px;
    }

    .card,
    .student-course-card {
        padding: 18px;
    }
}
.solve-header-card {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.solve-path {
    color: #64748b;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
}

.solve-header-card h1 {
    margin: 0 0 6px;
    color: #0f172a;
}

.solve-header-card p {
    margin: 0;
    color: #64748b;
}

.solve-timer-box {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 14px 18px;
    min-width: 140px;
    text-align: center;
}

.solve-timer-box span {
    display: block;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.solve-timer-box strong {
    font-size: 28px;
    color: #0f172a;
}

.solve-card {
    background: #fff;
    border-radius: 20px;
    padding: 26px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    border: 5px solid #2563eb;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.solve-normal {
    border-color: #2563eb;
}

.solve-warning {
    border-color: #facc15;
    box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.18);
}

.solve-danger {
    border-color: #ef4444;
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.18);
}

.solve-card-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
}

.question-type-badge {
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 800;
}

.time-rule {
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}

.solve-question-body {
    font-size: 18px;
    line-height: 2;
    color: #0f172a;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 22px;
    margin-bottom: 22px;
}

.solve-question-image {
    margin: 16px 0;
}

.solve-question-image img {
    max-width: 100%;
    max-height: 460px;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.answer-form {
    margin-top: 18px;
}

.answer-choice-list {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.answer-choice {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
    cursor: pointer;
    font-weight: 700;
}

.answer-choice:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.answer-choice input {
    width: auto;
    transform: scale(1.2);
}

.submit-answer-btn {
    width: 100%;
    font-size: 17px;
    padding: 14px 18px;
}

.result-card {
    background: #fff;
    border-radius: 24px;
    padding: 34px;
    text-align: center;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
}

.result-title span {
    display: inline-block;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 10px;
}

.result-title h1 {
    margin: 0;
}

.result-score {
    font-size: 72px;
    font-weight: 900;
    color: #1d4ed8;
    margin: 20px 0;
}

.result-score span {
    font-size: 32px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 24px 0;
}

.result-grid div {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
}

.result-grid span {
    display: block;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.result-grid strong {
    font-size: 22px;
}

.result-message {
    border-radius: 14px;
    padding: 14px;
    font-weight: 700;
    margin: 20px 0;
}

.result-message.success {
    background: #dcfce7;
    color: #166534;
}

.result-message.warning {
    background: #fef9c3;
    color: #854d0e;
}

@media (max-width: 900px) {
    .solve-header-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .solve-timer-box {
        width: 100%;
    }

    .solve-card-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .result-score {
        font-size: 56px;
    }
}
.math-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.math-toolbar button {
    background: #334155;
    padding: 8px 12px;
    border-radius: 9px;
    font-size: 13px;
}

.math-toolbar button:hover {
    background: #1e293b;
}

.default-setting-grid-wide {
    grid-template-columns: repeat(6, 1fr);
}

.question-block {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 22px;
    margin-bottom: 24px;
}

.question-block-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 14px;
    margin-bottom: 18px;
}

.question-block-head h3 {
    margin: 0;
}

.question-edit-preview-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 20px;
    align-items: start;
}

.question-edit-pane {
    min-width: 0;
}

.question-preview-pane {
    min-width: 0;
}

.preview-sticky {
    position: sticky;
    top: 18px;
}

.live-preview {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 18px;
    min-height: 320px;
    line-height: 1.9;
    font-size: 15px;
}

.preview-badges {
    margin-bottom: 12px;
}

.preview-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 14px;
}

.preview-explanation {
    border-left: 4px solid #2563eb;
}

.question-section-label {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 8px;
}

.registered-main-question,
.registered-sub-question {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
}

.preview-choices {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px;
    margin-top: 12px;
}

.question-add-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-top: 18px;
}

@media (max-width: 1100px) {
    .question-edit-preview-layout {
        grid-template-columns: 1fr;
    }

    .preview-sticky {
        position: static;
    }

    .default-setting-grid-wide {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .question-block {
        padding: 16px;
    }

    .question-block-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .question-add-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .default-setting-grid-wide {
        grid-template-columns: 1fr;
    }
}
/* PC作成画面用：横幅を広く使う */
.app-main {
    max-width: min(1800px, calc(100vw - 40px));
}

.wide-page {
    width: 100%;
}

/* 問題作成画面 */

.question-edit-preview-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(420px, 0.65fr);
    gap: 24px;
    align-items: start;
}

.question-edit-pane,
.question-preview-pane {
    min-width: 0;
}

.preview-sticky {
    position: sticky;
    top: 18px;
}

.live-preview {
    min-height: 520px;
}

/* 小問下のツールエリア */

.local-tool-panel {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    margin: 12px 0 18px;
}

.local-tool-title {
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 8px;
}

.image-tool-title {
    margin-top: 16px;
}

.math-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.math-toolbar button {
    background: #334155;
    padding: 8px 12px;
    border-radius: 9px;
    font-size: 13px;
}

.math-toolbar button:hover {
    background: #1e293b;
}

/* 画像挿入ボタン */

.image-button-row {
    display: grid;
    grid-template-columns: 150px 1fr 220px;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.image-select-btn {
    background: #0f766e;
}

.image-select-btn:hover {
    background: #115e59;
}

.visually-hidden-file {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.image-caption-input {
    min-width: 160px;
}

.selected-file-name {
    color: #64748b;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* プレビュー */

.preview-badges {
    margin-bottom: 12px;
}

.preview-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 14px;
}

.preview-explanation {
    border-left: 4px solid #2563eb;
}

.question-section-label {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 8px;
}

.preview-choices {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px;
    margin-top: 12px;
}

/* 登録済み問題の大問・小問 */

.registered-main-question,
.registered-sub-question {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
}

/* レスポンシブ */

@media (max-width: 1200px) {
    .question-edit-preview-layout {
        grid-template-columns: 1fr;
    }

    .preview-sticky {
        position: static;
    }

    .image-button-row {
        grid-template-columns: 1fr;
    }
}
.question-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.question-card-actions form {
    display: inline-block;
}

.edit-question-details {
    margin-top: 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px 14px;
}

.edit-question-details summary {
    cursor: pointer;
    font-weight: 800;
    color: #1e3a8a;
}

.edit-question-form {
    margin-top: 16px;
}

.edit-image-box {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px;
    margin: 18px 0;
}

.edit-image-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 0;
}

.edit-image-row img {
    max-width: 200px;
    max-height: 140px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    margin-top: 8px;
}

.edit-new-image-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

@media (max-width: 900px) {
    .question-card-actions {
        width: 100%;
    }

    .question-card-actions form,
    .question-card-actions button {
        width: 100%;
    }

    .edit-image-row,
    .edit-new-image-row {
        grid-template-columns: 1fr;
    }
}
/* 回答時間超過時のふちを強調 */
.solve-card {
    border-width: 8px;
}

.solve-warning {
    border-color: #facc15;
    box-shadow:
        0 0 0 10px rgba(250, 204, 21, 0.22),
        0 12px 30px rgba(250, 204, 21, 0.25);
}

.solve-danger {
    border-color: #ef4444;
    box-shadow:
        0 0 0 12px rgba(239, 68, 68, 0.25),
        0 12px 34px rgba(239, 68, 68, 0.30);
}
.handwriting-answer-area {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 20px;
}

.handwriting-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.handwriting-status {
    color: #64748b;
    font-size: 14px;
    font-weight: 700;
}

.handwriting-canvas {
    width: 100%;
    height: 260px;
    background: #fff;
    border: 3px solid #cbd5e1;
    border-radius: 16px;
    touch-action: none;
    display: block;
}

.candidate-box {
    margin-top: 18px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
}

.candidate-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.candidate-button {
    width: 100%;
    background: #f8fafc;
    color: #0f172a;
    border: 2px solid #e5e7eb;
    text-align: left;
    padding: 14px;
    border-radius: 14px;
    font-size: 16px;
}

.candidate-button:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.candidate-button.selected {
    background: #dbeafe;
    border-color: #2563eb;
    color: #1e3a8a;
}

.candidate-button span {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 800;
    margin-right: 8px;
}

.selected-candidate-box {
    margin-top: 14px;
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px;
    color: #334155;
}
.review-filter-grid {
    display: grid;
    grid-template-columns: 220px 1fr 160px;
    gap: 14px;
    align-items: end;
}

.review-filter-button {
    margin-bottom: 16px;
}

.review-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
    gap: 22px;
    align-items: start;
}

.review-list-card,
.review-detail-card {
    min-width: 0;
}

.review-detail-card {
    position: sticky;
    top: 18px;
}

.review-table {
    min-width: 1200px;
}

.selected-review-row {
    background: #eff6ff;
}

.rf-status {
    display: inline-block;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.rf-status-open {
    background: #fee2e2;
    color: #991b1b;
}

.rf-status-instructed {
    background: #fef9c3;
    color: #854d0e;
}

.rf-status-retest {
    background: #dbeafe;
    color: #1d4ed8;
}

.rf-status-closed {
    background: #dcfce7;
    color: #166534;
}

.review-detail-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.review-detail-head h3 {
    margin: 0 0 6px;
}

.review-detail-head p {
    margin: 0;
    color: #64748b;
}

.review-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.review-summary-grid div {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
}

.review-summary-grid span {
    display: block;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.review-summary-grid strong {
    color: #0f172a;
}

.review-update-form {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 18px;
}

.review-answer-list {
    display: grid;
    gap: 14px;
}

.review-answer-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
}

.review-answer-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.answer-correct {
    color: #166534;
    font-weight: 800;
}

.answer-wrong {
    color: #991b1b;
    font-weight: 800;
}

.answer-unknown {
    color: #64748b;
    font-weight: 800;
}

.rf-question-section {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 8px;
    line-height: 1.8;
}

.rf-question-section span {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
}

.review-answer-text,
.review-correct-answer {
    background: #f8fafc;
    border-radius: 12px;
    padding: 10px;
    margin-top: 10px;
    line-height: 1.7;
}

.review-handwriting-image {
    margin-top: 12px;
}

.review-handwriting-image img {
    max-width: 100%;
    max-height: 280px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

@media (max-width: 1200px) {
    .review-layout {
        grid-template-columns: 1fr;
    }

    .review-detail-card {
        position: static;
    }

    .review-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .review-filter-grid,
    .review-summary-grid {
        grid-template-columns: 1fr;
    }

    .review-detail-head {
        flex-direction: column;
    }
}
.spg-filter-grid {
    display: grid;
    grid-template-columns: 260px 260px 180px 180px 140px;
    gap: 14px;
    align-items: end;
}

.spg-filter-button {
    margin-bottom: 16px;
}

.spg-student-hero {
    background: linear-gradient(135deg, #0f172a, #1e3a8a);
    color: #fff;
    border-radius: 22px;
    padding: 26px;
    margin-bottom: 22px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
}

.spg-student-hero h2 {
    margin: 0 0 8px;
}

.spg-student-hero p {
    margin: 4px 0;
    color: #dbeafe;
}

.spg-summary-badges {
    display: grid;
    grid-template-columns: repeat(4, 110px);
    gap: 10px;
}

.spg-summary-badges div {
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 14px;
    padding: 12px;
    text-align: center;
}

.spg-summary-badges span {
    display: block;
    font-size: 12px;
    color: #bfdbfe;
    font-weight: 700;
    margin-bottom: 4px;
}

.spg-summary-badges strong {
    font-size: 22px;
}

.spg-course-table {
    min-width: 1300px;
}

.spg-progress-bar {
    width: 100%;
    height: 9px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 6px;
}

.spg-progress-bar div {
    height: 100%;
    background: #2563eb;
    border-radius: 999px;
}

.spg-progress-survival div {
    background: #dc2626;
}

.spg-review-badge {
    display: inline-block;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 800;
    font-size: 12px;
}

.spg-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
    gap: 22px;
    align-items: start;
}

.spg-attempt-list-card,
.spg-attempt-detail-card {
    min-width: 0;
}

.spg-attempt-detail-card {
    position: sticky;
    top: 18px;
}

.spg-attempt-table {
    min-width: 1200px;
}

.spg-status {
    display: inline-block;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
}

.spg-status-passed {
    background: #dcfce7;
    color: #166534;
}

.spg-status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.spg-status-in_progress {
    background: #dbeafe;
    color: #1d4ed8;
}

.spg-attempt-detail-head {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.spg-attempt-detail-head h3 {
    margin: 0 0 8px;
}

.spg-attempt-detail-head p {
    margin: 0;
    color: #64748b;
}

.spg-detail-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.spg-detail-summary-grid div {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
}

.spg-detail-summary-grid span {
    display: block;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.spg-detail-summary-grid strong {
    color: #0f172a;
}

.spg-answer-list {
    display: grid;
    gap: 14px;
}

.spg-answer-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
}

.spg-answer-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.answer-correct {
    color: #166534;
    font-weight: 800;
}

.answer-wrong {
    color: #991b1b;
    font-weight: 800;
}

.answer-unknown {
    color: #64748b;
    font-weight: 800;
}

.spg-question-section {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 8px;
    line-height: 1.8;
}

.spg-question-section span {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
}

.spg-answer-text,
.spg-correct-answer,
.spg-explanation {
    background: #f8fafc;
    border-radius: 12px;
    padding: 10px;
    margin-top: 10px;
    line-height: 1.7;
}

.spg-explanation {
    border-left: 4px solid #2563eb;
}

.spg-answer-image {
    margin-top: 12px;
}

.spg-answer-image img {
    max-width: 100%;
    max-height: 280px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

@media (max-width: 1200px) {
    .spg-layout {
        grid-template-columns: 1fr;
    }

    .spg-attempt-detail-card {
        position: static;
    }

    .spg-summary-badges,
    .spg-detail-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .spg-filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .spg-student-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .spg-summary-badges,
    .spg-detail-summary-grid,
    .spg-filter-grid {
        grid-template-columns: 1fr;
        width: 100%;
    }
}
.spg-subject-completion-table {
    min-width: 1100px;
}

.spg-subject-completion-table th,
.spg-subject-completion-table td {
    vertical-align: middle;
}
.export-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.solution-help-box {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 16px;
    padding: 16px;
    margin: 18px 0;
}

.solution-box {
    margin-top: 14px;
    background: #fff;
    border: 2px solid #fb923c;
    border-radius: 16px;
    padding: 18px;
}

.solution-box h3 {
    margin-top: 0;
    color: #9a3412;
}

.solution-section,
.solution-answer {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    line-height: 1.8;
    margin-bottom: 14px;
}

.solution-understood-btn {
    width: 100%;
    background: #ea580c;
    margin-top: 12px;
}

.solution-understood-btn:hover {
    background: #c2410c;
}
.lbs-priority-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.lbs-priority-flow div {
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 800;
}

.lbs-priority-flow span {
    color: #64748b;
    font-weight: 800;
}

.lbs-form-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 14px;
    align-items: end;
}

.lbs-form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.lbs-setting-box {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    margin: 16px 0;
}

.lbs-setting-box h3 {
    margin-top: 0;
}

.lbs-recommend-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.lbs-recommend-box div {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 12px;
    padding: 12px;
    font-weight: 800;
}

.lbs-table {
    min-width: 1300px;
}

.lbs-pill {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
}

.lbs-on {
    background: #dcfce7;
    color: #166534;
}

.lbs-off {
    background: #f1f5f9;
    color: #64748b;
}

@media (max-width: 900px) {
    .lbs-form-grid,
    .lbs-form-grid-2,
    .lbs-recommend-box {
        grid-template-columns: 1fr;
    }
}
.solution-used-badge-box {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 10px 12px;
    margin: 10px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.solution-used-badge {
    display: inline-block;
    background: #ea580c;
    color: #fff;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
}
.survival-btn {
    background: #dc2626;
    color: #fff;
}

.survival-btn:hover {
    background: #b91c1c;
}

.student-survival-note {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 12px;
    padding: 10px 12px;
    margin-top: 10px;
    font-weight: 700;
}
.solution-help-box {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 16px;
    padding: 16px;
    margin: 18px 0;
}

.solution-box {
    margin-top: 14px;
    background: #fff;
    border: 2px solid #fb923c;
    border-radius: 16px;
    padding: 18px;
}

.solution-box h3 {
    margin-top: 0;
    color: #9a3412;
}

.solution-section,
.solution-answer {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    line-height: 1.8;
    margin-bottom: 14px;
}

.solution-understood-btn {
    width: 100%;
    background: #ea580c;
    margin-top: 12px;
}

.solution-understood-btn:hover {
    background: #c2410c;
}

.result-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 18px;
}

.survival-btn {
    background: #dc2626;
    color: #fff;
}

.survival-btn:hover {
    background: #b91c1c;
}