/* ===== FREETOOLS.STUDY — MAIN STYLES ===== */
:root {
    --bg: #0d0f14;
    --bg-1: #10131a;
    --bg-2: #13161e;
    --bg-3: #1a1e2a;
    --bg-4: #222737;
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.15);
    --text: #f0f2f8;
    --text-muted: #8891a8;
    --text-dim: #7a8499;
    --accent: #6C63FF;
    --accent-hover: #5048d4;
    --accent-glow: rgba(108,99,255,0.3);
    --green: #22d98a;
    --red: #ff5b5b;
    --yellow: #ffd166;
    --radius: 12px;
    --radius-lg: 20px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
    --font-display: 'Syne', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
    --navbar-bg: rgba(13,15,20,0.92);
    color-scheme: dark;
}


/* Accessibility: white text on accent btn needs darker bg in dark theme */
:root .btn-primary,
[data-theme="dark"] .btn-primary {
    background: #5048d4;
    border-color: #5048d4;
}
[data-theme="dark"] .btn-primary:hover {
    background: #4238c0;
    border-color: #4238c0;
}
/* ── Light theme variables ── */
[data-theme="light"] {
    --bg: #f4f5f8;
    --bg-1: #ffffff;
    --bg-2: #ffffff;
    --bg-3: #f0f1f5;
    --bg-4: #e4e6ee;
    --border: rgba(0,0,0,0.1);
    --border-hover: rgba(0,0,0,0.2);
    --text: #111318;
    --text-muted: #4a5068;
    --text-dim: #6b7491;
    --accent: #5b54e8;
    --accent-hover: #4940c8;
    --accent-glow: rgba(91,84,232,0.2);
    --shadow: 0 4px 24px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 48px rgba(0,0,0,0.15);
    --navbar-bg: rgba(244,245,248,0.95);
    color-scheme: light;
}

/* ── System prefers light — unless user has overridden ── */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #f4f5f8;
        --bg-1: #ffffff;
        --bg-2: #ffffff;
        --bg-3: #f0f1f5;
        --bg-4: #e4e6ee;
        --border: rgba(0,0,0,0.1);
        --border-hover: rgba(0,0,0,0.2);
        --text: #111318;
        --text-muted: #4a5068;
        --text-dim: #6b7491;
        --accent: #5b54e8;
        --accent-hover: #4940c8;
        --accent-glow: rgba(91,84,232,0.2);
        --shadow: 0 4px 24px rgba(0,0,0,0.1);
        --shadow-lg: 0 8px 48px rgba(0,0,0,0.15);
        --navbar-bg: rgba(244,245,248,0.95);
        color-scheme: light;
    }
}


*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
input, textarea, select, button { font-family: inherit; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }

/* ===== NAVBAR ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--navbar-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.025em;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
}

.nav-search {
    flex: 1;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.nav-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.nav-search svg { color: var(--text-muted); flex-shrink: 0; }

.nav-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.875rem;
    padding: 10px 0;
}

.nav-search input::placeholder { color: var(--text-muted); }

.nav-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== USER MENU ===== */
.nav-user-menu { position: relative; }

.nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 700;
    color: white;
    font-size: 0.9rem;
    transition: transform var(--transition), box-shadow var(--transition);
}

.nav-avatar:hover { transform: scale(1.08); box-shadow: 0 0 0 3px var(--accent-glow); }

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 200;
}

.nav-user-menu:hover .dropdown-menu,
.nav-user-menu:focus-within .dropdown-menu { display: block; }

.dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-header strong { font-size: 0.9rem; }
.dropdown-header small { color: var(--text-muted); font-size: 0.78rem; }

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    font-size: 0.875rem;
    transition: background var(--transition);
}

.dropdown-menu a:hover { background: var(--bg-4); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.logout-link { color: var(--red) !important; }

/* ── Theme toggle ────────────────────────────────── */
.theme-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px; font-size: .82rem; color: var(--text-muted);
    gap: 10px;
}
.theme-toggle-row svg { flex-shrink: 0; }
.theme-switch {
    position: relative; width: 36px; height: 20px; flex-shrink: 0;
}
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-switch-track {
    position: absolute; inset: 0; background: var(--bg-4);
    border-radius: 20px; cursor: pointer; transition: background .2s;
    border: 1.5px solid var(--border);
}
.theme-switch input:checked + .theme-switch-track { background: var(--accent); border-color: var(--accent); }
.theme-switch-track::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--text-muted); transition: transform .2s, background .2s;
}
.theme-switch input:checked + .theme-switch-track::after {
    transform: translateX(16px); background: #fff;
}
/* Mobile theme toggle row */
.mobile-theme-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; color: var(--text-muted); font-size: .85rem;
    border-top: 1px solid var(--border); margin-top: 4px;
}


/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-sm { padding: 7px 14px; font-size: 0.8rem; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: 12px; }

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 16px var(--accent-glow); transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); border-color: var(--border-hover); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #e04444; }

.btn-green { background: var(--green); color: #0d1a12; }
.btn-green:hover { background: #1bc47a; }

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-icon:hover { background: var(--bg-4); color: var(--text); border-color: var(--border-hover); }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-input, .form-textarea, .form-select {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-error {
    font-size: 0.8rem;
    color: var(--red);
    margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card-link { display: block; }

/* ===== SET CARDS ===== */
.sets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 20px;
}

.set-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.set-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(108,99,255,0.2);
}

.set-card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.set-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.set-card-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-4);
    padding: 3px 8px;
    border-radius: 6px;
}

.set-card-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.set-card-author {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: auto;
}

.author-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

/* ===== LAYOUT ===== */
.page-wrapper {
    flex: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 40px 24px;
    width: 100%;
}

.page-header {
    margin-bottom: 36px;
}

.page-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    letter-spacing: -0.03em;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle { color: var(--text-muted); font-size: 1rem; margin-top: 8px; }

.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-error { background: rgba(255,91,91,0.12); border: 1px solid rgba(255,91,91,0.3); color: #ff8a8a; }
.alert-success { background: rgba(34,217,138,0.12); border: 1px solid rgba(34,217,138,0.3); color: #4de8a5; }
.alert-info { background: rgba(108,99,255,0.12); border: 1px solid rgba(108,99,255,0.3); color: #a09aff; }

/* ===== BADGE ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-purple { background: rgba(108,99,255,0.2); color: #a09aff; }
.badge-green { background: rgba(34,217,138,0.2); color: var(--green); }
.badge-yellow { background: rgba(255,209,102,0.2); color: var(--yellow); }

/* ===== AUTH PAGES ===== */
.auth-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.auth-box {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.auth-box h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

.auth-box .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 32px; }

.auth-form { display: flex; flex-direction: column; gap: 20px; }

.auth-switch {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 24px;
}

.auth-switch a { color: var(--accent); font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ===== CREATE/EDIT SET ===== */
.create-layout { display: flex; flex-direction: column; gap: 24px; }

.set-meta-box {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 20px;
    align-items: end;
}

@media (max-width: 700px) {
    .set-meta-box { grid-template-columns: 1fr; }
}

.cards-list { display: flex; flex-direction: column; gap: 12px; }

.card-editor {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: start;
    transition: border-color var(--transition);
    position: relative;
}

.card-editor:focus-within { border-color: var(--accent); }

.card-editor-num {
    position: absolute;
    top: -10px;
    left: 16px;
    background: var(--bg-4);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
    padding: 2px 8px;
    border-radius: 4px;
}

.card-editor textarea {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    resize: vertical;
    min-height: 60px;
    width: 100%;
    transition: border-color var(--transition);
}

.card-editor textarea:focus { border-color: var(--accent); }
.card-editor textarea::placeholder { color: var(--text-dim); }

.card-editor-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; padding-top: 4px; }

.add-card-btn {
    background: var(--bg-2);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition);
    width: 100%;
}

.add-card-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(108,99,255,0.05);
}

.sv-page { padding-bottom: 80px; }

/* Hero */
.sv-hero {
    position: relative;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 36px 40px 28px;
    margin-bottom: 20px;
    overflow: hidden;
}
.sv-hero-glow {
    position: absolute;
    top: -60px; right: -60px;
    width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(124,111,255,.15) 0%, transparent 70%);
    pointer-events: none;
}
.sv-hero-inner { /* wrapper kept for compat */ }

/* Top bar: back link + icon buttons */
.sv-hero-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 20px;
}
.sv-hero-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-dim);
    text-decoration: none;
    transition: color .15s;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 10px;
    margin-left: 6px;
}
.sv-hero-back:hover { color: var(--text); border-color: var(--accent); }

/* Body: full-width, zero interference */
.sv-hero-body { width: 100%; }

.sv-private-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,196,0,.1);
    border: 1px solid rgba(255,196,0,.25);
    color: var(--yellow);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 100px;
    margin-bottom: 12px;
}
.sv-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.7rem, 4.5vw, 2.8rem);
    letter-spacing: -.03em;
    line-height: 1.1;
    margin-bottom: 10px;
    color: var(--text);
}
.sv-desc {
    color: var(--text-muted);
    font-size: .9rem;
    line-height: 1.6;
    max-width: 560px;
    margin-bottom: 16px;
}
.sv-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: .82rem;
}
.sv-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 800; color: #fff;
    flex-shrink: 0;
}
.sv-meta-author { font-weight: 600; color: var(--text); }
.sv-meta-dot {
    width: 3px; height: 3px;
    background: var(--border-hover);
    border-radius: 50%;
    flex-shrink: 0;
}
.sv-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Hero action buttons */
.sv-hero-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
}
/* Icon-only action buttons */
.sv-icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    flex-shrink: 0;
    position: relative;
}
.sv-icon-btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-4);
    color: var(--text);
    transform: translateY(-1px);
}
.sv-icon-starred {
    color: var(--yellow) !important;
    border-color: rgba(255,196,0,.35) !important;
    background: rgba(255,196,0,.08) !important;
}
.sv-icon-danger:hover {
    color: #ff6b6b !important;
    border-color: rgba(255,91,91,.35) !important;
    background: rgba(255,91,91,.08) !important;
}

/* Progress bar */
.sv-progress-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.sv-progress-track {
    position: relative;
    height: 6px;
    background: var(--bg-4);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}
.sv-progress-fill {
    position: absolute;
    top: 0; height: 100%;
    border-radius: 4px;
    transition: width .6s ease;
}
.sv-fill-know  { background: var(--green); left: 0; }
.sv-fill-learn { background: var(--yellow); }
.sv-progress-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: .78rem;
}
.sv-legend-item { display: flex; align-items: center; gap: 5px; color: var(--text-muted); }
.sv-legend-dot {
    width: 8px; height: 8px; border-radius: 50%;
}
.sv-legend-know  .sv-legend-dot { background: var(--green); }
.sv-legend-learn .sv-legend-dot { background: var(--yellow); }
.sv-legend-new   .sv-legend-dot { background: var(--bg-4); border: 1px solid var(--border-hover); }
.sv-legend-pct {
    margin-left: auto;
    font-weight: 700;
    color: var(--text);
    font-size: .82rem;
}

/* Study mode buttons */
.sv-modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 36px;
}
@media (max-width: 480px) {
    .sv-modes { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}
.sv-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 8px;
    height: 100px;
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    text-decoration: none;
    color: var(--text);
    transition: all .15s;
    position: relative;
    overflow: hidden;
    text-align: center;
    box-sizing: border-box;
}
.sv-mode::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .15s;
    pointer-events: none;
}
.sv-mode:hover { transform: translateY(-2px); }
.sv-mode:hover::before { opacity: 1; }

.sv-mode-flash  { --mc: #7c6fff; }
.sv-mode-learn  { --mc: #a78bfa; }
.sv-mode-written { --mc: #60a5fa; }
.sv-mode-match  { --mc: #34d399; }
.sv-mode-test    { --mc: #f59e0b; }
.sv-mode-gravity { --mc: #e879f9; }

.sv-mode:hover { border-color: var(--mc); box-shadow: 0 4px 20px rgba(0,0,0,.2); }
.sv-mode::before { background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--mc) 14%, transparent), transparent 75%); }

.sv-mode-icon {
    width: 44px; height: 44px;
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--mc) 14%, transparent);
    color: var(--mc);
    transition: transform .15s;
}
.sv-mode:hover .sv-mode-icon { transform: scale(1.1); }
.sv-mode-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: .85rem;
    color: var(--text);
    white-space: nowrap;
    line-height: 1;
}

/* Terms section */
.sv-terms-section { }
.sv-terms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.sv-terms-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sv-terms-count {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 9px;
    color: var(--text-muted);
}
.sv-terms-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
}
.sv-toggle-btn {
    background: none;
    border: none;
    border-radius: 7px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-dim);
    transition: all .15s;
    display: flex; align-items: center;
}
.sv-toggle-btn.sv-toggle-active {
    background: var(--bg-4);
    color: var(--text);
}
@media (max-width: 640px) {
    .sv-terms-toggle { display: none; }
}

/* Card items */
.sv-cards-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sv-card-item {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color .15s, background .15s;
    animation: sv-card-in .3s both ease-out;
}
@keyframes sv-card-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sv-card-item:hover {
    border-color: rgba(124,111,255,.22);
    background: var(--bg-3);
}
.sv-card-num {
    width: 44px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 800;
    color: var(--text-dim);
    background: var(--bg-3);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.sv-card-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-width: 0;
    padding: 14px 18px;
    gap: 16px;
}
.sv-card-term {
    font-weight: 600;
    font-size: .92rem;
    line-height: 1.4;
    color: var(--text);
}
.sv-card-def {
    font-size: .88rem;
    line-height: 1.4;
    color: var(--text-muted);
}
.sv-card-sep {
    width: 1px;
    height: 36px;
    background: var(--border);
    flex-shrink: 0;
}
.sv-card-img {
    display: block;
    max-height: 72px;
    max-width: 140px;
    object-fit: contain;
    border-radius: 6px;
    margin-top: 8px;
    border: 1px solid var(--border);
}
.sv-card-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 100px;
    margin-right: 14px;
    white-space: nowrap;
    flex-shrink: 0;
}
.sv-status-know {
    background: rgba(34,217,138,.1);
    border: 1px solid rgba(34,217,138,.25);
    color: var(--green);
}
.sv-status-learning {
    background: rgba(255,196,0,.1);
    border: 1px solid rgba(255,196,0,.25);
    color: var(--yellow);
}

/* Stacked view */
.sv-cards-stacked .sv-card-body {
    grid-template-columns: 1fr;
}
.sv-cards-stacked .sv-card-sep {
    width: 100%;
    height: 1px;
}

/* Responsive */
@media (max-width: 640px) {
    .sv-hero { padding: 24px 20px 20px; }
    /* Modes stay 3-col on mobile */
    /* Cards always stacked on mobile regardless of toggle */
    .sv-card-body { grid-template-columns: 1fr; padding: 12px 14px; }
    .sv-card-sep { width: 100%; height: 1px; }
    .sv-card-num { min-height: 100%; padding: 14px 0; align-items: flex-start; padding-top: 16px; }
}

/* ===== FLASHCARD VIEWER ===== */
/* ===== FLASHCARD REDESIGN ===== */
.fc-root {
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Toolbar */
.fc-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.fc-toolbar-left, .fc-toolbar-right {
    display: flex;
    gap: 6px;
}
.fc-tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .15s;
}
.fc-tool-btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-3); }
.fc-tool-btn.fc-tool-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.fc-counter {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: -.01em;
}
.fc-counter span { color: var(--text-dim); font-weight: 500; font-size: .9rem; }

/* Progress bar */
.fc-progress-wrap {
    height: 4px;
    background: var(--bg-4);
    border-radius: 2px;
    overflow: hidden;
}
.fc-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.35s ease;
}

/* Card stack */
.fc-stack-wrap {
    position: relative;
    margin-bottom: 4px;
}
/* Ghost divs hidden — stack effect done via box-shadow on the face */
.fc-ghost { display: none; }
.fc-ghost-2 { display: none; }
.fc-ghost-1 { display: none; }

.fc-scene {
    position: relative;
    height: 340px;
    perspective: 1400px;
    cursor: pointer;
    will-change: transform, opacity;
    user-select: none;
    -webkit-user-select: none;
}
.fc-card {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.48s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.fc-card.fc-flipped { transform: rotateY(180deg); }

/* Card faces */
.fc-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 22px;
    border: 1.5px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 26px 16px;
    box-sizing: border-box;
    overflow: hidden;
    transition: border-color .2s;
}
.fc-face-front {
    background: var(--bg-2);
    /* layered box-shadow creates two ghost cards peeking below */
    box-shadow:
        0 6px 0 -2px var(--bg-3),
        0 6px 0 -1px var(--border),
        0 11px 0 -4px var(--bg-3),
        0 11px 0 -3px var(--border);
}
.fc-face-back {
    background: var(--bg-3);
    transform: rotateY(180deg);
    border-color: rgba(124,111,255,.4);
}
.fc-face[data-status="know"] { border-color: rgba(34,217,138,.5); box-shadow: 0 0 0 1px rgba(34,217,138,.15); }
.fc-face[data-status="learning"] { border-color: rgba(255,209,102,.4); box-shadow: 0 0 0 1px rgba(255,209,102,.12); }

.fc-face-label {
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-dim);
    flex-shrink: 0;
    /* sit at top-left, no big margin pushing content down */
    margin-bottom: 0;
}
.fc-face-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 0;
    overflow: hidden;
    /* small vertical padding so text never touches edges */
    padding: 8px 0 4px;
}
.fc-face-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.2rem, 3.2vw, 2rem);
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: break-word;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text);
}
.fc-face-img {
    max-height: 130px;
    max-width: 85%;
    object-fit: contain;
    border-radius: 10px;
    flex-shrink: 0;
}
@keyframes fc-hint-fade {
    0%   { opacity: .85; }
    60%  { opacity: .85; }
    100% { opacity: .4; }
}
.fc-flip-hint {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .7rem;
    color: var(--text-muted);
    opacity: .4;
    margin-top: 2px;
    align-self: center;
    animation: fc-hint-fade 2.2s ease-out forwards;
}

/* Status row */
.fc-status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 24px;
    font-size: .78rem;
    font-weight: 600;
}
.fc-stat { display: flex; align-items: center; gap: 5px; }
.fc-stat-know    { color: #22d98a; }
.fc-stat-learning { color: var(--yellow); }
.fc-stat-left    { color: var(--text-dim); }

/* Nav */
.fc-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.fc-nav-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: 1.5px solid var(--border);
    background: var(--bg-2);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0;
}
.fc-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: rgba(124,111,255,.08); }
.fc-nav-btn:disabled { opacity: .3; cursor: default; }

.fc-mark-btns {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: center;
}
.fc-mark-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 12px;
    border: 1.5px solid transparent;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: .82rem;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.fc-mark-learning {
    background: rgba(255,209,102,.07);
    border-color: rgba(255,209,102,.25);
    color: #ffd166;
}
.fc-mark-learning:hover, .fc-mark-learning.fc-mark-active {
    background: rgba(255,209,102,.15);
    border-color: #ffd166;
}
.fc-mark-know {
    background: rgba(34,217,138,.07);
    border-color: rgba(34,217,138,.25);
    color: #22d98a;
}
.fc-mark-know:hover, .fc-mark-know.fc-mark-active {
    background: rgba(34,217,138,.15);
    border-color: #22d98a;
}

/* Keyboard hint */
.fc-keyhint {
    text-align: center;
    font-size: .7rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: .6;
}
.fc-keyhint-dot { opacity: .4; }

