:root {
    --primary: #007BFF;
    --primary-dark: #0056b3;
    --text-main: #2d3748;
    --bg-canvas: #f7fafc;
    --card-border: #cbd5e1;
    --slogan: #718096;
    --gold: #d69e2e;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background-color: var(--bg-canvas);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100%;
}

/* ── Canvas viewport engine ── */
.app-shell {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

@media (min-width: 769px) {
    .app-container {
        max-width: 700px;
        margin: 2rem auto;
        padding: 0 16px 2rem;
    }
    .workspace-card {
        border-radius: 16px;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
    }
}

@media (max-width: 768px) {
    body { padding: 0; overflow-x: hidden; }
    .app-container {
        width: 100vw;
        min-height: 100vh;
        margin: 0;
        padding: 12px;
        max-width: none;
    }
    .workspace-card {
        width: 100%;
        border-radius: 0;
        box-shadow: none;
        border-left: none;
        border-right: none;
        padding: 16px 12px;
    }
    .option-btn { min-height: 52px; padding: 16px 12px; font-size: 16px; }
    .pool-tile { min-height: 72px; }
    .btn-drill-start { min-height: 56px; font-size: 17px; }
}

/* ── Persistent corporate header ── */
.corp-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0 10px;
    flex-shrink: 0;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 12px;
}

.corp-header-logo {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.corp-header-logo img {
    max-width: 40px;
    max-height: 40px;
    object-fit: contain;
    display: block;
}

.corp-header-text {
    flex: 1;
    min-width: 0;
}

.corp-header-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #1a202c;
    line-height: 1.25;
    letter-spacing: 0.01em;
}

.corp-header-slogan {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--slogan);
    margin-top: 2px;
    line-height: 1.3;
}

.corp-header-actions {
    flex-shrink: 0;
}

.btn-stop-low {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #718096;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-stop-low:hover,
.btn-stop-low:active {
    border-color: #e53e3e;
    color: #e53e3e;
    background: #fff5f5;
}

.btn-stop-low.hidden { display: none; }

/* ── Workspace ── */
.workspace-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 20px;
    position: relative;
    overflow: hidden;
    flex: 1;
}

.view-panel { display: none; }
.view-panel.active { display: block; }

/* Assessment countdown (top of card) */
.timer-container {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: #e53e3e;
    transform-origin: left;
}

.status-badge {
    display: none;
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    color: #4a5568;
    margin-bottom: 14px;
    text-align: center;
}

/* ── Ongoing session (Assessment + Drill shared) ── */
.ongoing-session {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.session-progress-wrap {
    margin-bottom: 14px;
}

.session-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78em;
    color: #a0aec0;
    margin-bottom: 6px;
}

.session-progress-track {
    width: 100%;
    height: 5px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.session-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #4299e1);
    border-radius: 999px;
    transition: width 0.35s ease;
    width: 0%;
}

.prompt-box {
    text-align: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 16px;
    margin-bottom: 10px;
}

.prompt-box-word {
    font-size: 1.45em;
    font-weight: 700;
    color: #1a202c;
    line-height: 1.4;
    word-break: break-word;
}

.question-hint {
    font-size: 0.85em;
    color: #718096;
    text-align: center;
    margin-bottom: 14px;
}

/* 6-option grid — mirrors assessment ongoing layout */
.options-grid-six {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}

@media (max-width: 480px) {
    .options-grid-six {
        grid-template-columns: 1fr;
    }
    .prompt-box-word { font-size: 1.22em; }
    .prompt-box { padding: 16px 12px; }
    .question-hint { font-size: 0.8em; }
}

