/* ── Reset & Base ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f0e8;
    --bg-deep: #ebe4d6;
    --text: #2c2417;
    --text-muted: #7a6e5d;
    --accent: #8b6914;
    --accent-soft: #c9a84c;
    --border: #d4cbb8;
    --code-bg: #1e1e2e;
    --code-text: #cdd6f4;
    --code-accent: #89b4fa;
    --panel-shadow: 0 0 40px rgba(0, 0, 0, 0.06);
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Times New Roman', 'Playfair Display', Georgia, serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
}

/* ── Left Panel ── */
.left-panel {
    width: 380px;
    min-width: 380px;
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.panel-inner {
    padding: 40px 32px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    margin-bottom: 32px;
}

header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.header-visualize {
    display: inline-block;
    margin-top: 16px;
    background: transparent;
    border: 1px solid #6b4226;
    color: #6b4226;
    padding: 8px 16px;
    border-radius: 20px;
    font-family: 'Times New Roman', serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.header-visualize:hover {
    background: #6b4226;
    color: #fff;
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── Drop Zone ── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: var(--bg-deep);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(139, 105, 20, 0.06);
}

.upload-icon {
    color: var(--accent-soft);
    margin-bottom: 12px;
    opacity: 0.8;
}

.drop-text {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.drop-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Divider & arXiv Input ── */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.arxiv-input-row {
    display: flex;
    gap: 8px;
}

.arxiv-input {
    flex: 1;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-family: 'Times New Roman', Georgia, serif;
    font-size: 0.9rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease;
}

.arxiv-input:focus {
    border-color: var(--accent);
    background: #fff;
}

.arxiv-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.arxiv-btn {
    padding: 14px 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    font-family: 'Times New Roman', Georgia, serif;
}

/* ── Status Boxes ── */
.status-box {
    text-align: center;
    padding: 32px 0;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.pulse-dot {
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.3);
    }
}

.status-label {
    font-family: 'Times New Roman', Georgia, serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-sub {
    font-family: 'Times New Roman', Georgia, serif;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.done-check {
    font-size: 2rem;
    color: #22c55e;
    margin-bottom: 8px;
}

.error-x {
    font-size: 2rem;
    color: #ef4444;
    margin-bottom: 8px;
}

/* ── Buttons ── */
.btn-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s ease;
    font-family: 'Times New Roman', Georgia, serif;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: #6f5410;
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-deep);
}

/* ── Footer ── */
footer {
    margin-top: auto;
    padding-top: 24px;
    text-align: center;
}

footer p {
    font-size: 0.72rem;
    color: var(--text-muted);
}

footer strong {
    color: var(--accent);
    font-weight: 600;
}

/* ── Right Panel: Code Viewer ── */
.right-panel {
    flex: 1;
    height: 100vh;
    background: var(--code-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: #181825;
    border-bottom: 1px solid #313244;
}

.code-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: #6c7086;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.code-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    padding: 3px 10px;
    border-radius: 20px;
    background: #313244;
    color: #6c7086;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.code-badge.streaming {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    animation: pulse 1.5s ease-in-out infinite;
}

.code-badge.done {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.code-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    margin: 0;
    font-family: 'Times New Roman', Georgia, serif;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--code-text);
    white-space: pre-wrap;
    word-wrap: break-word;
    scrollbar-width: thin;
    scrollbar-color: #313244 transparent;
}

.code-viewer::-webkit-scrollbar {
    width: 6px;
}

.code-viewer::-webkit-scrollbar-thumb {
    background: #313244;
    border-radius: 3px;
}

.code-viewer code {
    font-family: inherit;
    color: inherit;
}

/* Feedback Footer */
.feedback-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 0.95rem;
    color: #6b4226;
    line-height: 1.5;
}

.feedback-link {
    display: inline-block;
    margin-top: 6px;
    color: #5a3318;
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 700;
    transition: opacity 0.2s;
}

.feedback-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* ── Floating Window ── */
.float-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}

.float-header {
    background: #fdfaf6;
    /* Beige header */
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    /* Indicate draggable */
    user-select: none;
}

.float-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: #6b4226;
}

.float-actions {
    display: flex;
    gap: 8px;
}

.float-btn {
    background: transparent;
    border: none;
    color: #8b8b8b;
    font-size: 1rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.float-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #6b4226;
}

.float-body {
    position: relative;
    min-height: 200px;
    max-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
}

.float-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 400px;
    object-fit: contain;
}

.float-spinner {
    padding: 40px;
    text-align: center;
    color: #8b8b8b;
    font-size: 0.85rem;
}

/* ── Paint Brush Loading ── */
.paint-brush-container {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brush {
    font-size: 32px;
    z-index: 2;
    animation: sweep 1.5s infinite ease-in-out;
    transform-origin: bottom center;
}

@keyframes sweep {

    0%,
    100% {
        transform: rotate(-15deg) translateX(-10px);
    }

    50% {
        transform: rotate(15deg) translateX(10px);
    }
}

.shimmer-line {
    position: absolute;
    bottom: 10px;
    width: 40px;
    height: 4px;
    background: var(--accent-soft);
    border-radius: 2px;
    opacity: 0.3;
    animation: paint-shimmer 1.5s infinite ease-in-out;
}

@keyframes paint-shimmer {

    0%,
    100% {
        width: 0;
        left: 10px;
        opacity: 0;
    }

    50% {
        width: 40px;
        left: 10px;
        opacity: 0.6;
    }
}

.float-spinner p {
    font-family: 'Times New Roman', serif;
    font-style: italic;
    color: var(--text-muted);
}

.header-visualize:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Minimized Pill */
.float-pill {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #6b4226;
    color: #fff;
    padding: 10px 20px;
    border-radius: 30px;
    font-family: 'Playfair Display', serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
}

.float-pill:hover {
    transform: translateY(-2px);
}

/* ── Utility ── */
.hidden {
    display: none !important;
}