:root {
    --black: #080808;
    --void: #141414;
    --surface: #1a1a1a;
    --raised: #212121;
    --border: #2a2a2a;
    --border-hi: #383838;
    --amber: #f5a623;
    --amber-dim: #c07d10;
    --amber-glow: rgba(245, 166, 35, 0.18);
    --amber-trace: rgba(245, 166, 35, 0.06);
    --gold: #e8c96d;
    --cream: #f0e6c8;
    --text: #e8e2d4;
    --muted: #7a7060;
    --faint: #3a3530;
}

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

html {
    scroll-behavior: smooth;
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--black);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    height: 100%;
    overflow: hidden;
}

/* ── Noise overlay ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
    opacity: 0.6;
}

/* ── Ambient glow ── */
.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
}

.glow-orb-1 {
    width: 500px;
    height: 500px;
    top: -150px;
    right: -100px;
    background: radial-gradient(circle, rgba(245, 166, 35, 0.07) 0%, transparent 70%);
}

.glow-orb-2 {
    width: 400px;
    height: 400px;
    bottom: 100px;
    left: -100px;
    background: radial-gradient(circle, rgba(245, 166, 35, 0.04) 0%, transparent 70%);
}

/* ── Header ── */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 0 3rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(8, 8, 8, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--amber);
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-dot {
    width: 9px;
    height: 9px;
    background: var(--amber);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--amber);
    animation: pulse-dot 2.5s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 8px var(--amber);
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 20px var(--amber);
    }
}

/* ── Layout ── */
.app {
    position: relative;
    z-index: 1;
    max-width: 100%;
    margin-top: 64px;
    padding: 0.75rem 1.25rem 0;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 64px);
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
    padding-bottom: 1rem;
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.panel-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.panel-title {
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.panel-icon {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* ── Upload ── */
.upload-zone {
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.upload-zone:hover {
    background: var(--amber-trace);
}

.upload-zone input {
    display: none;
}

.upload-ring {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1.5px solid var(--border-hi);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.3s;
}

.upload-zone:hover .upload-ring {
    border-color: var(--amber);
    box-shadow: 0 0 20px var(--amber-glow);
}

.upload-text {
    text-align: center;
}

.upload-text strong {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.upload-text span {
    font-size: 0.75rem;
    color: var(--muted);
}

.upload-btn-fake {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--amber);
    border: 1px solid var(--amber-dim);
    padding: 0.5rem 1.2rem;
    border-radius: 2px;
    background: var(--amber-trace);
}

#upload-status {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
    padding: 0 1.25rem 1rem;
    min-height: 1.2rem;
}

#upload-status.uploading {
    color: var(--muted);
}

#upload-status.success {
    color: #6fcf7a;
}

#upload-status.error {
    color: #e07070;
}

/* ── Mode selector ── */
.mode-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mode-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-radius: 3px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    position: relative;
}

.mode-item:hover {
    background: var(--raised);
    border-color: var(--border);
}

.mode-item.active {
    background: var(--amber-trace);
    border-color: var(--amber-dim);
}

.mode-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--amber);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px var(--amber);
}

.mode-emoji {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
}

.mode-info {
    flex: 1;
}

.mode-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.mode-desc {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.mode-item.active .mode-name {
    color: var(--amber);
}

.mode-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0.875rem;
}

/* ── Chat area ── */
.chat-area {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    height: 100%;
    position: relative;
}

.chat-topbar {
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--void);
    flex-shrink: 0;
}

.chat-mode-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.chat-mode-badge {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber);
    background: var(--amber-trace);
    border: 1px solid var(--amber-dim);
    padding: 0.2rem 0.6rem;
    border-radius: 2px;
}

/* ── Messages ── */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    justify-content: flex-start;
}

.messages::-webkit-scrollbar {
    width: 4px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.msg {
    display: flex;
    gap: 0.875rem;
    animation: msgIn 0.3s ease-out;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.msg.user {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.msg.ai .msg-avatar {
    background: var(--amber-trace);
    border: 1px solid var(--amber-dim);
    color: var(--amber);
    font-family: 'Playfair Display', serif;
    font-size: 0.9rem;
    font-weight: 700;
}

.msg.user .msg-avatar {
    background: var(--raised);
    border: 1px solid var(--border);
    color: var(--muted);
}

.msg-body {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.msg-bubble {
    padding: 0.875rem 1.1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    line-height: 1.65;
}

.msg.ai .msg-bubble {
    background: var(--void);
    border: 1px solid var(--border);
    color: var(--text);
    border-top-left-radius: 1px;
}

.msg.user .msg-bubble {
    background: var(--amber-trace);
    border: 1px solid var(--amber-dim);
    color: var(--cream);
    border-top-right-radius: 1px;
}

.msg-bubble strong {
    color: var(--amber);
    font-weight: 500;
}

.msg-bubble .tag-technical {
    display: inline-block;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    background: rgba(232, 201, 109, 0.08);
    border: 1px solid rgba(232, 201, 109, 0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    margin-bottom: 0.5rem;
}

.msg-bubble .tag-eli5 {
    display: inline-block;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber);
    background: var(--amber-trace);
    border: 1px solid var(--amber-dim);
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.msg-meta {
    font-size: 0.68rem;
    color: var(--faint);
    font-family: 'DM Mono', monospace;
    padding: 0 0.25rem;
}

.msg.user .msg-meta {
    text-align: right;
}

.sources-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    color: var(--muted);
    background: var(--raised);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 2px;
    margin-top: 0.35rem;
}

.sources-pill::before {
    content: '▸';
    color: var(--amber);
}

/* ── System message ── */
.msg.system {
    justify-content: center;
}

.msg.system .msg-bubble {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--muted);
    font-size: 0.75rem;
    font-family: 'DM Mono', monospace;
    text-align: center;
    padding: 0.5rem 1.25rem;
    border-radius: 2px;
}

/* ── Welcome message ── */
.welcome-msg .msg-bubble {
    background: linear-gradient(135deg, var(--void) 0%, rgba(245, 166, 35, 0.04) 100%);
    border-color: var(--border-hi);
}

/* ── Loading dots ── */
.loading-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 0.5rem 0;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--amber);
    border-radius: 50%;
    opacity: 0.3;
    animation: dot-blink 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot-blink {

    0%,
    100% {
        opacity: 0.2;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ── Input zone ── */
.input-zone {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--void);
    flex-shrink: 0;
}

.input-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#query-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.75rem 1rem;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 300;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

#query-input::placeholder {
    color: var(--faint);
}

#query-input:focus {
    border-color: var(--amber-dim);
    box-shadow: 0 0 0 2px var(--amber-trace);
}

#send-btn {
    width: 44px;
    height: 44px;
    border-radius: 3px;
    background: var(--amber);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    color: var(--black);
}

