* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: #f9fafb;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1F2933;
    overflow-x: hidden;
}

.auth-bar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    /* Overflow fix: prevents bar from exceeding viewport width at 320px */
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
}


.auth-bar strong {
    font-weight: 700;
}

.auth-link {
    color: #2563EB;
    text-decoration: none;
    font-weight: 600;
}

.auth-link:hover {
    text-decoration: underline;
}

/* Brand wordmark in the auth bar. Across templates the home-link's HTML
   content is the home emoji or the literal word "Home" — we hide that with
   font-size: 0 and inject the CORTIX wordmark via ::before so a single CSS
   change updates every page without touching 40+ templates. */
.home-link {
    color: #fff;
    text-decoration: none;
    font-size: 0;                /* hide whatever sits inside (emoji/text) */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    background: #2563EB;
    font-family: "Inter", system-ui, sans-serif;
    line-height: 1;
    transition: background 0.12s ease;
}
.home-link::before {
    content: "CORTIX";
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.home-link:hover {
    background: #1D4ED8;
}

.auth-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1f2937;
    margin-left: auto;
    margin-right: 12px;
}

.logout-link {
    color: #1f2937;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    font-weight: 600;
}

.logout-link:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.status-pill {
    padding: 6px 10px;
    border-radius: 999px;
    background: #e5e7eb;
    font-size: 12px;
}

.status-pill.guest {
    background: #fff7ed;
    color: #9a3412;
}

.status-name {
    color: #374151;
    font-weight: 600;
    font-size: 14px;
}

.auth-separator {
    color: #9CA3AF;
}

.inline-upgrade {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #eef2ff;
    border-bottom: 1px solid #dbeafe;
    flex-wrap: wrap;
}

.inline-upgrade-text {
    font-weight: 600;
    color: #1f2937;
}

.inline-upgrade-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-upgrade-form input[type="password"] {
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    min-width: min(200px, 100%);
}

.inline-upgrade-form button {
    background: #2563EB;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 9px 12px;
    font-weight: 700;
    cursor: pointer;
}

.inline-upgrade-form button:hover {
    background: #1d4ed8;
}

.auth-form {
    max-width: 420px;
    width: calc(100% - 32px);
    margin: 32px auto;
    padding: 24px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.auth-form h2 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #1F2933;
}

.auth-form label {
    display: block;
    margin-bottom: 6px;
    color: #4B5563;
    font-size: 14px;
}

.auth-form input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 14px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: 14px;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background-color: #2563EB;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
}

.auth-form button:hover {
    background-color: #1D4ED8;
}

.auth-form .error {
    color: #B91C1C;
    margin-bottom: 12px;
}

.auth-form .helper {
    margin-top: 10px;
    font-size: 14px;
}

.auth-note {
    margin-top: 12px;
    font-size: 14px;
    color: #374151;
    background: #f3f4f6;
    padding: 10px 12px;
    border-radius: 6px;
}

.auth-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.profile-card h2 {
    margin-bottom: 8px;
}

.muted {
    color: #6b7280;
    margin-top: 4px;
    margin-bottom: 12px;
}

.flag-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 12px;
}

.flag-form {
    flex: 1;
}

.flag-pill {
    display: inline-block;
    padding: 8px 12px;
    background: #eef2ff;
    color: #1d4ed8;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.flag-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.flag-input-row input {
    flex: 0 0 90px;
    text-transform: uppercase;
}

.flag-input-row button {
    flex: 1;
}

.notice {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.notice.success {
    background: #ecfdf3;
    color: #166534;
}

.notice.error {
    background: #fef2f2;
    color: #b91c1c;
}

.attempt-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.attempt-table th,
.attempt-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px;
    text-align: left;
}

.attempt-table th {
    color: #4b5563;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.insight-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
}

.insight-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.score-pill {
    background: #2563eb;
    color: white;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
    min-width: 54px;
    text-align: center;
}

.insight-card h3 {
    margin: 6px 0;
}

.insight-body {
    margin-top: 8px;
}

.list-block {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.list-block ul {
    margin: 6px 0;
    padding-left: 18px;
    color: #111827;
}

.insight-body .muted {
    margin: 2px 0;
}
.auth-button {
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.26);
    font-size: 14px;
}

/* WCAG fix: #auth-toggle tap target was ~32px, below 44px touch-target floor.
   Scoped to coarse pointers (touch screens) so desktop hover layout is unchanged. */
