@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

:root {
    --bg: #f0f4ff;
    --bg2: #e8eeff;
    --bg3: #dde6ff;
    --surface: #fff;
    --surface2: #eef0f8;
    --border: rgba(15,26,78,.1);
    --accent: #2563eb;
    --accent2: #7c3aed;
    --accent3: #0891b2;
    --green: #059669;
    --red: #dc2626;
    --yellow: #b45309;
    --text: #0f1a4e;
    --text-inverse: #fff;
    --muted: #8891b4;
    --radius: 14px;
    --glow: 0 4px 20px rgba(99,102,241,.15);
    --nav-bg: #fff;
    --footer-bg: #060b2e;
    --shadow-sm: 0 2px 12px rgba(15,26,78,.05);
    --overlay: rgba(15,26,78,.5);
    /* Sam's orb "stage" (interview.css .sam-box) — a deliberately deep,
       fixed-dark panel in BOTH themes (like --footer-bg) so the glowing
       orb always has a rich backdrop to pop against, instead of looking
       washed out on light mode or mismatched against a different dark
       tone in dark mode. Distinct from --footer-bg so the two can be
       tuned independently. */
    --orb-stage-bg-1: #0f1a4e;
    --orb-stage-bg-2: #1e3a8a;
    --orb-stage-ring: rgba(37,99,235,.28);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0b0f1e;
    --bg2: #121729;
    --bg3: #1a2036;
    --surface: #151b2e;
    --surface2: #1c2338;
    --border: rgba(255,255,255,.1);
    --accent: #5b8def;
    --accent2: #9c7dfa;
    --accent3: #22b8d6;
    --green: #34d399;
    --red: #f87171;
    --yellow: #fbbf24;
    --text: #e8ecfb;
    --text-inverse: #0b0f1e;
    --muted: #9aa3c4;
    --glow: 0 4px 20px rgba(91,141,239,.25);
    --nav-bg: #10152a;
    --footer-bg: #05070f;
    --shadow-sm: 0 2px 12px rgba(0,0,0,.35);
    --overlay: rgba(0,0,0,.6);
    /* Slightly lighter than light mode's navy so the orb's stage still
       reads as a distinct panel against the page's own near-black
       background, instead of the two blending into one flat dark mass. */
    --orb-stage-bg-1: #141b3a;
    --orb-stage-bg-2: #24336b;
    --orb-stage-ring: rgba(91,141,239,.35);
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    scroll-behavior: smooth;
}
body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background .2s, color .2s;
    /* Sticky footer: on pages shorter than the viewport (e.g. the coding
       practice gallery), the footer used to sit right below the content
       instead of at the bottom of the screen. Making body a column flex
       container and pushing the footer down with margin-top:auto means it
       only appears where content ends — at the viewport bottom on short
       pages, after a scroll on long ones — without requiring every page to
       wrap its content in a dedicated <main> element. */
    display: flex;
    flex-direction: column;
}
body > * {
    /* Flex items shrink below their content size by default, which on
       long pages let sections above a tall .footer get visually clipped
       instead of expanding. Every direct section should keep its full
       natural height; only the footer is pushed down via margin-top:auto. */
    flex-shrink: 0;
}
.footer {
    margin-top: auto;
}
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.3;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
h1,
h2,
h3,
h4 {
    font-family: 'Syne', sans-serif;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    border: none;
    font-family: 'DM Sans', sans-serif;
    letter-spacing: .3px;
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg,var(--accent),var(--accent2));
    color: #fff;
    box-shadow: 0 4px 20px rgba(99,102,241,.4);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99,102,241,.5);
}
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--surface);
    border-color: var(--accent);
}
.btn-danger {
    background: var(--red);
    color: #fff;
}
.btn-success {
    background: var(--green);
    color: #fff;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    backdrop-filter: blur(20px);
}
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 68px;
    padding: 0 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: background .2s, border-color .2s;
}
.nav-left {
    display: flex;
    align-items: center;
    gap: 40px;
}
.nav-menu {
    display: flex;
    align-items: center;
    gap: 24px;
}
.nav-item {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    position: relative;
    padding: 6px 0;
    letter-spacing: 0.5px;
}
.nav-item:hover, .nav-item.active {
    color: var(--text);
}
.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2.5px;
    background: var(--accent);
    border-radius: 4px;
}
.nav-logo img {
    height: 40px;
    width: 148px;
    object-fit: contain;
    object-position: left;
    display: block;
    transition: filter .2s;
}
/* Nav bar goes dark in dark mode (--nav-bg), so the logo's own colors
   (designed for a white bar) need to render white too — same technique
   already used by .footer-logo img, which sits on the always-dark footer. */