#send-btn:hover {
    background: var(--gold);
    box-shadow: 0 0 16px var(--amber-glow);
}

#send-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.6rem;
}

.input-hint {
    font-size: 0.68rem;
    color: var(--faint);
    font-family: 'DM Mono', monospace;
}

/* ── Exam button ── */
.exam-btn {
    margin: 0 1rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.75rem;
    background: transparent;
    border: 1px dashed var(--border-hi);
    border-radius: 3px;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    width: calc(100% - 2rem);
}

.exam-btn:hover {
    border-color: var(--amber-dim);
    color: var(--amber);
    background: var(--amber-trace);
}

.exam-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Clear chat button ── */
.clear-btn {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.3rem 0.75rem;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    color: var(--text);
    border-color: var(--border-hi);
}

/* ── Document list ── */
#doc-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 48px;
}

.doc-empty {
    font-size: 0.72rem;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    text-align: center;
    padding: 0.75rem;
}

.doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 3px;
    background: var(--raised);
    border: 1px solid var(--border);
}

.doc-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.doc-ext {
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    color: var(--amber);
    background: var(--amber-trace);
    border: 1px solid var(--amber-dim);
    padding: 0.15rem 0.4rem;
    border-radius: 2px;
    flex-shrink: 0;
}

.doc-name {
    font-size: 0.75rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}

.doc-delete-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    padding-bottom: 2px;
}

.doc-delete-btn:hover {
    color: #e07070;
    border-color: #e07070;
    background: rgba(224, 112, 112, 0.1);
}

/* ── Hero section ── */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 120px 2rem 80px;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.hero-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 70% 70% at 50% 40%, black 20%, transparent 100%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 720px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2rem;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--amber);
    border: 1px solid var(--amber-dim);
    background: var(--amber-trace);
    padding: 0.35rem 0.9rem;
    border-radius: 2px;
    animation: h-up 0.5s ease both;
}

.hero-badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 8px var(--amber);
    animation: pulse-dot 2s ease-in-out infinite;
}

.hero-heading {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2.6rem, 5.5vw, 4.5rem);
    font-weight: 700;
    line-height: 1.12;
    color: var(--text);
    letter-spacing: -0.02em;
    animation: h-up 0.5s ease 0.1s both;
}

.hero-heading-em {
    background: linear-gradient(120deg, var(--amber), var(--gold), var(--amber));
    background-size: 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: h-shimmer 4s linear infinite;
}

@keyframes h-shimmer {
    0% {
        background-position: 0% center;
    }

    100% {
        background-position: 200% center;
    }
}

.hero-para {
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.75;
    max-width: 500px;
    font-weight: 300;
    animation: h-up 0.5s ease 0.2s both;
}

.hero-para em {
    color: var(--text);
    font-style: normal;
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--amber);
    color: var(--black);
    border: none;
    padding: 0.85rem 1.75rem;
    border-radius: 3px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    animation: h-up 0.5s ease 0.3s both;
}

.hero-cta:hover {
    background: var(--gold);
    box-shadow: 0 0 24px var(--amber-glow);
    transform: translateY(-2px);
}

.hero-cta svg {
    transition: transform 0.2s;
}

.hero-cta:hover svg {
    transform: translateY(3px);
}

.hero-steps {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    width: 100%;
    margin-top: 0;
    animation: h-up 0.5s ease 0.4s both;
}

.hero-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    transition: border-color 0.2s, transform 0.2s;
}

.hero-step:hover {
    border-color: var(--amber-dim);
    transform: translateY(-2px);
}

.hero-step-n {
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--amber);
    background: var(--amber-trace);
    border: 1px solid var(--amber-dim);
    padding: 0.15rem 0.45rem;
    border-radius: 2px;
}

.hero-step-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.hero-step-desc {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.5;
}

@keyframes h-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

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

/* ── Responsive ── */
@media (max-width: 1024px) and (min-width: 769px) {
    .app {
        grid-template-columns: 240px 1fr;
        gap: 1rem;
        padding: 72px 1rem 0;
    }

    .doc-name {
        max-width: 110px;
    }

    .mode-desc {
        display: none;
    }
}

@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
        padding: 80px 1rem 2rem;
    }

    .chat-area {
        height: 70vh;
        position: static;
    }

    header {
        padding: 0 1.25rem;
    }

    .hero-steps {
        flex-direction: column;
    }

    .hero-heading {
        font-size: 2.2rem;
    }
}