/* ================================================================
   EducationHUB Resources — Shared Design System
   Warm professional palette: Fraunces serif + Switzer sans
   ================================================================ */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&display=swap');
@import url('https://api.fontshare.com/v2/css?f[]=switzer@400,500,600,700&display=swap');

/* ----------------------------------------------------------------
   Design tokens
   ---------------------------------------------------------------- */
:root {
    --r-font:          'Switzer', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --r-font-display:  'Fraunces', Georgia, 'Times New Roman', serif;

    /* Colours */
    --r-bg:            #faf7f1;
    --r-surface:       #ffffff;
    --r-text:          #1a1814;
    --r-text-muted:    #615b4e;
    --r-accent:        #2d5a3d;
    --r-accent-soft:   #436f52;
    --r-accent-tint:   rgba(45, 90, 61, 0.08);
    --r-border:        #e6dfcf;
    --r-shadow:        0 1px 3px rgba(26, 24, 18, 0.06), 0 1px 2px rgba(26, 24, 18, 0.04);
    --r-shadow-md:     0 4px 12px rgba(26, 24, 18, 0.08);

    /* Radii */
    --r-radius:        10px;
    --r-radius-lg:     16px;
    --r-radius-sm:     6px;

    /* Spacing */
    --r-space-1:       4px;
    --r-space-2:       8px;
    --r-space-3:       12px;
    --r-space-4:       16px;
    --r-space-5:       20px;
    --r-space-6:       24px;
    --r-space-8:       32px;
    --r-space-12:      48px;

    /* Typography scale */
    --r-text-xs:   11px;
    --r-text-sm:   13px;
    --r-text-base: 14px;
    --r-text-md:   16px;
    --r-text-lg:   20px;
    --r-text-xl:   24px;
    --r-text-2xl:  32px;
}

/* ----------------------------------------------------------------
   Reset & base
   ---------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--r-font);
    background: var(--r-bg);
    color: var(--r-text);
    line-height: 1.55;
    min-height: 100vh;
}

img, svg { display: block; }

a {
    color: var(--r-accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ----------------------------------------------------------------
   Code entry screen (full-page overlay)
   ---------------------------------------------------------------- */
#code-screen {
    position: fixed;
    inset: 0;
    background: var(--r-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--r-space-4);
}

.r-code-card {
    background: var(--r-surface);
    padding: var(--r-space-12) 40px;
    border-radius: var(--r-radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.r-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--r-space-2) + 2px;
    gap: 10px;
    margin-bottom: var(--r-space-6);
    color: var(--r-accent);
}

.r-brand span {
    font-family: var(--r-font-display);
    font-size: var(--r-text-md);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.r-code-card h2 {
    font-family: var(--r-font-display);
    font-size: var(--r-text-xl);
    font-weight: 600;
    margin-bottom: var(--r-space-2);
    color: var(--r-text);
}

.r-code-card > p {
    font-size: var(--r-text-sm);
    color: var(--r-text-muted);
    margin-bottom: var(--r-space-6);
    line-height: 1.6;
}

.r-code-card input[type="text"] {
    width: 100%;
    padding: var(--r-space-4);
    font-size: 28px;
    text-align: center;
    letter-spacing: 0.3em;
    border: 2px solid var(--r-border);
    border-radius: var(--r-radius);
    margin-bottom: var(--r-space-4);
    font-family: var(--r-font);
    font-weight: 600;
    color: var(--r-text);
    background: var(--r-bg);
    transition: border-color 0.15s;
}

.r-code-card input[type="text"]:focus {
    outline: none;
    border-color: var(--r-accent);
    box-shadow: 0 0 0 3px var(--r-accent-tint);
}

.r-code-card input[aria-invalid="true"] {
    border-color: #dc2626;
}

.r-error {
    color: #dc2626;
    font-size: var(--r-text-sm);
    margin-top: var(--r-space-2);
}

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.r-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--r-space-2);
    padding: 10px 20px;
    border-radius: var(--r-radius-sm) + 2px;
    border-radius: 8px;
    border: none;
    font-family: var(--r-font);
    font-weight: 600;
    font-size: var(--r-text-base);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.r-btn:focus-visible {
    outline: 2px solid var(--r-accent);
    outline-offset: 2px;
}

