/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #000000;
    /* Pure Black */
    --card-bg: rgba(20, 20, 20, 0.6);
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    /* Zinc 400 */
    --accent-primary: #e4e4e7;
    /* Zinc 200 */
    --accent-secondary: #52525b;
    /* Zinc 600 */
    --accent-glow: rgba(255, 255, 255, 0.15);
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;
    --grid-color: rgba(255, 255, 255, 0.1);
}

body.light-mode {
    --bg-color: #f8fafc;
    /* Slate 50 */
    --card-bg: rgba(255, 255, 255, 0.7);
    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --accent-primary: #cbd5e1;
    /* Slate 300 */
    --accent-secondary: #94a3b8;
    /* Slate 400 */
    --accent-glow: rgba(0, 0, 0, 0.1);
    --grid-color: rgba(0, 0, 0, 0.1);
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    line-height: 1.5;
}

/* Background Animation Placeholder */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 50% 10%, #18181b 0%, #000000 70%);
    transition: background 0.3s ease;
}

body.light-mode #canvas-container {
    background: radial-gradient(circle at 50% 10%, #f1f5f9 0%, #e2e8f0 70%);
}

.overlay {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 2rem 4rem;
    overflow-y: auto;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-top: 1rem;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -1px;
    color: var(--text-primary);
    text-transform: uppercase;
}

.status-indicator {
    padding: 0.3rem 0.8rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    color: #d4d4d8;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-indicator::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background-color: #d4d4d8;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

body.light-mode .status-indicator {
    background: rgba(0, 0, 0, 0.05);
    color: #475569;
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .status-indicator::before {
    background-color: #475569;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

/* Theme Toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.light-mode .theme-toggle {
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-mode .theme-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Main Layout */
.main-content {
    flex: 1;
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding-bottom: 2rem;
    gap: 2rem;
    height: 100%;
    transition: all 0.5s ease;
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: all 0.5s ease;
    overflow-y: auto;
    padding: 0;
}


.hero-section {
    text-align: center;
    margin-bottom: 0;
    transition: all 0.5s ease;
    animation: fadeIn 1s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 4rem);
    padding-bottom: 16rem;
    /* upward optical bias */
}

.hero-section.compact {
    margin-bottom: 1.5rem;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 4rem;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -2px;
}

body.light-mode .hero-title {
    color: #0f172a;
    /* Force dark color */
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 550px;
    margin: 0 auto 3rem;
    font-weight: 300;
}

.hero-section.compact .hero-title,
.hero-section.compact .hero-subtitle {
    display: none;
}

/* Make input wrapper take full width initially, but center it */
.hero-section.compact .input-wrapper {
    margin: 0 auto;
    max-width: 800px;
}

/* Input Area */
.input-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.4rem;
    border-radius: 0;
    /* Sharp corners for brutalist feel */
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
}

/* Header Input State */
.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 2rem;
}

.input-wrapper.in-header {
    max-width: 500px;
    margin: 0;
    height: 40px;
    padding: 0.2rem;
}

.input-wrapper.in-header textarea {
    min-height: auto;
    max-height: 36px;
    padding: 0.4rem 1rem;
    white-space: nowrap;
    overflow: hidden;
}

.input-wrapper.in-header .generate-btn {
    padding: 0 1rem;
    font-size: 0.75rem;
}

body.light-mode .input-wrapper {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Header Problem Dropdown Accordion */
.header-problem-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
}

.header-problem-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.header-problem-summary:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.light-mode .header-problem-summary:hover {
    background: rgba(0, 0, 0, 0.05);
}

.header-problem-summary .problem-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

body.light-mode .header-problem-summary .problem-title {
    color: #0f172a;
}

.header-problem-summary .dropdown-icon {
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.header-problem-details {
    position: absolute;
    top: 100%;
    margin-top: 0.5rem;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 1rem;
    border-radius: 4px;
    width: max-content;
    max-width: 600px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transform-origin: top center;
    animation: dropdownFade 0.2s ease-out;
}

body.light-mode .header-problem-details {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-problem-details .problem-statement {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
    font-family: var(--font-body);
    line-height: 1.5;
    text-align: left;
}

.input-wrapper:focus-within {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.6);
}

textarea#custom-problem-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    padding: 1rem;
    outline: none;
    resize: vertical;
    min-height: 60px;
    max-height: 300px;
}