.option-btn {
    width: 100%;
    padding: 12px 10px;
    background: #fff;
    border: 1.5px solid var(--card-border);
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: flex-start;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.option-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.option-btn:active,
.option-btn.selected {
    background: #f0f7ff;
    border-color: var(--primary);
    color: var(--primary);
}

.option-label {
    background: #f1f5f9;
    color: #64748b;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.option-text-wrap {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.option-text-primary {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.option-text-secondary {
    display: block;
    font-size: 0.82em;
    font-weight: 500;
    color: #718096;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* Triple anchor (Active pool drill only) */
.triple-anchor-box {
    margin: 0 0 14px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #fffbeb 0%, #f0fff4 100%);
    border: 1px solid #f6e05e;
    border-radius: 10px;
    font-size: 0.84em;
    line-height: 1.6;
    color: #2d3748;
}

.triple-anchor-box .anchor-line { margin-bottom: 6px; }
.triple-anchor-box .anchor-line:last-child { margin-bottom: 0; }

/* Dashboard (distinct from ongoing — cover style OK here) */
.pool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 16px 0;
}

@media (min-width: 500px) {
    .pool-grid { grid-template-columns: repeat(4, 1fr); }
}

.pool-tile {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
}

.pool-tile .pool-num {
    font-size: 1.6em;
    font-weight: 800;
    color: var(--primary);
}

.pool-tile .pool-label {
    font-size: 0.72em;
    color: #718096;
    font-weight: 600;
    margin-top: 4px;
}

.dash-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: #718096;
    margin-bottom: 8px;
}

.dash-stat-row strong { color: #2d3748; }

input[type="text"], input[type="email"], input[type="number"] {
    width: 100%;
    padding: 16px;
    border: 1.5px solid var(--card-border);
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 14px;
    background: #f8fafc;
}

button.action-submit, .btn-drill-start {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

button.action-submit:disabled, .btn-drill-start:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    padding: 14px;
    background: #fff;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

.btn-track-assessment {
    width: auto;
    max-width: 100%;
    display: inline-block;
    padding: 8px 14px;
    margin: 0 0 10px;
    background: #fff;
    color: #4a5568;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: none;
}
.btn-track-assessment:hover {
    background: #f7fafc;
    border-color: #a0aec0;
}
.btn-track-drill { margin-top: 0; }

.info-banner {
    margin: 8px 0 12px;
    padding: 10px 12px;
    font-size: 0.9em;
    line-height: 1.45;
    color: #2d3748;
    background: #ebf8ff;
    border: 1px solid #90cdf4;
    border-radius: 8px;
}

/* ── Bookmarklet sync card ── */
.bookmarklet-card {
    margin: 16px 0 18px;
    padding: 16px 14px;
    border-radius: 14px;
    border: 1px solid #bee3f8;
    background: linear-gradient(145deg, #ebf8ff 0%, #f0fff4 100%);
    box-shadow: 0 4px 14px rgba(0, 123, 255, 0.08);
}

.bookmarklet-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a365d;
    margin-bottom: 8px;
    line-height: 1.35;
}

.bookmarklet-card-lead {
    font-size: 0.88rem;
    color: #4a5568;
    margin-bottom: 8px;
}

.bookmarklet-drag-hint {
    font-size: 0.84rem;
    color: #4a5568;
    margin-bottom: 8px;
}

.bookmarklet-drag-btn {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 14px 16px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2b7de9 0%, #1a5fbf 100%);
    color: #fff !important;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: grab;
    box-shadow: 0 6px 16px rgba(43, 125, 233, 0.35);
    user-select: none;
    -webkit-user-drag: element;
}

.bookmarklet-drag-btn:hover {
    filter: brightness(1.05);
}

.bookmarklet-drag-btn:active {
    cursor: grabbing;
}

.bookmarklet-steps {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.86rem;
    color: #2d3748;
    line-height: 1.55;
}

.bookmarklet-steps li {
    margin-bottom: 6px;
}

.bookmarklet-steps li:last-child {
    margin-bottom: 0;
}

.btn-drill-start.btn-disabled-look,
.btn-drill-start:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    opacity: 0.85;
}

.drill-hint-banner {
    font-size: 0.88em;
    color: #718096;
    background: #fffaf0;
    border: 1px solid #f6e05e;
    border-radius: 10px;
    padding: 12px;
    margin: 12px 0;
    line-height: 1.5;
}

.dash-section-label {
    font-size: 0.9em;
    color: #718096;
    margin: 12px 0 4px;
}

.pool-inspector {
    margin: 14px 0;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.88em;
}

.pool-inspector summary {
    cursor: pointer;
    font-weight: 600;
    color: #2d3748;
    user-select: none;
}

.pool-inspector-meta {
    margin: 10px 0 8px;
    color: #4a5568;
    line-height: 1.5;
}

.pool-inspector-banks {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 420px;
    overflow-y: auto;
}

.pool-bank-block {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
}

.pool-bank-title {
    font-weight: 700;
    color: #007bff;
    margin-bottom: 6px;
}

.pool-bank-levels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.85em;
    color: #718096;
}

