/* ============================================
   Poetry Explainer — Three-Phase UI
   Phase 0: Front page (hero / marketing)
   Phase 1: Auth + Centered landing
   Phase 2: Full-viewport dashboard
   ============================================ */

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

/* --- Variables --- */
:root {
    --bg: #faf5f0;
    --bg-card: #ffffff;
    --text: #2d1f3d;
    --text-secondary: #5a4a6b;
    --text-muted: #9b8ba8;
    --accent: #9b59b6;
    --accent-hover: #7d3c98;
    --accent-light: #d2a8e0;
    --accent-bg: #f5ebfa;
    --border: #e8ddf0;
    --border-light: #f0e8f5;
    --error: #c0392b;
    --error-bg: #fdf0ef;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(100,50,120,0.05);
    --shadow: 0 2px 12px rgba(100,50,120,0.08);
    --shadow-lg: 0 8px 32px rgba(100,50,120,0.14);
    --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-display: "Playfair Display", Georgia, serif;
    --font-poetry: "Georgia", "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
    --gap: 8px;
    --transition: 0.2s ease;

    /* Vibrant gradient palette */
    --grad-1: #9b59b6;
    --grad-2: #e74c8b;
    --grad-3: #f39c12;
    --gradient-main: linear-gradient(135deg, var(--grad-1), var(--grad-2));
    --gradient-warm: linear-gradient(135deg, var(--grad-2), var(--grad-3));
    --gradient-full: linear-gradient(135deg, var(--grad-1), var(--grad-2), var(--grad-3));
}

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100dvh;
}

/* ============================================
   FRONT PAGE
   ============================================ */
.front-page {
    min-height: 100dvh;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #fdf8ff 0%, #faf5f0 30%, #fff5f8 60%, #faf5f0 100%);
}

/* --- Background decorations --- */
.fp-bg-decor {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.fp-circle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.12;
}

.fp-circle-1 {
    width: 500px; height: 500px;
    background: var(--grad-1);
    top: -120px; right: -100px;
    animation: fpFloat 20s ease-in-out infinite;
}

.fp-circle-2 {
    width: 350px; height: 350px;
    background: var(--grad-2);
    bottom: 10%; left: -80px;
    animation: fpFloat 25s ease-in-out infinite reverse;
}

.fp-circle-3 {
    width: 250px; height: 250px;
    background: var(--grad-3);
    top: 50%; right: 20%;
    animation: fpFloat 18s ease-in-out infinite 3s;
}

.fp-blob {
    position: absolute;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    opacity: 0.07;
}

.fp-blob-1 {
    width: 600px; height: 400px;
    background: var(--gradient-full);
    top: 15%; left: 10%;
    animation: fpMorph 30s ease-in-out infinite;
}

.fp-blob-2 {
    width: 400px; height: 300px;
    background: var(--gradient-warm);
    bottom: 5%; right: 5%;
    animation: fpMorph 25s ease-in-out infinite reverse;
}

@keyframes fpFloat {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(30px, -20px); }
    66% { transform: translate(-20px, 15px); }
}

@keyframes fpMorph {
    0%, 100% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
    25% { border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%; }
    50% { border-radius: 50% 60% 30% 60% / 50% 40% 70% 40%; }
    75% { border-radius: 30% 40% 60% 50% / 60% 70% 30% 40%; }
}

/* --- Navigation --- */
.fp-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    background: rgba(253, 248, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(155, 89, 182, 0.08);
}

.fp-nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.3px;
}

.fp-nav-icon { width: 24px; height: 24px; }

.fp-nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Nav link — text with a living underline */
.fp-btn-ghost {
    padding: 8px 4px;
    font-size: 0.88rem;
    font-weight: 500;
    font-family: var(--font-body);
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: color 0.3s ease;
}

.fp-btn-ghost::after {
    content: "";
    position: absolute;
    bottom: 4px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: var(--accent);
    border-radius: 1px;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.fp-btn-ghost:hover {
    color: var(--accent);
}

.fp-btn-ghost:hover::after {
    width: 100%;
}

/* Nav CTA — compact pill with soft fill, not a screaming gradient */
.fp-btn-solid {
    padding: 9px 22px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--accent);
    background: var(--accent-bg);
    border: 1.5px solid var(--accent-light);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.01em;
}

