
    * { box-sizing: border-box; margin: 0; padding: 0; }
    html, body { height: 100%; }
    body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        line-height: 1.6;
        background: #f5f7fa;
        color: #2c3e50;
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    header {
        background: #2c3e50;
        color: #bbb;
        padding: 0.85rem 2rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
    }
    header p, footer p { color: inherit; margin-bottom: 0; }
    header nav, header .user-info {
        display: flex;
        align-items: center;
        line-height: 1.5;
        font-size: 1rem;
    }
    header nav a {
        color: #fff;
        margin-right: 1.5rem;
        text-decoration: none;
        font-weight: 500;
    }
    header nav a:hover { opacity: 0.8; }
    header nav a:last-child { margin-right: 0; }
    header .user-info { color: #bbb; white-space: nowrap; }
    header .user-info * { color: inherit; }
    header .user-info a { margin-left: 1rem; color: #b0d8ff; }

    main.container {
        flex: 1;
        max-width: 800px;
        width: 100%;
        margin: 0 auto;
        padding: 2rem 1rem;
    }

    .card {
        background: white;
        border-radius: 12px;
        padding: 2rem;
        margin-bottom: 1.5rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }

    h1 { color: #2c3e50; margin-bottom: 1rem; }
    h2 { color: #34495e; margin-bottom: 0.75rem; margin-top: 1.5rem; }
    p { color: #555; margin-bottom: 1rem; }
    a { color: #3498db; text-decoration: none; }
    a:hover { color: #2980b9; text-decoration: underline; }

    .reading-body {
        background: #fafbfc;
        border-left: 4px solid #3498db;
        padding: 1.25rem 1.5rem;
        border-radius: 6px;
        margin: 1rem 0 1.5rem;
        white-space: pre-wrap;
        font-size: 1.05rem;
    }

    .question-block { margin-bottom: 1.5rem; }
    .question-block label {
        display: block;
        font-weight: 600;
        color: #34495e;
        margin-bottom: 0.5rem;
    }
    .question-block textarea {
        width: 100%;
        min-height: 90px;
        padding: 0.75rem;
        border: 2px solid #e0e0e0;
        border-radius: 6px;
        font-family: inherit;
        font-size: 1rem;
        resize: vertical;
    }
    .question-block textarea:focus { outline: none; border-color: #3498db; }

    .form-group { margin-bottom: 1.25rem; }
    .form-group > label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: #34495e; }
    .form-group input[type="text"], .form-group input[type="number"],
    .form-group input[type="email"], .form-group input[type="password"],
    .form-group textarea, .form-group select {
        width: 100%; padding: 0.6rem 0.75rem;
        border: 2px solid #e2e8f0; border-radius: 8px; font-size: 0.95rem; font-family: inherit; background: #fff;
    }
    .form-group textarea { min-height: 90px; resize: vertical; }
    .form-group input:focus, .form-group textarea:focus, .form-group select:focus {
        outline: none; border-color: #3498db; box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
    }

    button, .btn {
        background: #3498db; color: white; border: none;
        padding: 0.75rem 1.5rem; border-radius: 6px; cursor: pointer;
        font-size: 1rem; font-weight: 500; text-decoration: none; display: inline-block;
    }
    button:hover, .btn:hover { background: #2980b9; color: #fff; text-decoration: none; }
    button[disabled], .btn[disabled], button.btn-loading, .btn.btn-loading {
        opacity: 0.75; cursor: progress;
    }
    .spinner {
        display: inline-block; width: 1em; height: 1em;
        margin-right: 0.4em; vertical-align: -0.125em;
        border: 2px solid currentColor; border-right-color: transparent;
        border-radius: 50%; animation: percipio-spin 0.7s linear infinite;
    }
    @keyframes percipio-spin { to { transform: rotate(360deg); } }
    .btn-secondary { background: #6c757d; }
    .btn-secondary:hover { background: #545b62; }

    .skill-tag {
        display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
        text-transform: uppercase; color: #fff; background: #6c757d;
        padding: 0.1rem 0.5rem; border-radius: 10px; margin-right: 0.5rem;
        vertical-align: middle;
    }
    .skill-tag.comprehension { background: #2980b9; }
    .skill-tag.inference { background: #8e44ad; }
    .skill-tag.logic { background: #c0392b; }
    .skill-tag.application { background: #16a085; }
    .skill-tag.terminology { background: #d35400; }
    .skill-tag.evaluation { background: #34495e; }
    .skill-tag.thesis { background: #0e6655; }
    .skill-summary {
        text-align: center; font-size: 0.95rem; color: #34495e;
        padding: 0.6rem 1rem; background: #f0f3f7; border-radius: 6px; margin: 0.75rem 0;
    }
    .skill-summary strong { color: #2c3e50; }

    .alert { padding: 1rem; border-radius: 6px; margin-bottom: 1rem; }
    .alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
    .alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
    .error-message { color: #dc3545; font-size: 0.9rem; margin-top: 0.5rem; }

    .challenge-list { list-style: none; }
    .challenge-list li {
        padding: 1rem 1.25rem;
        background: #fafbfc;
        border-radius: 8px;
        margin-bottom: 0.75rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .challenge-list .meta { color: #7f8c8d; font-size: 0.9rem; }
    .score-badge {
        background: #3498db; color: white; padding: 0.25rem 0.75rem;
        border-radius: 20px; font-weight: 600; font-size: 0.85rem; white-space: nowrap;
    }
    .score-badge.none { background: #bdc3c7; }

    .result-item {
        padding: 1rem; margin-bottom: 1rem; border-radius: 8px;
        background: #fafbfc; border-left: 4px solid #3498db;
    }
    .result-item .score { font-weight: 700; color: #2c3e50; }
    .result-item .label { font-weight: 600; color: #34495e; margin-top: 0.5rem; display: block; }
    .result-item .feedback, .result-item .model-answer { color: #555; margin-top: 0.25rem; }
    .total-score {
        text-align: center; font-size: 1.5rem; font-weight: 700;
        color: #2c3e50; padding: 1rem; background: #eaf4fb; border-radius: 8px; margin: 1rem 0;
    }
    .reading-body { margin-bottom: 1.5rem; }
    .question-block { margin-bottom: 1.5rem; }
    .question-block label {
        display: block; font-weight: 600; color: #34495e; margin-bottom: 0.5rem;
    }
    .question-block textarea {
        width: 100%; min-height: 90px; padding: 0.75rem;
        border: 2px solid #e0e0e0; border-radius: 6px;
        font-family: inherit; font-size: 1rem; resize: vertical;
    }
    .question-block textarea:focus { outline: none; border-color: #3498db; }

    table.progress { width: 100%; border-collapse: collapse; }
    table.progress th, table.progress td {
        text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid #eee;
    }
    table.progress th { color: #34495e; }

    footer {
        background: #2c3e50; color: #bbb;
        padding: 1.25rem; text-align: center; flex-shrink: 0;
    }

    .spry-login-form { max-width: 400px; }
    .login-btn { width: 100%; margin-top: 1rem; }

    /* ---- Admin layout ---- */
    .admin-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
    .admin-section {
        background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
        padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
    }
    .admin-section > h2 {
        margin-top: 0; font-size: 1.1rem; color: #2c3e50;
        border-bottom: 2px solid #eef2f7; padding-bottom: 0.6rem; margin-bottom: 1rem;
    }
    .admin-section p.muted, p.muted { color: #7f8c8d; font-size: 0.9rem; margin-bottom: 1rem; }
    .subhead { font-size: 1rem; color: #34495e; margin: 1.25rem 0 0.75rem; }
    .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
    .form-group.compact { margin-bottom: 0; }
    .form-group .checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; cursor: pointer; }
    .form-group .checkbox-label input { width: auto; }
    .admin-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.25rem; }

    /* ---- Question cards ---- */
    .question-card {
        border: 1px solid #e2e8f0; border-radius: 10px; padding: 1rem 1.25rem;
        margin-bottom: 1rem; background: #fbfcfd;
    }
    .question-card .q-head { display: flex; gap: 1rem; align-items: flex-end; margin-bottom: 0.75rem; flex-wrap: wrap; }
    .question-card .q-head .form-group { flex: 0 0 12rem; }
    .q-delete { display: inline; }
    .hidden-delete { display: none; }
    .btn-danger { background: #c0392b; }
    .btn-danger:hover { background: #a93226; }

    .actions-row { display: flex; flex-wrap: wrap; row-gap: 1rem; column-gap: 0.75rem; align-items: center; margin-top: 1.5rem; }

    /* ---- Generate grid ---- */
    .generate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
    .gen-type {
        display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
        border: 1px solid #e2e8f0; border-radius: 8px; padding: 0.55rem 0.8rem;
        background: #fff; font-size: 0.9rem; color: #34495e;
    }
    .gen-type input { width: 3.5rem; padding: 0.3rem; border: 2px solid #e2e8f0; border-radius: 6px; text-align: center; }
    .gen-dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.45rem; vertical-align: middle; padding: 0; }

    /* ---- Danger zone ---- */
    .admin-section.danger-zone { border-color: #f5c6cb; background: #fff8f8; }
    .admin-section.danger-zone > h2 { color: #c0392b; border-color: #f5c6cb; }

    select { cursor: pointer; }
    code { background: #f0f3f7; padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.9em; color: #2c3e50; }

    /* ---- Challenge two-pane layout ---- */
    body { overflow-x: hidden; }
    .challenge-layout {
        /* Break out of the 800px container so the two panes have room. */
        width: 100vw;
        margin-left: calc(50% - 50vw);
        padding: 0 1rem;
    }
    .challenge-split {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 1.5rem;
        align-items: start;
        max-width: 1180px;
        margin: 0 auto;
    }
    .challenge-pane {
        background: #fff;
        border-radius: 12px;
        padding: 1.5rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    .challenge-pane h1 { font-size: 1.4rem; }
    .challenge-passage {
        position: sticky;
        top: 5rem;
        max-height: calc(100vh - 6.5rem);
        overflow-y: auto;
    }
    .challenge-passage .reading-body { margin: 0.5rem 0 0; }
    @media (max-width: 860px) {
        .challenge-split { grid-template-columns: 1fr; }
        .challenge-passage { position: static; max-height: none; }
        .challenge-layout { width: auto; margin-left: 0; padding: 0; }
    }
    