:root {
    --lime: #c8f135;
    --coral: #ff5c5c;
    --sky: #5ce1ff;
    --ink: #0e0e12;
    --paper: #f5f2eb;
    --muted: #8a8794;
    --border: #e2ddd4;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--paper);
    color: var(--ink);
    display: flex;
    flex-direction: column;
}

/* ── TOPBAR ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--ink);
    flex-shrink: 0;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.logo span {
    display: inline-block;
    background: var(--lime);
    color: var(--ink);
    padding: 1px 7px;
    border-radius: 4px;
    margin-right: 6px;
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    font-weight: 700;
    vertical-align: middle;
    font-family: 'DM Mono', monospace;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-link {
    font-size: 0.78rem;
    font-weight: 500;
    color: #666;
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: color 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    font-family: 'DM Sans', sans-serif;
    padding: 0;
    white-space: nowrap;
}

.nav-link:hover {
    color: #fff;
}

.nav-link-dialogue {
    color: var(--coral) !important;
    border: 1px solid #ff5c5c44;
    padding: 4px 12px;
    border-radius: 6px;
    transition: background 0.15s, border-color 0.15s !important;
}

.nav-link-dialogue:hover {
    background: #ff5c5c18;
    border-color: var(--coral);
}

/* mobile tab bar (hidden on desktop) */
.tab-bar {
    display: none;
    background: var(--ink);
    border-top: 1px solid #222;
    flex-shrink: 0;
}

.tab-bar button {
    flex: 1;
    padding: 10px 0;
    background: none;
    border: none;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #555;
    cursor: pointer;
    transition: color 0.15s, border-bottom 0.15s;
    border-bottom: 2px solid transparent;
}

.tab-bar button.active {
    color: var(--lime);
    border-bottom-color: var(--lime);
}

.tab-bar button.tab-mag.active {
    color: var(--sky);
    border-bottom-color: var(--sky);
}

/* ── WORKSPACE ── */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-left {
    width: 52%;
    min-width: 260px;
}

.panel-right {
    flex: 1;
    min-width: 260px;
}

/* ── PANEL HEADERS ── */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 20px;
    background: var(--ink);
    border-bottom: 1px solid #222;
    flex-shrink: 0;
}

.panel-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.panel-left .panel-label {
    color: var(--lime);
}

.panel-right .panel-label {
    color: var(--sky);
}

.panel-tag {
    font-family: 'DM Mono', monospace;
    font-size: 0.64rem;
    color: #444;
    letter-spacing: 0.05em;
}

/* ── PDF ── */
.pdf-body {
    flex: 1;
    background: #2a2a2a;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

.pdf-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 14px;
    background: linear-gradient(to bottom, #1a1a1a55, transparent);
    z-index: 2;
    pointer-events: none;
}

.pdf-body img {
    width: 95%;
    display: block;
    margin: 10px auto;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: opacity 0.5s ease-in;
}

.pdf-body img.loaded {
    opacity: 1;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ── DIVIDER ── */
.divider {
    width: 4px;
    background: #1c1c1c;
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    transition: background 0.18s;
}

.divider::after {
    content: '⋮';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #3a3a3a;
    font-size: 13px;
    pointer-events: none;
}

.divider:hover,
.divider.active {
    background: var(--lime);
}

.divider:hover::after,
.divider.active::after {
    color: var(--ink);
}

/* ── MARKDOWN BODY ── */
.md-body {
    flex: 1;
    overflow-y: auto;
    padding: 36px 44px 60px;
    background: var(--paper);
    scroll-behavior: smooth;
}

.md-body::-webkit-scrollbar {
    width: 5px;
}

.md-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.md-body::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* loader */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 14px;
}

.loader-ring {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--coral);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.loader p {
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.04em;
}

/* ── MARKDOWN TYPOGRAPHY ── */
#md-out {
    max-width: 660px;
    margin: 0 auto;
    animation: fadeUp 0.38s ease both;
}