textarea#custom-problem-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.hero-section.compact .input-wrapper {
    margin: 0;
}

.generate-btn {
    background: #fff;
    border: none;
    border-radius: 0;
    color: #000;
    font-family: var(--font-heading);
    font-weight: 700;
    padding: 0 2rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
}

.generate-btn:hover {
    background: #e4e4e7;
    transform: translateY(-1px);
}

body.light-mode .generate-btn {
    background: #0f172a;
    /* Slate 900 */
    color: #fff;
}

body.light-mode .generate-btn:hover {
    background: #020617;
    /* Slate 950 (darker) */
}

/* Templates Section */
.templates-label {
    text-align: center;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.3);
    margin-bottom: 2rem;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    /* Sharp corners */
    padding: 1.5rem;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 220px;
}

body.light-mode .card {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

body.light-mode .card-footer {
    border-top-color: rgba(0, 0, 0, 0.05);
}

.card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
}

.card h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 500;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.5px;
}

body.light-mode .card h2 {
    color: #0f172a;
    /* Force dark color */
}

.card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
    font-weight: 300;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    font-size: 0.7rem;
    margin-top: auto;
    font-size: 0.7rem;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1rem;
    font-family: 'Fira Code', monospace;
}

/* Keep container generic incase we revert */
#terminal-container {
    display: none;
}

.terminal-header {
    padding: 0.5rem 1rem;
    background: #09090b;
    border-bottom: 1px solid #27272a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terminal-title {
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: #71717a;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
}

.terminal-title::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background-color: #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.3;
    }
}

.terminal-close {
    display: none;
}

#terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    font-family: 'Fira Code', 'Roboto Mono', monospace;
    font-size: 0.85rem;
    color: #e4e4e7;
    white-space: pre-wrap;
    background-color: #030303;
    line-height: 1.5;
}

/* Phases CSS */
.hidden {
    display: none !important;
}

/* Phase Viewer — replaces old big-card wrapper */
.phase-viewer {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    min-height: 0;
}

/* Progress Stepper */
.phase-progress {
    position: relative;
    padding: 1.2rem 2rem 0.8rem;
    flex-shrink: 0;
}

.progress-track {
    position: absolute;
    top: 50%;
    left: 2rem;
    right: 2rem;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%);
    margin-top: -8px;
    border-radius: 2px;
    z-index: 0;
}

body.light-mode .progress-track {
    background: rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #a78bfa, #60a5fa);
    border-radius: 2px;
    transition: width 0.6s ease;
    width: 0%;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.45;
    transition: opacity 0.3s, color 0.3s;
}

.progress-step.done,
.progress-step.active {
    opacity: 1;
}

.progress-step.active {
    color: #a78bfa;
}

.progress-step.done {
    color: var(--text-primary);
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s;
}

body.light-mode .step-dot {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
}

.progress-step.done .step-dot {
    background: #60a5fa;
    border-color: #60a5fa;
    box-shadow: 0 0 6px rgba(96, 165, 250, 0.5);
}

.progress-step.active .step-dot {
    background: #a78bfa;
    border-color: #a78bfa;
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.7);
    animation: stepPulse 1.5s ease-in-out infinite;
}

@keyframes stepPulse {

    0%,
    100% {
        box-shadow: 0 0 6px rgba(167, 139, 250, 0.5);
    }

    50% {
        box-shadow: 0 0 14px rgba(167, 139, 250, 0.9);
    }
}

/* Panel title shown inside each card */
.panel-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1.25rem;
    color: var(--text-primary);
    letter-spacing: 0.3px;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1.5px;
}

