:root {
    --bg: #f0f4f8;
    --card: #ffffff;
    --text: #1a2332;
    --text-muted: #5c6b7a;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --border: #e2e8f0;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 520px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

.container-wide {
    max-width: 860px;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}

.subtitle {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
}

.card-center {
    text-align: center;
    padding: 3rem 2rem;
}

.page-footer {
    text-align: center;
    margin-top: 1.5rem;
}

.page-footer a {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
textarea,
.file-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
    resize: vertical;
    min-height: 140px;
}

textarea:disabled,
.file-input:disabled {
    background: #f8fafc;
    cursor: not-allowed;
}

.btn {
    display: inline-block;
    padding: 0.7rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 0.9rem 2rem;
    font-size: 1.05rem;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.875rem;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid #fde68a;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    max-width: 480px;
    width: 100%;
    margin: 0;
}

.modal h2 {
    margin-bottom: 1rem;
}

.warning-list {
    margin: 0 0 1.5rem 1.25rem;
    color: var(--text-muted);
}

.warning-list li {
    margin-bottom: 0.5rem;
}

.timer-display {
    background: var(--card);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    text-align: center;
    min-width: 140px;
}

.timer-display.timer-low {
    border-color: var(--error);
    background: var(--error-bg);
}

.timer-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.timer-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
}

.timer-low .timer-value {
    color: var(--error);
}

.task-card {
    margin-bottom: 1.5rem;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.task-header h2 {
    font-size: 1.2rem;
}

.word-hint {
    background: #eff6ff;
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.task-context {
    background: #f8fafc;
    border-left: 4px solid var(--primary);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0 8px 8px 0;
    font-size: 0.95rem;
}

.task-context p {
    margin-top: 0.35rem;
    color: var(--text-muted);
}

.task-prompt {
    font-weight: 500;
    margin-bottom: 1.25rem;
}

.option-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.upload-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--border);
}

.current-upload {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.submit-bar {
    text-align: center;
    padding: 1rem 0 2rem;
}

.success-icon {
    width: 64px;
    height: 64px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1.25rem;
    font-weight: 700;
}

.text-muted {
    color: var(--text-muted);
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-pending {
    background: #fef3c7;
    color: var(--warning);
}

.response-block {
    margin-bottom: 1.5rem;
}

.response-block h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.response-text {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    white-space: pre-wrap;
    line-height: 1.7;
}

.response-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
}

/* Admin review & annotation */
.admin-review .annotate-notice {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.85rem 1.1rem;
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
    color: #1e40af;
}

.annotate-block {
    margin-top: 0.5rem;
}

.annotate-toolbar {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    padding: 0.4rem;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

.annotate-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text);
    transition: background 0.12s, border-color 0.12s;
}

.annotate-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.annotate-btn:active,
.annotate-btn:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.annotate-btn-highlight {
    background: #fef9c3;
    font-weight: 700;
    color: #854d0e;
}

.underline-u {
    text-decoration: underline;
}

.annotate-block .response-text.editable-annotate {
    border-radius: 0 0 8px 8px;
    min-height: 120px;
    cursor: text;
    outline: none;
    white-space: pre-wrap;
}

.annotate-block .response-text.editable-annotate:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.annotate-block .response-text.editable-annotate mark,
.annotate-block .response-text.editable-annotate [style*="background"] {
    background: #fef08a;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.ocr-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--border);
}

.ocr-loading {
    margin-top: 0.75rem;
    color: var(--primary);
    font-size: 0.92rem;
    font-weight: 500;
}

.ocr-result {
    margin-top: 1rem;
}

.ocr-result h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.ocr-unavailable {
    margin-top: 1rem;
    font-size: 0.9rem;
}

.ocr-unavailable code {
    background: #f1f5f9;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .container {
        padding: 1.25rem 1rem;
    }

    .card {
        padding: 1.25rem;
    }

    .header-row {
        flex-direction: column;
    }

    .timer-display {
        width: 100%;
    }
}
