:root {
    --primary: #002147;
    --primary-light: #003366;
    --accent: #5c768d;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-muted: #6c757d;
    --border: #e2e8f0;
    --success: #2e7d32;
    --warning: #d97706;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--primary);
    color: white;
    padding: 16px 24px;
    border-radius: 8px 8px 0 0;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
}

.subject-badge {
    background-color: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    border-top: none;
}

.banner-privacy {
    background-color: #e8f4fd;
    border-left: 4px solid #1976d2;
    padding: 12px 16px;
    margin-bottom: 24px;
    border-radius: 4px;
    font-size: 0.95rem;
}

.highlight-box {
    background-color: #f8fafc;
    border: 1px solid var(--border);
    padding: 18px;
    border-radius: 6px;
    margin-bottom: 24px;
}

.section {
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.section h2 {
    font-size: 1.15rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.question-block {
    margin-bottom: 20px;
}

.question-label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

.help-text {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    margin-top: 4px;
}

.likert-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.likert-option {
    flex: 1;
    min-width: 120px;
    text-align: center;
    border: 1px solid var(--border);
    padding: 10px 8px;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.likert-option:hover {
    border-color: var(--primary);
    background-color: #f0f4f8;
}

.likert-option input {
    margin-right: 6px;
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

.override-badge {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--warning);
    font-weight: 600;
}

.actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 12px 28px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-light);
}

.save-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.success-box {
    text-align: center;
    padding: 40px 20px;
    color: var(--success);
}

.error-heading { color: #d32f2f; margin-bottom: 12px; }
.error-body { margin-bottom: 20px; }
.footer-note { font-size: 0.85rem; color: var(--text-muted); margin-top: 20px; }

/* ---- Wording review highlight (temporary) ---- */
.review-flag {
    background: #fff3b0;
    color: inherit;
    padding: 0 3px;
    border-radius: 3px;
    box-shadow: inset 0 -2px 0 #f0c000;
    cursor: help;
}
.review-legend {
    background: #fffbe6;
    border: 1px dashed #e0b400;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text);
}
.review-legend .review-flag { cursor: default; }

/* ---- Likert matrix ---- */
.matrix-block { margin-bottom: 28px; }
.matrix-title {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 4px;
}
.matrix-block .help-text { margin-bottom: 10px; }

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.matrix-table thead th {
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 6px;
    text-align: center;
    vertical-align: bottom;
    border-bottom: 2px solid var(--border);
}
.matrix-col-head {
    font-size: 0.78rem;
    line-height: 1.2;
    width: 9%;
    cursor: help;
}
.matrix-row-head {
    text-align: left;
    font-weight: 500;
    color: var(--text);
    padding: 10px 12px 10px 4px;
    width: 34%;
}
.matrix-table tbody tr { border-bottom: 1px solid var(--border); }
.matrix-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }
.matrix-cell { text-align: center; padding: 8px 4px; }
.matrix-radio {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 6px 0;
    border-radius: 4px;
    transition: background 0.15s;
}
.matrix-radio:hover { background: rgba(0,33,71,0.06); }
.matrix-radio input { cursor: pointer; }
.matrix-mobile-label { display: none; }

/* Stack matrices into cards on narrow screens */
@media (max-width: 640px) {
    .matrix-table, .matrix-table thead, .matrix-table tbody,
    .matrix-table tr, .matrix-table th, .matrix-table td { display: block; width: 100%; }
    .matrix-table thead { display: none; }
    .matrix-table tbody tr {
        margin-bottom: 16px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: var(--card-bg);
    }
    .matrix-table tbody tr:nth-child(even) { background: var(--card-bg); }
    .matrix-row-head { width: 100%; padding: 0 0 10px; font-weight: 600; }
    .matrix-cell { text-align: left; padding: 3px 0; }
    .matrix-radio { justify-content: flex-start; gap: 8px; }
    .matrix-mobile-label { display: inline; font-size: 0.9rem; }
}

/* ---- Dark mode (follows the visitor's OS/browser preference) ---- */
@media (prefers-color-scheme: dark) {
    :root {
        --primary: #1c3d5f;
        --primary-light: #274d75;
        --accent: #7f97ad;
        --bg: #0f141a;
        --card-bg: #1a212b;
        --text: #e2e8f0;
        --text-muted: #9aa7b5;
        --border: #313c4a;
        --success: #6fcf7f;
        --warning: #f0a94a;
    }

    .card { box-shadow: 0 4px 16px rgba(0,0,0,0.5); }

    .banner-privacy {
        background-color: #12263a;
        border-left-color: #3b82f6;
    }

    .highlight-box { background-color: #131a23; }

    .likert-option { background: #131a23; }
    .likert-option:hover { background-color: #1f2937; }

    .form-control {
        background-color: #131a23;
        color: var(--text);
    }
    .form-control::placeholder { color: var(--text-muted); }

    code {
        background-color: #131a23;
        color: #e2e8f0;
        padding: 1px 5px;
        border-radius: 3px;
    }

    .error-heading { color: #f87171; }

    a { color: #7fb0ec; }

    .review-flag {
        background: #4a3d00;
        color: #ffe57a;
        box-shadow: inset 0 -2px 0 #7a6400;
    }
    .review-legend {
        background: #22200f;
        border-color: #7a6400;
    }
    .review-legend .review-flag { color: #ffe57a; }

    .matrix-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
    .matrix-radio:hover { background: rgba(255,255,255,0.06); }
    @media (max-width: 640px) {
        .matrix-table tbody tr,
        .matrix-table tbody tr:nth-child(even) { background: #131a23; }
    }
}