/* ── Learn mode guest nudge banner ── */
.lq-guest-nudge {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    background: rgba(124,111,255,.07);
    border: 1px solid rgba(124,111,255,.22);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: .8rem;
    line-height: 1.5;
}
.lq-guest-nudge-left {
    display: flex; align-items: flex-start; gap: 8px;
    color: var(--text-muted); flex: 1; min-width: 0;
}
.lq-guest-nudge-left svg { flex-shrink: 0; margin-top: 2px; }
.lq-guest-btn {
    display: inline-flex; align-items: center;
    background: var(--accent); color: #fff;
    font-family: var(--font-display); font-weight: 700; font-size: .75rem;
    padding: 6px 13px; border-radius: 8px; text-decoration: none;
    white-space: nowrap; flex-shrink: 0; transition: opacity .15s;
    box-shadow: 0 2px 10px rgba(124,111,255,.3);
}
.lq-guest-btn:hover { opacity: .88; }

/* Keep old progress-bar / progress-fill classes working for Learn mode */
.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-4);
    border-radius: 2px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

@media (max-width: 520px) {
    .fc-scene { height: 260px; }
    .fc-face { padding: 18px 20px 16px; }
    .fc-mark-btn { padding: 9px 12px; font-size: .78rem; }
    .fc-keyhint { display: none; }
}

/* ===== STUDY PAGE TOPBAR & SCROLLABLE TABS ===== */
.study-topbar {
    margin-bottom: 12px;
}
.study-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 4px;
    transition: color .15s;
}
.study-back-link:hover { color: var(--text-muted); }
.study-mode-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -.02em;
}
.study-tabs-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border);
}
.study-tabs-wrap::-webkit-scrollbar { display: none; }
.study-tabs {
    display: flex;
    gap: 0;
    min-width: max-content;
}
.study-tab {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-dim);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}
.study-tab:hover { color: var(--text-muted); }
.study-tab-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ===== LEARN MODE ===== */

/* ===== LEARN MODE ===== */
.learn-container { max-width: 680px; margin: 0 auto; }

/* Progress bar */
.lq-progress {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}
.lq-progress-bar {
    flex: 1;
    height: 5px;
    background: var(--bg-4);
    border-radius: 3px;
    overflow: hidden;
}
.lq-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .4s ease;
}
.lq-progress-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Question card */
.lq-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px 40px;
    text-align: center;
    margin-bottom: 16px;
}
.lq-eyebrow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}
.lq-eyebrow-text {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-dim);
}
.lq-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(108,99,255,.12);
    border: 1px solid rgba(108,99,255,.22);
    color: #a09aff;
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 100px;
}
.lq-term {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 3.5vw, 2rem);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.2;
    color: var(--text);
}
.lq-term-img {
    max-height: 120px;
    max-width: 75%;
    object-fit: contain;
    border-radius: 10px;
    margin-top: 16px;
}

/* Answer options */
.lq-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
@media (max-width: 520px) { .lq-options { grid-template-columns: 1fr; } }

.lq-option {
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color .12s, background .12s, transform .1s;
    width: 100%;
}
.lq-option:hover:not(.lq-disabled) {
    border-color: rgba(108,99,255,.5);
    background: rgba(108,99,255,.07);
    transform: translateY(-1px);
}
.lq-option:active:not(.lq-disabled) { transform: translateY(0); }
.lq-option.lq-correct {
    border-color: #22d98a;
    background: rgba(34,217,138,.08);
}
.lq-option.lq-wrong {
    border-color: #ff5b5b;
    background: rgba(255,91,91,.08);
}
.lq-option.lq-disabled { cursor: default; }
.lq-option.lq-disabled:not(.lq-correct):not(.lq-wrong) { opacity: .55; }

.lq-key {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .75rem;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: background .12s, color .12s, border-color .12s;
    font-family: var(--font-display);
}
.lq-option.lq-correct .lq-key {
    background: rgba(34,217,138,.2);
    border-color: #22d98a;
    color: #22d98a;
}
.lq-option.lq-wrong .lq-key {
    background: rgba(255,91,91,.2);
    border-color: #ff5b5b;
    color: #ff5b5b;
}

.lq-opt-text {
    font-size: .9rem;
    line-height: 1.4;
    color: var(--text);
}
.lq-option.lq-correct .lq-opt-text { color: #22d98a; font-weight: 600; }
.lq-option.lq-wrong .lq-opt-text { color: #ff5b5b; }

/* Feedback bar */
.lq-feedback-wrap {
    border-radius: 14px;
    overflow: hidden;
    transition: all .2s;
}
.lq-fb-correct { background: rgba(34,217,138,.08); border: 1.5px solid rgba(34,217,138,.3); }
.lq-fb-wrong   { background: rgba(255,91,91,.08);  border: 1.5px solid rgba(255,91,91,.25); }
.lq-fb-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    flex-wrap: wrap;
}
.lq-fb-msg {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    font-weight: 600;
}
.lq-fb-correct .lq-fb-msg { color: #22d98a; }
.lq-fb-wrong   .lq-fb-msg { color: #ff8080; }
.lq-fb-msg strong { color: var(--text); font-weight: 700; }

.lq-next-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    padding: 8px 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: background .15s, transform .1s;
    white-space: nowrap;
    flex-shrink: 0;
}
.lq-next-btn:hover { background: #5a52e0; transform: translateY(-1px); }
.lq-next-btn:active { transform: translateY(0); }

/* Loading state */
.lq-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 80px 20px;
    color: var(--text-muted);
    font-size: .875rem;
}
.lq-loading-spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(108,99,255,.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex-shrink: 0;
}

/* ===== BLITZ MODE ===== */
.blitz-container {
    max-width: 620px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.blitz-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 18px;
}
.blitz-hud-left, .blitz-hud-right { display: flex; flex-direction: column; gap: 2px; min-width: 50px; }
.blitz-hud-right { align-items: flex-end; }
.blitz-hud-center { flex: 1; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.blitz-hud-label { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.blitz-hud-val { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: var(--text); }
.blitz-round-label { font-size: .8rem; font-weight: 700; color: var(--text-muted); }
.blitz-streak { font-size: .9rem; font-weight: 700; color: var(--yellow); min-height: 1.2em; }

.blitz-timer {
    height: 5px;
    background: var(--bg-4);
    border-radius: 3px;
    overflow: hidden;
}
.blitz-timer-fill {
    height: 100%;
    width: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: background .3s;
}

.blitz-card {
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: 22px;
    padding: 32px 36px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: grab;
    user-select: none;
    transition: border-color .2s, box-shadow .2s, transform .15s;
    will-change: transform;
}
.blitz-card-correct {
    border-color: #22d98a !important;
    background: rgba(34,217,138,.06) !important;
    box-shadow: 0 0 0 2px rgba(34,217,138,.2) !important;
}
.blitz-card-wrong {
    border-color: #ff5b5b !important;
    background: rgba(255,91,91,.06) !important;
    box-shadow: 0 0 0 2px rgba(255,91,91,.2) !important;
}
.blitz-swipe-right { animation: blitz-fly-right .35s ease forwards; }
.blitz-swipe-left  { animation: blitz-fly-left  .35s ease forwards; }
@keyframes blitz-fly-right { to { transform: translateX(120%) rotate(15deg); opacity: 0; } }
@keyframes blitz-fly-left  { to { transform: translateX(-120%) rotate(-15deg); opacity: 0; } }

.blitz-label {
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.blitz-term {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    color: var(--text);
    line-height: 1.3;
}
.blitz-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}
.blitz-def {
    font-size: .92rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.blitz-feedback {
    text-align: center;
    font-size: .88rem;
    min-height: 24px;
}
.blitz-hint {
    text-align: center;
    font-size: .75rem;
    color: var(--text-dim);
    margin-top: -4px;
}
.blitz-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.blitz-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 12px;
    border-radius: 16px;
    border: 1.5px solid transparent;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    transition: all .15s;
}
.blitz-btn-wrong {
    background: rgba(255,91,91,.08);
    border-color: rgba(255,91,91,.3);
    color: #ff8080;
}
.blitz-btn-wrong:hover {
    background: rgba(255,91,91,.15);
    border-color: #ff5b5b;
    transform: translateY(-2px);
}
.blitz-btn-correct {
    background: rgba(34,217,138,.08);
    border-color: rgba(34,217,138,.3);
    color: #22d98a;
}
.blitz-btn-correct:hover {
    background: rgba(34,217,138,.15);
    border-color: #22d98a;
    transform: translateY(-2px);
}

.blitz-swipe-guide {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 0 2px;
    margin-top: -2px;
}
.blitz-guide-wrong {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .8rem;
    font-weight: 600;
    color: rgba(255,91,91,.7);
    white-space: nowrap;
}
.blitz-guide-correct {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    font-size: .8rem;
    font-weight: 600;
    color: rgba(34,217,138,.7);
    white-space: nowrap;
}
.blitz-guide-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: .72rem;
    color: var(--text-dim);
    white-space: nowrap;
    opacity: .6;
}
@media (max-width: 480px) {
    .blitz-card { padding: 24px 20px; min-height: 160px; }
    .blitz-btn { padding: 14px 8px; }
}

/* ===== WRITTEN MODE ===== */
.wt-root {
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.wt-progress-row {
    display: flex;
    align-items: center;
    gap: 14px;
}
.wt-progress-track {
    flex: 1;
    height: 5px;
    background: var(--bg-4);
    border-radius: 3px;
    overflow: hidden;
}
.wt-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .35s ease;
}
.wt-counter {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1rem;
    white-space: nowrap;
}
.wt-counter span { color: var(--text-dim); font-weight: 500; font-size: .85rem; }

.wt-question {
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}
.wt-question-label {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.wt-question-term {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.3rem, 4vw, 2rem);
    letter-spacing: -.02em;
    line-height: 1.2;
    color: var(--text);
}
.wt-term-img {
    max-height: 120px;
    max-width: 75%;
    object-fit: contain;
    border-radius: 10px;
    margin-top: 4px;
}

.wt-answer-area { display: flex; flex-direction: column; gap: 10px; }
.wt-input-wrap { position: relative; }
.wt-input {
    width: 100%;
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 16px 18px 36px;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.5;
    outline: none;
    resize: vertical;
    min-height: 100px;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
    box-sizing: border-box;
}
.wt-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,111,255,.12); }
.wt-input.wt-correct { border-color: #22d98a; box-shadow: 0 0 0 3px rgba(34,217,138,.1); }
.wt-input.wt-almost  { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255,209,102,.1); }
.wt-input.wt-wrong   { border-color: #ff5b5b; box-shadow: 0 0 0 3px rgba(255,91,91,.1); animation: wt-shake .3s ease; }
@keyframes wt-shake {
    0%,100% { transform:translateX(0); }
    25% { transform:translateX(-6px); }
    75% { transform:translateX(6px); }
}
.wt-char-hint {
    position: absolute;
    bottom: 10px;
    right: 14px;
    font-size: .68rem;
    color: var(--text-dim);
    pointer-events: none;
}

/* Feedback panels */
.wt-feedback {
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: .875rem;
}
.wt-fb-correct { background: rgba(34,217,138,.08);  border: 1.5px solid rgba(34,217,138,.3); }
.wt-fb-almost  { background: rgba(255,209,102,.08); border: 1.5px solid rgba(255,209,102,.3); }
.wt-fb-wrong   { background: rgba(255,91,91,.07);   border: 1.5px solid rgba(255,91,91,.25); }
.wt-fb-icon {
    font-size: 1.1rem;
    font-weight: 800;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}
.wt-fb-correct .wt-fb-icon { color: #22d98a; }
.wt-fb-almost  .wt-fb-icon { color: var(--yellow); }
.wt-fb-wrong   .wt-fb-icon { color: #ff5b5b; }
.wt-fb-text { display: flex; flex-direction: column; gap: 4px; color: var(--text-muted); }
.wt-fb-text strong { color: var(--text); }
.wt-fb-def { font-style: italic; color: var(--text-muted); line-height: 1.4; }
.wt-fb-hint { font-size: .75rem; color: var(--yellow); opacity: .85; margin-top: 2px; }
.wt-override-btns {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.wt-override-wrong, .wt-override-correct {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 10px;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all .15s;
}
.wt-override-wrong   { background: rgba(255,91,91,.1);   border-color: rgba(255,91,91,.3);   color: #ff8080; }
.wt-override-correct { background: rgba(34,217,138,.1);  border-color: rgba(34,217,138,.3);  color: #22d98a; }
.wt-override-wrong:hover   { background: rgba(255,91,91,.18); }
.wt-override-correct:hover { background: rgba(34,217,138,.18); }

.wt-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.wt-skip-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 16px; border-radius: 12px;
    border: 1.5px solid var(--border); background: transparent;
    color: var(--text-dim); font-size: .85rem; font-weight: 600; cursor: pointer;
    transition: all .15s;
}
.wt-skip-btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-3); }
.wt-check-btn {
    display: flex; align-items: center; gap: 7px;
    padding: 11px 24px; border-radius: 12px;
    border: none; background: var(--accent);
    color: #fff; font-family: var(--font-display);
    font-weight: 700; font-size: .95rem; cursor: pointer;
    transition: opacity .15s, transform .15s;
    box-shadow: 0 4px 16px rgba(124,111,255,.3);
}
.wt-check-btn:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.wt-check-btn:disabled { opacity: .45; cursor: default; }
.wt-hint-text { font-size: .72rem; color: var(--text-dim); text-align: right; }

@media (max-width: 520px) {
    .wt-question { padding: 20px 18px; }
    .wt-actions { flex-direction: column; align-items: stretch; }
    .wt-check-btn { justify-content: center; }
}

/* ===== MATCH GAME ===== */
.mt-root {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.mt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mt-hint { font-size: .8rem; color: var(--text-dim); font-weight: 500; }
.mt-timer {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text);
    letter-spacing: .02em;
}
.mt-board {
    display: grid;
    grid-template-columns: 1fr 48px 1fr;
    gap: 0;
    align-items: start;
}
.mt-col { display: flex; flex-direction: column; gap: 8px; }
.mt-connector { position: relative; align-self: stretch; }

.mt-card {
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    cursor: pointer;
    font-size: .875rem;
    line-height: 1.4;
    transition: border-color .15s, background .15s, transform .12s, box-shadow .15s, opacity .2s;
    user-select: none;
    min-height: 58px;
    display: flex;
    align-items: center;
}
.mt-card-text { word-break: break-word; }
.mt-card-term { justify-content: flex-end; text-align: right; }
.mt-card-def  { justify-content: flex-start; text-align: left; }

.mt-card:hover:not(.mt-matched):not(.mt-locked) {
    border-color: rgba(124,111,255,.5);
    background: rgba(124,111,255,.06);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.mt-card.mt-selected {
    border-color: var(--accent) !important;
    background: rgba(124,111,255,.12) !important;
    box-shadow: 0 0 0 3px rgba(124,111,255,.2);
    transform: translateY(-2px);
}
.mt-card.mt-matched {
    border-color: rgba(34,217,138,.5);
    background: rgba(34,217,138,.08);
    opacity: .65;
    cursor: default;
    pointer-events: none;
}
.mt-card.mt-wrong {
    border-color: #ff5b5b !important;
    background: rgba(255,91,91,.1) !important;
    animation: mt-shake .35s ease;
}
@keyframes mt-shake {
    0%,100% { transform:translateX(0); }
    25% { transform:translateX(-7px); }
    75% { transform:translateX(7px); }
}

@media (max-width: 560px) {
    .mt-board { grid-template-columns: 1fr 28px 1fr; }
    .mt-card { padding: 11px 10px; font-size: .78rem; min-height: 48px; }
}

/* ===== RESULTS ===== */
.results-box {
    text-align: center;
    padding: 40px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.results-score {
    font-family: var(--font-display);
    font-size: 5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 12px;
}

.results-label { font-size: 1.2rem; color: var(--text-muted); margin-bottom: 32px; }

.results-breakdown {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 32px;
}

.result-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.result-stat-num { font-family: var(--font-display); font-size: 2rem; font-weight: 800; }
.result-stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.result-correct .result-stat-num { color: var(--green); }
.result-wrong .result-stat-num { color: var(--red); }

/* ===== CARD LIST (in set view) ===== */

.empty-state svg { color: var(--bg-4); margin-bottom: 16px; }

/* ===== RESPONSIVE ===== */

/* ===== TABS ===== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    gap: 4px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 6px 16px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--bg-3);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-block;
}

.filter-chip:hover, .filter-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Animations */

.fade-in-1 { animation-delay: 0.05s; opacity: 0; }
.fade-in-2 { animation-delay: 0.1s; opacity: 0; }
.fade-in-3 { animation-delay: 0.15s; opacity: 0; }

/* Confetti overlay */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.mobile-menu.open { transform: translateY(0); opacity: 1; }

/* ===== LIBRARY PAGE ===== */
.library-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.library-header-left {}

.library-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 32px;
    padding: 20px 24px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.lib-stat {
    text-align: center;
    padding: 8px 0;
}
.lib-stat-num {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -.03em;
    color: var(--accent);
    line-height: 1.1;
}
.lib-stat-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-top: 4px;
}

.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--bg-4);
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
    margin-left: 6px;
    color: var(--text-muted);
}
.tab-btn.active .tab-count { background: rgba(108,99,255,.25); color: var(--accent); }

.lib-sets-list { display: flex; flex-direction: column; gap: 10px; }

.lib-set-row {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    transition: all var(--transition);
}
.lib-set-row:hover {
    border-color: rgba(108,99,255,.4);
    box-shadow: 0 4px 20px rgba(108,99,255,.1);
}

.lib-set-main { flex: 1; text-decoration: none; min-width: 0; }
.lib-set-info {}

.lib-set-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-set-desc {
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-set-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.lib-set-count {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-4);
    padding: 3px 9px;
    border-radius: 6px;
}

.lib-set-date {
    font-size: .75rem;
    color: var(--text-dim);
}

.lib-set-author {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    color: var(--text-dim);
}

.lib-set-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== HOMEPAGE ADDITIONS ===== */
.hero-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    margin-top: 48px;
    padding: 24px 32px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}
.hero-stat { text-align: center; }
.hero-stat-num {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: -.03em;
    color: var(--accent);
}
.hero-stat-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-top: 2px;
}
.hero-stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border);
}

/* How it works section */
.how-it-works {
    padding: 60px 24px;
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.how-inner { max-width: 960px; margin: 0 auto; }
.steps-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    gap: 20px;
    align-items: center;
}
.step-card {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
}
.step-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(108,99,255,.2);
    border: 2px solid rgba(108,99,255,.4);
    color: var(--accent);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.step-card h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 10px;
}
.step-card p { font-size: .85rem; color: var(--text-muted); line-height: 1.6; }
.step-arrow {
    font-size: 1.5rem;
    color: var(--text-dim);
    font-weight: 300;
    flex-shrink: 0;
}

/* CTA banner */
.cta-banner {
    margin-top: 60px;
    padding: 48px;
    background: linear-gradient(135deg, rgba(108,99,255,.15), rgba(108,99,255,.05));
    border: 1px solid rgba(108,99,255,.25);
    border-radius: var(--radius-lg);
}
.cta-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    flex-wrap: wrap;
}
.cta-banner h2 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: -.03em;
    margin-bottom: 8px;
}
.cta-banner p { color: var(--text-muted); max-width: 440px; }

