/* ═══════════════════════════════════════════════════
   DESIGN TOKENS — Light & Dark
   ═══════════════════════════════════════════════════ */
:root {
    --bg:            #f5f0e8;
    --bg2:           #ede7dc;
    --surface:       #fffdf9;
    --surface2:      #f7f3ed;
    --border:        #e5ddd2;
    --charcoal:      #28231e;
    --muted:         #7a6e65;
    --accent:        #c0604f;
    --accent-soft:   #f5ddd9;
    --accent-glow:   rgba(192,96,79,0.18);
    --green:         #4d7a57;
    --green-soft:    #e6f3e9;
    --gold:          #d99b05;
    --gold-soft:     #fef8e6;
    --radius:        12px;
    --radius-lg:     20px;
    --radius-pill:   999px;
    --shadow-sm:     0 2px 8px rgba(40,35,30,0.07);
    --shadow-md:     0 8px 28px rgba(40,35,30,0.10);
    --shadow-lg:     0 20px 52px rgba(40,35,30,0.13);
    --transition:    200ms cubic-bezier(0.4,0,0.2,1);
    --nav-h:         72px;
}

[data-theme="dark"] {
    --bg:            #12100e;
    --bg2:           #1a1714;
    --surface:       #1f1c19;
    --surface2:      #272320;
    --border:        #38322c;
    --charcoal:      #f0ebe4;
    --muted:         #9a8e84;
    --accent:        #d97060;
    --accent-soft:   #4a2420;
    --accent-glow:   rgba(217,112,96,0.15);
    --green:         #66a872;
    --green-soft:    #1e3623;
    --gold:          #f0b429;
    --gold-soft:     #3d2f0a;
    --shadow-sm:     0 2px 8px rgba(0,0,0,0.28);
    --shadow-md:     0 8px 28px rgba(0,0,0,0.38);
    --shadow-lg:     0 20px 52px rgba(0,0,0,0.50);
}

/* ═══════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--charcoal);
    font-family: 'Outfit', 'Segoe UI', 'Noto Sans Khmer', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    transition: background var(--transition), color var(--transition);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

h1, h2, h3, h4 { line-height: 1.12; font-weight: 800; }
h1 { font-size: clamp(2.4rem, 5vw, 4.4rem); margin-bottom: 20px; }
h2 { font-size: clamp(1.7rem, 3vw, 2.6rem); margin-bottom: 10px; }
h3 { font-size: 1.12rem; margin-bottom: 8px; }

p { color: var(--muted); }
p + p { margin-top: 8px; }
.charcoal { color: var(--charcoal); }

code {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 0.88em;
}

/* ═══════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════ */
input, select, textarea {
    width: 100%;
    min-height: 48px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 14px;
    background: var(--surface);
    color: var(--charcoal);
    font: inherit;
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; min-height: 90px; }
select { cursor: pointer; }

/* ═══════════════════════════════════════════════════
   HEADER / NAV
   ═══════════════════════════════════════════════════ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-h);
    background: rgba(245,240,232,0.86);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
[data-theme="dark"] .app-header {
    background: rgba(18,16,14,0.86);
}

.nav-shell {
    max-width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: -0.01em;
    color: var(--charcoal);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}
.nav-links a {
    padding: 6px 13px;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}
.nav-links a:hover { color: var(--charcoal); background: var(--surface2); }
.nav-links a.active-nav-link { color: var(--charcoal); background: var(--surface); box-shadow: var(--shadow-sm); }

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

.session-pill {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}
.session-pill.signed-in {
    color: var(--green);
    border-color: var(--green);
    background: var(--green-soft);
}

.theme-toggle-btn {
    width: 40px;
    height: 40px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--charcoal);
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), background var(--transition), border-color var(--transition);
    flex-shrink: 0;
}
.theme-toggle-btn:hover {
    background: var(--surface2);
    transform: rotate(20deg) scale(1.1);
    border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════
   SPA ROUTING — all sections hidden; only .active shown
   ═══════════════════════════════════════════════════ */
main > .section {
    display: none;
    opacity: 0;
    transform: translateY(8px);
}
main > .section.active {
    display: block;
    animation: section-enter 0.28s ease forwards;
}
@keyframes section-enter {
    to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════
   LAYOUT HELPERS
   ═══════════════════════════════════════════════════ */
.section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 72px 24px;
}