[data-theme="dark"] .nav-logo img {
    filter: brightness(0) invert(1);
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.nav-user {
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
}
.nav-btn {
    background: var(--surface2);
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter',sans-serif;
    transition: all .2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.nav-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
/* ── Theme toggle button ── */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    transition: all .2s;
    color: var(--text);
}
.theme-toggle-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.theme-toggle-floating {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 500;
}
.theme-toggle-floating .theme-toggle-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    box-shadow: var(--glow);
    font-size: 18px;
}

/* ── Animated speaking orb (sam-orb.js) — Sam's avatar across every mode:
   main interview, voice verification, coding-split mini avatar, coding
   practice. Canvas-drawn, theme-aware (reads --accent/--accent3), driven
   by live TTS audio amplitude where available.
   Only lays out flex centering here — each mount site controls its own
   position/inset/padding inline (some are absolutely-positioned overlays
   over an existing sized box, others — like coding-practice's circular
   mini avatar — ARE the sized box itself and must stay in normal flow),
   so this class deliberately never sets position/inset/padding itself. ── */
.sam-orb-host {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.sam-orb-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}
/* Profile dropdown in nav-right */
.nav-profile-wrap {
    position: relative;
}
.nav-profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    font-family: 'Inter',sans-serif;
    transition: all .2s;
}
.nav-profile-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.nav-profile-caret {
    font-size: 9px;
    opacity: 0.6;
}
.nav-profile-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.13);
    min-width: 150px;
    overflow: hidden;
    z-index: 200;
}
.nav-profile-dropdown.open {
    display: block;
}
.nav-profile-dd-item {
    display: block;
    width: 100%;
    padding: 11px 18px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    font-family: 'Inter',sans-serif;
    transition: background .15s, color .15s;
}
.nav-profile-dd-item:hover {
    background: var(--surface2);
    color: var(--text);
}
/* Ghost variant — used for secondary action (Login, Logout) */
.nav-btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--muted);
}
.nav-btn-ghost:hover {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--accent);
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.form-group label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}
.form-group input,
.form-group select {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 13px 16px;
    color: var(--text);
    font-family: 'DM Sans',sans-serif;
    font-size: 15px;
    outline: none;
    transition: border-color .2s,box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-easy {
    background: rgba(16,185,129,.15);
    color: var(--green);
}
.badge-medium {
    background: rgba(245,158,11,.15);
    color: var(--yellow);
}
.badge-hard {
    background: rgba(239,68,68,.15);
    color: var(--red);
}
.progress-bar {
    height: 6px;
    background: var(--bg3);
    border-radius: 99px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg,var(--accent),var(--accent3));
    transition: width .5s ease;
}
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg2);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}
#toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 14px;
    transform: translateY(100px);
    opacity: 0;
    transition: all .3s;
    pointer-events: none;
    box-shadow: var(--glow);
}
#toast.show {
    transform: translateY(0);
    opacity: 1;
}
#toast.error {
    border-color: var(--red);
    color: var(--red);
}
#toast.success {
    border-color: var(--green);
    color: var(--green);
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
@keyframes pulse {
    0%,100% {
        opacity: 1;
    }
    50% {
        opacity: .5;
    }
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
@keyframes glow {
    0%,100% {
        box-shadow: 0 0 20px rgba(99,102,241,.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(99,102,241,.6);
    }
}
.fade-in {
    animation: fadeIn .5s ease forwards;
}
.spin {
    animation: spin 1s linear infinite;
}
.loader {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}

/* ── FOOTER EXPANDED ── */

.footer {
    background: var(--footer-bg);
    padding: 64px 52px 0;
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 48px;
    max-width: 1100px;
    margin: 0 auto;
    padding-bottom: 56px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.footer-logo img {
    height: 38px;
    width: 145px;
    object-fit: contain;
    object-position: left;
    filter: brightness(0) invert(1);
    opacity: .8;
    display: block;
    margin-bottom: 2px;
}
.footer-brand-desc {
    font-size: 13px;
    color: rgba(255,255,255,.42);
    line-height: 1.75;
    max-width: 230px;
    margin: 14px 0 22px;
}
.footer-socials {
    display: flex;
    gap: 10px;
}
.footer-soc {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,.45);
    text-decoration: none;
    transition: all .2s;
}
.footer-soc:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.f-col-title {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,.85);
    text-transform: uppercase;
    letter-spacing: .7px;
    margin-bottom: 18px;
}
.f-col-links {
    display: flex;
    flex-direction: column;
    gap: 11px;
}
.f-col-links a {
    font-size: 13px;
    color: rgba(255,255,255,.38);
    text-decoration: none;
    transition: color .2s;
}
.f-col-links a:hover {
    color: #60a5fa;
}
.footer-bottom {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.footer-copy {
    font-size: 12px;
    color: rgba(255,255,255,.25);
}
.footer-bottom-links {
    display: flex;
    gap: 20px;
}
.footer-bottom-links a {
    font-size: 12px;
    color: rgba(255,255,255,.28);
    text-decoration: none;
    transition: color .2s;
}
.footer-bottom-links a:hover {
    color: #fff;
}

/* ── Shared Leaderboard Sidebar ── */
.lb-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    position: sticky;
    top: 88px;
}
.lb-panel-header { margin-bottom: 16px; }
.lb-panel-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.05rem; font-weight: 700; color: var(--text); display: block; }
.lb-panel-sub { font-size: 12px; color: var(--muted); margin-top: 3px; display: block; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.lb-row:last-child { border-bottom: none; padding-bottom: 0; }
.lb-rank { font-size: 1.1rem; width: 28px; text-align: center; flex-shrink: 0; font-weight: 700; color: var(--muted); }
.lb-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.lb-value { font-size: 12px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.lb-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 0; }

/* ── RESPONSIVE DESIGN FOR ALL DEVICES ── */

/* Global safety for responsive images and media */
img, video, canvas, svg {
    max-width: 100%;
}

/* Tablet & Mobile Breakpoints */
@media (max-width: 1024px) {
    .nav {
        padding: 0 24px;
    }
    .nav-left {
        gap: 20px;
    }
    .nav-menu {
        gap: 16px;
    }
    .footer {
        padding: 52px 32px 0;
    }
    .footer-grid {
        grid-template-columns: 1.5fr 1fr 1fr 1fr;
        gap: 32px;
    }
    .lb-panel {
        position: static;
        margin-top: 24px;
    }
}

@media (max-width: 860px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 36px;
        padding-bottom: 40px;
    }
}