.fp-btn-solid:hover {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

/* --- Hero Section --- */
.fp-hero {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 60px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 32px 60px;
}

.fp-hero-content {
    flex: 1;
    max-width: 560px;
}

/*
 * Hero badge — a gentle label, not a blinking billboard.
 * Thin border, muted palette, modest presence.
 */
.fp-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(255,255,255,0.6);
    border: 1px solid var(--border);
    border-radius: 100px;
    margin-bottom: 22px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.fp-badge-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.7;
}

.fp-hero-title {
    font-family: var(--font-display);
    font-size: 3.4rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    margin-bottom: 18px;
    letter-spacing: -1px;
}

.fp-gradient-text {
    background: var(--gradient-full);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fp-hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 28px;
}

.fp-hero-subtitle strong {
    color: var(--accent);
    font-weight: 600;
}

.fp-hero-cta {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 34px;
    flex-wrap: wrap;
}

/*
 * Primary CTA — warm pill with a hand-drawn feel.
 * Thick enough to feel substantial, round enough to feel friendly.
 * Hover: background shifts subtly, the arrow slides right.
 */
.fp-btn-primary-lg {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 34px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-body);
    letter-spacing: 0.01em;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.4s ease, padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.fp-btn-primary-lg::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
    pointer-events: none;
}

.fp-btn-primary-lg svg {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.fp-btn-primary-lg:hover {
    background: var(--accent-hover);
    padding-right: 38px;
}

.fp-btn-primary-lg:hover svg {
    transform: translateX(4px);
}

.fp-btn-primary-lg:active {
    transform: scale(0.97);
}

/*
 * Secondary CTA — a text link with character.
 * No box. Just text + a little arrow that breathes.
 * Feels like a gentle invitation, not a billboard.
 */
.fp-btn-outline-lg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 6px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: var(--font-body);
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: color 0.3s ease;
}

.fp-btn-outline-lg::after {
    content: "\2192";
    display: inline-block;
    font-size: 1.1em;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0.5;
}

.fp-btn-outline-lg:hover {
    color: var(--accent);
}

.fp-btn-outline-lg:hover::after {
    transform: translateX(3px);
    opacity: 1;
}

/* Language pills */
.fp-lang-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fp-pill {
    padding: 5px 14px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: all var(--transition);
}

.fp-pill:hover {
    color: var(--accent);
    border-color: var(--accent-light);
    background: var(--accent-bg);
}

/* --- Hero Visual (preview card) --- */
.fp-hero-visual {
    flex: 0 0 420px;
    position: relative;
}

.fp-preview-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(100, 50, 120, 0.12), 0 1px 3px rgba(100,50,120,0.06);
    overflow: hidden;
    animation: fpCardFloat 6s ease-in-out infinite;
}

@keyframes fpCardFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.fp-preview-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f8f0fc, #fef5f8);
    border-bottom: 1px solid var(--border-light);
}

.fp-preview-dots {
    display: flex;
    gap: 5px;
}