.section-heading {
    margin-bottom: 40px;
}
.section-heading.centered { text-align: center; max-width: 640px; margin: 0 auto 48px; }

.eyebrow {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
}

.full-width { width: 100%; }

/* ═══════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════ */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 22px;
    border: 1.5px solid transparent;
    border-radius: var(--radius-pill);
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0); }

.primary-button {
    background: var(--charcoal);
    color: var(--surface);
    border-color: var(--charcoal);
    box-shadow: var(--shadow-md);
}
.primary-button:hover { box-shadow: var(--shadow-lg); }

.secondary-button {
    background: var(--surface);
    color: var(--charcoal);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.secondary-button:hover { border-color: var(--charcoal); }

.ghost-button {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}
.ghost-button:hover { background: var(--surface2); color: var(--charcoal); }

.mode-button {
    border-radius: var(--radius);
    font-size: 0.88rem;
    padding: 0 10px;
    background: var(--surface);
    color: var(--charcoal);
    border-color: var(--border);
}
.mode-button:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.starred {
    background: var(--gold-soft) !important;
    border-color: var(--gold) !important;
    color: #8a620a !important;
}

/* ═══════════════════════════════════════════════════
   HERO SECTION
   ═══════════════════════════════════════════════════ */
.hero-section {
    min-height: calc(100vh - var(--nav-h));
    padding-top: 40px;
    padding-bottom: 60px;
    position: relative;
    overflow: hidden;
}

.hero-split-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 40px;
    align-items: center;
    width: 100%;
}

.auth-card-container {
    display: none;
    z-index: 10;
}

/* Gateway vs App Visibility Toggles */
body.gateway-active .gateway-only-content {
    display: grid !important;
}
body.gateway-active .app-only-content {
    display: none !important;
}
body:not(.gateway-active) .gateway-only-content {
    display: none !important;
}
body:not(.gateway-active) .app-only-content {
    display: flex !important;
}

/* Hide header links, search wrapper, and avatar in gateway */
body.gateway-active .nav-links,
body.gateway-active #navSearchWrap,
body.gateway-active .nav-user-dropdown {
    display: none !important;
}

@media (max-width: 992px) {
    .dashboard-split-grid {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }
}

@media (max-width: 992px) {
    body.gateway-active .hero-split-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Blob is decorative — excluded from grid flow */
.hero-bg-blob {
    position: absolute;
    top: -120px;
    right: -80px;
    width: 560px;
    height: 560px;
    background: radial-gradient(circle at center, var(--accent-soft) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.7;
    display: none; /* removed from grid flow entirely */
}

.hero-copy {
    position: relative;
    z-index: 1;
    max-width: 580px;
}

.hero-board {
    position: relative;
    z-index: 1;
}

/* Animated badge */
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}
.hero-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
    flex-shrink: 0;
    animation: pulse-dot 2s ease infinite;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent) 0%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.08rem;
    color: var(--muted);
    max-width: 560px;
    margin-bottom: 32px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 44px;
}

/* CTA button extra polish */
.hero-cta {
    background: linear-gradient(135deg, var(--charcoal) 0%, #4a3f38 100%);
    box-shadow: 0 8px 24px rgba(40,35,30,0.25), 0 2px 6px rgba(40,35,30,0.12);
    padding: 0 26px;
    font-size: 1rem;
    letter-spacing: 0.01em;
}
.hero-cta:hover {
    box-shadow: 0 14px 32px rgba(40,35,30,0.32), 0 4px 10px rgba(40,35,30,0.18);
    transform: translateY(-3px);
}
[data-theme="dark"] .hero-cta {
    background: linear-gradient(135deg, var(--accent) 0%, #b84a38 100%);
    color: #fff;
}

.hero-stats {
    display: flex;
    align-items: center;
    gap: 20px;
}
.stat-item { text-align: center; }
.stat-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--charcoal);
    line-height: 1;
}
.stat-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    margin-top: 3px;
}
.stat-sep {
    width: 1px;
    height: 32px;
    background: var(--border);
}

/* Feature cards grid — 2×2 */
.hero-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-content: center;
}

.feature-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px 18px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    cursor: default;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