.pool-level-group {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #e2e8f0;
}

.pool-level-group:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.pool-level-heading {
    font-weight: 600;
    color: #c53030;
    margin-bottom: 6px;
    font-size: 0.9em;
}

.pool-word-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pool-word-list li {
    background: #edf2f7;
    border-radius: 6px;
    padding: 4px 8px;
    line-height: 1.35;
}

.pool-word-list .pw-word {
    font-weight: 600;
    color: #2d3748;
}

.pool-word-list .pw-def {
    color: #718096;
    font-size: 0.92em;
}

.pool-word-list .pw-meta {
    color: #a0aec0;
    font-size: 0.8em;
    margin-left: 4px;
}

#statusTracker.status-badge { display: block; }

.error-alert {
    color: #c53030;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    padding: 14px;
    border-radius: 10px;
    display: none;
    margin-bottom: 12px;
}

/* Lockout */
.ongoing-session.blurred {
    filter: blur(6px);
    pointer-events: none;
    user-select: none;
}

.lockout-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(247, 250, 252, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.lockout-overlay.visible {
    display: flex;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.medal-card {
    text-align: center;
    max-width: 360px;
    padding: 32px 28px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
    border: 2px solid var(--gold);
}

.medal-icon { font-size: 4rem; margin-bottom: 12px; }
.medal-title { font-size: 1.35em; font-weight: 800; color: #1a202c; margin-bottom: 10px; }
.medal-body { font-size: 0.95em; color: #4a5568; line-height: 1.6; }
.medal-stat { margin-top: 16px; font-size: 1.1em; font-weight: 700; color: var(--gold); }

.btn-dismiss-lockout {
    margin-top: 20px;
    padding: 12px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
}

/* Assessment summary (end page — separate template) */
.summary-panel { text-align: center; padding: 10px 0; }
.summary-panel h2 { color: #3a3568; margin-bottom: 20px; font-size: 1.3em; font-weight: 600; letter-spacing: .3px; }
.summary-stats {
    background: linear-gradient(180deg, #ffffff 0%, #f7f6fd 100%);
    border: 1px solid rgba(85, 72, 160, 0.10);
    padding: 22px 26px;
    border-radius: 16px;
    margin: 14px 0;
    text-align: left;
    color: #4a5568;
    box-shadow: 0 6px 24px rgba(36, 31, 104, 0.07);
}
.summary-stats p { margin: 0 0 13px; font-size: 1.02em; line-height: 1.5; }
.summary-stats p:last-child { margin-bottom: 0; }
.summary-stats p strong { color: #3a3568; font-weight: 600; margin-right: 6px; }
.highlight-blue { color: #5548a0; font-weight: 700; font-size: 1.2em; }
.highlight-red  { color: #b7791f; font-weight: 700; font-size: 1.1em; }
.highlight-green { color: #2c7a7b; font-weight: 700; }
.placement-result-stats p { font-size: 1.08em; margin-bottom: 14px; }
.placement-result-note { text-align: center; color: #4a5568; margin: 8px 0 18px; font-size: 0.95em; }
#assessmentResultsView .btn-track-drill { max-width: 320px; margin: 0 auto; display: block; }