@keyframes fadeUp {
    from {
    opacity: 0;
    transform: translateY(10px);
    }

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

#md-out::before {
    content: 'result.md';
    display: block;
    font-family: 'DM Mono', monospace;
    font-size: 0.64rem;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

#md-out h1 {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 2.1rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 0.5em;
}

#md-out h1::after {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--coral);
    border-radius: 2px;
    margin-top: 10px;
}

#md-out h2 {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 2.2em 0 0.7em;
    display: flex;
    align-items: center;
    gap: 10px;
}

#md-out h2::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--lime);
    border-radius: 2px;
    flex-shrink: 0;
}

#md-out h3 {
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: #333;
    margin: 1.6em 0 0.5em;
}

#md-out p {
    font-size: 0.95rem;
    line-height: 1.85;
    color: #3a3740;
    margin-bottom: 1.1em;
    font-weight: 300;
}

#md-out strong {
    color: var(--ink);
    font-weight: 600;
}

#md-out em {
    color: #5a5770;
    font-style: italic;
}

#md-out a {
    color: var(--coral);
    text-decoration: none;
    border-bottom: 1px solid #ff5c5c55;
    transition: border-color 0.15s;
}

#md-out a:hover {
    border-color: var(--coral);
}

#md-out code {
    font-family: 'DM Mono', monospace;
    font-size: 0.82em;
    background: #ede9df;
    color: #b8393a;
    padding: 2px 7px;
    border-radius: 5px;
}

#md-out pre {
    background: var(--ink);
    border-radius: 10px;
    padding: 20px 24px;
    overflow-x: auto;
    margin: 1.4em 0;
    position: relative;
}

#md-out pre::before {
    content: 'code';
    position: absolute;
    top: 10px;
    right: 14px;
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    color: #444;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#md-out pre code {
    background: none;
    color: var(--lime);
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.7;
}

#md-out blockquote {
    margin: 1.4em 0;
    padding: 14px 20px;
    border-left: 3px solid var(--sky);
    background: #eef8ff;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #4a5070;
    font-size: 0.93rem;
    line-height: 1.72;
}

#md-out ul,
#md-out ol {
    padding-left: 1.4em;
    margin-bottom: 1.1em;
    color: #3a3740;
    font-size: 0.95rem;
    line-height: 1.8;
    font-weight: 300;
}

#md-out li {
    margin-bottom: 0.25em;
}

#md-out li::marker {
    color: var(--coral);
}

#md-out hr {
    border: none;
    border-top: 1px dashed var(--border);
    margin: 2em 0;
}

#md-out table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.4em 0;
    font-size: 0.88rem;
}

#md-out th {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    background: var(--ink);
    color: var(--lime);
    padding: 10px 14px;
    text-align: left;
}

#md-out td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    color: #3a3740;
    font-weight: 300;
}

#md-out tr:hover td {
    background: #efebe0;
}

#md-out img {
    max-width: 100%;
    border-radius: 10px;
    margin: 1em 0;
    box-shadow: 0 4px 20px #0001;
}

/* ── FOOTER ── */
.footer-strip {
    background: var(--ink);
    padding: 6px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.footer-strip span {
    font-family: 'DM Mono', monospace;
    font-size: 0.63rem;
    color: #444;
    letter-spacing: 0.06em;
}

.dot-row {
    display: flex;
    gap: 5px;
}

.dot-row i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.dot-row i:nth-child(1) {
    background: var(--coral);
}

.dot-row i:nth-child(2) {
    background: var(--lime);
}

.dot-row i:nth-child(3) {
    background: var(--sky);
}

/* ── MODAL (shared) ── */
.modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: #0e0e1288;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-bg.open {
    display: flex;
}

.modal {
    background: var(--paper);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 32px 80px #0007;
    position: relative;
    animation: popIn 0.24s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    overflow: hidden;
}

@keyframes popIn {
    from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    }

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

.modal-top {
    background: var(--ink);
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-top-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#modal-abstract .modal-top-label {
    color: var(--lime);
}

#modal-authors .modal-top-label {
    color: var(--sky);
}