/* Primary */
.r-btn-primary {
    background: var(--r-accent);
    color: #fff;
    width: 100%;
    padding: 14px;
    font-size: 15px;
}

.r-btn-primary:hover { background: var(--r-accent-soft); }
.r-btn-primary:active { opacity: 0.85; }

.r-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Secondary */
.r-btn-secondary {
    background: var(--r-surface);
    color: var(--r-text);
    border: 1.5px solid var(--r-border);
}

.r-btn-secondary:hover { background: var(--r-accent-tint); border-color: var(--r-accent); }

/* Ghost */
.r-btn-ghost {
    background: none;
    color: var(--r-accent);
    padding: 8px 12px;
}

.r-btn-ghost:hover { background: var(--r-accent-tint); }

/* Danger */
.r-btn-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1.5px solid #fecaca;
}

.r-btn-danger:hover { background: #fee2e2; }

/* Size modifiers */
.r-btn-sm {
    padding: 6px 14px;
    font-size: var(--r-text-xs) + 1px;
    font-size: 12px;
    border-radius: 6px;
}

.r-btn-lg {
    padding: 14px 28px;
    font-size: var(--r-text-md);
}

/* ----------------------------------------------------------------
   Cards
   ---------------------------------------------------------------- */
.r-card {
    background: var(--r-surface);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    padding: var(--r-space-6);
    box-shadow: var(--r-shadow);
}

.r-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--r-space-4);
    padding-bottom: var(--r-space-4);
    border-bottom: 1px solid var(--r-border);
}

.r-card-title {
    font-family: var(--r-font-display);
    font-size: var(--r-text-md);
    font-weight: 600;
}

/* ----------------------------------------------------------------
   Form fields
   ---------------------------------------------------------------- */
.r-field {
    margin-bottom: var(--r-space-4) - 2px;
    margin-bottom: 14px;
}

.r-field label {
    display: block;
    font-size: var(--r-text-xs);
    font-weight: 600;
    color: var(--r-text-muted);
    margin-bottom: var(--r-space-1);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.r-input,
.r-select,
.r-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--r-border);
    border-radius: 8px;
    font-family: var(--r-font);
    font-size: var(--r-text-base);
    color: var(--r-text);
    background: var(--r-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.r-input::placeholder,
.r-textarea::placeholder {
    color: #b0a898;
}

.r-input:focus,
.r-select:focus,
.r-textarea:focus {
    outline: none;
    border-color: var(--r-accent);
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.12);
}

.r-textarea {
    min-height: 80px;
    resize: vertical;
    line-height: 1.55;
}

.r-select {
    appearance: auto;
    cursor: pointer;
}

.r-field-hint {
    font-size: var(--r-text-xs);
    color: var(--r-text-muted);
    margin-top: var(--r-space-1);
}

/* Checkbox / radio */
.r-checkbox,
.r-radio {
    display: flex;
    align-items: center;
    gap: var(--r-space-2);
    font-size: var(--r-text-sm);
    color: var(--r-text-muted);
    cursor: pointer;
    user-select: none;
}

.r-checkbox input,
.r-radio input {
    width: 16px;
    height: 16px;
    accent-color: var(--r-accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ----------------------------------------------------------------
   Modal
   ---------------------------------------------------------------- */
.r-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    padding: var(--r-space-4);
}

.r-modal {
    background: var(--r-surface);
    padding: var(--r-space-8);
    border-radius: var(--r-radius-lg);
    max-width: 440px;
    width: 100%;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
}

.r-modal h3 {
    font-family: var(--r-font-display);
    font-size: var(--r-text-lg);
    font-weight: 600;
    margin-bottom: var(--r-space-2);
}

.r-modal > p {
    font-size: var(--r-text-sm);
    color: var(--r-text-muted);
    margin-bottom: var(--r-space-5);
    line-height: 1.6;
}

.r-modal-footer {
    display: flex;
    gap: var(--r-space-2);
    justify-content: flex-end;
    margin-top: var(--r-space-5);
}

.r-modal-footer .r-btn {
    width: auto;
    padding: 10px 20px;
    font-size: var(--r-text-base);
}

/* ----------------------------------------------------------------
   Toast notifications
   ---------------------------------------------------------------- */
.r-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--r-radius-sm) + 2px;
    border-radius: 8px;
    font-size: var(--r-text-sm);
    font-weight: 500;
    z-index: 1100;
    transition: opacity 0.3s ease;
    max-width: 340px;
    box-shadow: var(--r-shadow-md);
    pointer-events: none;
}

