:root {
    color-scheme: dark;
    --bg: #0c1020;
    --bg-soft: #11172a;
    --panel: rgba(22, 29, 49, 0.86);
    --panel-solid: #171e34;
    --panel-hover: #1d2742;
    --text: #e8ecf7;
    --muted: #8e99b4;
    --faint: #5e6a87;
    --line: rgba(146, 160, 197, 0.16);
    --accent: #9b8cff;
    --accent-strong: #7060ef;
    --cyan: #6de0d1;
    --user: #d7ceff;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 320px;
    background:
        radial-gradient(circle at 75% -10%, rgba(114, 94, 239, 0.2), transparent 34rem),
        radial-gradient(circle at -5% 55%, rgba(53, 185, 184, 0.08), transparent 28rem),
        var(--bg);
    color: var(--text);
    font: 15px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f5fb;
    --bg-soft: #e9edf7;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-solid: #fff;
    --panel-hover: #f0efff;
    --text: #1d2540;
    --muted: #66708b;
    --faint: #8b95ab;
    --line: rgba(44, 58, 97, 0.13);
    --accent: #6654dc;
    --accent-strong: #5543c8;
    --cyan: #168d89;
    --user: #4c3bb6;
    --shadow: 0 24px 70px rgba(41, 52, 94, 0.12);
}

button, input { font: inherit; }
button, label { cursor: pointer; }
a { color: inherit; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 3;
    display: flex;
    width: 270px;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: rgba(11, 15, 31, 0.68);
    padding: 28px 20px 20px;
    backdrop-filter: blur(20px);
}

body[data-theme="light"] .sidebar { background: rgba(242, 245, 252, 0.82); }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 8px 38px;
    text-decoration: none;
}

.brand-mark, .hero-orbit, .message-avatar {
    display: grid;
    place-items: center;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(155, 140, 255, 0.55);
    border-radius: 12px;
    color: var(--accent);
    background: rgba(125, 108, 255, 0.12);
    font-size: 19px;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: 11px; }