/* Colored icon wraps */
.feature-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.fc-icon-blue   { background: #e8f0fe; }
.fc-icon-purple { background: #f0e8fe; }
.fc-icon-green  { background: var(--green-soft); }
.fc-icon-gold   { background: var(--gold-soft); }
[data-theme="dark"] .fc-icon-blue   { background: #1a2340; }
[data-theme="dark"] .fc-icon-purple { background: #2a1a40; }
[data-theme="dark"] .fc-icon-green  { background: var(--green-soft); }
[data-theme="dark"] .fc-icon-gold   { background: var(--gold-soft); }

.feature-card:hover.fc-upload { border-color: #6c9af5; }
.feature-card:hover.fc-ai     { border-color: #a06cf5; }
.feature-card:hover.fc-share  { border-color: var(--green); }
.feature-card:hover.fc-star   { border-color: var(--gold); }

.feature-card strong { display: block; font-size: 0.94rem; color: var(--charcoal); margin-bottom: 4px; font-weight: 800; }
.feature-card p { font-size: 0.83rem; margin: 0; line-height: 1.5; }


.gradient-text {
    background: linear-gradient(135deg, var(--accent) 0%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.08rem;
    color: var(--muted);
    max-width: 620px;
    margin-bottom: 32px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 48px;
}

.hero-stats {
    display: flex;
    align-items: center;
    gap: 20px;
}
.stat-item { text-align: center; }
.stat-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--charcoal);
    line-height: 1;
}
.stat-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    margin-top: 3px;
}
.stat-sep {
    width: 1px;
    height: 32px;
    background: var(--border);
}

.hero-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-content: center;
}

.feature-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px 20px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    cursor: default;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }

.feature-icon { font-size: 1.6rem; line-height: 1; }
.feature-card strong { display: block; font-size: 0.97rem; color: var(--charcoal); margin-bottom: 4px; font-weight: 800; }
.feature-card p { font-size: 0.84rem; margin: 0; line-height: 1.5; }

/* ═══════════════════════════════════════════════════
   PANEL / CARD
   ═══════════════════════════════════════════════════ */
.panel {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: box-shadow var(--transition);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.panel-icon { font-size: 1.4rem; }
.panel-header h3 { margin: 0; }
.panel-desc { font-size: 0.92rem; color: var(--muted); margin: 0; }

/* ═══════════════════════════════════════════════════
   ONBOARDING GUIDE
   ═══════════════════════════════════════════════════ */
.onboarding-guide {
    background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 100%);
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 28px;
    animation: section-enter 0.35s ease forwards;
}
[data-theme="dark"] .onboarding-guide {
    background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 100%);
}

.onboarding-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.onboarding-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--charcoal);
}
.onboarding-dismiss {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 4px 12px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.onboarding-dismiss:hover {
    background: var(--surface2);
    border-color: var(--accent);
    color: var(--accent);
}

.onboarding-steps {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.onboarding-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    transition: box-shadow var(--transition), transform var(--transition);
}
.onboarding-step:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.step-body strong {
    display: block;
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--charcoal);
    margin-bottom: 5px;
}
.step-body p {
    font-size: 0.83rem;
    line-height: 1.55;
    margin: 0;
}
.step-body em { font-style: normal; font-weight: 700; color: var(--charcoal); }

.step-arrow {
    font-size: 1.4rem;
    color: var(--accent);
    font-weight: 900;
    padding-top: 36px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .onboarding-steps { flex-direction: column; }
    .step-arrow { padding-top: 0; transform: rotate(90deg); align-self: center; }
}

/* ═══════════════════════════════════════════════════
   RESULT & OUTPUT BOXES
   ═══════════════════════════════════════════════════ */
.result-box, .output-box {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--surface2);
    color: var(--muted);
    font-size: 0.92rem;
    overflow-wrap: anywhere;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.output-box { min-height: 180px; }
.result-box.success, .output-box.success {
    background: var(--green-soft);
    border-color: var(--green);
    color: var(--green);
}
.result-box.error {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════
   AUTH — Single card toggle (Facebook-style)
   ═══════════════════════════════════════════════════ */
.auth-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-h));
    padding-top: 40px;
    padding-bottom: 60px;
}

.auth-wrapper {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    text-align: center;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.auth-logo-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 5px var(--accent-soft);
    display: inline-block;
    animation: pulse-dot 2.4s ease infinite;
}
.auth-logo-name {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--charcoal);
}
.auth-tagline {
    font-size: 0.92rem;
    color: var(--muted);
    margin-bottom: 32px;
}