.r-toast-info    { background: var(--r-accent); color: #fff; }
.r-toast-success { background: #059669; color: #fff; }
.r-toast-error   { background: #dc2626; color: #fff; }
.r-toast-warning { background: #d97706; color: #fff; }

/* ----------------------------------------------------------------
   Tool page layout
   ---------------------------------------------------------------- */
.r-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--r-space-4) var(--r-space-6);
    border-bottom: 1px solid var(--r-border);
    background: var(--r-surface);
    position: sticky;
    top: 0;
    z-index: 100;
}

.r-header-brand {
    display: flex;
    align-items: center;
    gap: var(--r-space-2);
    text-decoration: none;
    color: inherit;
}

.r-header-brand svg {
    width: 24px;
    height: 24px;
    color: var(--r-accent);
    flex-shrink: 0;
}

.r-header-brand span {
    font-family: var(--r-font-display);
    font-size: var(--r-text-md);
    font-weight: 600;
    color: var(--r-text);
}

.r-header-title {
    font-size: var(--r-text-sm);
    color: var(--r-text-muted);
}

.r-header-actions {
    display: flex;
    gap: var(--r-space-2);
    align-items: center;
}

.r-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--r-space-6);
}

.r-page-title {
    font-family: var(--r-font-display);
    font-size: var(--r-text-2xl);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: var(--r-space-2);
}

.r-page-subtitle {
    font-size: var(--r-text-base);
    color: var(--r-text-muted);
    margin-bottom: var(--r-space-6);
}

/* ----------------------------------------------------------------
   Proficiency tier badges
   ---------------------------------------------------------------- */
.r-tier {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: var(--r-text-xs);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.r-tier-beginning    { background: #dbeafe; color: #1e40af; }
.r-tier-intermediate { background: #fef3c7; color: #92400e; }
.r-tier-advanced     { background: #d1fae5; color: #065f46; }

/* Generic status badges */
.r-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: var(--r-text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.r-badge-green  { background: #d1fae5; color: #065f46; }
.r-badge-blue   { background: #dbeafe; color: #1e40af; }
.r-badge-amber  { background: #fef3c7; color: #92400e; }
.r-badge-gray   { background: #f3f4f6; color: #374151; }

/* ----------------------------------------------------------------
   Tabs
   ---------------------------------------------------------------- */
.r-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--r-border);
    margin-bottom: var(--r-space-5);
    overflow-x: auto;
    scrollbar-width: none;
}

.r-tabs::-webkit-scrollbar { display: none; }

.r-tab {
    padding: 10px 20px;
    font-size: var(--r-text-sm);
    font-weight: 600;
    color: var(--r-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--r-font);
}

.r-tab:hover       { color: var(--r-text); }
.r-tab.active      { color: var(--r-accent); border-bottom-color: var(--r-accent); }
.r-tab:focus-visible { outline: 2px solid var(--r-accent); outline-offset: -2px; }

.r-tab-panel { display: none; }
.r-tab-panel.active { display: block; }

/* ----------------------------------------------------------------
   Data grid / table
   ---------------------------------------------------------------- */
.r-table-wrapper { overflow-x: auto; }

.r-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--r-text-sm);
}

.r-table th {
    text-align: left;
    font-size: var(--r-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--r-text-muted);
    padding: 10px 14px;
    border-bottom: 2px solid var(--r-border);
    white-space: nowrap;
}

.r-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--r-border);
    vertical-align: top;
}

.r-table tr:last-child td { border-bottom: none; }
.r-table tbody tr:hover   { background: var(--r-accent-tint); }

/* ----------------------------------------------------------------
   Empty state
   ---------------------------------------------------------------- */
.r-empty {
    text-align: center;
    padding: var(--r-space-12) var(--r-space-6);
    color: var(--r-text-muted);
}

.r-empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--r-space-4);
    opacity: 0.35;
}

.r-empty h3 {
    font-size: var(--r-text-md);
    font-weight: 600;
    margin-bottom: var(--r-space-2);
    color: var(--r-text);
}

.r-empty p { font-size: var(--r-text-sm); max-width: 340px; margin: 0 auto; }

/* ----------------------------------------------------------------
   Loading spinner
   ---------------------------------------------------------------- */
.r-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--r-border);
    border-top-color: var(--r-accent);
    border-radius: 50%;
    animation: r-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes r-spin { to { transform: rotate(360deg); } }

