:root {
    --ink-900: #0b1f3a;
    --ink-700: #1f3b5c;
    --ink-500: #4b647a;
    --blue-700: #1e5ad7;
    --blue-600: #2b6fff;
    --blue-500: #3c7dff;
    --blue-200: #c9ddff;
    --blue-100: #e6f1ff;
    --blue-50: #f5faff;
    --border: #d7e6fb;
    --shadow: 0 18px 40px rgba(14, 34, 69, 0.12);
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --success: #12b76a;
    --error: #f04438;
    --warning: #f79009;
}

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

body {
    font-family: "IBM Plex Sans", "Source Sans 3", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--ink-900);
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at -10% -20%, #d9ecff 0%, transparent 60%),
        radial-gradient(900px 700px at 110% -10%, #e6f2ff 0%, transparent 55%),
        linear-gradient(180deg, #f6fbff 0%, #ffffff 70%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(to right, rgba(30, 90, 215, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(30, 90, 215, 0.06) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

.page {
    max-width: 1080px; /* Increased width for 2-col */
    margin: 0 auto;
    padding: 36px 24px 40px;
    position: relative;
    z-index: 1;
}

.hero {
    background: linear-gradient(135deg, #ffffff 0%, #f2f8ff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 34px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 16px;
    animation: rise 0.6s ease-out both;
    margin-bottom: 24px;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    font-size: 1.1rem;
}

.brand-mark {
    width: 14px;
    height: 14px;
    border-radius: 5px;
    background: linear-gradient(135deg, #2b6fff, #72a9ff);
    box-shadow: 0 6px 12px rgba(43, 111, 255, 0.35);
}

.tag {
    background: var(--blue-100);
    color: var(--blue-700);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.hero h1 {
    font-size: clamp(1.8rem, 2.5vw, 2.4rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    color: var(--ink-500);
    font-size: 1rem;
    max-width: 600px;
}

.hero-features {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.feature {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: grid;
    gap: 4px;
    box-shadow: 0 8px 18px rgba(15, 36, 72, 0.08);
}

.feature-title {
    font-weight: 600;
    color: var(--ink-700);
}

.feature-desc {
    font-size: 0.9rem;
    color: var(--ink-500);
}

/* Workspace Layout */
.workspace {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    align-items: stretch; /* Stretch to make columns equal height */
    min-height: 500px; /* Ensure minimum height for the workspace */
}

.column-right {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex overflow issues */
}

.panel {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: rise 0.6s ease-out both;
    height: 100%; /* Fill the grid cell */
}

.panel:nth-child(1) { animation-delay: 0.06s; }
.panel:nth-child(2) { animation-delay: 0.12s; }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tabs {
    display: flex;
    background: var(--blue-50);
    padding: 2px;
    border-radius: 8px;
}

.tab {
    border: none;
    background: transparent;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-500);
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--blue-600);
}

.tab.active {
    background: #ffffff;
    color: var(--blue-700);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.panel-header h2 {
    font-size: 1.1rem;
}

.panel-desc {
    color: var(--ink-500);
    font-size: 0.85rem;
}

.pill {
    background: var(--blue-100);
    color: var(--blue-700);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.pill-outline {
    background: #ffffff;
    border: 1px solid var(--blue-200);
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--blue-200);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    background: var(--blue-50);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.dropzone:hover {
    border-color: var(--blue-500);
    background: #eef6ff;
}

.dropzone.is-dragover {
    border-color: var(--blue-600);
    background: #e9f2ff;
    box-shadow: 0 0 0 4px rgba(43, 111, 255, 0.15);
}

.dropzone-icon {
    color: var(--blue-600);
    background: #e8f1ff;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
}

.dropzone-text strong {
    font-size: 1rem;
    display: block;
}

.dropzone-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.dropzone-action {
    background: #ffffff;
    border: 1px solid var(--blue-200);
    color: var(--blue-700);
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.dropzone-action:hover {
    background: var(--blue-50);
    border-color: var(--blue-500);
}

/* File List & Progress */
.list-container {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1; /* Take remaining vertical space */
    min-height: 0; /* Allow shrinking for scroll */
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.status-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--blue-700);
}

.progress-area {
    width: 100%;
    flex-shrink: 0;
}

.progress-bar-bg {
    height: 6px;
    background: var(--blue-100);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--blue-600);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 999px;
}

.progress-info {
    text-align: right;
    font-size: 0.8rem;
    color: var(--ink-500);
}

.file-list {
    list-style: none;
    /* max-height: 240px; removed fixed height */
    flex: 1; /* Fill container */
    overflow-y: auto; /* Scroll inside */
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f8fbff;
}

.file-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.file-list-item:last-child {
    border-bottom: none;
}

.file-info {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--ink-500);
    margin-left: 6px;
}

.file-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.status-pending { color: var(--ink-500); background: #f1f5f9; }
.status-processing { color: var(--blue-700); background: var(--blue-100); }
.status-success { color: #027a48; background: #ecfdf3; }
.status-error { color: #b42318; background: #fef3f2; }

/* Output Area */
.output-panel {
    height: 100%;
    /* min-height: 500px; removed fixed min-height */
    display: flex;
    flex-direction: column;
    flex: 1; /* Ensure it fills the flex container */
}

textarea#markdownOutput, textarea#jsonOutput {
    width: 100%;
    flex: 1; /* Fill remaining height */
    height: auto; /* Allow auto height */
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    background: #f8fbff;
    font-family: "IBM Plex Mono", "JetBrains Mono", "Fira Code", Consolas, monospace;
    font-size: 0.95rem;
    color: var(--ink-900);
    resize: none;
    /* height: 420px; removed fixed height */
}

.actions-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--blue-600);
    color: #ffffff;
    transition: all 0.2s ease;
}

.btn:hover {
    background: var(--blue-700);
    box-shadow: 0 4px 12px rgba(30, 90, 215, 0.2);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--ink-700);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--blue-50);
    color: var(--blue-700);
    border-color: var(--blue-200);
}

/* Removed empty-state styles */

.status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--blue-100);
    color: var(--blue-700);
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.status--visible {
    opacity: 1;
    transform: translateY(0);
}

.status--error {
    background: #ffecec;
    color: #b42318;
}

.footer {
    margin-top: 26px;
    text-align: center;
    color: var(--ink-500);
    font-size: 0.85rem;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 850px) {
    .workspace {
        grid-template-columns: 1fr;
    }
    
    .page {
        padding: 24px 16px;
    }

    textarea#markdownOutput, textarea#jsonOutput {
        height: 300px;
    }
}