.auth-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
    text-align: left;
}

.auth-view { display: flex; flex-direction: column; gap: 14px; }

.auth-title {
    font-size: 1.55rem;
    font-weight: 900;
    color: var(--charcoal);
    margin: 0 0 4px;
    line-height: 1.2;
}
.auth-subtitle {
    font-size: 0.92rem;
    color: var(--muted);
    margin: 0 0 8px;
}

.auth-fields { display: flex; flex-direction: column; gap: 12px; }
.auth-row { display: flex; gap: 10px; }
.auth-row input { flex: 1; }

.auth-toggle-text {
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted);
    margin: 4px 0 0;
}
.auth-toggle-link {
    background: none;
    border: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    transition: opacity var(--transition);
}
.auth-toggle-link:hover { opacity: 0.75; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
    margin: 2px 0;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ═══════════════════════════════════════════════════
   WORKSPACE
   ═══════════════════════════════════════════════════ */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 24px;
    align-items: start;
}

.upload-panel, .study-panel { min-height: 560px; }

.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    background: var(--surface2);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
    user-select: none;
}
.file-drop-zone:hover, .file-drop-zone:focus {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(1.01);
    outline: none;
}
.file-drop-zone.dragover {
    border-color: var(--green);
    background: var(--green-soft);
    transform: scale(1.02);
}
.file-input { display: none; }
.drop-icon { font-size: 2.4rem; display: block; margin-bottom: 10px; }
.browse-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
.file-info { display: block; font-size: 0.84rem; font-weight: 700; color: var(--muted); margin-top: 6px; }

.form-row { display: flex; gap: 12px; }

.mode-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.ai-output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1.5px solid var(--border);
    font-size: 0.9rem;
}
.ai-meta { color: var(--muted); font-size: 0.8rem; }

/* ═══════════════════════════════════════════════════
   LIBRARY / DOCUMENT GRID
   ═══════════════════════════════════════════════════ */
.document-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 32px;
}

.document-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    min-height: 220px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    cursor: pointer;
}
.document-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }

.document-card h3 { font-size: 1rem; color: var(--charcoal); overflow-wrap: anywhere; margin: 8px 0 4px; }
.document-card p { font-size: 0.86rem; margin: 2px 0; }

.card-top { display: flex; justify-content: space-between; align-items: center; }
.tag {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--border);
    background: var(--surface2);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
}
.tag.public { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.tag.private { border-color: var(--border); }
.star-count { font-size: 0.86rem; font-weight: 700; color: var(--gold); }

.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.card-actions .button { min-height: 38px; padding: 0 14px; font-size: 0.84rem; }

.author-line { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.author-line strong { color: var(--charcoal); }

/* Preview zone */
.preview-zone { display: grid; gap: 20px; }
.preview-card, .ai-history-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 26px;
}
.preview-heading { margin-bottom: 18px; }
.preview-heading h2 { margin-bottom: 6px; }
.preview-heading a { font-size: 0.85rem; color: var(--accent); text-decoration: underline; }

.text-preview {
    max-height: 460px;
    overflow: auto;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    padding: 16px;
    font-size: 0.92rem;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--charcoal);
    margin-bottom: 18px;
}

.share-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.share-controls select, .share-controls input { min-height: 42px; }

.ai-history { display: grid; gap: 14px; }
.ai-history h3 { margin-bottom: 6px; }
.ai-history-card { padding: 18px; }
.ai-history-card pre {
    font: inherit;
    font-size: 0.88rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--muted);
    margin: 8px 0 0;
    max-height: 180px;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════
   FEED
   ═══════════════════════════════════════════════════ */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 30px;
}
.filter-bar input { max-width: 240px; min-height: 44px; }

/* ═══════════════════════════════════════════════════
   PROFILE
   ═══════════════════════════════════════════════════ */
.profile-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 24px; }

.profile-stars-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    background: var(--gold-soft);
    border: 1.5px solid var(--gold);
    border-radius: var(--radius-pill);
    color: #8a620a;
    font-size: 0.9rem;
    font-weight: 800;
}

.guest-warning {
    text-align: center;
    padding: 48px 24px;
}
.guest-warning .warn-icon { font-size: 3rem; display: block; margin-bottom: 16px; }
.guest-warning h3 { margin-bottom: 10px; color: var(--charcoal); }

