:root {
    --lt-red: #C8102E;
    --lt-red-dark: #a30b25;
    --lt-navy: #012169;
    --lt-navy-dark: #001a52;
    --lt-cream: #FBF7F0;
    --lt-cream-dark: #f3ecde;
    --lt-gold: #b8860b;
    --lt-text: #1A1A2E;
    --lt-text-muted: #5b5e6b;
    --lt-border: #e6e0d3;
    --lt-surface: #ffffff;
    --lt-sidebar-bg: #012169;
    --lt-sidebar-text: #f5f1e8;
    --lt-sidebar-muted: #9aa6c4;
    --lt-sidebar-hover: rgba(255, 255, 255, 0.08);
    --lt-sidebar-active: rgba(255, 255, 255, 0.14);
    --lt-bubble-bot: #f3ecde;
    --lt-bubble-user: var(--lt-red);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--lt-text);
    background: var(--lt-cream);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, .serif {
    font-family: 'Playfair Display', 'Times New Roman', serif;
    letter-spacing: -0.01em;
}

a { color: var(--lt-red); text-decoration: none; }
a:hover { color: var(--lt-red-dark); }

::selection { background: rgba(200, 16, 46, .2); }

/* ===== AUTH (Union Jack inspired) ===== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lt-cream);
    position: relative;
    overflow: hidden;
}

.auth-body::before,
.auth-body::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

.auth-body::before {
    inset: 0;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent 0,
            transparent 80px,
            rgba(1, 33, 105, .04) 80px,
            rgba(1, 33, 105, .04) 82px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent 0,
            transparent 80px,
            rgba(200, 16, 46, .04) 80px,
            rgba(200, 16, 46, .04) 82px
        );
}

.auth-body::after {
    width: 600px; height: 600px;
    border-radius: 50%;
    bottom: -300px; right: -200px;
    background: radial-gradient(circle, rgba(200, 16, 46, .06), transparent 70%);
}

.auth-wrapper {
    width: 100%;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--lt-surface);
    border: 1px solid var(--lt-border);
    border-radius: 4px;
    padding: 3rem 2.5rem;
    position: relative;
    box-shadow: 0 30px 70px rgba(1, 33, 105, .08);
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(
        to right,
        var(--lt-navy) 0%,
        var(--lt-navy) 33%,
        var(--lt-cream) 33%,
        var(--lt-cream) 66%,
        var(--lt-red) 66%,
        var(--lt-red) 100%
    );
    border-radius: 4px 4px 0 0;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2.5rem;
}

.auth-logo {
    width: 76px;
    height: 76px;
    object-fit: contain;
    margin-bottom: 1.25rem;
}

.auth-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 .35rem;
    color: var(--lt-navy);
}

.auth-subtitle {
    color: var(--lt-text-muted);
    margin: 0;
    font-size: .95rem;
    font-style: italic;
}

.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--lt-navy);
    margin-bottom: .4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-control {
    border-radius: 4px;
    border: 1px solid var(--lt-border);
    padding: .85rem 1rem;
    font-size: .95rem;
    background: var(--lt-cream);
    transition: all .15s ease;
}
.form-control:focus {
    border-color: var(--lt-navy);
    box-shadow: 0 0 0 3px rgba(1, 33, 105, .1);
    background: #fff;
}

.btn { border-radius: 4px; font-weight: 600; transition: all .15s ease; }
.btn-lg { padding: .9rem 1rem; font-size: .9rem; text-transform: uppercase; letter-spacing: 0.08em; }
.btn-primary {
    background: var(--lt-red);
    border: none;
    color: #fff;
}
.btn-primary:hover {
    background: var(--lt-red-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(200, 16, 46, .35);
}
.btn-primary:active { transform: translateY(0); }

/* ===== APP SHELL ===== */
.app-body {
    min-height: 100vh;
    background: var(--lt-cream);
}

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* ===== SIDEBAR (left, navy) ===== */
.app-sidebar {
    background: var(--lt-sidebar-bg);
    color: var(--lt-sidebar-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 1rem;
    gap: 1rem;
    border-right: 4px solid var(--lt-red);
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    padding-bottom: 1rem;
}
.app-sidebar-logo {
    width: 36px; height: 36px;
    object-fit: contain;
    background: var(--lt-cream);
    padding: 4px;
    border-radius: 4px;
}
.app-sidebar-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    color: #fff;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    padding: .85rem 1rem;
    background: var(--lt-red);
    border: none;
    color: #fff;
    border-radius: 4px;
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all .15s ease;
}
.new-chat-btn:hover {
    background: var(--lt-red-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(200, 16, 46, .35);
}

.app-sidebar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.app-sidebar-section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    font-size: .72rem;
    font-weight: 700;
    color: var(--lt-sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.app-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 .25rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.app-sidebar-list::-webkit-scrollbar { width: 6px; }
.app-sidebar-list::-webkit-scrollbar-track { background: transparent; }
.app-sidebar-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 999px;
}

.lesson-item {
    display: flex;
    gap: .65rem;
    padding: .7rem .75rem;
    border-radius: 4px;
    color: var(--lt-sidebar-text);
    transition: background .15s ease;
    border-left: 3px solid transparent;
}
.lesson-item:hover {
    background: var(--lt-sidebar-hover);
    color: #fff;
    border-left-color: var(--lt-red);
}
.lesson-item.active {
    background: var(--lt-sidebar-active);
    border-left-color: var(--lt-red);
}

.lesson-icon {
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(200, 16, 46, .15);
    color: #ffb3bf;
    border-radius: 4px;
    flex-shrink: 0;
    font-size: .9rem;
}

.lesson-body { min-width: 0; flex: 1; }
.lesson-title {
    font-weight: 500;
    font-size: .88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lesson-meta {
    color: var(--lt-sidebar-muted);
    font-size: .74rem;
    margin-top: 1px;
    font-style: italic;
}
.lesson-tags { margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .25rem; }
.lesson-tag {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border-radius: 2px;
    padding: 1px 8px;
    font-size: .68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--lt-sidebar-muted);
}
.empty-state-icon {
    width: 52px; height: 52px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 4px;
    font-size: 1.4rem;
    color: #ffb3bf;
}
.empty-state p { font-size: .85rem; margin-bottom: 1rem; font-style: italic; }
.empty-state .btn-outline-light {
    border-color: rgba(255, 255, 255, .2);
    color: var(--lt-sidebar-text);
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: .72rem;
}
.empty-state .btn-outline-light:hover {
    background: var(--lt-red);
    border-color: var(--lt-red);
}

.app-sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .08);
}