.r-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--r-space-3);
    padding: var(--r-space-8);
    color: var(--r-text-muted);
    font-size: var(--r-text-sm);
}

/* ----------------------------------------------------------------
   Grid helpers
   ---------------------------------------------------------------- */
.r-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--r-space-4); }
.r-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--r-space-4); }
.r-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--r-space-4); }

@media (max-width: 900px) {
    .r-grid-3, .r-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .r-grid-2, .r-grid-3, .r-grid-4 { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------------
   Divider
   ---------------------------------------------------------------- */
.r-divider {
    border: none;
    border-top: 1px solid var(--r-border);
    margin: var(--r-space-6) 0;
}

/* ----------------------------------------------------------------
   AI callout strip
   ---------------------------------------------------------------- */
.r-ai-strip {
    background: var(--r-accent-tint);
    border: 1px solid rgba(45, 90, 61, 0.2);
    border-radius: var(--r-radius);
    padding: var(--r-space-4) var(--r-space-5);
    display: flex;
    align-items: center;
    gap: var(--r-space-3);
    margin-bottom: var(--r-space-5);
    font-size: var(--r-text-sm);
    color: var(--r-accent);
    font-weight: 500;
}

/* ----------------------------------------------------------------
   Footer
   ---------------------------------------------------------------- */
.r-footer {
    text-align: center;
    padding: var(--r-space-6);
    font-size: var(--r-text-xs);
    color: var(--r-text-muted);
    border-top: 1px solid var(--r-border);
    margin-top: 40px;
}

.r-footer a {
    color: var(--r-accent);
    text-decoration: none;
}

.r-footer a:hover { text-decoration: underline; }

/* ----------------------------------------------------------------
   Print styles
   ---------------------------------------------------------------- */
@media print {
    /* Hide chrome */
    #code-screen,
    .r-header,
    .r-footer,
    .r-tabs,
    .r-btn,
    .no-print,
    .r-toast,
    .r-modal-overlay,
    .r-ai-strip { display: none !important; }

    body  { background: #fff; color: #000; }

    .r-main {
        max-width: none;
        padding: 0;
        margin: 0;
    }

    .r-card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    /* Print formats */
    body.print-poster  { font-size: 24pt; }
    body.print-slide   { /* intentionally minimal */ }

    body.print-handout .frame-card { page-break-inside: avoid; }
}

/* ----------------------------------------------------------------
   Responsive overrides
   ---------------------------------------------------------------- */
@media (max-width: 768px) {
    .r-main { padding: var(--r-space-4); }

    .r-header {
        flex-wrap: wrap;
        gap: var(--r-space-2);
        padding: var(--r-space-3) var(--r-space-4);
    }

    .r-header-title { display: none; } /* save space on mobile */

    .r-code-card { padding: var(--r-space-8) var(--r-space-6); }
}

@media (max-width: 480px) {
    .r-modal { padding: var(--r-space-5); }
    .r-btn-primary { font-size: var(--r-text-base); }
}

/* ================================================================
   StudentApp — student-facing identity gate + page chrome
   Used by Annotation, Error Analysis, Perspective Switch, Essay
   ================================================================ */

/* ----------------------------------------------------------------
   Identity gate overlay
   ---------------------------------------------------------------- */
.sa-gate {
    position: fixed;
    inset: 0;
    background: var(--r-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--r-space-4);
}

.sa-gate-card {
    background: var(--r-surface);
    border-radius: var(--r-radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    padding: var(--r-space-12) 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.sa-gate-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--r-accent);
    margin-bottom: var(--r-space-6);
}

.sa-gate-brand span {
    font-family: var(--r-font-display);
    font-size: var(--r-text-md);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sa-gate-card h2 {
    font-family: var(--r-font-display);
    font-size: var(--r-text-xl);
    font-weight: 600;
    margin-bottom: var(--r-space-2);
    color: var(--r-text);
}

.sa-gate-card > p {
    font-size: var(--r-text-sm);
    color: var(--r-text-muted);
    margin-bottom: var(--r-space-5);
    line-height: 1.6;
}

.sa-gate-field {
    text-align: left;
    margin-bottom: var(--r-space-3);
}

.sa-gate-field label {
    display: block;
    font-size: var(--r-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--r-text-muted);
    margin-bottom: 6px;
}

.sa-gate-field input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--r-border);
    border-radius: 8px;
    font-family: var(--r-font);
    font-size: var(--r-text-base);
    color: var(--r-text);
    background: var(--r-bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sa-gate-field input:focus {
    outline: none;
    border-color: var(--r-accent);
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.12);
}

.sa-gate-btn {
    display: block;
    width: 100%;
    margin-top: var(--r-space-4);
    padding: 14px;
    background: var(--r-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--r-font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.sa-gate-btn:hover   { background: var(--r-accent-soft); }
.sa-gate-btn:active  { opacity: 0.85; }
.sa-gate-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.sa-gate-error {
    color: #dc2626;
    font-size: var(--r-text-sm);
    margin-top: var(--r-space-3);
    text-align: center;
}

/* ----------------------------------------------------------------
   Student page header (sticky)
   ---------------------------------------------------------------- */
.sa-header {
    display: flex;
    align-items: center;
    gap: var(--r-space-3);
    padding: var(--r-space-3) var(--r-space-5);
    background: var(--r-surface);
    border-bottom: 1px solid var(--r-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.sa-header-brand {
    display: flex;
    align-items: center;
    gap: var(--r-space-2);
    color: var(--r-accent);
}

.sa-header-brand svg { flex-shrink: 0; }

.sa-header-brand span {
    font-family: var(--r-font-display);
    font-weight: 600;
    font-size: var(--r-text-base);
    color: var(--r-text);
}

.sa-header-sep {
    color: var(--r-border);
    font-size: 18px;
    flex-shrink: 0;
}

.sa-header-title {
    font-size: var(--r-text-sm);
    color: var(--r-text-muted);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ----------------------------------------------------------------
   Student page body
   ---------------------------------------------------------------- */
.sa-body {
    max-width: 760px;
    margin: 0 auto;
    padding: var(--r-space-6) var(--r-space-4);
}

.sa-hero {
    margin-bottom: var(--r-space-6);
}

.sa-hero-label {
    font-size: var(--r-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--r-accent);
    margin-bottom: var(--r-space-1);
}

.sa-hero-title {
    font-family: var(--r-font-display);
    font-size: var(--r-text-xl);
    font-weight: 600;
    color: var(--r-text);
    line-height: 1.25;
    margin-bottom: var(--r-space-2);
}

.sa-hero-sub {
    font-size: var(--r-text-sm);
    color: var(--r-text-muted);
}

/* ----------------------------------------------------------------
   Student card (used by slot cards, step cards, etc.)
   ---------------------------------------------------------------- */
.sa-card {
    background: var(--r-surface);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    padding: var(--r-space-5);
    margin-bottom: var(--r-space-4);
    box-shadow: var(--r-shadow);
}

.sa-card-section {
    font-size: var(--r-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--r-accent);
    margin-bottom: var(--r-space-1);
}

.sa-card-prompt {
    font-size: var(--r-text-md);
    font-weight: 600;
    color: var(--r-text);
    margin-bottom: var(--r-space-3);
    line-height: 1.4;
}

.sa-card-hint {
    font-size: var(--r-text-sm);
    color: var(--r-text-muted);
    margin-bottom: var(--r-space-3);
    font-style: italic;
}

.sa-textarea {
    width: 100%;
    min-height: 110px;
    resize: vertical;
    padding: 11px 14px;
    border: 1.5px solid var(--r-border);
    border-radius: 8px;
    font-family: var(--r-font);
    font-size: var(--r-text-base);
    color: var(--r-text);
    background: var(--r-bg);
    line-height: 1.55;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sa-textarea:focus {
    outline: none;
    border-color: var(--r-accent);
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.12);
}

.sa-save-status {
    font-size: var(--r-text-xs);
    color: var(--r-text-muted);
    text-align: right;
    margin-top: var(--r-space-1);
    min-height: 16px;
}

/* ----------------------------------------------------------------
   Progress bar
   ---------------------------------------------------------------- */
.sa-progress-wrap {
    display: flex;
    align-items: center;
    gap: var(--r-space-3);
    margin-bottom: var(--r-space-5);
}

.sa-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--r-border);
    border-radius: 3px;
    overflow: hidden;
}

.sa-progress-fill {
    height: 100%;
    background: var(--r-accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.sa-progress-label {
    font-size: var(--r-text-xs);
    color: var(--r-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ----------------------------------------------------------------
   Submit bar
   ---------------------------------------------------------------- */
.sa-submit-bar {
    display: flex;
    justify-content: flex-end;
    padding: var(--r-space-4) 0 var(--r-space-8);
}

.sa-submit-btn {
    padding: 12px 32px;
    background: var(--r-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--r-font);
    font-size: var(--r-text-base);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.sa-submit-btn:hover   { background: var(--r-accent-soft); }
.sa-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----------------------------------------------------------------
   Confirmation screen
   ---------------------------------------------------------------- */
.sa-confirm {
    position: fixed;
    inset: 0;
    background: var(--r-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--r-space-6);
    z-index: 500;
}

.sa-confirm-card {
    background: var(--r-surface);
    border-radius: var(--r-radius-lg);
    padding: var(--r-space-12) 40px;
    max-width: 460px;
    width: 100%;
    text-align: center;
    box-shadow: var(--r-shadow-md);
}

.sa-confirm-icon {
    width: 64px;
    height: 64px;
    background: var(--r-accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    margin: 0 auto var(--r-space-5);
}

.sa-confirm-card h2 {
    font-family: var(--r-font-display);
    font-size: var(--r-text-xl);
    font-weight: 600;
    color: var(--r-text);
    margin-bottom: var(--r-space-3);
}

.sa-confirm-card p {
    font-size: var(--r-text-base);
    color: var(--r-text-muted);
    line-height: 1.6;
}

/* ----------------------------------------------------------------
   Word count indicator
   ---------------------------------------------------------------- */
.sa-word-count {
    font-size: var(--r-text-xs);
    color: var(--r-text-muted);
    margin-top: var(--r-space-1);
}

.sa-word-count.sa-word-ok     { color: #059669; }
.sa-word-count.sa-word-short  { color: #d97706; }
.sa-word-count.sa-word-long   { color: #dc2626; }

/* ----------------------------------------------------------------
   AI feedback badge (used in Perspectives check-response)
   ---------------------------------------------------------------- */
.sa-ai-badge {
    display: none;
    margin-top: var(--r-space-3);
    padding: var(--r-space-3) var(--r-space-4);
    border-radius: 8px;
    font-size: var(--r-text-sm);
    line-height: 1.5;
}

.sa-ai-badge.visible        { display: block; }
.sa-ai-badge.sa-ai-strong   { background: #d1fae5; color: #065f46; }
.sa-ai-badge.sa-ai-ok       { background: #fef3c7; color: #92400e; }
.sa-ai-badge.sa-ai-weak     { background: #fee2e2; color: #991b1b; }

/* ----------------------------------------------------------------
   Responsive — tablet / Chromebook (768px – 1366px)
   ---------------------------------------------------------------- */
@media (max-width: 900px) {
    .sa-body { padding: var(--r-space-4) var(--r-space-3); }
    .sa-gate-card { padding: var(--r-space-8) var(--r-space-5); }
    .sa-confirm-card { padding: var(--r-space-8) var(--r-space-5); }
}

@media (max-width: 600px) {
    .sa-header-sep,
    .sa-header-title { display: none; }
    .sa-hero-title { font-size: var(--r-text-lg); }
    .sa-submit-bar { justify-content: stretch; }
    .sa-submit-btn { width: 100%; }
    .sa-gate-card { padding: var(--r-space-6) var(--r-space-4); }
}