/* ═══════════════════════════════════════════════════
   STATUS
   ═══════════════════════════════════════════════════ */
.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.status-card { position: relative; }
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    position: absolute;
    top: 22px;
    right: 22px;
    transition: background var(--transition);
}
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-dot.error { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ═══════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════ */
.empty-state {
    grid-column: 1 / -1;
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.96rem;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════
   LOADING SPINNER
   ═══════════════════════════════════════════════════ */
.spinner-center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
}
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Loading overlay on buttons */
.button.loading { opacity: 0.7; pointer-events: none; }

/* ═══════════════════════════════════════════════════
   FLASHCARD WIDGET
   ═══════════════════════════════════════════════════ */
.flashcard-container { margin-top: 16px; }

.flashcards-wrapper {
    perspective: 1200px;
    position: relative;
    height: 260px;
}

.flashcard-slide {
    display: none;
    width: 100%;
    height: 100%;
}
.flashcard-slide.active { display: block; }

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-front, .flashcard-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border);
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    box-shadow: var(--shadow-md);
}
.flashcard-front { background: var(--surface); }
.flashcard-back {
    background: linear-gradient(135deg, var(--accent-soft), var(--surface));
    border-color: var(--accent);
    transform: rotateY(180deg);
}

.card-label {
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    padding: 4px 10px;
    background: var(--accent-soft);
    border-radius: var(--radius-pill);
}
.card-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--charcoal);
    line-height: 1.45;
    margin: auto 0;
    padding: 0 8px;
}
.card-hint { font-size: 0.72rem; color: var(--muted); font-style: italic; }

.carousel-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}
.carousel-indicator { font-size: 0.9rem; font-weight: 700; color: var(--muted); }

/* ═══════════════════════════════════════════════════
   QUIZ WIDGET
   ═══════════════════════════════════════════════════ */
.quiz-container {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px;
    margin-top: 14px;
    box-shadow: var(--shadow-md);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.quiz-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 20px;
    overflow: hidden;
}
.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    border-radius: 2px;
    transition: width 0.4s ease;
}

.quiz-num { font-size: 0.78rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); }
.quiz-score-pill {
    height: 28px;
    padding: 0 12px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--charcoal);
    display: flex;
    align-items: center;
}

.quiz-question { font-size: 1.15rem; font-weight: 700; color: var(--charcoal); line-height: 1.45; margin-bottom: 22px; }

.quiz-options { display: grid; gap: 10px; }