#modal-dialogue .modal-top-label {
    color: var(--coral);
}

.modal-title {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    margin-top: 5px;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.modal-close {
    background: #ffffff18;
    border: none;
    color: #aaa;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    align-self: flex-start;
}

.modal-close:hover {
    background: #ffffff28;
    color: #fff;
}

.modal-body {
    padding: 20px 22px 24px;
}

/* abstract */
.modal-abstract-text {
    font-size: 0.92rem;
    line-height: 1.85;
    color: #3a3740;
    font-weight: 300;
}

.modal-abstract-text strong {
    color: var(--ink);
    font-weight: 600;
}

/* authors */
.authors-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.author-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.author-card:hover {
    border-color: #ccc;
    box-shadow: 0 2px 12px #0000080a;
}

.author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
    color: var(--ink);
}

.author-info {
    flex: 1;
    min-width: 0;
}

.author-name {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.author-affil {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 300;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.author-tag {
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 20px;
    background: #f0f0f0;
    color: #888;
    white-space: nowrap;
}

/* ── DIALOGUE MODAL ── */
#modal-dialogue .modal {
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

#modal-dialogue .modal-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.dialogue-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.agent-pill {
    font-family: 'DM Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid;
    text-transform: uppercase;
}

.dialogue-scroll {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

.dialogue-scroll::-webkit-scrollbar {
    width: 4px;
}

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

.turn {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: fadeUp 0.2s ease both;
}

.turn-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 0.68rem;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.turn-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 5px;
}

.turn-agent {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
}

.turn-role {
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    color: var(--muted);
    letter-spacing: 0.05em;
}

.turn-text {
    font-size: 0.88rem;
    line-height: 1.75;
    color: #3a3740;
    font-weight: 300;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px 12px 12px 12px;
    padding: 10px 14px;
}

.round-divider {
    text-align: center;
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    color: #bbb;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    position: relative;
    margin: 4px 0;
    flex-shrink: 0;
}

.round-divider::before,
.round-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}

.round-divider::before {
    left: 0;
}

.round-divider::after {
    right: 0;
}

.dialogue-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.dialogue-err {
    color: var(--coral);
    font-size: 0.82rem;
    text-align: center;
    padding: 30px 0;
    line-height: 1.8;
}

/* ────────────────────────────────────────
RESPONSIVE — tablet ≤ 768px
──────────────────────────────────────── */
@media (max-width: 768px) {

    /* hide desktop divider */
    .divider {
    display: none;
    }

    /* stack panels vertically, show only the active one */
    .workspace {
    position: relative;
    }

    .panel {
    position: absolute;
    inset: 0;
    transition: opacity 0.2s, transform 0.2s;
    }

    .panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(12px);
    }

    .panel-left,
    .panel-right {
    width: 100%;
    min-width: 0;
    flex: 1;
    }

    /* show tab bar */
    .tab-bar {
    display: flex;
    }

    /* hide Dialogue button text on very small screens if needed */
    .topbar-right {
    gap: 10px;
    }

    .nav-link {
    font-size: 0.72rem;
    }

    .nav-link-dialogue {
    padding: 3px 9px;
    }

    /* tighten topbar */
    .topbar {
    padding: 0 16px;
    }

    /* tighter markdown padding */
    .md-body {
    padding: 24px 20px 40px;
    }

    /* modal full-width on small screens */
    .modal-bg {
    padding: 10px;
    align-items: flex-end;
    }

    .modal {
    border-radius: 16px 16px 12px 12px;
    max-height: 90vh;
    }

    #modal-dialogue .modal {
    max-height: 88vh;
    }

    /* footer shorter */
    .footer-strip {
    padding: 5px 16px;
    }

    .footer-strip .dot-row {
    display: none;
    }
}

/* ── extra small ≤ 420px ── */
@media (max-width: 420px) {
    .logo span {
    display: none;
    }

    #md-out h1 {
    font-size: 1.6rem;
    }

    .modal-title {
    font-size: 0.95rem;
    }
}