/* ===== RESPONSIVE IMPROVEMENTS ===== */
@media (max-width: 900px) {
    .steps-grid {
        grid-template-columns: 1fr;
        max-width: 400px;
        margin: 0 auto;
    }
    .step-arrow { transform: rotate(90deg); font-size: 1.2rem; }
}

@media (max-width: 480px) {
    .sets-grid { grid-template-columns: 1fr; }
    .library-stats { grid-template-columns: repeat(2, 1fr); }
    .lib-stat-num { font-size: 1.6rem; }
    .hero-stats { flex-wrap: wrap; gap: 16px; }
    .hero-stat-divider { display: none; }
    .how-it-works { padding: 40px 16px; }
    .page-wrapper { padding: 24px 16px; }

    /* Card editor mobile */
    .card-editor { grid-template-columns: 1fr; }
    .set-meta-box { grid-template-columns: 1fr; }
    .ai-generate-row { grid-template-columns: 1fr 1fr; }
    .ai-go { grid-column: 1/-1; }

    /* Navbar padding */
    .nav-inner { padding: 0 16px; }
}

/* Safe area for iPhone notch/home indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    
    .navbar { padding-top: env(safe-area-inset-top); }
}

/* PWA standalone tweaks */
html.pwa-active .navbar { padding-top: env(safe-area-inset-top); }
html.pwa-active body { padding-bottom: env(safe-area-inset-bottom); }

/* ===== FreeTools.Study — Featured / Top Sets ===== */
.set-card-featured {
    border-color: rgba(108, 99, 255, 0.35);
    background: linear-gradient(135deg, var(--bg-2) 0%, rgba(108,99,255,0.06) 100%);
    position: relative;
    overflow: hidden;
}
.set-card-featured::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), #a29bfe);
    opacity: 0.8;
}
.set-card-featured:hover {
    border-color: rgba(108, 99, 255, 0.6);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(108,99,255,0.18);
}

/* ===== FOLDERS ===== */
.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.folder-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}
.folder-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-3);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.folder-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    border: 1px solid transparent;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.folder-info { flex: 1; min-width: 0; }
.folder-name { font-weight: 600; font-size: .95rem; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-desc { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.folder-meta { font-size: .75rem; color: var(--text-dim); }
.folder-arrow { color: var(--text-dim); flex-shrink: 0; }

/* Color swatches */
.color-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}
.color-swatch:hover, .color-swatch.selected {
    border-color: white;
    transform: scale(1.15);
}

/* ===== MODALS ===== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-box {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%; max-width: 480px;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 2px 6px;
    border-radius: 6px; transition: var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg-3); }

/* ===== GOOGLE OAUTH BUTTON ===== */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    color: var(--text-muted);
    font-size: .78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after {
    content: ''; flex: 1;
    height: 1px; background: var(--border);
}

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: 10px; font-size: .875rem; margin-bottom: 16px; }
.alert-error   { background: rgba(255,91,91,0.12); border: 1px solid rgba(255,91,91,0.3); color: #ff8080; }
.alert-success { background: rgba(34,217,138,0.12); border: 1px solid rgba(34,217,138,0.3); color: var(--green); }

@media (max-width: 640px) {
    .folders-grid { grid-template-columns: 1fr; }
    .modal-box { padding: 20px; }
}

/* Avatar ring for premium users */

/* Hide AI pill on small screens — shown in mobile menu instead */

/* Premium badge (desktop nav) */

/* AI uses pill — shown in navbar for free users */

.nav-ai-pill-sep { opacity: .4; margin: 0 1px; }

/* Premium pill — shown for premium users */
.nav-prem-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, rgba(255,209,102,.15), rgba(255,159,67,.1));
    border: 1px solid rgba(255,209,102,.3);
    border-radius: 100px;
    padding: 5px 10px;
    font-size: .72rem;
    font-weight: 700;
    color: #ffd166;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}
.nav-prem-pill:hover {
    background: linear-gradient(135deg, rgba(255,209,102,.22), rgba(255,159,67,.16));
    border-color: rgba(255,209,102,.45);
}

/* Pricing link for logged-out visitors */

/* Hide "Create Set" nav button on the create page — it's redundant and clutters mobile nav */
.create-page .nav-create-btn { display: none; }

/* Dropdown premium link */
.dd-premium-link {
    color: #ffd166 !important;
    font-weight: 700 !important;
}
.dd-premium-link:hover {
    background: rgba(255,209,102,.08) !important;
}

/* Mobile premium link */
.mobile-prem-link {
    background: linear-gradient(135deg, rgba(255,209,102,.1), rgba(255,209,102,.04)) !important;
    color: #ffd166 !important;
    border: 1px solid rgba(255,209,102,.2) !important;
    font-weight: 700 !important;
}
.mobile-prem-link:hover {
    background: linear-gradient(135deg, rgba(255,209,102,.18), rgba(255,209,102,.08)) !important;
}

/* ===== HOMEPAGE PRICING PILLS ===== */
.bf-pricing-pills {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 40px;
    max-width: 640px;
    width: 100%;
    text-align: left;
}
.bf-pill-free, .bf-pill-prem {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    font-size: .78rem;
}
.bf-pill-free { background: rgba(34,217,138,.05); }
.bf-pill-free svg { color: #22d98a; margin-top: 2px; flex-shrink: 0; }
.bf-pill-prem { background: rgba(255,209,102,.06); border-left: 1px solid var(--border); }
.bf-pill-prem svg { color: #ffd166; margin-top: 2px; flex-shrink: 0; }
.bf-pill-free strong, .bf-pill-prem strong { display: block; font-weight: 700; margin-bottom: 2px; font-size: .8rem; }
.bf-pill-free span, .bf-pill-prem span { color: var(--text-muted); line-height: 1.4; }
.bf-pill-prem strong { color: #ffd166; }
.bf-pill-divider {
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: .7rem;
    font-weight: 800;
    color: var(--text-dim);
    background: var(--bg-2);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

/* ===== PRICING PLANS SECTION ===== */
.bf-plans { padding: 80px 24px; background: var(--bg-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.bf-plans-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 48px;
    max-width: 700px;
}
.bf-plan-card {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}
.bf-plan-featured {
    border-color: rgba(255,209,102,.35);
    background: linear-gradient(160deg, rgba(255,209,102,.06) 0%, var(--bg-3) 50%);
    box-shadow: 0 4px 32px rgba(255,209,102,.08);
}
.bf-plan-best {
    background: linear-gradient(135deg, #ffd166, #ff9f43);
    color: #1a1200;
    font-size: .68rem;
    font-weight: 800;
    text-align: center;
    padding: 5px 0;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.bf-plan-header { padding: 24px 20px 20px; border-bottom: 1px solid var(--border); }
.bf-plan-name { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 8px; }
.bf-plan-featured .bf-plan-name { color: #ffd166; }
.bf-plan-price { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; letter-spacing: -0.04em; line-height: 1; margin-bottom: 4px; }
.bf-plan-price span { font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.bf-plan-period { font-size: .75rem; color: var(--text-muted); margin-bottom: 16px; }
.bf-plan-btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 11px 16px;
    background: linear-gradient(135deg, #ffd166, #ff9f43);
    color: #1a1200; font-family: var(--font-display); font-weight: 800;
    font-size: .875rem; border-radius: 12px; border: none; cursor: pointer;
    transition: all .2s; text-decoration: none;
    box-shadow: 0 3px 14px rgba(255,209,102,.3);
}
.bf-plan-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(255,209,102,.4); }
.bf-plan-btn-ghost {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 11px 16px;
    background: transparent; color: var(--text-muted);
    font-weight: 600; font-size: .875rem; border-radius: 12px;
    border: 1px solid var(--border); cursor: pointer; transition: all .2s; text-decoration: none;
}
.bf-plan-btn-ghost:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-2); }
.bf-plan-features { list-style: none; margin: 0; padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 9px; }
.bf-plan-features li { display: flex; align-items: flex-start; gap: 8px; font-size: .82rem; color: var(--text-muted); }
.bf-plan-features li svg { flex-shrink: 0; margin-top: 1px; }
.bf-plan-features li.yes svg, .bf-plan-features li.yes::before { content: ''; }
.bf-plan-features li.yes { color: var(--text); }
.bf-plan-features li.yes::before { content: '✓'; color: #22d98a; font-weight: 700; font-size: .8rem; flex-shrink: 0; margin-top: 1px; }
.bf-plan-features li.yes.prem { color: var(--text); }
.bf-plan-features li.yes.prem svg { color: #ffd166; }
.bf-plan-features li.limited { color: var(--text-muted); }
.bf-plan-features li.limited svg { color: #a09aff; }

/* Feature tags */
.bf-feat-tag-free {
    display: inline-block;
    margin-top: 12px;
    background: rgba(34,217,138,.1);
    color: #22d98a;
    font-size: .68rem; font-weight: 700;
    padding: 3px 10px; border-radius: 100px;
    border: 1px solid rgba(34,217,138,.2);
    letter-spacing: .05em; text-transform: uppercase;
}
.bf-feat-tag-prem {
    display: inline-block;
    margin-top: 4px;
    background: rgba(255,209,102,.1);
    color: #ffd166;
    font-size: .68rem; font-weight: 700;
    padding: 3px 10px; border-radius: 100px;
    border: 1px solid rgba(255,209,102,.2);
    letter-spacing: .05em; text-transform: uppercase;
    text-decoration: none;
    transition: background .15s;
}
.bf-feat-tag-prem:hover { background: rgba(255,209,102,.18); }

/* Final CTA tag */
.bf-final-cta-tag {
    display: inline-block;
    font-size: .72rem; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase;
    color: #22d98a; margin-bottom: 12px;
}

/* Responsive */
@media (max-width: 640px) {
    .bf-pricing-pills { flex-direction: column; border-radius: 14px; }
    .bf-pill-prem { border-left: none; border-top: 1px solid var(--border); }
    .bf-pill-divider { display: none; }
    .bf-plans-grid { grid-template-columns: 1fr; max-width: 420px; }
}

/* Dropdown plan status line */
.dd-plan-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-3);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 100px;
}
.dd-plan-prem {
    color: #ffd166;
    background: rgba(255,209,102,.08);
    border-color: rgba(255,209,102,.25);
}
.dd-plan-low {
    color: #ff8080;
    background: rgba(255,91,91,.08);
    border-color: rgba(255,91,91,.25);
}

/* Set page search */
.sv-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    transition: border-color .15s;
    width: 200px;
}
.sv-search-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124,111,255,.12);
}
.sv-search-wrap svg { color: var(--text-dim); flex-shrink: 0; }
.sv-search-input {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: .82rem;
    flex: 1;
    min-width: 0;
    width: 100%;
}
.sv-search-input::placeholder { color: var(--text-dim); }
.sv-search-clear {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: .8rem;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: color .15s;
}
.sv-search-clear:hover { color: var(--text); }
.sv-no-results {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px;
    color: var(--text-muted);
    font-size: .88rem;
    justify-content: center;
}
mark.sv-hl {
    background: rgba(255,209,102,.25);
    color: var(--text);
    border-radius: 2px;
    padding: 0 1px;
}
@media (max-width: 640px) {
    .sv-search-wrap { width: 100%; }
}

/* Search page tabs */
.search-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}
.search-tab:hover { color: var(--text); }
.search-tab-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}
.search-tab-count {
    background: var(--accent);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    line-height: 1.6;
}

/* ── Search page — My Sets header ─────────────────────────────────────── */
.my-sets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.my-sets-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.my-sets-count-label {
    font-size: .85rem;
    color: var(--text-muted);
}
.my-sets-query-badge {
    font-size: .78rem;
    color: var(--text-dim);
}
.my-sets-live-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 7px 12px;
    transition: border-color .15s;
    min-width: 200px;
}
.my-sets-live-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124,111,255,.12);
}
.my-sets-live-search svg { color: var(--text-dim); flex-shrink: 0; }
.my-sets-live-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: .85rem;
    flex: 1;
    min-width: 0;
}
.my-sets-live-search input::placeholder { color: var(--text-dim); }
@media (max-width: 600px) {
    .my-sets-header { flex-direction: column; align-items: stretch; }
    .my-sets-live-search { min-width: 0; }
}

/* ── Impersonation banner ──────────────────────────────────────────────────── */
.impersonation-bar {
    position: sticky;
    top: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(90deg, #ff6b35, #f7c59f);
    color: #2d0a00;
    font-size: .8rem;
    font-weight: 600;
    padding: 8px 20px;
    text-align: center;
    flex-wrap: wrap;
}
.impersonation-bar svg { flex-shrink: 0; }
.impersonation-exit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,.15);
    color: #2d0a00;
    border-radius: 6px;
    padding: 3px 10px;
    text-decoration: none;
    font-weight: 700;
    font-size: .78rem;
    margin-left: 8px;
    transition: background .15s;
}
.impersonation-exit:hover { background: rgba(0,0,0,.28); }

/* ============================================================
   CONSOLIDATED UTILITIES, COMPONENTS & LAYOUT MODULES
   (single source of truth — no duplicates)
   ============================================================ */

/* ── Utilities ─────────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-yellow  { color: var(--yellow); }
.w-full       { width: 100%; justify-content: center; }
.flex-row     { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.grid-2col    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .grid-2col { grid-template-columns: 1fr; } }

/* ── Divider ────────────────────────────────────────────────── */
.divider {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-muted); font-size: .78rem;
    letter-spacing: .05em; text-transform: uppercase;
    margin: 14px 0 18px;
}
.divider::before, .divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Google sign-in button ─────────────────────────────────── */
.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 13px 20px;
    background: #fff; border: 1.5px solid #d0d0d0; border-radius: 10px;
    font-size: .9rem; font-weight: 600; color: #1f1f1f;
    text-decoration: none; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.18);
    transition: box-shadow .15s, border-color .15s; margin-bottom: 6px;
}
.btn-google:hover { box-shadow: 0 3px 10px rgba(0,0,0,.22); border-color: #b0b0b0; }

/* ── Fade in animation ─────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }
.fade-in { animation: fadeIn .3s ease forwards; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 12px;
    padding: 60px 24px; text-align: center; color: var(--text-muted);
}
.empty-state h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--text); }
.empty-state p  { font-size: .88rem; max-width: 320px; line-height: 1.6; }
.empty-icon     { color: var(--text-dim); margin-bottom: 4px; }

/* ── Toggle checkbox ────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--bg-4); border: 1px solid var(--border);
    border-radius: 100px; transition: .2s; cursor: pointer;
}
.toggle-slider::before {
    content: ''; position: absolute;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--text-dim); top: 3px; left: 3px; transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

/* ── Nav logo responsive ────────────────────────────────────── */
/* Always show FTS abbreviation; full name visible in footer */
.nav-logo-short { display: inline; }
.nav-logo-full  { display: none; }

/* ── Nav premium & AI badges ─────────────────────────────────── */
.nav-prem-badge {
    font-size: .7rem; font-weight: 800; letter-spacing: .08em;
    color: #ffd166; background: rgba(255,209,102,.1);
    border: 1px solid rgba(255,209,102,.25);
    padding: 4px 10px; border-radius: 100px; white-space: nowrap;
}
.nav-avatar-premium {
    box-shadow: 0 0 0 2.5px #ffd166, 0 0 0 4.5px rgba(255,209,102,.2);
}
.nav-ai-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .72rem; font-weight: 700;
    color: #a09aff; background: rgba(108,99,255,.1);
    border: 1px solid rgba(108,99,255,.2);
    padding: 5px 10px; border-radius: 100px;
    text-decoration: none; white-space: nowrap;
    transform-origin: center;
    transition: background .15s, color .15s, border-color .15s;
}
.nav-ai-pill:hover { background: rgba(108,99,255,.18); }
.nav-ai-pill-low { color: #ff8080; background: rgba(255,91,91,.08); border-color: rgba(255,91,91,.2); }
.nav-ai-pill-low:hover { background: rgba(255,91,91,.14); }
@media (max-width: 900px) { .nav-ai-pill-desktop { display: none !important; } }

@keyframes ai-counter-pop {
    0%   { transform: scale(1);    filter: brightness(1); }
    25%  { transform: scale(1.22); filter: brightness(1.4); }
    55%  { transform: scale(.94);  filter: brightness(1); }
    80%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.ai-counter-flash {
    animation: ai-counter-pop .45s cubic-bezier(.34,1.56,.64,1) both;
    /* disable transition during animation so keyframe wins */
    transition: none !important;
}
.nav-pricing-link {
    font-size: .85rem; font-weight: 600; color: var(--text-muted);
    text-decoration: none; transition: color .15s;
}
.nav-pricing-link:hover { color: var(--text); }
@media (max-width: 640px) { .nav-pricing-link { display: none; } }
.nav-create-btn .btn-create-text { /* hide text on mobile, keep icon */ }
@media (max-width: 768px) {
    .nav-create-btn { display: none; } /* hide rectangle button on mobile — square icon used instead */
    .nav-login-btn { display: none; }
}
/* Hide create button on create page (redundant) */
.create-page .nav-create-btn { display: none; }

/* ── Hamburger ───────────────────────────────────────────────── */
.nav-hamburger {
    display: none; flex-direction: column; justify-content: center;
    gap: 5px; padding: 6px; background: none; border: none;
    cursor: pointer; width: 36px; height: 36px;
}
.nav-hamburger span {
    display: block; height: 2px; background: var(--text-muted);
    border-radius: 2px; transition: all .25s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
@media (max-width: 768px) { .nav-hamburger { display: flex; } }

/* ── Mobile menu ─────────────────────────────────────────────── */
.mobile-menu {
    position: fixed; top: 58px; left: 0; right: 0; bottom: 0;
    background: var(--bg-2); border-top: 1px solid var(--border);
    z-index: 99; overflow-y: auto;
    display: block;
    transform: translateY(-8px); opacity: 0;
    pointer-events: none; visibility: hidden;
    transition: transform .22s ease, opacity .22s ease, visibility .22s;
}
.mobile-menu.open {
    transform: translateY(0); opacity: 1;
    pointer-events: auto; visibility: visible;
}
.mobile-menu-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 98;
}
.mobile-menu-overlay.open { display: block; }
.mobile-menu-inner { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.mobile-search {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-3); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px; margin-bottom: 10px;
}
.mobile-search input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text); font-size: .9rem;
}
.mobile-search input::placeholder { color: var(--text-dim); }
.mobile-menu-user {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 8px; margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.mobile-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700;
    font-size: .9rem; color: #fff; flex-shrink: 0;
}
.mobile-menu-links { display: flex; flex-direction: column; gap: 2px; }
.mobile-menu-link {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 10px;
    font-size: .9rem; font-weight: 500;
    color: var(--text-muted); text-decoration: none;
    transition: background .15s, color .15s;
}
.mobile-menu-link:hover { background: var(--bg-3); color: var(--text); }
.mobile-menu-link.primary {
    background: var(--accent); color: #fff;
    font-weight: 700; margin-bottom: 4px;
}
.mobile-menu-link.primary:hover { background: var(--accent-hover); }
.mobile-menu-link.danger { color: var(--red); }
.mobile-menu-link.danger:hover { background: rgba(255,91,91,.08); }