.quiz-option {
    width: 100%;
    min-height: 52px;
    text-align: left;
    padding: 13px 18px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--charcoal);
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
}
.quiz-option:hover:not(:disabled) { background: var(--surface); border-color: var(--accent); transform: translateX(3px); }
.quiz-option .opt-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.quiz-option.correct { background: var(--green-soft) !important; border-color: var(--green) !important; color: var(--green) !important; }
.quiz-option.correct .opt-letter { background: var(--green); border-color: var(--green); color: #fff; }
.quiz-option.incorrect { background: var(--accent-soft) !important; border-color: var(--accent) !important; color: var(--accent) !important; }
.quiz-option.incorrect .opt-letter { background: var(--accent); border-color: var(--accent); color: #fff; }

.quiz-feedback {
    margin-top: 16px;
    padding: 13px 16px;
    border-radius: var(--radius);
    font-size: 0.93rem;
    border: 1.5px solid transparent;
    border-left-width: 4px;
    animation: fadein 0.2s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.quiz-feedback.success { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.quiz-feedback.error { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.next-btn { margin-top: 18px; }

.quiz-results { text-align: center; padding: 32px 16px; }
.results-emoji { font-size: 3.5rem; display: block; margin-bottom: 12px; }
.results-score { font-size: 1.3rem; color: var(--charcoal); margin: 16px 0 24px; font-weight: 700; }
.results-actions { display: flex; justify-content: center; gap: 12px; }

/* ═══════════════════════════════════════════════════
   AI SUMMARY — CLAUDE-STYLE DOCUMENT
   ═══════════════════════════════════════════════════ */
.ai-markdown-content {
    font-size: 0.96rem;
    line-height: 1.85;
    color: var(--charcoal);
    max-width: 760px;
    margin: 0 auto;
}

/* Section heading pills */
.ai-markdown-content .md-h2,
.ai-markdown-content h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: hsl(25, 40%, 22%);
    margin: 36px 0 16px;
    padding: 11px 16px;
    background: hsl(38, 40%, 94%);
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
    letter-spacing: 0.01em;
}

/* Sub-section headings */
.ai-markdown-content .md-h3,
.ai-markdown-content h3 {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--charcoal);
    margin: 22px 0 8px;
    padding-bottom: 5px;
    border-bottom: 1.5px solid hsl(35, 20%, 87%);
}

/* Paragraphs */
.ai-markdown-content .md-p,
.ai-markdown-content p {
    color: var(--charcoal);
    margin-bottom: 10px;
    line-height: 1.85;
}

/* Bold term at start of paragraph */
.ai-markdown-content .md-term {
    color: hsl(20, 65%, 36%);
    font-weight: 700;
}
.ai-markdown-content .md-dash {
    color: hsl(35, 15%, 55%);
}

/* Bullet list — no default browser style */
.ai-markdown-content .md-ul,
.ai-markdown-content ul {
    margin: 6px 0 18px;
    padding: 0;
    list-style: none;
}
.ai-markdown-content .md-ul li,
.ai-markdown-content ul li {
    position: relative;
    padding: 7px 12px 7px 30px;
    border-bottom: 1px solid hsl(35, 18%, 91%);
    line-height: 1.7;
}
.ai-markdown-content .md-ul li:last-child,
.ai-markdown-content ul li:last-child { border-bottom: none; }
.ai-markdown-content .md-ul li::before,
.ai-markdown-content ul li::before {
    content: '›';
    position: absolute;
    left: 10px;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.15em;
    line-height: 1.6;
}

/* Ordered list */
.ai-markdown-content .md-ol,
.ai-markdown-content ol {
    margin: 6px 0 18px;
    padding-left: 22px;
}
.ai-markdown-content .md-ol li,
.ai-markdown-content ol li { margin-bottom: 7px; line-height: 1.7; }

/* Horizontal rule — visual section break */
.ai-markdown-content .md-hr,
.ai-markdown-content hr {
    border: none;
    border-top: 1.5px solid hsl(35, 18%, 87%);
    margin: 28px 0;
}

/* Blockquote — study insight callout */
.ai-markdown-content .md-callout,
.ai-markdown-content blockquote {
    margin: 22px 0;
    padding: 14px 18px;
    background: hsl(48, 90%, 96%);
    border-left: 4px solid hsl(42, 88%, 52%);
    border-radius: 0 10px 10px 0;
    color: hsl(28, 30%, 28%);
    font-style: normal;
}
.ai-markdown-content .md-callout p,
.ai-markdown-content blockquote p { margin: 0; line-height: 1.7; }

/* Comparison table */
.ai-markdown-content .md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0 24px;
    font-size: 0.91rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 6px hsl(35, 15%, 82%);
}
.ai-markdown-content .md-table thead {
    background: hsl(30, 25%, 22%);
    color: #fff;
}
.ai-markdown-content .md-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
}
.ai-markdown-content .md-table tbody tr {
    border-bottom: 1px solid hsl(35, 18%, 88%);
}
.ai-markdown-content .md-table tbody tr:nth-child(even) {
    background: hsl(40, 28%, 97%);
}
.ai-markdown-content .md-table tbody td {
    padding: 9px 14px;
    vertical-align: top;
    line-height: 1.6;
}

/* Inline code */
.ai-markdown-content code {
    font-family: 'Courier New', monospace;
    font-size: 0.87em;
    background: hsl(35, 18%, 92%);
    padding: 1px 5px;
    border-radius: 4px;
}

.ai-markdown-content strong { font-weight: 700; }
.ai-markdown-content em { font-style: italic; color: hsl(25, 20%, 45%); }
.ai-markdown-content .md-spacer { height: 6px; }

/* ═══════════════════════════════════════════════════
   PRIVATE LINK BOX
   ═══════════════════════════════════════════════════ */
.private-link-box { display: flex; gap: 10px; align-items: center; }
.private-link-box input { flex: 1; font-size: 0.88rem; font-family: monospace; }

/* ═══════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════ */
.site-footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 48px;
    border-top: 1.5px solid var(--border);
    text-align: center;
}
.site-footer p { font-size: 0.88rem; }