@media (max-width: 768px) {
    /* Prevent iOS Safari auto-zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Touch-friendly interactive targets */
    .btn, .nav-btn, .nav-profile-btn {
        min-height: 42px;
    }

    .nav {
        height: 60px;
        padding: 0 16px;
    }
    .nav-left {
        gap: 12px;
    }
    .nav-logo img {
        height: 32px;
        width: 120px;
    }
    .nav-menu {
        gap: 12px;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-right: 4px;
    }
    .nav-menu::-webkit-scrollbar {
        display: none;
    }
    .nav-item {
        font-size: 12px;
        padding: 4px 2px;
    }
    .nav-right {
        gap: 8px;
    }
    .nav-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .nav-user {
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 12px;
    }
    .card {
        padding: 20px 16px;
        border-radius: 12px;
    }
}

@media (max-width: 640px) {
    .nav-menu {
        display: none !important;
    }
    .nav-right {
        gap: 6px;
    }
    .nav-profile-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}


@media (max-width: 560px) {
    .nav {
        padding: 0 12px;
    }
    .nav-logo img {
        width: 108px;
        height: 30px;
    }
    .footer {
        padding: 36px 16px 0;
    }
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 28px;
        padding-bottom: 32px;
    }
    .footer-brand-desc {
        max-width: 100%;
        margin: 10px 0 18px;
    }
    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px 0 24px;
    }
    .footer-bottom-links {
        flex-wrap: wrap;
        gap: 14px;
    }
    .theme-toggle-floating {
        bottom: 16px;
        right: 16px;
    }
    .theme-toggle-floating .theme-toggle-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}