.user-avatar {
    width: 38px; height: 38px;
    border-radius: 4px;
    background: var(--lt-red);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.user-meta { flex: 1; min-width: 0; }
.user-name {
    font-size: .85rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
}
.user-email {
    font-size: .72rem;
    color: var(--lt-sidebar-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-logout {
    width: 32px; height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lt-sidebar-muted);
    transition: all .15s ease;
}
.user-logout:hover { background: var(--lt-red); color: #fff; }

/* ===== TOPBAR ===== */
.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--lt-border);
    background: var(--lt-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    color: var(--lt-navy);
}
.topbar-toggle {
    width: 40px; height: 40px;
    border: 0;
    background: transparent;
    border-radius: 4px;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--lt-navy);
}
.topbar-toggle:hover { background: var(--lt-cream); }

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== CHAT ===== */
.chat-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
    padding: 2rem 1.5rem;
}

.chat-header {
    text-align: center;
    padding: 1rem 0 2rem;
    position: relative;
}
.chat-header::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: var(--lt-red);
    margin: 1rem auto 0;
}
.chat-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--lt-navy);
    margin-bottom: .5rem;
}
.chat-header p { font-style: italic; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--lt-border);
    border-radius: 999px;
}

.chat-message { display: flex; animation: fadeUp .25s ease; }
.chat-message-user { justify-content: flex-end; }
.chat-message-bot  { justify-content: flex-start; }

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

.chat-bubble {
    max-width: 75%;
    padding: .85rem 1.1rem;
    border-radius: 4px;
    line-height: 1.55;
    font-size: .95rem;
    word-wrap: break-word;
    border: 1px solid transparent;
}
.chat-message-bot .chat-bubble {
    background: var(--lt-bubble-bot);
    color: var(--lt-text);
    border-color: var(--lt-border);
    border-bottom-left-radius: 0;
}
.chat-message-user .chat-bubble {
    background: var(--lt-red);
    color: #fff;
    border-bottom-right-radius: 0;
    box-shadow: 0 4px 12px rgba(200, 16, 46, .25);
}

.chat-input-form { padding-top: 1rem; }
.chat-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--lt-surface);
    border: 2px solid var(--lt-border);
    border-radius: 4px;
    padding: .35rem .35rem .35rem 1.35rem;
    transition: all .15s ease;
}
.chat-input-wrapper:focus-within {
    border-color: var(--lt-navy);
    box-shadow: 0 0 0 3px rgba(1, 33, 105, .1);
}

.chat-input {
    flex: 1;
    border: 0;
    outline: none;
    padding: .85rem 0;
    font-size: 1rem;
    background: transparent;
    font-family: inherit;
}
.chat-input::placeholder { color: var(--lt-text-muted); font-style: italic; }

.chat-send-btn {
    width: 44px; height: 44px;
    border-radius: 4px;
    border: 0;
    background: var(--lt-red);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .15s ease;
    font-size: 1.1rem;
}
.chat-send-btn:hover {
    background: var(--lt-red-dark);
    transform: scale(1.04);
    box-shadow: 0 4px 12px rgba(200, 16, 46, .35);
}
.chat-send-btn:active { transform: scale(.98); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 100;
        box-shadow: 4px 0 24px rgba(0,0,0,.2);
    }
    .app-sidebar.open { transform: translateX(0); }
    .chat-shell { padding: 1rem; }
}