@media (pointer: coarse) {
    .auth-button {
        min-height: 44px;
        padding: 12px 16px;
    }
}

.auth-dropdown {
    position: absolute;
    top: 56px; /* just below the auth-bar */
    right: 16px;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #d4d4d8;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
    padding: 16px 18px;
    z-index: 1000;
    width: 260px;
}

.auth-dropdown-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-dropdown-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}

.auth-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    font-size: 14px;
}

.auth-submit-button {
    background: #0ea5e9;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.auth-alt {
    font-size: 13px;
    color: #4b5563;
}

.auth-alt .auth-link {
    color: #2563eb;
    text-decoration: underline;
}

.auth-disclaimer {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.3;
}
.status-name-link {
    margin-left: 8px;
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    cursor: pointer;
}

.status-name-link:hover {
    background: #e0f2fe;
    border-color: #93c5fd;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .auth-bar { padding: 0 12px; }
    .status-name { display: none; }
}

@media (max-width: 480px) {
    .auth-bar { padding: 0 8px; height: 48px; }
    .auth-dropdown { width: calc(100% - 16px); max-width: 340px; right: 8px; top: 48px; }
    .auth-input { font-size: 16px; padding: 10px 12px; }
    .auth-submit-button { padding: 12px; }
    .auth-form { width: calc(100% - 20px); }
    .auth-form input { font-size: 16px; padding: 12px; }
    .inline-upgrade-form input[type="password"] { min-width: 100%; font-size: 16px; }
    .inline-upgrade-form button { width: 100%; }
    .insight-grid { grid-template-columns: 1fr; }
}

/* ── Coin chip + earn toast (Plan #11) ─────────────────────────────────
 * Per pedagogy memory: the chip shows BALANCE only. No cost UI is
 * rendered next to spend actions — gating is silent. The "+N" toast
 * fires only on EARN events.
 */

.coin-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    font-weight: 700;
    font-size: 13px;
    border: 1px solid #fcd34d;
    box-shadow: 0 1px 2px rgba(146, 64, 14, 0.08);
    white-space: nowrap;
    user-select: none;
}

.coin-chip-icon {
    color: #d97706;
    font-size: 14px;
    line-height: 1;
}

.coin-chip-value {
    font-variant-numeric: tabular-nums;
}

.coin-toast-container {
    position: fixed;
    top: 72px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1100;
    pointer-events: none;
}

.coin-toast {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fff;
    color: #1F2933;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #fcd34d;
    box-shadow: 0 4px 16px rgba(146, 64, 14, 0.15);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 320ms ease, opacity 320ms ease;
    max-width: 320px;
}

.coin-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.coin-toast-amount {
    color: #b45309;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.coin-toast-icon {
    color: #d97706;
}

.coin-toast-label {
    color: #4b5563;
    font-weight: 500;
    font-size: 13px;
}

@media (max-width: 480px) {
    .coin-toast-container { top: 60px; right: 8px; left: 8px; align-items: flex-end; }
    .coin-toast { max-width: 100%; font-size: 13px; }
    .coin-chip { font-size: 12px; padding: 3px 8px; }
}

/* Remember-me checkbox label — was inheriting a muted dropdown color and
   barely legible on phone screens. Force a readable contrast in both modes. */
.remember-me-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1f2937;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin: 4px 0;
}
.remember-me-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #2563EB;
    cursor: pointer;
}
@media (prefers-color-scheme: dark) {
    .remember-me-label { color: #e5e7eb; }

    /* Auth bar — global, appears on every page. */
    .auth-bar { background: #0b1220; }
    .auth-status { color: #e5e7eb; }
    .status-name { color: #e5e7eb; }
    .status-pill { background: #1e293b; color: #cbd5e1; }
    .status-pill.guest { background: #1e293b; color: #fbbf24; }
    .logout-link {
        background: #1e293b;
        color: #f1f5f9;
        border-color: #334155;
    }
    .logout-link:hover { background: #334155; }
    .auth-link { color: #60a5fa; }
    .auth-link:hover { color: #93c5fd; }
    .auth-separator { color: #475569; }

    /* Auth-alt blocks (sign-up / log-in panels) — light bg breaks contrast in dark. */
    .auth-alt { background: #0f172a; color: #cbd5e1; }
    .auth-alt .auth-link { color: #60a5fa; }

    /* Footer auth-note panel (Privacy policy link container). */
    .auth-note { background: #1e293b; color: #cbd5e1; }
    .auth-note .auth-link { color: #93c5fd; }
}