body.light-mode .panel-title {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

/* Panel content — flows within the scrollable phase-panel */
.panel-content {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

body.light-mode .panel-content {
    color: #475569;
}

/* Markdown typography spacing inside panel content */
.panel-content h1,
.panel-content h2,
.panel-content h3,
.panel-content h4 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin-top: 1.8rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.panel-content h1 {
    font-size: 1.2rem;
}

.panel-content h2 {
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 0.35rem;
}

.panel-content h3 {
    font-size: 0.95rem;
}

.panel-content h4 {
    font-size: 0.88rem;
}

.panel-content p {
    margin: 0.6rem 0 0.9rem;
}

.panel-content ul,
.panel-content ol {
    padding-left: 1.4rem;
    margin: 0.5rem 0 1rem;
}

.panel-content li {
    margin-bottom: 0.45rem;
    line-height: 1.65;
}

.panel-content li+li {
    margin-top: 0.2rem;
}

.panel-content strong {
    color: var(--text-primary);
}

.panel-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

.panel-content th,
.panel-content td {
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.panel-content th {
    background: rgba(255, 255, 255, 0.04);
    font-family: var(--font-heading);
}

.panel-content blockquote {
    border-left: 3px solid rgba(255, 255, 255, 0.15);
    margin: 1rem 0;
    padding: 0.4rem 1rem;
    color: var(--text-secondary);
}

.panel-content> :first-child {
    margin-top: 0 !important;
}

body.light-mode .panel-content h1,
body.light-mode .panel-content h2,
body.light-mode .panel-content h3,
body.light-mode .panel-content h4,
body.light-mode .panel-content strong {
    color: #0f172a;
}

body.light-mode .panel-content h2 {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .panel-content th {
    background: rgba(0, 0, 0, 0.04);
}

body.light-mode .panel-content th,
body.light-mode .panel-content td {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Bottom-Line callout box inside Phase 1 panel */
.bottom-line-box {
    margin-top: 2.5rem;
    flex-shrink: 0;
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-left: 3px solid #a78bfa;
    border-radius: 8px;
    background: rgba(167, 139, 250, 0.05);
    padding: 1rem 1.25rem 1.25rem;
}

body.light-mode .bottom-line-box {
    background: rgba(167, 139, 250, 0.08);
    border-color: rgba(167, 139, 250, 0.3);
    border-left-color: #a78bfa;
}

.bottom-line-label {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #a78bfa;
    margin-bottom: 0.75rem;
}

.content-bottom-line {
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

body.light-mode .content-bottom-line {
    color: #475569;
}

/* Carousel Layout */
.carousel-container {
    display: flex;
    flex: 1;
    align-items: stretch;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.carousel-track {
    display: flex;
    flex: 1;
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    width: 100%;
    height: 100%;
}

/* Phase panel card */
.phase-panel {
    flex: 0 0 76%;
    margin: 0.5rem 2%;
    padding: 1.5rem 2.5rem;
    overflow-y: auto;
    box-sizing: border-box;
    opacity: 0.25;
    transform: scale(0.92);
    transition: all 0.45s cubic-bezier(0.25, 1, 0.5, 1);
    background: rgba(10, 10, 10, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
}

.phase-panel.active {
    opacity: 1;
    transform: scale(1);
    background: rgba(16, 16, 20, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 2;
}

body.light-mode .phase-panel {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

body.light-mode .phase-panel.active {
    background: rgba(255, 255, 255, 0.97);
    border-color: rgba(0, 0, 0, 0.15);
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.nav-arrow:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-arrow.left {
    left: 10px;
}

.nav-arrow.right {
    right: 10px;
}

/* Detached Terminal */
.terminal-container {
    background: #030303;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1rem auto;
    max-width: 1200px;
    width: 100%;
    height: 250px;
    /* Initial height */
    min-height: 100px;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    resize: vertical;
    overflow: hidden;
}

body.light-mode .terminal-container {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Accordion Styles */
.accordion-item {
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

body.light-mode .accordion-item {
    border-color: rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.6);
}

.accordion-header {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-family: var(--font-heading);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

body.light-mode .accordion-header {
    background: rgba(241, 245, 249, 0.4);
}

.accordion-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.light-mode .accordion-header:hover {
    background: rgba(0, 0, 0, 0.05);
}

.accordion-content {
    padding: 1rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    display: none;
    /* hidden by default */
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

body.light-mode .accordion-content {
    color: #475569;
    border-top-color: rgba(0, 0, 0, 0.05);
}

.accordion-item.active .accordion-content {
    display: block;
}

.accordion-item.active .acc-icon {
    transform: rotate(180deg);
}

.acc-icon {
    transition: transform 0.3s ease;
    font-size: 0.7rem;
}

/* Floating Chatbot Toggle Button */
.chatbot-toggle-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    color: #000;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: transform 0.2s;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.05);
}

body.light-mode .chatbot-toggle-btn {
    background: #0f172a;
    color: #fff;
}

/* Chatbot Sidebar */
.chatbot-container {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 350px;
    height: 500px;
    background: rgba(10, 10, 10, 0.85);
    /* Slightly less opaque */
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 999;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Hidden by default state */
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

body.light-mode .chatbot-container {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.chatbot-container.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.chatbot-header {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.light-mode .chatbot-header {
    background: rgba(241, 245, 249, 0.8);
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

.chatbot-header h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    padding: 0.75rem 1rem;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
}

.system-msg {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border-radius: 0 10px 10px 10px;
}

body.light-mode .system-msg {
    background: rgba(0, 0, 0, 0.05);
}

.user-msg {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-radius: 10px 0 10px 10px;
}

body.light-mode .user-msg {
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
}

.bot-msg {
    align-self: flex-start;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-radius: 0 10px 10px 10px;
}

body.light-mode .bot-msg {
    border-color: rgba(0, 0, 0, 0.1);
}

.message.thinking {
    color: #a1a1aa;
    font-style: italic;
    animation: pulse 1.5s infinite;
}

.chatbot-input-area {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
}

body.light-mode .chatbot-input-area {
    border-top-color: rgba(0, 0, 0, 0.05);
    background: rgba(241, 245, 249, 0.5);
}

.chatbot-input-area textarea {
    flex: 1;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.5rem;
    resize: none;
    outline: none;
    border-radius: 4px;
}

body.light-mode .chatbot-input-area textarea {
    border-color: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
}

.chatbot-input-area textarea:focus {
    border-color: rgba(255, 255, 255, 0.3);
}

body.light-mode .chatbot-input-area textarea:focus {
    border-color: rgba(0, 0, 0, 0.4);
}

.chatbot-input-area button {
    background: #fff;
    color: #000;
    border: none;
    padding: 0 0.8rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chatbot-input-area button:hover {
    background: #e4e4e7;
}

body.light-mode .chatbot-input-area button {
    background: #0f172a;
    color: #fff;
}

body.light-mode .chatbot-input-area button:hover {
    background: #020617;
}

/* ===== Knowledge Graph ===== */
.lit-graph-container {
    position: relative;
    width: 100%;
    min-height: 350px;
    max-height: 500px;
    background: rgba(15, 15, 25, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.lit-graph-canvas {
    width: 100%;
    height: 420px;
    position: relative;
}

.lit-graph-canvas svg {
    width: 100%;
    height: 100%;
}

.graph-stage-label {
    position: absolute;
    top: 12px;
    left: 16px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 10;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    backdrop-filter: blur(4px);
    transition: color 0.4s ease, background 0.4s ease;
}

.graph-stage-label.stage-done {
    color: #00cec9;
    background: rgba(0, 206, 201, 0.1);
}

/* Tooltip */
.graph-tooltip {
    position: absolute;
    pointer-events: none;
    padding: 10px 14px;
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    font-family: var(--font-body);
    font-size: 0.78rem;
    line-height: 1.5;
    color: #dfe6e9;
    max-width: 300px;
    z-index: 100;
    transition: opacity 0.2s ease;
}

.graph-tooltip strong {
    display: block;
    margin-bottom: 4px;
    color: #fff;
    font-size: 0.82rem;
}

.graph-tooltip .authors {
    color: #a29bfe;
}

.graph-tooltip .year {
    color: #636e72;
}

.graph-tooltip .score {
    color: #00cec9;
    font-weight: 600;
}

/* Light mode overrides */
body.light-mode .lit-graph-container {
    background: rgba(245, 245, 250, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .graph-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.15);
    color: #2d3436;
}

body.light-mode .graph-stage-label {
    background: rgba(255, 255, 255, 0.6);
    color: #636e72;
}