.fp-preview-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.fp-preview-dots span:nth-child(1) { background: #e74c3c; }
.fp-preview-dots span:nth-child(2) { background: #f39c12; }
.fp-preview-dots span:nth-child(3) { background: #2ecc71; }

.fp-preview-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.fp-preview-body {
    padding: 20px;
}

.fp-preview-poem {
    font-family: var(--font-poetry);
    font-size: 1.1rem;
    line-height: 2.2;
    color: var(--text);
    margin-bottom: 14px;
}

.fp-preview-line {
    opacity: 0;
    animation: fpLineIn 0.8s ease forwards;
}

.fp-anim-line-1 { animation-delay: 0.5s; }
.fp-anim-line-2 { animation-delay: 1.2s; }

@keyframes fpLineIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fp-preview-divider {
    height: 1px;
    background: var(--gradient-full);
    opacity: 0.3;
    margin: 14px 0;
}

.fp-preview-meta {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.fp-preview-tag {
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-bg);
    border-radius: 10px;
}

.fp-preview-explanation {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Floating decorative elements */
.fp-float {
    position: absolute;
    z-index: 2;
    opacity: 0.7;
}

.fp-float-quill {
    top: -20px;
    right: -15px;
    color: var(--grad-1);
    animation: fpFloatSm 4s ease-in-out infinite;
}

.fp-float-heart {
    bottom: 30px;
    left: -25px;
    color: var(--grad-2);
    animation: fpFloatSm 5s ease-in-out infinite 1s;
}

.fp-float-star {
    top: 40%;
    right: -30px;
    color: var(--grad-3);
    animation: fpFloatSm 3.5s ease-in-out infinite 0.5s;
}

@keyframes fpFloatSm {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(8deg); }
}

/* --- Features Section --- */
.fp-features {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 60px 32px 80px;
}

.fp-section-header {
    text-align: center;
    margin-bottom: 48px;
}

.fp-section-title {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.fp-section-desc {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 550px;
    margin: 0 auto;
    line-height: 1.6;
}

.fp-features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/*
 * Feature cards — left-border accent for personality.
 * No lift. Hover warms the border and tints the background.
 * Each card has its own left-stripe color via nth-child.
 */
.fp-feature-card {
    background: rgba(255,255,255,0.75);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--border);
    border-radius: 4px 14px 14px 4px;
    padding: 26px 24px;
    transition: border-color 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
}

.fp-feature-card:nth-child(1) { --card-hue: #9b59b6; }
.fp-feature-card:nth-child(2) { --card-hue: #e74c8b; }
.fp-feature-card:nth-child(3) { --card-hue: #e67e22; }
.fp-feature-card:nth-child(4) { --card-hue: #3498db; }
.fp-feature-card:nth-child(5) { --card-hue: #27ae60; }
.fp-feature-card:nth-child(6) { --card-hue: #e74c3c; }

.fp-feature-card:hover {
    border-left-color: var(--card-hue);
    background: rgba(255,255,255,0.95);
    box-shadow: 0 2px 20px rgba(0,0,0,0.04);
}

.fp-feature-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    transition: transform 0.3s ease;
}

.fp-feature-card:hover .fp-feature-icon {
    transform: rotate(-4deg) scale(1.05);
}

.fp-fi-translate { background: #f3e8fb; color: #7b2d8e; }
.fp-fi-search { background: #fce4ec; color: #c2185b; }
.fp-fi-book { background: #fff3e0; color: #e65100; }
.fp-fi-chat { background: #e3f2fd; color: #0277bd; }
.fp-fi-palette { background: #e8f5e9; color: #2e7d32; }
.fp-fi-history { background: #fbe9e7; color: #bf360c; }

.fp-feature-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.2px;
}

.fp-feature-card p {
    font-size: 0.86rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* --- Quote Section --- */
.fp-quote-section {
    position: relative;
    z-index: 1;
    padding: 50px 32px;
    background: linear-gradient(135deg, rgba(155,89,182,0.06), rgba(231,76,139,0.04));
}

.fp-quote-inner {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
    position: relative;
}

.fp-quote-mark {
    color: var(--accent);
    margin-bottom: 10px;
}

.fp-quote-text {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-style: italic;
    font-weight: 400;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 16px;
    border: none;
}

.fp-quote-author {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
    font-style: normal;
}

/* --- Bottom CTA --- */
.fp-bottom-cta {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 70px 32px 60px;
}

.fp-bottom-cta h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    font-style: italic;
    color: var(--text);
    margin-bottom: 12px;
    letter-spacing: -0.3px;
}

.fp-bottom-cta p {
    font-size: 1rem;
    color: var(--text-muted);
    max-width: 440px;
    margin: 0 auto 32px;
    line-height: 1.65;
}

/* --- Footer --- */
.fp-footer {
    position: relative;
    z-index: 1;
    padding: 24px 32px;
    border-top: 1px solid var(--border-light);
    background: rgba(255,255,255,0.4);
}

.fp-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fp-footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
}

.fp-footer-text {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* --- Front Page Responsive --- */
@media (max-width: 900px) {
    .fp-hero {
        flex-direction: column;
        padding: 50px 24px 40px;
        gap: 40px;
    }

    .fp-hero-content { max-width: 100%; text-align: center; }

    .fp-hero-title { font-size: 2.6rem; }

    .fp-hero-cta { justify-content: center; }

    .fp-lang-pills { justify-content: center; }

    .fp-hero-visual {
        flex: none;
        width: 100%;
        max-width: 400px;
    }

    .fp-features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .fp-nav { padding: 12px 16px; }

    .fp-nav-brand span { font-size: 0.95rem; }

    .fp-btn-ghost { padding: 6px 2px; font-size: 0.82rem; }
    .fp-btn-solid { padding: 7px 16px; font-size: 0.82rem; }

    .fp-hero { padding: 36px 16px 30px; }

    .fp-hero-title { font-size: 2rem; }
    .fp-hero-subtitle { font-size: 1rem; }

    .fp-hero-cta {
        flex-direction: column;
        align-items: center;
    }

    .fp-btn-primary-lg {
        justify-content: center;
        width: 100%;
    }

    .fp-hero-visual {
        max-width: 100%;
    }

    .fp-features-grid {
        grid-template-columns: 1fr;
    }

    .fp-section-title { font-size: 1.8rem; }

    .fp-quote-text { font-size: 1.3rem; }

    .fp-bottom-cta h2 { font-size: 1.6rem; }

    .fp-footer-inner {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .fp-float { display: none; }
}

/* ============================================
   AUTH SCREEN
   ============================================ */
.auth-screen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    animation: landingIn 0.4s ease;
    background: linear-gradient(160deg, #fdf8ff 0%, #faf5f0 40%, #fff5f8 100%);
}

.auth-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font-body);
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.25s ease;
    margin-bottom: 18px;
}

.auth-back-btn svg {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-back-btn:hover {
    color: var(--accent);
}

.auth-back-btn:hover svg {
    transform: translateX(-3px);
}

.auth-card {
    width: 100%;
    max-width: 600px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
    padding: 2.8rem 3.2rem 2.4rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    justify-content: center;
}

.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
}

/* Auth tabs — segmented pill toggle */
.auth-tabs {
    display: flex;
    background: var(--accent-bg);
    border-radius: 100px;
    padding: 3px;
    margin-bottom: 1.4rem;
    gap: 0;
}

.auth-tab {
    flex: 1;
    padding: 9px 0;
    font-size: 0.84rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.auth-tab:hover {
    color: var(--text-secondary);
}

.auth-tab.active {
    color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 1px 4px rgba(100,50,120,0.1);
}

/* Auth alert messages */
.auth-alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 1rem;
    line-height: 1.45;
}

.auth-alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #f5c6cb;
}

.auth-alert-success {
    background: #eaf7ec;
    color: #2d6a3f;
    border: 1px solid #b8dfc3;
}

/* Auth forms */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 11px 14px;
    font-size: 0.9rem;
    font-family: var(--font-body);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.1);
    background: var(--bg-card);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.auth-btn {
    margin-top: 10px;
    width: 100%;
    min-height: 58px;
    padding: 12px 28px;
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Auth switch link */
.auth-switch {
    text-align: center;
    margin-top: 1.2rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    margin-left: 4px;
    transition: color var(--transition);
}

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

/* ============================================
   USER BAR (landing page top-right)
   ============================================ */
.landing-user-bar {
    position: absolute;
    top: 16px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.user-email-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.signout-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.signout-link:hover {
    color: var(--error);
    background: var(--error-bg);
}

/* Top bar user & signout */
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-user {
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 500;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.signout-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.signout-btn:hover {
    color: var(--error);
    border-color: var(--error);
    background: var(--error-bg);
}

/* ============================================
   PHASE 1: LANDING
   ============================================ */
.landing {
    position: relative;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    animation: landingIn 0.4s ease;
    background: linear-gradient(160deg, #fdf8ff 0%, #faf5f0 40%, #fff5f8 100%);
}

@keyframes landingIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.landing-inner {
    width: 100%;
    max-width: 580px;
}

.landing-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.landing-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
}

.landing-brand h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.landing-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.landing-form textarea {
    width: 100%;
    padding: 14px 16px;
    font-family: var(--font-poetry);
    font-size: 1.05rem;
    line-height: 1.8;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    resize: vertical;
    min-height: 140px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.landing-form textarea:focus {
    outline: none;
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(155,89,182,0.1);
}

.landing-form textarea::placeholder { color: var(--text-muted); }

.landing-controls {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-top: 12px;
}

.landing-controls .select-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.landing-controls .select-group label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding-left: 2px;
}

.landing-controls select {
    padding: 10px 32px 10px 12px;
    font-size: 0.9rem;
    font-family: var(--font-body);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--transition);
}

.landing-controls select:focus {
    outline: none;
    border-color: var(--accent-light);
}

.btn-primary {
    flex: 1;
    min-height: 48px;
    padding: 10px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-body);
    letter-spacing: 0.01em;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    pointer-events: none;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   LOADER OVERLAY
   ============================================ */
.loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(30,25,20,0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.loader-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem 3rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 380px;
    width: 90%;
}

.loader-ring {
    display: inline-block;
    position: relative;
    width: 48px;
    height: 48px;
    margin-bottom: 1.2rem;
}

.loader-ring div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 40px;
    height: 40px;
    margin: 4px;
    border: 3.5px solid var(--accent);
    border-radius: 50%;
    animation: ring 1.2s cubic-bezier(0.5,0,0.5,1) infinite;
    border-color: var(--accent) transparent transparent transparent;
}

.loader-ring div:nth-child(1) { animation-delay: -0.45s; }
.loader-ring div:nth-child(2) { animation-delay: -0.3s; }
.loader-ring div:nth-child(3) { animation-delay: -0.15s; }

@keyframes ring { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.loader-status {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.8rem;
    min-height: 1.4em;
}

.loader-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 140px;
    overflow-y: auto;
}

.loader-step {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.loader-step .step-check {
    color: #5a9a5a;
    font-weight: 700;
    font-size: 0.8rem;
}

/* ============================================
   ERROR BANNER
   ============================================ */
.error-msg {
    background: var(--error-bg);
    color: var(--error);
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    border-bottom: 1px solid #f5c6cb;
}

/* --- Spinner --- */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   PHASE 2: APP SHELL (top-bar + dashboard)
   ============================================ */
.app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: dashIn 0.35s ease;
}

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

/* --- Top Bar --- */
.top-bar {
    height: 46px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--accent);
    flex-shrink: 0;
}

.brand-icon { width: 18px; height: 18px; }

.brand span {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.new-analysis-btn {
    height: 30px;
    padding: 0 16px;
    font-size: 0.76rem;
    font-weight: 600;
    font-family: var(--font-body);
    background: var(--accent-bg);
    color: var(--accent);
    border: 1.5px solid var(--accent-light);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.new-analysis-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.new-analysis-btn:active { transform: scale(0.97); }

/* ============================================
   DASHBOARD GRID
   ============================================ */
.dashboard-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: var(--gap);
    padding: var(--gap);
    min-height: 0;
}

/* ============================================
   TILES
   ============================================ */
.tile {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.tile:hover { box-shadow: var(--shadow); }

.tile-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-light);
    background: #fdfbf9;
}

.tile-header h3 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    line-height: 1;
}

.tile-badge {
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--accent-bg);
    padding: 2px 7px;
    border-radius: 10px;
}

.tile-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px 10px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.tile-body::-webkit-scrollbar { width: 4px; }
.tile-body::-webkit-scrollbar-track { background: transparent; }
.tile-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.tile-body::-webkit-scrollbar-thumb:hover { background: var(--accent-light); }

/* ============================================
   POETRY BLOCK + WORD TOOLTIPS
   ============================================ */
.poetry-block {
    font-family: var(--font-poetry);
    font-size: 0.92rem;
    line-height: 2;
}

.poetry-block[dir="rtl"] { text-align: right; font-size: 1.02rem; }

.poetry-line {
    padding: 1px 5px;
    cursor: default;
}

.stanza-break {
    height: 0.7em;
}

/* Difficult word: underlined, hoverable */
.dict-word {
    display: inline;
    border-bottom: 1.5px dashed var(--accent-light);
    cursor: help;
    transition: border-color 0.15s, background 0.15s;
}

.dict-word:hover {
    border-bottom-color: var(--accent);
    background: rgba(155, 89, 182, 0.07);
    border-radius: 2px;
}

/* Global floating tooltip (appended to body, never clipped) */
.word-tooltip-global {
    position: fixed;
    z-index: 9999;
    background: #302520;
    color: #f5f0eb;
    font-family: var(--font-body);
    font-size: 0.74rem;
    line-height: 1.45;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    text-align: center;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(0,0,0,0.22);
    max-width: 260px;
    white-space: normal;
    word-wrap: break-word;
    animation: tooltipIn 0.12s ease;
}

@keyframes tooltipIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Arrow (added dynamically via data-arrow attribute) */
.word-tooltip-global::before {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
}

.word-tooltip-global[data-arrow="up"]::before {
    bottom: 100%;
    border-bottom-color: #302520;
}

.word-tooltip-global[data-arrow="down"]::before {
    top: 100%;
    border-top-color: #302520;
}

.word-tooltip-global .wt-easy {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.word-tooltip-global .wt-secondary {
    display: block;
    opacity: 0.8;
    font-size: 0.7rem;
}

[dir="rtl"] .word-tooltip-global { text-align: right; }

/* ============================================
   TRANSLATION & EXPLANATION
   ============================================ */
#translation-text { white-space: pre-wrap; }

#explanation-text {
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ============================================
   DICTIONARY TABLE
   ============================================ */
table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }

thead { position: sticky; top: -8px; z-index: 2; }

th {
    font-weight: 600;
    color: var(--accent);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 5px 6px;
    background: #fdfbf9;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    vertical-align: top;
}

tbody tr:hover { background: #faf6f2; }
td[dir="rtl"] { text-align: right; font-family: var(--font-poetry); }

/* ============================================
   POET & CONTEXT
   ============================================ */
.info-row {
    display: flex;
    gap: 8px;
    margin-bottom: 3px;
    font-size: 0.8rem;
    line-height: 1.45;
}

.info-label {
    font-weight: 600;
    color: var(--accent);
    min-width: 34px;
    flex-shrink: 0;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding-top: 2px;
}

.bio-text {
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 3px 0;
}

.wiki-link {
    display: inline-block;
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px dashed var(--accent-light);
    margin-bottom: 3px;
    transition: color var(--transition);
}

.wiki-link:hover { color: var(--accent-hover); }

.tile-divider { border: none; border-top: 1px solid var(--border-light); margin: 5px 0; }

/* ============================================
   THEMES, DEVICES & SOURCES
   ============================================ */
.section-label {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--accent);
    margin-top: 8px;
    margin-bottom: 4px;
}

.section-label:first-child { margin-top: 0; }

.tags { display: flex; flex-wrap: wrap; gap: 3px; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.5;
}

.source-links { list-style: none; padding: 0; }
.source-links li { margin-bottom: 2px; }

.source-links a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.72rem;
    word-break: break-all;
    border-bottom: 1px solid var(--border-light);
    transition: border-color var(--transition);
}

.source-links a:hover { border-color: var(--accent); }

/* ============================================
   CHAT WIDGET
   ============================================ */

/* Floating bubble */
.chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 500;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(155, 89, 182, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-bubble:hover {
    background: var(--accent-hover);
    border-color: rgba(255,255,255,0.5);
    transform: rotate(-8deg) scale(1.06);
}

.chat-bubble:active { transform: scale(0.95); }

/* Chat panel */
.chat-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 500;
    width: 360px;
    height: 480px;
    max-height: calc(100dvh - 40px);
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatPanelIn 0.25s ease;
}

@keyframes chatPanelIn {
    from { opacity: 0; transform: translateY(16px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.chat-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--accent);
    color: #fff;
}

.chat-title {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
    padding: 0 2px;
}

.chat-close:hover { opacity: 1; }

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Message bubbles */
.chat-msg {
    display: flex;
    max-width: 88%;
}

.chat-msg.user {
    align-self: flex-end;
}

.chat-msg.assistant {
    align-self: flex-start;
}

.chat-msg-body {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg.user .chat-msg-body {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-msg-body {
    background: var(--accent-bg);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.chat-msg.assistant .chat-msg-body.typing {
    color: var(--text-muted);
    font-style: italic;
}

/* Input area */
.chat-input-area {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border-light);
    background: #fdfbf9;
}

.chat-input-area input {
    flex: 1;
    height: 36px;
    padding: 0 10px;
    font-size: 0.82rem;
    font-family: var(--font-body);
    border: 1.5px solid var(--border);
    border-radius: 18px;
    background: var(--bg-card);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
}

.chat-input-area input:focus {
    border-color: var(--accent-light);
}

.chat-input-area input::placeholder { color: var(--text-muted); }

.chat-input-area button {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.25s ease, transform 0.15s ease;
}

.chat-input-area button:hover { background: var(--accent-hover); }
.chat-input-area button:active { transform: scale(0.92); }
.chat-input-area button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   HAMBURGER BUTTON
   ============================================ */
.hamburger-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.hamburger-btn:hover {
    color: var(--accent);
    border-color: var(--accent-light);
    background: var(--accent-bg);
}

/* ============================================
   HISTORY DRAWER
   ============================================ */
.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(30, 25, 20, 0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 650;
    width: 340px;
    max-width: 90vw;
    background: var(--bg-card);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-panel.open {
    transform: translateX(0);
}

.drawer-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    background: #fdfbf9;
}

.drawer-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.3px;
}

.drawer-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.drawer-close:hover {
    color: var(--text);
    background: var(--accent-bg);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Empty state */
.drawer-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.drawer-empty svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.drawer-empty p {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.drawer-empty-sub {
    font-size: 0.76rem;
    font-weight: 400 !important;
    opacity: 0.7;
}

/* Loading state */
.drawer-loading {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.drawer-loading .spinner {
    border-color: rgba(155, 89, 182, 0.2);
    border-top-color: var(--accent);
}

/* History list */
.drawer-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.drawer-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: var(--bg);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.drawer-item:hover {
    border-color: var(--accent-light);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
}

.drawer-item.active {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.drawer-item-body {
    flex: 1;
    min-width: 0;
}

.drawer-item-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
    line-height: 1.3;
}

.drawer-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.drawer-item-lang {
    display: inline-block;
    padding: 1px 6px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 8px;
    font-size: 0.64rem;
    font-weight: 600;
}

.drawer-item-delete {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color var(--transition), background var(--transition);
}

.drawer-item:hover .drawer-item-delete {
    opacity: 1;
}

.drawer-item-delete:hover {
    color: var(--error);
    background: var(--error-bg);
}

/* ============================================
   UTILITY
   ============================================ */
.hidden { display: none !important; }

/* ============================================
   RESPONSIVE — SMALL TABLET (<=900px)
   ============================================ */
@media (max-width: 900px) {
    :root { --gap: 6px; }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr 1fr;
    }
}

/* ============================================
   RESPONSIVE — MOBILE (<=600px)
   ============================================ */
@media (max-width: 600px) {
    html { font-size: 13px; }

    .app {
        height: auto;
        overflow: auto;
    }

    .top-bar { position: sticky; top: 0; z-index: 100; }

    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        flex: none;
        padding: 6px;
        gap: 6px;
    }

    .tile { min-height: 140px; max-height: 300px; }
    .tile-header { padding: 6px 10px; }
    .tile-body { padding: 6px 10px 8px; }

    .auth-card { padding: 1.5rem 1.2rem 1.4rem; }
    .auth-brand h1 { font-size: 1.3rem; }

    .landing { padding: 1.5rem 1rem; }
    .landing-brand h1 { font-size: 1.4rem; }
    .landing-controls { flex-direction: column; }
    .landing-controls .select-group { width: 100%; }
    .landing-controls select { width: 100%; }
    .btn-primary { width: 100%; }

    .landing-user-bar {
        position: relative;
        top: auto;
        right: auto;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    .top-bar-actions { gap: 6px; }
    .topbar-user { display: none; }

    .loader-card { padding: 1.8rem; max-width: 300px; }

    /* Chat widget: full-width on mobile */
    .chat-panel {
        width: calc(100vw - 16px);
        height: calc(100dvh - 80px);
        bottom: 8px;
        right: 8px;
        border-radius: 12px;
    }

    .chat-bubble {
        bottom: 14px;
        right: 14px;
        width: 46px;
        height: 46px;
    }

    .drawer-panel { width: 100%; max-width: 100vw; }
    .drawer-item-delete { opacity: 1; }
}

/* ============================================
   RESPONSIVE — LARGE DESKTOP (>=1400px)
   ============================================ */
@media (min-width: 1400px) {
    html { font-size: 15px; }
    :root { --gap: 10px; }
}