/* ── Mobile AI status pill ───────────────────────────────────── */
.mobile-ai-status {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; background: var(--bg-3);
    border: 1px solid var(--border); border-radius: 14px;
    margin-bottom: 4px; text-decoration: none;
    transition: background .15s, border-color .15s;
}
.mobile-ai-status:hover { background: var(--bg-4); border-color: var(--border-hover); }
.mobile-ai-status-low  { border-color: rgba(255,91,91,.3); background: rgba(255,91,91,.06); }
.mobile-ai-status-prem { border-color: rgba(255,209,102,.3); background: linear-gradient(135deg,rgba(255,209,102,.08),rgba(255,209,102,.03)); }
.mobile-ai-status-icon {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(160,154,255,.12);
    display: flex; align-items: center; justify-content: center;
    color: #a09aff; flex-shrink: 0;
}
.mobile-ai-status-prem .mobile-ai-status-icon { background: rgba(255,209,102,.12); color: #ffd166; }
.mobile-ai-status-low  .mobile-ai-status-icon { background: rgba(255,91,91,.12); color: #ff8080; }
.mobile-ai-status-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mobile-ai-status-text strong { font-size: .85rem; font-weight: 700; color: var(--text); display: block; }
.mobile-ai-status-prem .mobile-ai-status-text strong { color: #ffd166; }
.mobile-ai-status-low  .mobile-ai-status-text strong { color: #ff8080; }
.mobile-ai-status-text span { font-size: .72rem; color: var(--text-muted); display: block; }
.mobile-ai-status-badge { font-family: var(--font-display); font-weight: 800; font-size: .9rem; color: #a09aff; flex-shrink: 0; }
.mobile-ai-status-prem .mobile-ai-status-badge { color: #ffd166; font-size: 1.2rem; }
.mobile-ai-status-low  .mobile-ai-status-badge, .mobile-ai-status-badge.badge-empty { color: #ff8080; }

/* ── Dropdown plan status ────────────────────────────────────── */

/* ── IOS install banner ──────────────────────────────────────── */
#ios-install-banner {
    background: var(--bg-3); border-bottom: 1px solid var(--border);
}
.ios-banner-inner {
    display: flex; align-items: center; gap: 12px;
    max-width: 540px; margin: 0 auto; padding: 12px 16px;
}
.ios-banner-text { flex: 1; }
.ios-banner-text strong { display: block; font-size: .88rem; margin-bottom: 2px; }
.ios-banner-text span   { font-size: .75rem; color: var(--text-muted); }
.ios-banner-close {
    background: none; border: none; color: var(--text-dim);
    font-size: 1.1rem; cursor: pointer; padding: 4px; line-height: 1;
    flex-shrink: 0;
}

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer { background: var(--bg-2); border-top: 1px solid var(--border); margin-top: auto; }
.footer-inner {
    max-width: 1200px; margin: 0 auto;
    padding: 40px 24px 28px;
    display: flex; gap: 48px; flex-wrap: wrap; justify-content: space-between;
}
.footer-brand p { font-size: .82rem; color: var(--text-dim); margin-top: 8px; }
.footer-links { display: flex; gap: 48px; flex-wrap: wrap; }
.footer-links h4 {
    font-family: var(--font-display); font-weight: 700;
    font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: 12px;
}
.footer-links div { display: flex; flex-direction: column; gap: 8px; }
.footer-links a { font-size: .84rem; color: var(--text-muted); transition: color .15s; }
.footer-links a:hover { color: var(--text); }
.footer-bottom {
    border-top: 1px solid var(--border);
    padding: 14px 24px; text-align: center;
    font-size: .74rem; color: var(--text-dim);
}
@media (max-width: 640px) {
    .footer-inner { flex-direction: column; gap: 24px; }
    .footer-links { gap: 28px; }
}

/* ── Global mobile breakpoints ───────────────────────────────── */
@media (max-width: 768px) {
    .nav-search { display: none; }
    .mobile-menu { display: block; }
    .library-stats { grid-template-columns: repeat(2, 1fr); }
    .lib-set-row { flex-wrap: wrap; }
    .lib-set-actions { width: 100%; justify-content: flex-end; }
    .hero-stats { gap: 20px; padding: 16px 20px; }
    .cta-banner { padding: 28px 20px; }
    .cta-banner-inner { flex-direction: column; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .sets-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .sets-grid { grid-template-columns: 1fr; }
    .library-stats { grid-template-columns: repeat(2, 1fr); }
    .lib-stat-num { font-size: 1.6rem; }
    .hero-stats { flex-wrap: wrap; gap: 16px; }
    .hero-stat-divider { display: none; }
    .how-it-works { padding: 40px 16px; }
    .page-wrapper { padding: 24px 16px; }
    .card-editor { grid-template-columns: 1fr; }
    .set-meta-box { grid-template-columns: 1fr; }
    .ai-generate-row { grid-template-columns: 1fr 1fr; }
    .ai-go { grid-column: 1/-1; }
    .nav-inner { padding: 0 16px; }
}
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .site-footer { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── My Sets live filter (search page) ───────────────────────── */
.my-sets-live-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 16px;
    transition: border-color .15s;
}
.my-sets-live-filter:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124,111,255,.12);
}
.my-sets-live-filter svg { color: var(--text-dim); flex-shrink: 0; }
.my-sets-live-filter input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: .875rem;
}
.my-sets-live-filter input::placeholder { color: var(--text-dim); }

/* ── Search tab wrapper ───────────────────────────────────────── */
.search-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
}

/* ── Miscellaneous layout fixes ───────────────────────────────── */

/* Ensure page-wrapper has consistent top padding */
.page-wrapper { padding-top: 40px; }
@media (max-width: 480px) { .page-wrapper { padding-top: 24px; } }

/* Auth box consistent sizing */
.auth-box { box-shadow: var(--shadow); }

/* Prevent overflow on mobile for hero topbar */
.sv-hero-topbar { flex-wrap: wrap; gap: 6px; }
.sv-hero-actions { flex-wrap: wrap; }

/* Study tabs scrollable on mobile */
.study-tabs-wrap { padding-bottom: 1px; }

/* Ensure set cards have min-height for visual consistency */
.set-card { min-height: 120px; }

/* Better empty state spacing */
.empty-state { min-height: 200px; }

/* Fix footer brand logo alignment */
.footer-brand .nav-logo { 
    font-size: 1rem;
    margin-bottom: 8px;
    display: inline-flex;
}

/* Pagination consistency */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 40px; flex-wrap: wrap; }

/* Smooth anchor links */
a { transition: color .15s; }

/* Fix alert display flex gap */
.alert { gap: 10px; }

/* ===== UI POLISH — DEPLOY CLEANUP ===== */

/* Search page — search bar full width */
.search-form-bar {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px;
    margin-bottom: 24px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-form-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-form-bar svg { color: var(--text-muted); flex-shrink: 0; }
.search-form-bar input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: .9rem;
}
.search-form-bar input::placeholder { color: var(--text-muted); }
.search-form-bar .search-clear-btn {
    color: var(--text-dim);
    text-decoration: none;
    font-size: .82rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    transition: color .15s;
}
.search-form-bar .search-clear-btn:hover { color: var(--text); }

/* Search tabs — proper border wrapper */
.search-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.search-tabs::-webkit-scrollbar { display: none; }

/* Star count badge in cards */
.set-card-stars {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    color: var(--yellow);
    font-weight: 600;
}

/* Card date badge */
.set-card-date {
    font-size: .72rem;
    color: var(--text-dim);
    margin-left: auto;
}

/* Private badge on set cards */
.set-card-private {
    font-size: .68rem;
    color: var(--text-dim);
    background: var(--bg-4);
    border: 1px solid var(--border);
    padding: 1px 7px;
    border-radius: 6px;
    white-space: nowrap;
}

/* Set card edit link */
.set-card-edit-link {
    font-size: .75rem;
    color: var(--accent);
    font-weight: 600;
    margin-left: auto;
}

/* My sets live filter input */
.my-sets-live-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 14px;
    margin-bottom: 16px;
    transition: border-color .15s;
}
.my-sets-live-filter:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.my-sets-live-filter svg { color: var(--text-dim); flex-shrink: 0; }
.my-sets-live-filter input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: .88rem;
}
.my-sets-live-filter input::placeholder { color: var(--text-dim); }

/* Pagination row */
.pagination-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
    flex-wrap: wrap;
}

/* Section separator */
.section-sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* Section header row (icon + title) */
.section-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}
.section-header-row .section-title { margin-bottom: 0; }

/* Search results info bar */
.search-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    font-size: .85rem;
    color: var(--text-muted);
}

/* Filter bar spacing */
.filter-bar { margin-bottom: 20px; }

/* Homepage page-wrapper padding for logged-in view */
.home-logged-in .page-header {
    padding-top: 12px;
}

/* Profile page top padding */
.profile-wrap { padding-top: 40px; }
@media (max-width: 640px) {
    .profile-wrap { padding-top: 24px; }
}

/* Auth box mobile */
@media (max-width: 480px) {
    .auth-box { padding: 28px 20px; }
}

/* Set page: ensure hero actions wrap on mobile */
@media (max-width: 480px) {
    .sv-hero-actions { flex-wrap: wrap; }
    .sv-hero { padding: 20px 16px 18px; }
    .sv-modes { gap: 6px; }
    .sv-mode { padding: 14px 4px; height: 90px; }
    .sv-mode-icon { width: 36px; height: 36px; }
    .sv-mode-name { font-size: .75rem; }
}

/* Create page mobile card editor */
@media (max-width: 600px) {
    .card-editor { grid-template-columns: 1fr; gap: 10px; }
}

/* Footer logo text */
.footer-brand .nav-logo .nav-logo-full { display: inline; }
.footer-brand .nav-logo .nav-logo-short { display: none; }

/* Ensure navbar height consistent */
.nav-inner { height: 58px; }

/* Fix: dropdown-menu font color for links */
.dropdown-menu a { color: var(--text-muted); }
.dropdown-menu a:hover { color: var(--text); }

/* Fix: login page link colors */
.auth-switch a { color: var(--accent); }

/* Smooth page transitions */
.page-wrapper { animation: fadeIn .25s ease both; }

/* Fix: study-page wrapper padding top  */
.sv-page { padding-top: 32px; }
@media (max-width: 640px) { .sv-page { padding-top: 20px; } }

/* Fix: set card hover state fix for featured cards */
.set-card-featured:hover {
    box-shadow: 0 8px 32px rgba(108,99,255,0.25);
}

/* Library page mobile fixes */
@media (max-width: 480px) {
    .lib-set-row { gap: 10px; padding: 14px 14px; }
    .lib-set-title { font-size: .92rem; }
    .lib-set-actions { gap: 6px; }
}

/* ============================================================
   DEPLOY-READY POLISH — v6
   Utility classes, layout fixes, mobile improvements
   ============================================================ */