.eyebrow {
    color: var(--faint);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.sidebar-card {
    display: grid;
    gap: 7px;
    margin: 0 2px 34px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}

.sidebar-card strong { overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.load-status { color: var(--muted); font-size: 11px; }
.nav-label { display: block; margin: 0 8px 12px; }
.section-list { display: grid; gap: 3px; max-height: 52vh; overflow-y: auto; }
.section-list a {
    border-left: 2px solid transparent;
    border-radius: 0 8px 8px 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    padding: 8px 10px;
    text-decoration: none;
}
.section-list a:hover { border-left-color: var(--accent); background: var(--panel-hover); color: var(--text); }
.no-sections { padding: 8px; color: var(--faint); font-size: 12px; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; color: var(--faint); font-size: 11px; }
.status-dot, .chip-dot { display: inline-block; border-radius: 50%; background: var(--cyan); }
.status-dot { width: 7px; height: 7px; box-shadow: 0 0 10px var(--cyan); }

.main-content { width: min(1120px, calc(100% - 270px)); margin-left: 270px; padding: 0 56px 34px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 78px; border-bottom: 1px solid var(--line); }
.breadcrumb { color: var(--faint); font-size: 12px; }
.breadcrumb strong { color: var(--muted); font-weight: 600; }
.breadcrumb-separator { margin: 0 9px; color: var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.file-button, .icon-button {
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
    color: var(--muted);
    font-size: 12px;
    padding: 8px 11px;
}
.file-button:hover, .icon-button:hover { border-color: var(--accent); color: var(--text); }
.icon-button { width: 34px; height: 34px; padding: 0; font-size: 16px; }

.hero { position: relative; display: flex; min-height: 255px; align-items: center; justify-content: space-between; overflow: hidden; padding: 46px 8px 32px; }
.hero-copy { position: relative; z-index: 1; max-width: 680px; }
.chip { display: inline-flex; align-items: center; gap: 8px; color: var(--cyan); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.chip-dot { width: 6px; height: 6px; }
h1 { max-width: 680px; margin: 12px 0 10px; font-size: clamp(29px, 4vw, 48px); letter-spacing: -.045em; line-height: 1.1; }
.hero p { max-width: 590px; margin: 0; color: var(--muted); font-size: 16px; }
.hero-orbit { position: absolute; right: 50px; width: 180px; height: 180px; border-radius: 50%; }
.orbit-ring { position: absolute; border: 1px solid rgba(155, 140, 255, .25); border-radius: 50%; transform: rotate(-32deg); }
.ring-one { width: 180px; height: 70px; }
.ring-two { width: 130px; height: 170px; transform: rotate(38deg); }
.orbit-core { display: grid; width: 64px; height: 64px; place-items: center; border: 1px solid rgba(155, 140, 255, .6); border-radius: 20px; background: linear-gradient(135deg, rgba(125, 108, 255, .3), rgba(71, 213, 203, .18)); box-shadow: 0 0 50px rgba(123, 108, 255, .28); color: var(--accent); font-size: 28px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; }
.stat-card { display: grid; grid-template-columns: auto 1fr; column-gap: 11px; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); padding: 14px; }
.stat-icon { grid-row: span 2; display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px; background: rgba(155, 140, 255, .12); color: var(--accent); font-size: 17px; }
.assistant-icon { background: rgba(109, 224, 209, .1); color: var(--cyan); }
.stat-label { color: var(--muted); font-size: 10px; }
.stat-card strong { color: var(--text); font-size: 19px; line-height: 1.3; }
.stat-source { font-size: 14px !important; }

.conversation-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 46px 0 20px; }
.conversation-toolbar h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.result-count { color: var(--muted); font-size: 12px; }
.search-box { display: flex; width: min(290px, 100%); align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--faint); padding: 8px 11px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(155, 140, 255, .1); }

.conversation { display: grid; gap: 16px; }
.message { display: grid; grid-template-columns: 39px minmax(0, 1fr); gap: 13px; align-items: start; }
.message-avatar { width: 39px; height: 39px; border: 1px solid rgba(109, 224, 209, .35); border-radius: 12px; background: rgba(109, 224, 209, .1); color: var(--cyan); font-size: 12px; font-weight: 800; }
.message.user .message-avatar { border-color: rgba(155, 140, 255, .35); background: rgba(155, 140, 255, .13); color: var(--user); }
.message-body { min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 8px 30px rgba(0, 0, 0, .06); padding: 17px 20px 19px; }
.message.user .message-body { border-color: rgba(155, 140, 255, .23); }
.message-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--cyan); font-size: 12px; }
.message.user .message-meta { color: var(--user); }
.message-number { color: var(--faint); font-size: 10px; font-weight: 600; letter-spacing: .08em; }
.message-content { color: var(--muted); font-size: 14px; }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.message-content p { margin: 10px 0; }
.message-content h2, .message-content h3, .message-content h4, .message-content h5 { color: var(--text); line-height: 1.35; }
.message-content h2 { margin: 26px 0 8px; font-size: 19px; }
.message-content h3 { margin: 20px 0 7px; font-size: 16px; }
.message-content h4, .message-content h5 { margin: 16px 0 6px; font-size: 14px; }
.message-content strong { color: var(--text); font-weight: 700; }
.message-content a { color: var(--accent); }
.message-content ul, .message-content ol { margin: 10px 0; padding-left: 24px; }
.message-content li { margin: 4px 0; padding-left: 3px; }
.message-content li::marker { color: var(--accent); }
.message-content blockquote { margin: 12px 0; border-left: 2px solid var(--accent); color: var(--muted); padding: 2px 0 2px 14px; }
.message-content hr { margin: 22px 0; border: 0; border-top: 1px solid var(--line); }
.message-content code { border: 1px solid var(--line); border-radius: 4px; background: rgba(155, 140, 255, .1); color: var(--accent); font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 5px; }
.message-content pre { overflow-x: auto; margin: 13px 0; border: 1px solid var(--line); border-radius: 9px; background: #0a0e1b; padding: 13px; }
body[data-theme="light"] .message-content pre { background: #eef0f7; }
.message-content pre code { border: 0; background: transparent; color: var(--text); padding: 0; white-space: pre; }

.empty-state { border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); padding: 40px 20px; text-align: center; }
.error-state { border-color: rgba(240, 151, 92, .4); }
.error-state strong { color: #f0a36d; }
.error-state p { margin-bottom: 0; font-size: 13px; }
.page-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 36px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; padding-top: 19px; }
.page-footer code { color: var(--muted); }
.page-footer button { border: 0; background: transparent; color: var(--accent); font-size: 11px; }

@media (max-width: 900px) {
    .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 22px; }
    .app-shell { display: block; }
    .brand { margin: 0 0 18px; }
    .sidebar-card, .sidebar nav { display: none; }
    .sidebar-footer { display: none; }
    .main-content { width: 100%; margin-left: 0; padding: 0 22px 28px; }
    .hero { min-height: 245px; }
    .hero-orbit { right: 0; opacity: .65; }
}