/* ═══════════════════════════════════════════════════
   ACTIVE NAV HIGHLIGHT
   ═══════════════════════════════════════════════════ */
.active-nav-link {
    background: var(--surface) !important;
    color: var(--charcoal) !important;
    box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .hero-section { grid-template-columns: 1fr; min-height: auto; padding-top: 60px; }
    .hero-board { grid-template-columns: 1fr 1fr; }
    .workspace-grid { grid-template-columns: 1fr; }
    .document-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .nav-shell { padding: 0 16px; }
    .nav-links { display: none; }
    .section { padding: 48px 16px; }
    .auth-grid, .profile-grid, .status-grid { grid-template-columns: 1fr; }
    .document-grid { grid-template-columns: 1fr; }
    .mode-grid { grid-template-columns: repeat(3, 1fr); }
    .hero-board { grid-template-columns: 1fr 1fr; }
    .form-row { flex-direction: column; }
    h1 { font-size: 2.2rem; }
    .hero-actions { flex-direction: column; }
    .hero-actions .button { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    .hero-board { grid-template-columns: 1fr; }
    .mode-grid { grid-template-columns: repeat(2, 1fr); }
    .card-actions { flex-direction: column; }
    .card-actions .button { width: 100%; }
}

/* ═══════════════════════════════════════════════════
   ZEN MODE, POMODORO TIMER, AND SOUND DESIGN
   ═══════════════════════════════════════════════════ */
.zen-timer-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 2px 10px;
    height: 38px;
    box-shadow: var(--shadow-sm);
}

.timer-clock {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--charcoal);
    font-variant-numeric: tabular-nums;
}

.timer-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.timer-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.08);
}

/* Zen mode full screen toggle styles */
body.zen-active {
    background: var(--surface2) !important;
}

body.zen-active header.app-header {
    display: none !important;
}

body.zen-active footer.site-footer {
    display: none !important;
}

body.zen-active main {
    padding-top: 24px !important;
    max-width: 960px !important;
    margin: 0 auto !important;
}

/* Quiz Option visual enhancements for micro-interactions */
.quiz-option {
    transition: transform 0.12s ease-out, background var(--transition), border-color var(--transition);
}

.quiz-option:active {
    transform: scale(0.97);
}

/* Pulse animation for running timer */
@keyframes timerPulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.timer-running {
    animation: timerPulse 2s infinite ease-in-out;
    color: var(--accent) !important;
}

/* Sleek study tools grid */
.study-tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 20px 0;
}

@media (max-width: 600px) {
    .study-tools-grid {
        grid-template-columns: 1fr;
    }
}

.study-tool-card {
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    text-align: left;
    gap: 16px;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

.study-tool-card:hover {
    background: var(--surface);
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.tool-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.icon-blue { background: #e8f0fe; color: #1a73e8; }
.icon-purple { background: #f0e8fe; color: #9333ea; }
.icon-gold { background: var(--gold-soft); color: #b45309; }
.icon-green { background: var(--green-soft); color: #15803d; }

[data-theme="dark"] .icon-blue { background: #1a2340; color: #64b5f6; }
[data-theme="dark"] .icon-purple { background: #2a1a40; color: #c084fc; }
[data-theme="dark"] .icon-gold { background: #3c2a1a; color: #fbbf24; }
[data-theme="dark"] .icon-green { background: #1a3c22; color: #4ade80; }

.tool-body {
    flex: 1;
}

.tool-title {
    display: block;
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--charcoal);
    margin-bottom: 4px;
}

.tool-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
}

/* Pulse shimmer loader */
.shimmer-loader {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}

.shimmer-line {
    height: 14px;
    background: linear-gradient(90deg, var(--border) 25%, var(--surface) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmerSwipe 1.5s infinite linear;
    border-radius: var(--radius-sm);
}

.shimmer-line.title { width: 40%; height: 18px; margin-bottom: 8px; }
.shimmer-line.desc-1 { width: 95%; }
.shimmer-line.desc-2 { width: 75%; }

@keyframes shimmerSwipe {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Dropdown Item Styling */
.dropdown-item:hover {
    background: var(--surface2) !important;
    color: var(--accent) !important;
}

.nav-avatar-btn:hover {
    border-color: var(--accent) !important;
    background: var(--accent-glow) !important;
}