/* ── Profile page classes ──────────────────────────────────── */
.profile-form         { display: flex; flex-direction: column; gap: 18px; }
.profile-quick-links  { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.profile-banner-sub   { font-size: .82rem; color: var(--text-dim); }
.profile-stat-clickable { cursor: pointer; }
.profile-stat-clickable:hover { border-color: rgba(124,111,255,.3); }
.stat-card-prem       { background: linear-gradient(135deg,rgba(255,209,102,.08),rgba(255,209,102,.03)) !important; border-color: rgba(255,209,102,.25) !important; }
.stat-prem            { color: #ffd166 !important; font-size: 1.4rem; }
.stat-prem-label      { color: #ffd166 !important; }

/* ── Form helpers ──────────────────────────────────────────── */
.form-disabled        { opacity: .55; cursor: not-allowed; }
.form-help            { color: var(--text-dim); font-size: .75rem; margin-top: 4px; display: block; }
.form-optional        { color: var(--text-dim); font-weight: 400; font-size: .78rem; }

/* ── Button outline variants ───────────────────────────────── */
.btn-prem             { color: #ffd166 !important; border-color: rgba(255,209,102,.3) !important; }
.btn-prem:hover       { background: rgba(255,209,102,.08) !important; }
.btn-danger-outline   { color: var(--red) !important; border-color: rgba(255,91,91,.25) !important; }
.btn-danger-outline:hover { background: rgba(255,91,91,.06) !important; }

/* ── Set card helpers ──────────────────────────────────────── */
.set-card-edit-hint   { margin-left: auto; font-size: .7rem; color: var(--accent); font-weight: 600; }
.set-card-date        { margin-left: auto; font-size: .72rem; color: var(--text-dim); }

/* ── Text helpers ──────────────────────────────────────────── */
.text-dim             { color: var(--text-dim); }

/* ── Homepage section helpers ──────────────────────────────── */
.hp-user-section      { margin-top: 28px; }
.hp-recent-section    { }

/* ── Spacing helpers ───────────────────────────────────────── */
.page-header.flex-between { margin-bottom: 28px; }

/* ── Responsive page-wrapper breathing room ────────────────── */
.page-wrapper         { padding-bottom: 80px; }

/* ── Profile banner responsive ─────────────────────────────── */
@media (max-width: 500px) {
    .profile-banner       { flex-direction: column; gap: 14px; }
    .profile-banner-meta  { margin-left: 0; text-align: left; }
    .profile-quick-links  { flex-direction: column; }
    .profile-quick-links .btn { width: 100%; justify-content: center; }
}

/* ── Auth box mobile ───────────────────────────────────────── */
@media (max-width: 480px) {
    .auth-box { padding: 28px 20px; border-radius: 16px; }
    .auth-page { padding: 20px 16px; align-items: flex-start; padding-top: 32px; }
}

/* ── Set card grid: consistent sizing ──────────────────────── */
.sets-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
}
@media (max-width: 540px) {
    .sets-grid { grid-template-columns: 1fr; gap: 10px; }
}

/* ── Library page mobile ───────────────────────────────────── */
@media (max-width: 540px) {
    .library-stats { grid-template-columns: 1fr 1fr; }
    .lib-stat-num  { font-size: 1.6rem; }
}

/* ── Tabs: horizontal scroll on mobile ─────────────────────── */
.study-tabs-wrap,
.profile-tabs {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

/* ── Footer: full-name logo ────────────────────────────────── */
.site-footer .nav-logo-full { display: inline; }
.site-footer .nav-logo-short { display: none; }

/* ── Dropdown: keep open on focus-within (keyboard nav) ─────── */
.nav-user-menu:focus-within .dropdown-menu { display: block; }

/* ── Prevent body scroll bleed on iOS when menu open ────────── */
body.menu-open { overflow: hidden; position: fixed; width: 100%; }

/* ── Fix: page-title gradient clipping on Safari ────────────── */
.page-title {
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* ── Fix: mobile nav action gap on very small screens ─────────── */
@media (max-width: 360px) {
    .nav-inner { gap: 8px; padding: 0 12px; }
    .btn-sm    { padding: 6px 10px; font-size: .76rem; }
}

/* ── Fix: set view hero on small phones ────────────────────── */
@media (max-width: 420px) {
    .sv-hero { padding: 18px 16px 16px; border-radius: 16px; }
    .sv-title { font-size: 1.4rem; }
    .sv-modes { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .sv-mode  { padding: 14px 4px; height: 88px; }
    .sv-mode-name { font-size: .75rem; }
}

/* ── Fix: learn mode options on tiny screens ────────────────── */
@media (max-width: 400px) {
    .lq-options { grid-template-columns: 1fr; }
    .lq-card    { padding: 20px 16px; }
}

/* ── Smooth scrolling on study page tabs ────────────────────── */
.study-tabs-wrap { scroll-behavior: smooth; }

/* ── Search page responsive ─────────────────────────────────── */
@media (max-width: 600px) {
    .my-sets-header { flex-direction: column; align-items: stretch; }
    .my-sets-live-search { min-width: 0; width: 100%; }
    .search-tab { padding: 8px 10px; font-size: .8rem; }
}

/* ── Admin panel polish ─────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.admin-table th { text-align: left; padding: 10px 12px; color: var(--text-dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); font-weight: 600; }
.admin-table td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-3); }
@media (max-width: 700px) {
    .admin-table { font-size: .78rem; }
    .admin-table td, .admin-table th { padding: 8px 8px; }
}

/* ── Create page: card editor mobile stacking ───────────────── */
@media (max-width: 640px) {
    .card-editor { grid-template-columns: 1fr; gap: 10px; }
    .card-editor-actions { flex-direction: row; }
    .set-meta-box { grid-template-columns: 1fr; }
}

/* ── Global: no horizontal overflow ────────────────────────── */
html, body { overflow-x: hidden; max-width: 100vw; }

/* ── PWA standalone: add extra top space for iOS status bar ─── */
html.pwa-active .impersonation-bar { top: env(safe-area-inset-top); }

/* ============================================================
   DEPLOY POLISH v7 — all new classes from cleanup passes
   ============================================================ */

/* ── Visibility helpers ─────────────────────────────────────── */
.sv-hidden          { display: none !important; }
.sv-search-clear-hidden { display: none; }
.u-line             { text-decoration: underline; }
.mb-0               { margin-bottom: 0 !important; }

/* ── Homepage ───────────────────────────────────────────────── */
.hp-spacer          { height: 60px; }
.hp-header-actions  { display: flex; gap: 10px; flex-shrink: 0; }
.hp-user-header     { padding-top: 8px; }
.set-card-star      { font-size: .75rem; color: var(--yellow); }
.set-card-author-right { justify-content: flex-end; }
@media (max-width: 520px) {
    .hp-header-actions { flex-wrap: wrap; }
    .hp-header-actions .btn { font-size: .78rem; }
}

/* ── Set page / share modal ─────────────────────────────────── */
.share-section      { margin-bottom: 20px; }
.share-label        { font-size: .78rem; color: var(--text-muted); font-weight: 600; display: block; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.share-label-sub    { font-size: .72rem; color: var(--text-dim); text-transform: none; letter-spacing: 0; font-weight: 400; }
.share-input-row    { display: flex; gap: 8px; margin-bottom: 8px; }
.share-url-input    { font-size: .82rem; flex: 1; }
.share-social       { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.share-social-btns  { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-danger-sm      { color: var(--red); font-size: .78rem; }
.form-contents      { display: contents; }
.sv-terms-filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Search page ─────────────────────────────────────────────── */
.search-form        { margin-bottom: 24px; }
.search-bar-wrap    { display: flex; gap: 8px; align-items: center; background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; transition: border-color var(--transition); flex: 1; }
.search-bar-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-bar-wrap input { background: none; border: none; outline: none; color: var(--text); font-size: .875rem; padding: 10px 0; flex: 1; }
.search-clear-link  { color: var(--text-dim); text-decoration: none; font-size: .85rem; flex-shrink: 0; transition: color .15s; }
.search-clear-link:hover { color: var(--text); }
.search-results-section { margin-bottom: 36px; }
@media (max-width: 600px) {
    .search-form .search-bar-wrap { flex: 1; }
}

/* ── Admin page ──────────────────────────────────────────────── */
.admin-badge        { background: var(--red); color: white; font-size: .65rem; font-weight: 700; padding: 3px 7px; border-radius: 6px; letter-spacing: .05em; text-transform: uppercase; }
.admin-badge-sm     { font-size: .6rem; padding: 2px 6px; border-radius: 5px; }
.admin-nav-link     { color: var(--red) !important; }
.admin-stats-grid   { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 40px; }
.admin-stat-card    { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; }
.admin-stat-num     { font-size: 2rem; font-weight: 800; font-family: var(--font-display); line-height: 1; }
.admin-stat-label   { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.admin-search-form  { display: flex; gap: 10px; margin-bottom: 20px; max-width: 480px; }
.admin-search-input { flex: 1; }
.admin-result-count { font-size: .8rem; color: var(--text-muted); margin-bottom: 12px; }
.admin-user-list    { display: flex; flex-direction: column; gap: 8px; }
.admin-user-row     { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.admin-user-prem    { border-color: rgba(255,209,102,.3) !important; }
.admin-user-inner   { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-user-avatar  { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; flex-shrink: 0; color: #fff; }
.admin-user-info    { flex: 1; min-width: 0; }
.admin-user-meta    { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-user-name    { font-weight: 700; font-size: .9rem; }
@media (max-width: 700px) {
    .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-search-form { flex-direction: column; }
}
@media (max-width: 480px) {
    .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-stat-num   { font-size: 1.5rem; }
}

/* ── Header / nav helpers ────────────────────────────────────── */
.dd-username        { color: var(--text-dim); }
.dd-inf             { letter-spacing: .02em; }
.mobile-user-name   { font-weight: 600; font-size: .95rem; }
.mobile-user-handle { font-size: .78rem; color: var(--text-muted); }

/* ── Create page helpers ─────────────────────────────────────── */
.cp-optional        { opacity: .4; font-weight: 500; text-transform: none; letter-spacing: 0; }
.cp-hint-text       { font-size: .8rem; color: var(--text-muted); margin-bottom: 11px; line-height: 1.6; }
.cp-gen-btn-sm      { max-width: 190px; padding: 9px 14px; font-size: .82rem; }
.btn-dim            { color: var(--text-dim); }
.preview-clear-btn  { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: .75rem; line-height: 1; padding: 2px 4px; transition: color .15s; }
.preview-clear-btn:hover { color: var(--text); }
.icon-inline        { flex-shrink: 0; margin-top: 1px; }
.inline-code        { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; font-size: .875em; }
.cp-ai-unlimited    { background: rgba(34,217,138,.1); color: #22d98a; border: 1px solid rgba(34,217,138,.2); border-radius: 100px; padding: 3px 10px; font-size: .75rem; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.cp-ai-limit        { background: rgba(255,91,91,.08); color: var(--red); border: 1px solid rgba(255,91,91,.2); border-radius: 100px; padding: 3px 10px; font-size: .75rem; font-weight: 700; }
.cp-ai-ok           { background: rgba(124,111,255,.1); border: 1px solid rgba(124,111,255,.2); border-radius: 100px; padding: 3px 10px; font-size: .75rem; font-weight: 700; }
.cp-upgrade-link    { color: var(--yellow); text-decoration: underline; }
.cp-meta            { margin-top: 20px; }

/* ── Library author avatar xs ───────────────────────────────── */
.author-avatar-xs   { width: 18px !important; height: 18px !important; font-size: .6rem !important; }

/* ── Profile helpers ─────────────────────────────────────────── */
.text-dim           { color: var(--text-dim); }

/* ============================================================
   DEPLOY-READY POLISH — v7
   Missing classes, layout fixes, mobile perfection
   ============================================================ */

/* ── Search page input bar ─────────────────────────────────── */
.search-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 16px;
    height: 48px;
    transition: border-color var(--transition), box-shadow var(--transition);
    margin-bottom: 24px;
}
.search-input-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-input-bar svg { color: var(--text-muted); flex-shrink: 0; }
.search-input-bar input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
}
.search-input-bar input::placeholder { color: var(--text-dim); }
.search-clear-btn {
    color: var(--text-dim);
    text-decoration: none;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color var(--transition);
}
.search-clear-btn:hover { color: var(--text); }

/* ── Search tabs underline row ─────────────────────────────── */
.search-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.search-tabs::-webkit-scrollbar { display: none; }

/* ── Section header row (icon + title inline) ──────────────── */
.section-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.section-header-row .section-title { margin-bottom: 0; }

/* ── Section separator ─────────────────────────────────────── */
.section-sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* ── Star badge on set cards ───────────────────────────────── */
.set-star-badge {
    font-size: .75rem;
    color: var(--yellow);
    font-weight: 600;
}
.set-card-date {
    font-size: .72rem;
    color: var(--text-dim);
}
.set-card-edit-hint {
    font-size: .72rem;
    color: var(--accent);
    margin-left: auto;
}
.set-card-private {
    font-size: .68rem;
    font-weight: 700;
    color: var(--yellow);
    background: rgba(255,209,102,.1);
    border: 1px solid rgba(255,209,102,.25);
    padding: 2px 7px;
    border-radius: 6px;
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
    flex-wrap: wrap;
}

/* ── My-sets live filter ───────────────────────────────────── */
.my-sets-live-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 16px;
    transition: border-color var(--transition);
}
.my-sets-live-filter:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.my-sets-live-filter svg { color: var(--text-dim); flex-shrink: 0; }
.my-sets-live-filter input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: .88rem;
}
.my-sets-live-filter input::placeholder { color: var(--text-dim); }

/* ── Search results bar ────────────────────────────────────── */
.search-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    font-size: .875rem;
    color: var(--text-muted);
}

/* ── Profile additions ─────────────────────────────────────── */
.profile-wrap { max-width: 900px; margin: 0 auto; padding: 0 20px 80px; }
.profile-form { display: flex; flex-direction: column; gap: 20px; }
.form-help { font-size: .76rem; color: var(--text-dim); margin-top: 4px; }
.form-optional { font-size: .72rem; color: var(--text-dim); font-weight: 400; }
.form-input-disabled { opacity: .55; cursor: not-allowed; }
.profile-quick-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.btn-prem-outline { color: var(--yellow) !important; }
.btn-prem-outline:hover { border-color: rgba(255,209,102,.4) !important; background: rgba(255,209,102,.07) !important; }
.btn-danger-text { color: var(--red) !important; }
.btn-danger-text:hover { border-color: rgba(255,91,91,.3) !important; background: rgba(255,91,91,.07) !important; }
.stat-card-prem .profile-stat-num { color: var(--yellow); }
.profile-stat-clickable { cursor: pointer; }
.profile-stat-clickable:hover { border-color: rgba(124,111,255,.3); }

/* ── Homepage padded header fix ────────────────────────────── */
.page-header-padded { padding-top: 8px; }
.hp-user-section { margin-bottom: 36px; }
.hp-recent-section { }

/* ── body scroll lock when mobile menu open ────────────────── */
body.menu-open { overflow: hidden; }

/* ── Navbar: ensure search form submits on Enter ───────────── */
.nav-search form { display: contents; }

/* ── Fix set view modes grid on very small screens ─────────── */
@media (max-width: 360px) {
    .sv-modes { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .sv-mode { height: 88px; padding: 14px 6px; }
    .sv-mode-name { font-size: .78rem; }
}

/* ── Fix card editor on mobile ─────────────────────────────── */
@media (max-width: 580px) {
    .card-editor { grid-template-columns: 1fr; }
    .set-meta-box { grid-template-columns: 1fr; }
}

/* ── Premium page: ensure pricing grid collapses cleanly ────── */
@media (max-width: 560px) {
    .pricing-grid { grid-template-columns: 1fr; max-width: 380px; margin: 0 auto; }
    .prem-page { padding: 24px 16px 80px; }
    .prem-hero { padding: 40px 0 32px; }
    .prem-title { font-size: 2rem; }
    .prem-sub { font-size: .88rem; }
}

/* ── Library stats 4-col → 2-col on small screens ─────────── */
@media (max-width: 500px) {
    .library-stats { grid-template-columns: repeat(2, 1fr); }
    .lib-stat-num  { font-size: 1.6rem; }
}

/* ── Nav search: ensure correct flex on the inner form ─────── */
.nav-search > input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.875rem;
    padding: 10px 0;
}

/* ── Fix impersonation bar z-index stacking with navbar ─────── */
.impersonation-bar { top: 0; z-index: 10000; }
.navbar { z-index: 100; }

/* ── Fix dropdown arrow for admin link ─────────────────────── */
.dropdown-menu a[href*="admin"] { color: var(--red); }

/* ── Blitz mode: fix card min-height on very small screens ─── */
@media (max-width: 380px) {
    .blitz-card { padding: 20px 16px; min-height: 140px; }
    .blitz-btn  { padding: 12px 8px; font-size: .82rem; }
}

/* ── Match game: fix board on very narrow screens ───────────── */
@media (max-width: 400px) {
    .mt-board { grid-template-columns: 1fr 20px 1fr; }
    .mt-card  { padding: 10px 8px; font-size: .72rem; }
}

/* ── Written mode: fix actions on narrow screens ────────────── */
@media (max-width: 400px) {
    .wt-actions { gap: 8px; }
    .wt-check-btn { padding: 10px 16px; font-size: .88rem; }
}

/* ── Ensure footer logo shows full name in footer ───────────── */
.site-footer .nav-logo .nav-logo-full { display: inline; }
.site-footer .nav-logo .nav-logo-short { display: none; }

/* ── Alert: ensure display:flex for icon alignment ─────────── */
.alert { display: flex; align-items: center; gap: 10px; }

/* ── Auth box: ensure correct width on mobile ───────────────── */
@media (max-width: 480px) {
    .auth-box { padding: 28px 20px; }
}

/* ── Create page: AI generate row ──────────────────────────── */
.ai-generate-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: end;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
@media (max-width: 600px) {
    .ai-generate-row { grid-template-columns: 1fr 1fr; }
    .ai-go { grid-column: 1/-1; }
}

/* ── Ensure .tab-content works correctly ────────────────────── */
.tab-content { display: none !important; }
.tab-content.active { display: block !important; }


.icon-shrink-0 { flex-shrink: 0; }

/* ── Admin layout helpers ────────────────────────────────────── */
.admin-actions-group  { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.admin-inline-form    { display: flex; gap: 4px; align-items: center; }
.admin-flex-form      { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.d-inline             { display: inline; }
.flex-shrink-0        { flex-shrink: 0; }

/* ── Section row (flex-between + spacing) ───────────────────── */
.section-row          { margin-bottom: 16px; }

/* ── Modal backdrop flex centering ─────────────────────────── */
.modal-backdrop[style*="flex"] {
    align-items: center;
    justify-content: center;
}

/* ── Document upload dropzone polish ──────────────────────────────────────── */
.cp-dz-types {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin-top: 10px;
}
.cp-dz-types span {
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 2px 8px;
    font-size: .65rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: .04em;
}
.cp-dz-limit {
    font-size: .7rem;
    color: var(--text-dim);
    margin-top: 6px;
}


/* ── Guest nav redesign ──────────────────────────────────────── */
.nav-text-link {
    font-size: .85rem; font-weight: 500; color: var(--text-muted);
    text-decoration: none; transition: color .15s; white-space: nowrap;
    padding: 4px 2px;
}
.nav-text-link:hover { color: var(--text); }

.nav-divider {
    width: 1px; height: 18px;
    background: var(--border); flex-shrink: 0;
    margin: 0 2px;
}

/* Create — icon-only circle button */
.nav-icon-create {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex-shrink: 0;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    text-decoration: none; transition: all .18s;
}
.nav-icon-create:hover {
    border-color: var(--accent); color: var(--accent);
    background: rgba(124,111,255,.07);
}
.create-page .nav-icon-create { display: none; }

/* Sign up — the single strong CTA */
.nav-cta-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .82rem; font-weight: 800;
    background: var(--accent); color: #fff;
    border-radius: 9px; padding: 7px 14px;
    text-decoration: none; transition: all .18s; white-space: nowrap;
    font-family: var(--font-display); letter-spacing: -.01em;
    box-shadow: 0 2px 10px rgba(124,111,255,.35);
}
.nav-cta-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 18px rgba(124,111,255,.45);
    transform: translateY(-1px);
}

/* Responsive hide classes */
@media (max-width: 640px) { .nav-hide-sm { display: none !important; } }
@media (max-width: 420px) { .nav-hide-xs { display: none !important; } }
@media (max-width: 768px) { .nav-hide-mobile { display: none !important; } }
@media (min-width: 769px) { .nav-hide-desktop { display: none !important; } }

/* Mobile + create button (shown left of hamburger on mobile) */
.nav-mobile-create {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    color: var(--text); background: rgba(124,111,255,.15);
    border: 1.5px solid rgba(124,111,255,.3);
    text-decoration: none; transition: all .15s;
}
.nav-mobile-create:hover { background: rgba(124,111,255,.25); border-color: var(--accent); }
.create-page .create-page-hide { display: none !important; }

.nav-user-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    color: var(--text-muted); text-decoration: none;
    border: 1.5px solid var(--border); transition: all .15s;
}
.nav-user-icon-btn:hover {
    color: var(--text); border-color: rgba(124,111,255,.4);
    background: rgba(124,111,255,.06);
}

.mobile-menu-sep {
    height: 1px; background: var(--border);
    margin: 8px 0;
}
.mobile-guest-hide { display: none !important; }


/* PWA shell elements: hidden by default, shown only in standalone via .pwa-active class */
.pwa-topbar,
.pwa-tabbar,
#pwa-profile-sheet { display: none !important; }

/* ══════════════════════════════════════════════════════════════
   PWA STANDALONE — iOS App Shell
   Activated by JS adding .pwa-active to <html> when in standalone
   ══════════════════════════════════════════════════════════════ */

/* ── PWA shell: hidden by default ── */
.pwa-topbar,
.pwa-tabbar,
#pwa-profile-sheet { display: none !important; }

/* ── Show shell only when .pwa-active is on <html> ── */
html.pwa-active .pwa-topbar { display: flex !important; }
html.pwa-active .pwa-tabbar { display: flex !important; }

/* ── Variables ── */
html.pwa-active {
    --pwa-tab-h: 56px;
    --pwa-topbar-h: 52px;
    --pwa-safe-top: env(safe-area-inset-top, 0px);
    --pwa-safe-bot: env(safe-area-inset-bottom, 0px);
}

/* ── Hide web elements ── */
html.pwa-active .navbar,
html.pwa-active .site-footer,
html.pwa-active .ios-install-banner,
html.pwa-active .nav-hamburger,
html.pwa-active .mobile-menu,
html.pwa-active .mobile-menu-overlay,
html.pwa-active .nav-mobile-create,
html.pwa-active #pwa-install-btn { display: none !important; }

/* ── Body padding for top bar + bottom tab bar ── */
html.pwa-active body {
    padding-top: calc(var(--pwa-topbar-h) + var(--pwa-safe-top)) !important;
    padding-bottom: calc(var(--pwa-tab-h) + var(--pwa-safe-bot)) !important;
    background: var(--bg);
}

/* ── Top bar ── */
.pwa-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--pwa-topbar-h, 52px) + var(--pwa-safe-top, 0px));
    padding-top: var(--pwa-safe-top, 0px);
    background: var(--navbar-bg);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-bottom: 0.5px solid var(--border);
    z-index: 200;
    align-items: flex-end;
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 0;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
.pwa-topbar-inner {
    width: 100%;
    height: var(--pwa-topbar-h, 52px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.pwa-topbar-title {
    font-family: var(--font-display);
    font-size: 1.05rem; font-weight: 800;
    color: var(--text); letter-spacing: -.02em;
    flex: 1; text-align: center;
}
.pwa-topbar-left, .pwa-topbar-right {
    width: 60px; display: flex; align-items: center;
}
.pwa-topbar-right { justify-content: flex-end; }
.pwa-topbar-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--bg-3);
    border: none; color: var(--text-muted); cursor: pointer;
    text-decoration: none; -webkit-tap-highlight-color: transparent;
    transition: background .12s;
}
.pwa-topbar-btn:active { background: var(--bg-4); }
.pwa-topbar-logo {
    display: flex; align-items: center; gap: 7px;
    font-family: var(--font-display); font-weight: 800;
    font-size: .95rem; color: var(--text); letter-spacing: -.02em;
    text-decoration: none;
}

/* ── Bottom tab bar ── */
.pwa-tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--pwa-tab-h, 60px) + var(--pwa-safe-bot, 0px));
    padding-bottom: var(--pwa-safe-bot, 0px);
    background: var(--navbar-bg);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-top: 0.5px solid var(--border);
    z-index: 200;
    align-items: flex-start;
    padding-top: 6px;
    /* GPU compositing — prevents scroll repaint glitch on iOS */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    gap: 0;
}
.pwa-tab {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    gap: 4px; padding: 2px 4px 0;
    text-decoration: none; color: var(--text-dim);
    font-size: .62rem; font-weight: 500;
    letter-spacing: 0; text-transform: none;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s; border: none; background: none; cursor: pointer;
    min-width: 0;
    font-family: var(--font-body);
}
.pwa-tab-icon-wrap {
    width: 44px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 15px;
    transition: background .15s, transform .1s;
    position: relative;
}
.pwa-tab:active .pwa-tab-icon-wrap { transform: scale(.88); }
.pwa-tab.pwa-tab-active .pwa-tab-icon-wrap { background: rgba(108,99,255,.14); }
.pwa-tab.pwa-tab-active { color: var(--accent); }
.pwa-tab.pwa-tab-active svg { stroke: var(--accent); }
.pwa-tab-label { line-height: 1; white-space: nowrap; font-size: .6rem; }

/* Create tab — floating + button */
.pwa-tab.pwa-tab-create { color: var(--text-dim); }
.pwa-tab-create-wrap {
    width: 46px; height: 46px;
    background: var(--accent);
    border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px var(--accent-glow);
    margin-top: -18px;
    transition: transform .12s, box-shadow .12s;
    flex-shrink: 0;
}
.pwa-tab.pwa-tab-create:active .pwa-tab-create-wrap {
    transform: scale(.9);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.pwa-tab.pwa-tab-create .pwa-tab-label { margin-top: 4px; }

/* ── Page wrapper ── */
html.pwa-active .page-wrapper { padding: 16px 16px 24px !important; }

/* ── Cards ── */
html.pwa-active .set-card {
    border-radius: 16px !important; padding: 16px !important;
    border: none !important;
    box-shadow: 0 1px 4px rgba(0,0,0,.12), 0 0 0 0.5px var(--border) !important;
}
html.pwa-active[data-theme="light"] .set-card {
    box-shadow: 0 2px 12px rgba(0,0,0,.08), 0 0 0 0.5px rgba(0,0,0,.07) !important;
}

/* ── iOS grouped rows ── */
.pwa-section {
    background: var(--bg-2); border-radius: 16px;
    overflow: hidden; margin-bottom: 20px; border: 0.5px solid var(--border);
}
.pwa-section-label {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--text-dim); padding: 0 16px 8px; margin-top: 20px;
}
.pwa-row {
    display: flex; align-items: center; padding: 13px 16px;
    border-bottom: 0.5px solid var(--border);
    text-decoration: none; color: var(--text); gap: 12px;
    -webkit-tap-highlight-color: transparent;
}
.pwa-row:last-child { border-bottom: none; }
.pwa-row:active { background: var(--bg-3); }
.pwa-row-icon {
    width: 32px; height: 32px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pwa-row-text { flex: 1; }
.pwa-row-title { font-size: .9rem; font-weight: 600; }
.pwa-row-sub { font-size: .75rem; color: var(--text-muted); }
.pwa-row-chevron { color: var(--text-dim); }

/* ── Sets grid ── */
html.pwa-active .sets-grid { gap: 12px !important; }

/* ── Smooth scroll ── */
html.pwa-active * { -webkit-overflow-scrolling: touch; }

/* ── Page large title ── */
.pwa-page-title {
    font-family: var(--font-display); font-size: 1.7rem;
    font-weight: 800; letter-spacing: -.03em; color: var(--text); margin-bottom: 16px;
}


/* ── PWA shell extras ─────────────────────────────────────── */
.pwa-topbar-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; color: #fff;
    font-weight: 800; font-size: .78rem; font-family: var(--font-display);
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s;
}
.pwa-topbar-avatar:active { transform: scale(.9); }

.pwa-offline-badge {
    display: flex; align-items: center; gap: 5px;
    justify-content: center; padding: 4px 0;
    font-size: .68rem; font-weight: 700; color: var(--yellow);
    background: rgba(255,209,102,.1); letter-spacing: .04em;
}

/* Sheet */
.pwa-sheet-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
}
.pwa-sheet {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: var(--bg-2); border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    transition: transform .32s cubic-bezier(.32,.72,0,1);
    max-height: 90vh; overflow-y: auto;
    /* Always fully opaque — it sits on top of content */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.pwa-sheet-handle {
    width: 36px; height: 4px; background: var(--bg-4);
    border-radius: 2px; margin: 14px auto 16px;
}
.pwa-sheet-user {
    display: flex; align-items: center; gap: 14px;
    padding: 0 20px 14px; border-bottom: 0.5px solid var(--border);
}
.pwa-sheet-avatar {
    width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 1.1rem; font-family: var(--font-display);
}
.pwa-sheet-name { font-weight: 700; font-size: .95rem; color: var(--text); }
.pwa-sheet-handle-text { font-size: .78rem; color: var(--text-muted); }

/* ── PWA install promotion card ───────────────────────────── */
.pwa-install-card {
    display: none; /* shown by JS when beforeinstallprompt fires */
    align-items: center; gap: 14px;
    background: linear-gradient(135deg, rgba(108,99,255,.15), rgba(99,211,192,.1));
    border: 1px solid rgba(108,99,255,.25);
    border-radius: 16px; padding: 16px 18px; margin-bottom: 20px;
}
.pwa-install-card-icon {
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--accent); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.pwa-install-card-text { flex: 1; }
.pwa-install-card-text strong { display: block; font-size: .9rem; font-weight: 700; color: var(--text); }
.pwa-install-card-text span { font-size: .75rem; color: var(--text-muted); }
.pwa-install-card-btn {
    padding: 8px 14px; border-radius: 9px; border: none;
    background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700;
    cursor: pointer; white-space: nowrap; font-family: var(--font-display);
    flex-shrink: 0; -webkit-tap-highlight-color: transparent;
}
.pwa-install-card-btn:hover { background: var(--accent-hover); }
.pwa-install-dismiss {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; padding: 4px; font-size: 1rem; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

/* iOS install banner improved */
#ios-install-banner {
    background: var(--bg-3) !important;
    border-bottom: 1px solid var(--border) !important;
}
.ios-banner-cta {
    display: inline-block; margin-top: 4px;
    font-size: .72rem; font-weight: 700; color: var(--accent);
}

/* ── PWA: create tab always visible, just dims when on create page ── */
html.pwa-active.create-page .pwa-tab.pwa-tab-create .pwa-tab-create-wrap {
    opacity: 0.45;
    box-shadow: none;
}
html.pwa-active.create-page .pwa-tab.pwa-tab-create .pwa-tab-label {
    opacity: 0.45;
}

/* ── PWA home widgets ─────────────────────────────────────── */
.pwa-streak-row {
    display: flex; align-items: center;
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 16px; padding: 16px 20px;
    margin-bottom: 12px; gap: 0;
}
.pwa-streak-item {
    flex: 1; text-align: center;
}
.pwa-streak-sep {
    width: 1px; height: 36px; background: var(--border); flex-shrink: 0;
}
.pwa-streak-num {
    font-family: var(--font-display); font-size: 1.6rem; font-weight: 800;
    color: var(--text); letter-spacing: -.03em; line-height: 1;
    margin-bottom: 4px;
}
.pwa-streak-label {
    font-size: .68rem; color: var(--text-muted); font-weight: 500;
}

/* Quick resume card */
.pwa-resume-card {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, rgba(108,99,255,.12), rgba(99,211,192,.06));
    border: 1px solid rgba(108,99,255,.2); border-radius: 14px;
    padding: 14px 16px; margin-bottom: 16px;
}
.pwa-resume-left { flex: 1; min-width: 0; }
.pwa-resume-label {
    font-size: .62rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--accent); margin-bottom: 4px;
}
.pwa-resume-title {
    font-size: .9rem; font-weight: 700; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 2px;
}
.pwa-resume-sub { font-size: .72rem; color: var(--text-muted); }
.pwa-resume-btn {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--accent); color: #fff; padding: 8px 14px;
    border-radius: 9px; font-size: .8rem; font-weight: 700;
    text-decoration: none; white-space: nowrap; flex-shrink: 0;
    font-family: var(--font-display); transition: background .15s;
}
.pwa-resume-btn:hover { background: var(--accent-hover); }

/* Keyboard shortcuts modal (PWA) */
.pwa-shortcuts-overlay {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,.6); display: none;
    align-items: center; justify-content: center; padding: 20px;
}
.pwa-shortcuts-overlay.open { display: flex; }
.pwa-shortcuts-modal {
    background: var(--bg-2); border-radius: 20px;
    padding: 24px; width: 100%; max-width: 360px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.pwa-shortcuts-modal h3 {
    font-family: var(--font-display); font-size: .95rem; font-weight: 800;
    color: var(--text); margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.pwa-shortcut-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0; border-bottom: 0.5px solid var(--border);
    font-size: .85rem; color: var(--text-muted);
}
.pwa-shortcut-row:last-child { border-bottom: none; }
.pwa-shortcut-key {
    display: inline-flex; align-items: center; gap: 4px;
}
.pwa-kbd {
    background: var(--bg-4); border: 1px solid var(--border);
    border-radius: 5px; padding: 2px 7px;
    font-size: .72rem; font-family: monospace; color: var(--text);
    box-shadow: 0 1px 0 var(--border);
}

/* ── Search submit button (chevron in search bar) ─────────── */
.search-submit-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-dim); padding: 4px 6px; display: flex;
    align-items: center; flex-shrink: 0; border-radius: 6px;
    transition: color .15s, background .15s;
}
.search-submit-btn:hover { color: var(--accent); background: rgba(108,99,255,.08); }