@media (max-width: 620px) {
    .topbar { min-height: 66px; }
    .breadcrumb { font-size: 11px; }
    .file-button { font-size: 0; }
    .file-button::before { content: "＋"; font-size: 18px; }
    .hero { padding: 35px 0 26px; }
    .hero-orbit { right: -70px; opacity: .4; }
    .hero p { font-size: 14px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .conversation-toolbar { display: grid; align-items: stretch; margin-top: 35px; }
    .search-box { width: 100%; }
    .message { grid-template-columns: 31px minmax(0, 1fr); gap: 8px; }
    .message-avatar { width: 31px; height: 31px; border-radius: 9px; font-size: 10px; }
    .message-body { padding: 14px 14px 16px; }
    .message-content { font-size: 13px; }
    .page-footer { display: grid; }
}

/* Vista única del documento: limpia, clara y centrada en la conversación. */
:root {
    color-scheme: light;
    --bg: #f7f6f2;
    --panel: transparent;
    --panel-hover: #efeee9;
    --text: #292722;
    --muted: #65625b;
    --faint: #918d84;
    --line: #e4e1da;
    --accent: #bd5b36;
    --cyan: #bd5b36;
    --user: #292722;
    --shadow: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Georgia, "Times New Roman", serif;
}

.main-content {
    width: min(820px, calc(100% - 40px));
    margin: 0 auto;
    padding: 0 0 42px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 74px;
    border-bottom: 1px solid var(--line);
}

.brand { margin: 0; }
.brand-mark { width: 32px; height: 32px; border: 0; background: transparent; color: var(--accent); }
.brand strong { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.brand small, .load-status { color: var(--faint); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 11px; }
.hero { min-height: auto; padding: 82px 0 48px; }
.hero h1 { max-width: 700px; margin: 13px 0 14px; font-size: clamp(32px, 5vw, 48px); font-weight: 400; letter-spacing: -.045em; }
.hero p { color: var(--muted); font-size: 17px; }
.chip { color: var(--accent); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; }
.chip-dot { background: var(--accent); }
.conversation-toolbar { margin: 0 0 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.conversation-toolbar h2 { font-size: 18px; font-weight: 400; }
.result-count { font-family: ui-sans-serif, system-ui, sans-serif; }
.search-box { border: 1px solid var(--line); background: transparent; border-radius: 20px; }
.search-box input { color: var(--text); font-family: ui-sans-serif, system-ui, sans-serif; }
.conversation { gap: 0; }
.message { grid-template-columns: 35px minmax(0, 1fr); gap: 13px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.message-avatar { width: 29px; height: 29px; border: 0; border-radius: 50%; background: #e7e4dc; color: var(--accent); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; }
.message.user .message-avatar { border: 1px solid #d5d0c7; background: transparent; color: var(--muted); }
.message-body { border: 0; border-radius: 0; background: transparent; padding: 0; box-shadow: none; }
.message-meta { margin: 2px 0 8px; color: var(--accent); font-family: ui-sans-serif, system-ui, sans-serif; }
.message.user .message-meta { color: var(--muted); }
.message-content { color: var(--muted); font-size: 15px; }
.message-content h2, .message-content h3, .message-content h4, .message-content h5 { color: var(--text); font-weight: 600; }
.message-content h2, .message-content h3, .message-content h4, .message-content h5 { scroll-margin-top: 24px; }
.message-content code { border-color: #dedbd3; background: #eeece7; color: #8d452b; }
.message-content pre { border-color: #dedbd3; background: #eeece7; }
.message-content pre code { color: var(--text); }
.page-footer { border-top: 0; font-family: ui-sans-serif, system-ui, sans-serif; }
.page-footer button { color: var(--accent); }

@media (max-width: 620px) {
    .main-content { width: min(100% - 28px, 820px); }
    .page-header { min-height: 62px; }
    .hero { padding: 55px 0 38px; }
    .hero p { font-size: 15px; }
}

.conversation-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 4;
    display: flex;
    width: 248px;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: #f2f0eb;
    padding: 28px 16px 20px;
}

.sidebar-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 8px 30px;
}

.sidebar-symbol {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: #e7e2d9;
    color: var(--accent);
    font-size: 16px;
}

.sidebar-heading strong,
.sidebar-heading small {
    display: block;
    font-family: ui-sans-serif, system-ui, sans-serif;
}

.sidebar-heading strong { color: var(--text); font-size: 12px; }
.sidebar-heading small { color: var(--faint); font-size: 10px; }
.quick-nav { display: grid; gap: 27px; min-height: 0; }
.nav-group h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 8px 9px;
    color: var(--muted);
    font: 700 10px/1.3 ui-sans-serif, system-ui, sans-serif;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.nav-dot { width: 7px; height: 7px; border-radius: 50%; }
.user-dot { background: #8d877d; }
.report-dot { background: var(--accent); }
.nav-links { display: grid; max-height: 40vh; gap: 2px; overflow-y: auto; padding-right: 3px; }
.nav-link {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 7px;
    align-items: baseline;
    border-left: 2px solid transparent;
    border-radius: 0 7px 7px 0;
    color: var(--muted);
    font: 11px/1.35 ui-sans-serif, system-ui, sans-serif;
    padding: 7px 7px;
    text-decoration: none;
}

.nav-link:hover {
    border-left-color: var(--accent);
    background: #e9e6df;
    color: var(--text);
}

.nav-link-number { color: var(--faint); font-size: 9px; }
.nav-link-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-empty { color: var(--faint); font: 11px ui-sans-serif, system-ui, sans-serif; padding: 7px; }

.main-content {
    width: min(820px, calc(100% - 308px));
    margin-left: 280px;
    margin-right: auto;
}

@media (max-width: 900px) {
    .conversation-sidebar {
        position: static;
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 14px 14px 12px;
    }

    .sidebar-heading { margin: 0 6px 12px; }
    .quick-nav { display: flex; gap: 12px; overflow-x: auto; }
    .nav-group { min-width: 230px; }
    .nav-links { max-height: 94px; }
    .main-content {
        width: min(100% - 28px, 820px);
        margin: 0 auto;
    }
}

/* La conversación ocupa todo el espacio disponible junto al panel lateral. */
@media (min-width: 901px) {
    .main-content {
        width: calc(100% - 248px);
        margin-left: 248px;
        padding-right: clamp(32px, 5vw, 88px);
        padding-left: clamp(32px, 5vw, 88px);
    }

    .page-header,
    .hero,
    .conversation-toolbar,
    .conversation,
    .page-footer {
        width: 100%;
    }

    .message-body {
        width: 100%;
    }
}