/* ── Disabled study mode card ──────────────────────────────── */
.sv-mode-disabled {
    opacity: 0.45; cursor: not-allowed; pointer-events: none;
    position: relative;
}
.sv-mode-lock {
    display: block; font-size: .6rem; color: var(--text-dim);
    margin-top: 3px; font-weight: 600;
}

/* ── Search bar: Enter key hint ─────────────────────────────── */
.search-enter-hint {
    font-size: .65rem; font-weight: 600; color: var(--text-dim);
    white-space: nowrap; flex-shrink: 0; padding: 2px 7px;
    background: var(--bg-4); border-radius: 5px; border: 1px solid var(--border);
    letter-spacing: .02em; pointer-events: none;
}
/* Hide hint when field has a value (clear btn is shown instead) */
#search-q:not(:placeholder-shown) ~ .search-enter-hint { display: none; }

/* ── Nav theme toggle button ─────────────────────────────── */
.nav-theme-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid var(--border);
    background: none; cursor: pointer; color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    transition: all .15s; flex-shrink: 0;
}
.nav-theme-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(108,99,255,.06); }
/* Show moon in dark mode, sun in light mode */
.nav-theme-sun  { display: none; }
.nav-theme-moon { display: block; }
[data-theme="light"] .nav-theme-sun  { display: block; }
[data-theme="light"] .nav-theme-moon { display: none; }
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .nav-theme-sun  { display: block; }
    :root:not([data-theme="dark"]) .nav-theme-moon { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   HOMEPAGE — PART 1 DESIGN IMPROVEMENTS
   ══════════════════════════════════════════════════════════════ */

/* ── 1.1 Hero fade-in animation ─────────────────────────────── */
@keyframes fts-fadein-up {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}
.hp-hero-inner > * { animation: fts-fadein-up 0.55s ease both; }
.hp-hero-inner > *:nth-child(1) { animation-delay: 0.00s; }
.hp-hero-inner > *:nth-child(2) { animation-delay: 0.08s; }
.hp-hero-inner > *:nth-child(3) { animation-delay: 0.14s; }
.hp-hero-inner > *:nth-child(4) { animation-delay: 0.20s; }
.hp-hero-inner > *:nth-child(5) { animation-delay: 0.26s; }
.hp-hero-inner > *:nth-child(6) { animation-delay: 0.32s; }

/* Secondary CTA — properly visible button */
.hp-btn-outline-strong {
    border: 1.5px solid rgba(255,255,255,0.22);
    color: var(--text);
    background: rgba(255,255,255,0.04);
    padding: 11px 22px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    font-family: var(--font-display);
    transition: border-color 0.18s, background 0.18s;
    text-decoration: none; display: inline-flex;
    align-items: center;
}
.hp-btn-outline-strong:hover {
    border-color: rgba(255,255,255,0.38);
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

/* Primary CTA glow pulse */
.hp-btn-primary { position: relative; overflow: visible; }
.hp-btn-primary::after {
    content: ''; position: absolute; inset: -4px; border-radius: 16px;
    background: var(--accent); opacity: 0; filter: blur(14px); z-index: -1;
    animation: btn-pulse 3s ease-in-out infinite;
}
@keyframes btn-pulse {
    0%, 100% { opacity: 0; }
    50%       { opacity: 0.35; }
}

/* ── 1.2 How It Works steps ─────────────────────────────────── */
.hp-step {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: default;
}
.hp-step:hover {
    transform: translateY(-3px);
    border-color: rgba(108,99,255,0.3);
    box-shadow: 0 8px 32px rgba(108,99,255,0.12);
}
.hp-step-line { color: var(--accent); opacity: 0.5; }
.hp-step-line::after { color: var(--accent) !important; opacity: 0.7; }
.hp-steps > .hp-step:nth-child(1) .hp-step-num { background: rgba(108,99,255,0.15); border-color: rgba(108,99,255,0.35); color: #a09aff; }
.hp-steps > .hp-step:nth-child(3) .hp-step-num { background: rgba(34,217,138,0.12);  border-color: rgba(34,217,138,0.3);   color: #22d98a; }
.hp-steps > .hp-step:nth-child(5) .hp-step-num { background: rgba(255,107,157,0.1);  border-color: rgba(255,107,157,0.28); color: #ff6b9d; }

/* ── 1.3 Features grid ──────────────────────────────────────── */
.hp-feat-grid { align-items: stretch; }
.hp-feat { display: flex; flex-direction: column; }
.hp-feat p { flex: 1; }
.hp-feat-cta {
    background: linear-gradient(135deg, rgba(34,217,138,0.09), rgba(34,217,138,0.02)) !important;
    border-color: rgba(34,217,138,0.25) !important;
    box-shadow: 0 4px 24px rgba(34,217,138,0.08);
}
.hp-feat-link {
    display: inline-flex !important; align-items: center; gap: 6px;
    margin-top: auto; padding: 9px 16px;
    background: rgba(34,217,138,0.1); border: 1px solid rgba(34,217,138,0.25);
    border-radius: 8px; font-size: 0.82rem; font-weight: 700; color: #22d98a;
    transition: background 0.18s, border-color 0.18s; width: fit-content;
    text-decoration: none !important;
}
.hp-feat-link:hover { background: rgba(34,217,138,0.18); border-color: rgba(34,217,138,0.4); }

/* ── 1.4 Demo card ──────────────────────────────────────────── */
.hp-demo-section {
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 60px 24px;
}

/* ── 1.5 Testimonials ───────────────────────────────────────── */
.hp-testi-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 14px !important;
}
@media (max-width: 760px) { .hp-testi-grid { grid-template-columns: 1fr !important; } }
.hp-testi {
    background: var(--bg-1, var(--bg-2));
    border: 1.5px solid var(--border);
    border-radius: 16px; padding: 22px 20px;
    display: flex; flex-direction: column; gap: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.hp-testi:hover { border-color: rgba(108,99,255,0.25); box-shadow: 0 6px 28px rgba(0,0,0,0.2); }
.hp-testi p { font-size: 0.88rem; line-height: 1.7; color: var(--text-muted); font-style: italic; flex: 1; }
.hp-testi-stars { color: #ffd166 !important; font-size: .88rem; letter-spacing: 1px; font-style: normal; }
.hp-testi p { font-size: .87rem; line-height: 1.7; color: var(--text-muted); font-style: italic; flex: 1; }
.hp-testi-author { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.hp-testi-author strong { font-size: .83rem; color: var(--text); display: block; }
.hp-testi-author span { font-size: .72rem; color: var(--text-dim); }
.hp-testi-avatar {
    width: 36px; height: 36px; border-radius: 50% !important; flex-shrink: 0;
    display: flex !important; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-family: var(--font-display);
    font-size: .85rem;
}

/* ── 1.6 Pricing ────────────────────────────────────────────── */
.hp-pricing-section .hp-section-wrap { display: flex; flex-direction: column; align-items: center; }
.hp-pricing-section .hp-label,
.hp-pricing-section .hp-sh2  { text-align: center; }
.hp-plans { margin-left: auto; margin-right: auto; }
.hp-plan-btn-ghost {
    background: rgba(255,255,255,0.04) !important;
    border: 1.5px solid rgba(255,255,255,0.18) !important;
    color: var(--text) !important;
}
.hp-plan-btn-ghost:hover { background: rgba(255,255,255,0.08) !important; border-color: rgba(255,255,255,0.3) !important; }
@keyframes plan-shimmer {
    0%,100% { box-shadow: 0 4px 24px rgba(108,99,255,0.12); }
    50%      { box-shadow: 0 4px 36px rgba(108,99,255,0.28); }
}
.hp-plan-pro { animation: plan-shimmer 3s ease-in-out infinite; }

/* ── 1.7 Set category filters ───────────────────────────────── */
.hp-sets-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.hp-sets-filter {
    background: var(--bg-3); border: 1.5px solid var(--border);
    border-radius: 100px; padding: 6px 16px;
    font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
    cursor: pointer; transition: all 0.18s; font-family: var(--font-body);
}
.hp-sets-filter:hover { border-color: var(--border-hover); color: var(--text); }
.hp-sets-filter.active {
    background: rgba(108,99,255,0.12); border-color: rgba(108,99,255,0.35); color: #a09aff;
}

/* ── 1.8 Footer newsletter ──────────────────────────────────── */
.footer-newsletter { margin-top: 8px; }
.footer-newsletter-label { font-size: .72rem; color: var(--text-dim); margin-bottom: 6px; }
.footer-newsletter-form { display: flex; gap: 6px; }
.footer-newsletter-input {
    flex: 1; background: var(--bg-3); border: 1.5px solid var(--border);
    border-radius: 8px; padding: 7px 10px; font-size: 0.78rem;
    color: var(--text); font-family: var(--font-body); outline: none;
    transition: border-color 0.18s; min-width: 0;
}
.footer-newsletter-input::placeholder { color: var(--text-dim); }
.footer-newsletter-input:focus { border-color: var(--accent); }
.footer-newsletter-btn {
    background: var(--accent); color: #fff; border: none; border-radius: 8px;
    padding: 7px 12px; font-size: 0.82rem; font-weight: 700;
    font-family: var(--font-display); cursor: pointer; transition: background 0.18s; flex-shrink: 0;
}
.footer-newsletter-btn:hover { background: var(--accent-hover); }

/* ══════════════════════════════════════════════════════════════
   PART 2 — ONBOARDING MODAL
   ══════════════════════════════════════════════════════════════ */
.fts-ob-overlay {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
    animation: ob-overlay-in 0.35s ease both;
    overflow: hidden;
}
@keyframes ob-overlay-in { from { opacity: 0; } to { opacity: 1; } }
.fts-ob-overlay.fts-ob-closing { animation: ob-overlay-out 0.28s ease forwards; }
@keyframes ob-overlay-out { to { opacity: 0; } }
.fts-ob-modal {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px 20px 32px; position: relative;
    overflow-y: auto;
}
.fts-ob-progress-track { position:fixed; top:0; left:0; right:0; height:3px; background:var(--bg-4); z-index:1; overflow:hidden; border-radius:0; }
.fts-ob-progress-fill { height:100%; background:linear-gradient(90deg,var(--accent),#22d98a); border-radius:24px; transition:width 0.4s cubic-bezier(0.4,0,0.2,1); width:20%; }
.fts-ob-close { position:fixed; top:16px; right:20px; background:none; border:none; color:var(--text-dim); font-size:1rem; cursor:pointer; padding:8px 10px; border-radius:8px; line-height:1; transition:color .15s, background .15s; z-index:2; }
.fts-ob-close:hover { color:var(--text-muted); background:var(--bg-3); }
.fts-ob-step { display:none; flex-direction:column; align-items:center; text-align:center; animation:ob-step-in 0.3s ease; max-width:560px; width:100%; }
.fts-ob-step.active { display:flex; }
@keyframes ob-step-in { from { opacity:0; transform:translateX(18px); } to { opacity:1; transform:translateX(0); } }
.fts-ob-icon { width:72px; height:72px; border-radius:20px; font-size:2rem; display:flex; align-items:center; justify-content:center; margin:0 auto 20px; flex-shrink:0; }
.fts-ob-icon-lg { width:72px; height:72px; font-size:2rem; border-radius:22px; }
.fts-ob-icon-purple { background:rgba(108,99,255,0.15); border:1.5px solid rgba(108,99,255,0.3); }
.fts-ob-icon-blue   { background:rgba(100,180,255,0.1);  border:1.5px solid rgba(100,180,255,0.25); }
.fts-ob-icon-green  { background:rgba(34,217,138,0.1);   border:1.5px solid rgba(34,217,138,0.28); }
.fts-ob-icon-pink   { background:rgba(255,107,157,0.1);  border:1.5px solid rgba(255,107,157,0.25); }
.fts-ob-h2 { font-family:var(--font-display); font-size:1.75rem; font-weight:800; letter-spacing:-0.04em; color:var(--text); margin-bottom:12px; line-height:1.2; }
.fts-ob-p  { font-size:1rem; color:var(--text-muted); line-height:1.7; max-width:440px; margin:0 auto 20px; }
.fts-ob-tip { font-size:0.8rem; color:var(--text-muted); background:rgba(255,209,102,0.07); border:1px solid rgba(255,209,102,0.18); border-radius:10px; padding:10px 14px; margin-top:10px; max-width:380px; line-height:1.6; }
.fts-ob-tip strong { color:var(--yellow); }
.fts-ob-feature-list { display:flex; flex-direction:column; gap:8px; margin:4px 0 10px; text-align:left; width:100%; max-width:300px; }
.fts-ob-feat-item { display:flex; align-items:center; gap:10px; font-size:0.88rem; color:var(--text-muted); font-weight:500; }
.fts-ob-feat-icon { font-weight:800; flex-shrink:0; }
.fts-ob-mockup-create { background:var(--bg-3); border:1.5px solid var(--border); border-radius:14px; padding:16px 18px; width:100%; max-width:380px; margin:0 auto 12px; text-align:left; }
.fts-ob-mock-bar { display:flex; gap:5px; margin-bottom:12px; }
.fts-ob-mock-dot { width:8px; height:8px; border-radius:50%; background:var(--bg-4); }
.fts-ob-mock-dot-accent { background:var(--accent); }
.fts-ob-mock-input { background:var(--bg-4); border:1.5px solid rgba(108,99,255,0.25); border-radius:8px; padding:9px 12px; font-size:0.78rem; color:var(--text-dim); margin-bottom:10px; }
.fts-ob-mock-or { font-size:0.72rem; color:var(--text-dim); text-align:center; margin:6px 0; }
.fts-ob-mock-card-row { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:6px; }
.fts-ob-mock-field { background:var(--bg-4); border-radius:6px; padding:8px 10px; font-size:0.7rem; color:var(--text-dim); font-weight:700; letter-spacing:.06em; text-align:center; }
.fts-ob-mode-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; width:100%; max-width:400px; margin:0 auto 12px; }
.fts-ob-mode-card { background:var(--bg-3); border:1.5px solid var(--border); border-radius:12px; padding:12px 8px; display:flex; flex-direction:column; align-items:center; gap:4px; }
.fts-ob-mode-hot { border-color:rgba(255,107,157,0.3); background:rgba(255,107,157,0.07); }
.fts-ob-mode-icon { font-size:1.3rem; }
.fts-ob-mode-name { font-size:0.78rem; font-weight:700; color:var(--text); font-family:var(--font-display); }
.fts-ob-mode-desc { font-size:0.62rem; color:var(--text-dim); text-align:center; }
.fts-ob-mockup-library { background:var(--bg-3); border:1.5px solid var(--border); border-radius:14px; overflow:hidden; width:100%; max-width:360px; margin:0 auto 12px; }
.fts-ob-mock-lib-row { display:flex; align-items:center; gap:10px; padding:11px 16px; border-bottom:1px solid var(--border); font-size:0.82rem; color:var(--text-muted); }
.fts-ob-mock-lib-row:last-child { border-bottom:none; }
.fts-ob-mock-lib-folder { font-weight:700; color:var(--text); }
.fts-ob-mock-lib-badge { margin-left:auto; font-size:0.65rem; font-weight:700; background:rgba(34,217,138,0.12); color:#22d98a; border:1px solid rgba(34,217,138,0.25); border-radius:20px; padding:2px 8px; white-space:nowrap; }
.fts-ob-final-btns { display:flex; gap:12px; flex-wrap:wrap; justify-content:center; margin:8px 0 14px; }
.fts-ob-btn-primary { background:var(--accent); color:#fff; padding:12px 22px; border-radius:12px; font-weight:800; font-size:0.9rem; font-family:var(--font-display); text-decoration:none; transition:background .18s; }
.fts-ob-btn-primary:hover { background:var(--accent-hover); }
.fts-ob-btn-secondary { background:rgba(255,255,255,0.06); color:var(--text-muted); border:1.5px solid var(--border); padding:11px 20px; border-radius:12px; font-weight:700; font-size:0.88rem; text-decoration:none; transition:all .18s; }
.fts-ob-btn-secondary:hover { border-color:var(--border-hover); color:var(--text); }
.fts-ob-remind { font-size:0.75rem; color:var(--text-dim); margin-top:4px; }
.fts-ob-remind a { color:var(--accent); }
.fts-ob-nav { display:flex; align-items:center; justify-content:space-between; margin-top:32px; width:100%; max-width:400px; }
.fts-ob-dots { display:flex; gap:6px; }
.fts-ob-dot { width:7px; height:7px; border-radius:50%; background:var(--bg-4); border:1px solid var(--border); transition:all .2s; cursor:pointer; }
.fts-ob-dot.active { background:var(--accent); border-color:var(--accent); width:20px; border-radius:4px; }
.fts-ob-btn-back,.fts-ob-btn-next { background:none; border:1.5px solid var(--border); border-radius:9px; padding:8px 16px; font-size:0.82rem; font-weight:700; color:var(--text-muted); cursor:pointer; transition:all .15s; font-family:var(--font-display); }
.fts-ob-btn-back:hover,.fts-ob-btn-next:hover { border-color:var(--border-hover); color:var(--text); }
.fts-ob-btn-next { background:var(--accent); border-color:var(--accent); color:#fff; }
.fts-ob-btn-next:hover { background:var(--accent-hover); border-color:var(--accent-hover); color:#fff; }
.fts-ob-btn-back:disabled { opacity:0.3; pointer-events:none; }

/* ── iOS PWA: prevent input zoom (font-size must be ≥16px on iOS) ── */
html.pwa-active input,
html.pwa-active textarea,
html.pwa-active select {
    font-size: 16px !important;
}
/* Also apply globally for all iOS Safari (not just PWA) */
@supports (-webkit-overflow-scrolling: touch) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* ── Hero card mockup ─────────────────────────────────────── */
.hp2-mock-topbar {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 14px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.hp2-mock-title {
    font-size: .72rem; font-weight: 700; color: var(--text);
    flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hp2-mock-prog {
    width: 48px; height: 4px; background: var(--bg-4);
    border-radius: 4px; overflow: hidden; flex-shrink: 0;
}
.hp2-mock-prog-fill {
    height: 100%; background: var(--accent); border-radius: 4px;
}
.hp2-mock-card {
    background: var(--bg-3); border: 1.5px solid rgba(108,99,255,.2);
    border-radius: 14px; padding: 18px 16px;
    text-align: center; margin-bottom: 14px;
}
.hp2-mock-card-label {
    font-size: .55rem; font-weight: 800; letter-spacing: .1em;
    text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px;
}
.hp2-mock-card-word {
    font-family: var(--font-display); font-size: 1.3rem; font-weight: 800;
    color: var(--text); letter-spacing: -.03em; margin-bottom: 8px;
}
.hp2-mock-card-hint {
    font-size: .65rem; color: var(--accent); font-weight: 700;
}
.hp2-mock-stats {
    display: flex; gap: 0; margin-top: 12px;
    border-top: 1px solid var(--border); padding-top: 12px;
}
.hp2-mock-stat {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 2px; text-align: center;
}
.hp2-mock-stat span:last-child {
    font-size: .6rem; color: var(--text-dim); font-weight: 600;
}
.hp2-mock-stat-n {
    font-family: var(--font-display); font-size: 1.1rem; font-weight: 800;
    color: var(--text-muted);
}

/* ── Social proof: stars below avatars on mobile ─────────── */
.hp2-social-proof {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
}
.hp2-proof-text {
    display: flex; flex-direction: column; gap: 2px;
    font-size: .82rem; color: var(--text-muted);
}
.hp2-proof-text strong { color: var(--text); }
.hp2-proof-stars { line-height: 1; }
@media (max-width: 480px) {
    .hp2-social-proof { flex-direction: column; align-items: flex-start; gap: 6px; }
}
@media (max-width: 900px) {
    .hp2-social-proof { justify-content: center; }
    .hp2-proof-text { align-items: center; }
}

/* ── Shared activity log styles (profile + admin) ─────────── */
.act-list { display: flex; flex-direction: column; }
.act-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.act-row:last-child { border-bottom: none; }
.act-icon {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: .95rem;
}
.act-icon-login { background: rgba(108,99,255,.12); }
.act-icon-ai    { background: rgba(255,209,102,.1); }
.act-icon-study { background: rgba(34,217,138,.1); }
.act-body { flex: 1; min-width: 0; }
.act-title {
    font-size: .84rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.act-meta  { font-size: .72rem; color: var(--text-dim); margin-top: 2px; }
.act-time  { font-size: .7rem; color: var(--text-dim); white-space: nowrap; flex-shrink: 0; }
.act-empty { color: var(--text-dim); font-size: .84rem; padding: 16px 0; text-align: center; }

/* ══════════════════════════════════════════════════════════════
   MODERN THEME — Chromatic Glass
   Deep midnight base · teal-violet chromatic tints · glow edges
   ══════════════════════════════════════════════════════════════ */

/* ── CSS variables ── */
[data-theme="modern"] {
    --bg:              #07080f;
    --bg-1:            rgba(96,220,200,0.04);
    --bg-2:            rgba(120,100,255,0.07);
    --bg-3:            rgba(140,120,255,0.10);
    --bg-4:            rgba(160,140,255,0.14);
    --border:          rgba(130,210,220,0.14);
    --border-hover:    rgba(160,240,230,0.32);
    --text:            #e8edf8;
    --text-muted:      rgba(195,210,235,0.7);
    --text-dim:        #7585a8;
    --accent:          #7b6fff;
    --accent-hover:    #6a5ef0;
    --accent-glow:     rgba(123,111,255,0.45);
    --green:           #2de8a0;
    --red:             #ff5f72;
    --yellow:          #ffc844;
    --radius:          16px;
    --radius-lg:       24px;
    --shadow:          0 8px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(140,220,210,0.1);
    --shadow-lg:       0 24px 72px rgba(0,0,0,0.75), inset 0 1px 0 rgba(140,220,210,0.14);
    --navbar-bg:       rgba(7,8,15,0.72);
    color-scheme: dark;
}

/* ── Animated background ── */
[data-theme="modern"] body {
    background: #07080f;
}
[data-theme="modern"] body::before {
    content: '';
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(ellipse 100vw 70vh at 10% 0%,   rgba(60,180,220,0.14) 0%, transparent 55%),
        radial-gradient(ellipse 80vw 80vh  at 90% 100%, rgba(110,80,255,0.18) 0%, transparent 55%),
        radial-gradient(ellipse 70vw 50vh  at 50% 55%,  rgba(0,200,180,0.08)  0%, transparent 50%),
        #07080f;
    animation: chromatic-drift 22s ease-in-out infinite alternate;
}
@keyframes chromatic-drift {
    0%   { transform: scale(1);    filter: hue-rotate(0deg)   brightness(1);    }
    50%  { transform: scale(1.04); filter: hue-rotate(18deg)  brightness(1.05); }
    100% { transform: scale(1);    filter: hue-rotate(-10deg) brightness(0.96); }
}

/* ── Glass mixin — teal-tinted frost ── */
[data-theme="modern"] .set-card,
[data-theme="modern"] .profile-card,
[data-theme="modern"] .profile-stat-card,
[data-theme="modern"] .adm-stat,
[data-theme="modern"] .hp-plan,
[data-theme="modern"] .hp-testi,
[data-theme="modern"] .hp2-bento-card,
[data-theme="modern"] .hp2-step,
[data-theme="modern"] .adm-user,
[data-theme="modern"] .adm-form-card,
[data-theme="modern"] .adm-report-card,
[data-theme="modern"] .pwa-streak-row,
[data-theme="modern"] .pwa-resume-card,
[data-theme="modern"] .profile-card,
[data-theme="modern"] .fts-ob-mode-card {
    background: rgba(96,200,220,0.05) !important;
    backdrop-filter: blur(28px) saturate(2.2) brightness(1.08);
    -webkit-backdrop-filter: blur(28px) saturate(2.2) brightness(1.08);
    border: 1px solid rgba(100,220,210,0.14) !important;
    border-top: 1px solid rgba(160,240,230,0.24) !important;
    box-shadow:
        0 8px 40px rgba(0,0,0,0.45),
        inset 0 1px 0 rgba(140,230,220,0.12),
        inset 0 -1px 0 rgba(100,80,255,0.06) !important;
}

[data-theme="modern"] .set-card:hover,
[data-theme="modern"] .hp2-bento-card:hover,
[data-theme="modern"] .hp-testi:hover,
[data-theme="modern"] .adm-user:hover {
    background: rgba(100,220,215,0.09) !important;
    border-color: rgba(160,240,230,0.26) !important;
    border-top-color: rgba(180,255,245,0.38) !important;
    box-shadow:
        0 16px 56px rgba(0,0,0,0.55),
        inset 0 1px 0 rgba(160,240,230,0.2),
        0 0 0 1px rgba(100,200,220,0.12),
        0 0 24px rgba(80,180,220,0.08) !important;
    transform: translateY(-2px);
}

/* ── Navbar / bars ── */
[data-theme="modern"] .navbar,
[data-theme="modern"] .pwa-topbar,
[data-theme="modern"] .pwa-tabbar {
    background: rgba(7,8,15,0.72) !important;
    backdrop-filter: blur(32px) saturate(2.5) brightness(1.1);
    -webkit-backdrop-filter: blur(32px) saturate(2.5) brightness(1.1);
    border-color: rgba(100,220,210,0.12) !important;
    box-shadow: 0 1px 0 rgba(140,230,220,0.08) !important;
}


/* Modern theme: btn bg darker than --accent so white text passes AA */
[data-theme="modern"] .btn-primary,
[data-theme="modern"] .hp2-btn-primary,
[data-theme="modern"] .fts-ob-btn-primary {
    background: linear-gradient(135deg, rgba(61,216,200,0.75), rgba(92,79,212,0.9)) !important;
    color: #fff !important;
}
/* ── Accent glow on primary buttons ── */
[data-theme="modern"] .btn-primary,
[data-theme="modern"] .hp2-btn-primary,
[data-theme="modern"] .hp-plan-btn-pro,
[data-theme="modern"] .fts-ob-btn-primary {
    background: linear-gradient(135deg, rgba(100,220,200,0.7), rgba(110,85,255,0.85)) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(160,240,230,0.2) !important;
    box-shadow:
        0 4px 24px rgba(100,200,220,0.3),
        0 0 0 1px rgba(100,220,200,0.1),
        inset 0 1px 0 rgba(255,255,255,0.18) !important;
    color: #fff !important;
}
[data-theme="modern"] .btn-primary:hover,
[data-theme="modern"] .hp2-btn-primary:hover {
    box-shadow:
        0 8px 40px rgba(100,200,220,0.5),
        0 0 0 1px rgba(140,240,220,0.2),
        inset 0 1px 0 rgba(255,255,255,0.22) !important;
    transform: translateY(-1px);
}

/* ── Ghost buttons ── */
[data-theme="modern"] .btn-ghost,
[data-theme="modern"] .hp2-btn-ghost {
    background: rgba(96,200,220,0.06) !important;
    border: 1px solid rgba(100,220,210,0.18) !important;
    backdrop-filter: blur(8px);
}
[data-theme="modern"] .btn-ghost:hover,
[data-theme="modern"] .hp2-btn-ghost:hover {
    background: rgba(100,220,215,0.12) !important;
    border-color: rgba(140,240,230,0.28) !important;
}

/* ── Inputs ── */
[data-theme="modern"] .form-input,
[data-theme="modern"] .form-textarea,
[data-theme="modern"] .form-select,
[data-theme="modern"] .adm-field-input,
[data-theme="modern"] .adm-search-field,
[data-theme="modern"] .footer-newsletter-input,
[data-theme="modern"] .adm-select {
    background: rgba(80,180,200,0.07) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(100,210,200,0.15) !important;
    border-top-color: rgba(140,240,230,0.22) !important;
    color: var(--text) !important;
}
[data-theme="modern"] .form-input:focus,
[data-theme="modern"] .adm-field-input:focus,
[data-theme="modern"] .adm-search-field:focus {
    border-color: rgba(100,200,220,0.5) !important;
    box-shadow: 0 0 0 3px rgba(80,200,220,0.15), inset 0 1px 0 rgba(140,240,230,0.08);
    background: rgba(80,190,210,0.1) !important;
}

/* ── Auth box ── */
[data-theme="modern"] .auth-box {
    background: rgba(80,160,200,0.07) !important;
    backdrop-filter: blur(40px) saturate(2.2);
    -webkit-backdrop-filter: blur(40px) saturate(2.2);
    border: 1px solid rgba(100,220,210,0.15) !important;
    border-top-color: rgba(160,240,230,0.28) !important;
    box-shadow: 0 24px 72px rgba(0,0,0,0.6), inset 0 1px 0 rgba(140,230,220,0.14) !important;
}

/* ── PWA sheet — fully opaque, all themes ── */
[data-theme="modern"] .pwa-sheet {
    background: #0d1020 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-top: 1.5px solid rgba(100,220,210,0.25) !important;
    box-shadow: 0 -12px 48px rgba(0,0,0,0.7), 0 -1px 0 rgba(100,220,210,0.15) !important;
}
/* Sections inside the sheet: solid, no glass */
[data-theme="modern"] .pwa-sheet .pwa-section {
    background: #141828 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid rgba(100,220,210,0.12) !important;
    border-top: 1px solid rgba(140,240,230,0.18) !important;
    box-shadow: none !important;
}
[data-theme="modern"] .pwa-sheet .pwa-row:active {
    background: rgba(96,200,220,0.12) !important;
}
/* Sheet text readable against solid bg */
[data-theme="modern"] .pwa-sheet .pwa-row-title { color: #e8edf8 !important; }
[data-theme="modern"] .pwa-sheet .pwa-row-sub   { color: #b8c4d8 !important; }
[data-theme="modern"] .pwa-sheet .pwa-section-label { color: #7585a8 !important; }
[data-theme="modern"] .pwa-sheet .pwa-sheet-name { color: #e8edf8 !important; }
[data-theme="modern"] .pwa-sheet .pwa-sheet-handle-text { color: #b8c4d8 !important; }

/* ── Hero floating card ── */
[data-theme="modern"] .hp2-hero-card {
    background: rgba(80,180,210,0.08) !important;
    backdrop-filter: blur(36px) saturate(2.2);
    -webkit-backdrop-filter: blur(36px) saturate(2.2);
    border: 1px solid rgba(100,220,210,0.18) !important;
    border-top-color: rgba(180,250,240,0.3) !important;
    box-shadow:
        0 28px 72px rgba(0,0,0,0.55),
        inset 0 1px 0 rgba(160,240,230,0.16),
        0 0 60px rgba(60,160,200,0.06) !important;
}

/* ── Demo card ── */
[data-theme="modern"] .hp-demo-face {
    background: rgba(80,180,210,0.07) !important;
    backdrop-filter: blur(24px) saturate(2);
    -webkit-backdrop-filter: blur(24px) saturate(2);
    border: 1px solid rgba(100,220,210,0.16) !important;
    border-top-color: rgba(160,240,230,0.24) !important;
}
[data-theme="modern"] .hp-demo-back {
    background: rgba(40,200,180,0.09) !important;
    border-color: rgba(60,220,180,0.22) !important;
}

/* ── Onboarding modal ── */
[data-theme="modern"] .fts-ob-overlay {
    background: rgba(4,5,12,0.85) !important;
    backdrop-filter: blur(8px);
}
[data-theme="modern"] .fts-ob-modal {
    background: rgba(80,160,200,0.08) !important;
    backdrop-filter: blur(44px) saturate(2.5);
    -webkit-backdrop-filter: blur(44px) saturate(2.5);
    border: 1px solid rgba(100,220,210,0.16) !important;
    border-top-color: rgba(180,250,240,0.26) !important;
    box-shadow: 0 32px 88px rgba(0,0,0,0.7), inset 0 1px 0 rgba(140,230,220,0.12) !important;
}

/* ── Progress bar — teal-violet gradient ── */
[data-theme="modern"] .fts-ob-progress-fill {
    background: linear-gradient(90deg, #3dd8c8, #7b6fff) !important;
}

/* ── Section backgrounds — transparent to show mesh ── */
[data-theme="modern"] .hp2-hero,
[data-theme="modern"] .hp2-bento-section,
[data-theme="modern"] .hp2-demo-section,
[data-theme="modern"] .hp2-steps-section,
[data-theme="modern"] .hp2-testi-section,
[data-theme="modern"] .hp2-pricing-section,
[data-theme="modern"] .hp2-cta-section,
[data-theme="modern"] .hp-testimonials-section,
[data-theme="modern"] .hp-pwa-section {
    background: transparent !important;
    border-color: rgba(100,210,200,0.07) !important;
}

/* ── Eyebrow / label badges ── */
[data-theme="modern"] .hp2-eyebrow {
    background: rgba(50,200,190,0.1) !important;
    border-color: rgba(80,220,200,0.2) !important;
    color: #3dd8c8 !important;
}
[data-theme="modern"] .hp2-eyebrow-dot {
    background: #3dd8c8 !important;
    box-shadow: 0 0 8px rgba(61,216,200,0.6);
}
[data-theme="modern"] .hp2-section-label {
    background: rgba(60,200,200,0.08) !important;
    border-color: rgba(80,220,210,0.18) !important;
    color: #3dd8c8 !important;
}

/* ── Headline accent gradient ── */
[data-theme="modern"] .hp2-h1-accent {
    background: linear-gradient(135deg, #3dd8c8 0%, #a090ff 50%, #ff7eb3 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

/* ── Active tab pill ── */
[data-theme="modern"] .pwa-tab.pwa-tab-active .pwa-tab-icon-wrap {
    background: rgba(80,200,220,0.18) !important;
}
[data-theme="modern"] .pwa-tab.pwa-tab-active {
    color: #3dd8c8 !important;
}
[data-theme="modern"] .pwa-tab.pwa-tab-active svg {
    stroke: #3dd8c8 !important;
}

/* ── Accent colour override ── */
[data-theme="modern"] .profile-stat-num,
[data-theme="modern"] .adm-stat-n {
    color: #3dd8c8 !important;
}

/* ── Theme cycle badge style ── */
.theme-cycle-badge {
    font-size: .7rem; font-weight: 700; color: var(--accent);
    background: rgba(108,99,255,.1); border: 1px solid rgba(108,99,255,.2);
    padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
[data-theme="modern"] .theme-cycle-badge {
    color: #3dd8c8;
    background: rgba(61,216,200,.1);
    border-color: rgba(61,216,200,.2);
}
[data-theme="light"] .theme-cycle-badge {
    color: var(--accent);
    background: rgba(91,84,232,.08);
    border-color: rgba(91,84,232,.18);
}

/* ══════════════════════════════════════════════════════════════
   RETRO THEME — Terminal Green
   Phosphor green on near-black · scanline texture · CRT feel
   ══════════════════════════════════════════════════════════════ */
[data-theme="retro"] {
    --bg:              #030a03;
    --bg-1:            #060e06;
    --bg-2:            #0a140a;
    --bg-3:            #0f1e0f;
    --bg-4:            #152615;
    --border:          rgba(0,255,80,0.15);
    --border-hover:    rgba(0,255,80,0.35);
    --text:            #a8ffb0;
    --text-muted:      rgba(100,220,110,0.7);
    --text-dim:        rgba(60,160,70,0.5);
    --accent:          #00ff50;
    --accent-hover:    #00dd44;
    --accent-glow:     rgba(0,255,80,0.3);
    --green:           #00ff50;
    --red:             #ff4444;
    --yellow:          #ffee00;
    --radius:          4px;
    --radius-lg:       6px;
    --shadow:          0 0 20px rgba(0,255,80,0.12), inset 0 0 0 1px rgba(0,255,80,0.08);
    --shadow-lg:       0 0 48px rgba(0,255,80,0.18);
    --navbar-bg:       rgba(3,10,3,0.95);
    --font-display:    'Courier New', 'Courier', monospace;
    --font-body:       'Courier New', 'Courier', monospace;
    color-scheme: dark;
}

/* ── CRT phosphor background ── */
[data-theme="retro"] body {
    background: #030a03;
}
[data-theme="retro"] body::before {
    content: '';
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0,0,0,0.15) 2px,
            rgba(0,0,0,0.15) 4px
        ),
        radial-gradient(ellipse 100% 100% at 50% 50%, rgba(0,255,80,0.04) 0%, transparent 70%),
        #030a03;
}

/* ── Scanline flicker on page ── */
[data-theme="retro"] body::after {
    content: '';
    position: fixed; inset: 0; z-index: 9998; pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0,255,80,0.015) 0px,
        rgba(0,255,80,0.015) 1px,
        transparent 1px,
        transparent 3px
    );
    animation: scanlines 8s linear infinite;
}
@keyframes scanlines {
    0%   { background-position: 0 0; }
    100% { background-position: 0 100vh; }
}

/* ── Terminal glow on text ── */
[data-theme="retro"] * {
    text-shadow: 0 0 6px rgba(0,255,80,0.25);
}
[data-theme="retro"] h1, [data-theme="retro"] h2, [data-theme="retro"] h3,
[data-theme="retro"] .hp2-h1, [data-theme="retro"] .hp2-sh2,
[data-theme="retro"] .adm-header-title, [data-theme="retro"] .page-title {
    text-shadow: 0 0 12px rgba(0,255,80,0.5), 0 0 28px rgba(0,255,80,0.2);
    color: #00ff50 !important;
    letter-spacing: .02em;
}

/* ── Cards — terminal box style ── */
[data-theme="retro"] .set-card,
[data-theme="retro"] .profile-card,
[data-theme="retro"] .profile-stat-card,
[data-theme="retro"] .hp-plan,
[data-theme="retro"] .hp-testi,
[data-theme="retro"] .hp2-bento-card,
[data-theme="retro"] .hp2-step,
[data-theme="retro"] .adm-user,
[data-theme="retro"] .adm-stat,
[data-theme="retro"] .adm-form-card,
[data-theme="retro"] .pwa-streak-row,
[data-theme="retro"] .pwa-section {
    background: var(--bg-2) !important;
    border: 1px solid rgba(0,255,80,0.2) !important;
    border-radius: 4px !important;
    box-shadow: 0 0 12px rgba(0,255,80,0.06), inset 0 0 0 1px rgba(0,255,80,0.04) !important;
    position: relative;
}
[data-theme="retro"] .set-card:hover,
[data-theme="retro"] .hp2-bento-card:hover,
[data-theme="retro"] .hp-testi:hover,
[data-theme="retro"] .adm-user:hover {
    border-color: rgba(0,255,80,0.45) !important;
    box-shadow: 0 0 20px rgba(0,255,80,0.15), 0 0 0 1px rgba(0,255,80,0.25) !important;
    transform: none;
}

/* Blinking cursor on card hover */
[data-theme="retro"] .set-card::before {
    content: '> ';
    position: absolute; top: 10px; left: 10px;
    font-size: .7rem; color: rgba(0,255,80,0.4);
    font-family: monospace; animation: blink 1.2s step-end infinite;
    pointer-events: none;
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }

/* ── Navbar terminal bar ── */
[data-theme="retro"] .navbar,
[data-theme="retro"] .pwa-topbar,
[data-theme="retro"] .pwa-tabbar {
    background: rgba(3,10,3,0.97) !important;
    border-color: rgba(0,255,80,0.2) !important;
    box-shadow: 0 1px 0 rgba(0,255,80,0.15) !important;
}

/* ── Buttons — terminal style ── */
[data-theme="retro"] .btn-primary,
[data-theme="retro"] .hp2-btn-primary,
[data-theme="retro"] .hp-plan-btn-pro,
[data-theme="retro"] .fts-ob-btn-primary,
[data-theme="retro"] .hp-plan-btn-solid {
    background: #00ff50 !important;
    border: 1.5px solid #00ff50 !important;
    color: #030a03 !important;
    font-family: 'Courier New', monospace !important;
    box-shadow: 0 0 12px rgba(0,255,80,0.2), inset 0 0 12px rgba(0,255,80,0.05) !important;
    border-radius: 3px !important;
    text-transform: uppercase !important;
    letter-spacing: .08em !important;
}
[data-theme="retro"] .btn-primary:hover,
[data-theme="retro"] .hp2-btn-primary:hover {
    background: rgba(0,255,80,0.12) !important;
    box-shadow: 0 0 24px rgba(0,255,80,0.4), inset 0 0 12px rgba(0,255,80,0.1) !important;
    color: #00ff50 !important;
    transform: none !important;
}

/* ── Ghost buttons ── */
[data-theme="retro"] .btn-ghost,
[data-theme="retro"] .hp2-btn-ghost,
[data-theme="retro"] .btn {
    border-color: rgba(0,255,80,0.3) !important;
    color: rgba(0,255,80,0.7) !important;
    background: transparent !important;
    border-radius: 3px !important;
}
[data-theme="retro"] .btn-ghost:hover,
[data-theme="retro"] .hp2-btn-ghost:hover {
    border-color: rgba(0,255,80,0.6) !important;
    color: #00ff50 !important;
    background: rgba(0,255,80,0.07) !important;
}

/* ── Inputs ── */
[data-theme="retro"] .form-input,
[data-theme="retro"] .form-textarea,
[data-theme="retro"] .form-select,
[data-theme="retro"] .adm-field-input,
[data-theme="retro"] .adm-search-field {
    background: rgba(0,255,80,0.04) !important;
    border: 1px solid rgba(0,255,80,0.25) !important;
    border-radius: 3px !important;
    color: #a8ffb0 !important;
    font-family: 'Courier New', monospace !important;
    caret-color: #00ff50;
}
[data-theme="retro"] .form-input:focus,
[data-theme="retro"] .adm-field-input:focus,
[data-theme="retro"] .adm-search-field:focus {
    border-color: #00ff50 !important;
    box-shadow: 0 0 12px rgba(0,255,80,0.25) !important;
    background: rgba(0,255,80,0.07) !important;
}

/* ── Auth box ── */
[data-theme="retro"] .auth-box {
    background: var(--bg-2) !important;
    border: 1px solid rgba(0,255,80,0.25) !important;
    border-radius: 4px !important;
    box-shadow: 0 0 40px rgba(0,255,80,0.1) !important;
}

/* ── PWA sheet ── */
[data-theme="retro"] .pwa-sheet {
    background: #050d05 !important;
    border-top: 1px solid rgba(0,255,80,0.25) !important;
    box-shadow: 0 -12px 40px rgba(0,255,80,0.08) !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
}
[data-theme="retro"] .pwa-sheet .pwa-row:active {
    background: rgba(0,255,80,0.07) !important;
}

/* ── Section backgrounds ── */
[data-theme="retro"] .hp2-hero,
[data-theme="retro"] .hp2-bento-section,
[data-theme="retro"] .hp2-demo-section,
[data-theme="retro"] .hp2-steps-section,
[data-theme="retro"] .hp2-testi-section,
[data-theme="retro"] .hp2-pricing-section,
[data-theme="retro"] .hp2-cta-section {
    background: transparent !important;
    border-color: rgba(0,255,80,0.08) !important;
}

/* ── Headline ── */
[data-theme="retro"] .hp2-h1-accent {
    background: none !important;
    -webkit-text-fill-color: #00ff50 !important;
    text-shadow: 0 0 20px rgba(0,255,80,0.6), 0 0 40px rgba(0,255,80,0.3) !important;
}
[data-theme="retro"] .hp2-eyebrow {
    background: rgba(0,255,80,0.08) !important;
    border-color: rgba(0,255,80,0.2) !important;
    color: #00ff50 !important;
    border-radius: 2px !important;
}
[data-theme="retro"] .hp2-eyebrow-dot {
    background: #00ff50 !important;
    box-shadow: 0 0 8px rgba(0,255,80,0.8) !important;
    animation: blink 1s step-end infinite !important;
}
[data-theme="retro"] .hp2-section-label {
    background: rgba(0,255,80,0.07) !important;
    border-color: rgba(0,255,80,0.18) !important;
    color: #00ff50 !important;
    border-radius: 2px !important;
}

/* ── Active tab ── */
[data-theme="retro"] .pwa-tab.pwa-tab-active .pwa-tab-icon-wrap {
    background: rgba(0,255,80,0.12) !important;
    box-shadow: 0 0 10px rgba(0,255,80,0.2) !important;
}
[data-theme="retro"] .pwa-tab.pwa-tab-active {
    color: #00ff50 !important;
}
[data-theme="retro"] .pwa-tab.pwa-tab-active svg {
    stroke: #00ff50 !important;
}

/* ── Nav logo glow ── */
[data-theme="retro"] .nav-logo {
    filter: drop-shadow(0 0 6px rgba(0,255,80,0.4));
}

/* ── Progress bars green ── */
[data-theme="retro"] .fts-ob-progress-fill,
[data-theme="retro"] .hp-plan-pro {
    background: linear-gradient(90deg, #00ff50, #00cc40) !important;
    animation: none !important;
}

/* ── Theme badge ── */
[data-theme="retro"] .theme-cycle-badge {
    color: #00ff50 !important;
    background: rgba(0,255,80,0.08) !important;
    border-color: rgba(0,255,80,0.2) !important;
    text-shadow: 0 0 8px rgba(0,255,80,0.5);
}

/* ── Demo card ── */
[data-theme="retro"] .hp-demo-face {
    background: var(--bg-2) !important;
    border: 1px solid rgba(0,255,80,0.2) !important;
    border-radius: 4px !important;
}
[data-theme="retro"] .hp-demo-back {
    border-color: rgba(0,255,80,0.35) !important;
    background: rgba(0,255,80,0.05) !important;
}

/* ── Stat numbers ── */
[data-theme="retro"] .profile-stat-num,
[data-theme="retro"] .adm-stat-n {
    color: #00ff50 !important;
    text-shadow: 0 0 10px rgba(0,255,80,0.4) !important;
}

/* ── PWA theme segmented control ─────────────────────────── */
.pwa-theme-seg {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}
.pwa-theme-opt {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 5px; padding: 10px 4px;
    background: var(--bg-3); border: 1.5px solid var(--border);
    border-radius: 12px; cursor: pointer; font-family: var(--font-body);
    transition: all .15s; -webkit-tap-highlight-color: transparent;
    color: var(--text-muted); min-width: 0;
}
.pwa-theme-opt:active { opacity: .7; }
.pwa-theme-opt-icon { font-size: 1.1rem; line-height: 1; }
.pwa-theme-opt-label {
    font-size: .65rem; font-weight: 700; letter-spacing: .03em;
    text-transform: uppercase; white-space: nowrap;
}
.pwa-theme-opt.active {
    background: var(--accent); border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

/* Per-theme active colours */
[data-theme="dark"]   .pwa-theme-opt[data-theme="dark"].active,
[data-theme="light"]  .pwa-theme-opt[data-theme="light"].active {
    background: var(--accent); border-color: var(--accent); color: #fff;
}
[data-theme="modern"] .pwa-theme-opt[data-theme="modern"].active {
    background: linear-gradient(135deg, rgba(61,216,200,.8), rgba(123,111,255,.8));
    border-color: rgba(61,216,200,.5);
    box-shadow: 0 2px 16px rgba(61,216,200,.35);
    color: #fff;
}
[data-theme="retro"]  .pwa-theme-opt[data-theme="retro"].active {
    background: rgba(0,255,80,.12);
    border-color: #00ff50;
    color: #00ff50;
    box-shadow: 0 0 16px rgba(0,255,80,.3);
    text-shadow: 0 0 8px rgba(0,255,80,.6);
}

/* Light theme sheet — explicitly opaque */
[data-theme="light"] .pwa-sheet {
    background: #f4f5f8 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-top: 1px solid rgba(0,0,0,0.1) !important;
}
[data-theme="light"] .pwa-sheet .pwa-section {
    background: #ffffff !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
}
[data-theme="light"] .pwa-sheet .pwa-row:active {
    background: #f0f1f5 !important;
}
/* ══════════════════════════════════════════════════════════════
   ACCESSIBILITY — WCAG 2.1 AA compliance for all themes
   ══════════════════════════════════════════════════════════════ */

/* ── Focus rings — visible in every theme ── */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}
[data-theme="retro"] :focus-visible {
    outline-color: #00ff50;
    box-shadow: 0 0 0 4px rgba(0,255,80,0.25);
}
[data-theme="modern"] :focus-visible {
    outline-color: #7b6fff;
    box-shadow: 0 0 0 4px rgba(123,111,255,0.25);
}
/* Remove default outline only when we provide a visible replacement */
:focus:not(:focus-visible) { outline: none; }

/* ── Minimum touch target size (44×44px iOS / 48×48px Android) ── */
.btn, .pwa-tab, .pwa-row, .profile-tab, .act-tab,
.adm-btn, .adm-tab, .adm-action-row, .nav-link,
.pwa-theme-opt, .dropdown-item, .mobile-menu-link {
    min-height: 44px;
}
/* Ensure pwa-row hits 44px */
.pwa-row {
    min-height: 44px;
}
/* Theme seg buttons stay compact but still tappable */
.pwa-theme-opt {
    min-height: 60px; /* icon + label */
}

/* ── Skip to content link ── */
.skip-to-content {
    position: absolute; top: -100px; left: 16px;
    background: var(--accent); color: #fff; font-weight: 700;
    padding: 10px 16px; border-radius: 8px; z-index: 9999;
    text-decoration: none; font-size: .9rem;
    transition: top .15s;
}
.skip-to-content:focus { top: 16px; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Mobile text legibility ── */
@media (max-width: 480px) {
    /* Min font size 16px on inputs to prevent iOS auto-zoom */
    .form-input, .form-textarea, .form-select,
    .adm-field-input, .adm-search-field, textarea, input, select {
        font-size: 16px !important;
    }
    /* Body text readable on mobile */
    body { font-size: 16px; }
    /* Ensure links are underlined on mobile for colour-blind users */
    main a:not(.btn):not(.pwa-tab):not(.pwa-row):not(.nav-link):not([class*="btn"]) {
        text-decoration: underline;
    }
}

/* ── Colour-blind safe accent for links ── */
/* Links use underline as secondary cue, not just colour */
a:not([class]) { text-decoration: underline; }
a:not([class]):hover { text-decoration: none; }

/* ── Retro: dim text override for accessibility ──  
   Retro --text-dim computes to ~5.6 on bg-2, which passes.
   But text-shadow on ALL elements reduces legibility — limit it */
[data-theme="retro"] *:not(h1):not(h2):not(h3):not(.adm-header-title):not(.page-title) {
    text-shadow: 0 0 4px rgba(0,255,80,0.15);
}
/* Ensure body text in retro still has enough contrast */
[data-theme="retro"] body, [data-theme="retro"] .pwa-row-title,
[data-theme="retro"] .set-card-title, [data-theme="retro"] .profile-stat-num {
    color: #b8ffc0;
}
[data-theme="retro"] .pwa-row-sub, [data-theme="retro"] .act-meta,
[data-theme="retro"] .set-card-meta {
    color: rgba(140,230,150,0.85);
}

/* ── Modern: ensure text inside glass cards has enough contrast ──
   Glass bg resolves to ~#0d0c14 so our --text values are fine,
   but text-muted rgba needs a concrete fallback */
[data-theme="modern"] .pwa-row-title { color: #e8edf8; }
[data-theme="modern"] .pwa-row-sub   { color: #b8c4d8; }

/* ── Dark: dim text raised to #7a8499 (already in vars) — enforce ── */
[data-theme="dark"] .form-label, [data-theme="dark"] .form-help,
[data-theme="dark"] small, [data-theme="dark"] .badge {
    color: #7a8499;
}

/* ── Light: dim text raised to #6b7491 (already in vars) — enforce ── */
[data-theme="light"] .form-label, [data-theme="light"] .form-help,
[data-theme="light"] small, [data-theme="light"] .badge {
    color: #6b7491;
}

/* ── High contrast mode support ── */
@media (forced-colors: active) {
    .btn-primary { forced-color-adjust: none; background: Highlight; color: HighlightText; }
    .set-card, .profile-card { border: 2px solid ButtonText; }
}
