:root {
    --bg: #f7f8fb;
    --ink: #111827;
    --muted: #667085;
    --panel: #ffffff;
    --line: #e4e7ec;
    --soft: #f9fafb;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: #eaf1ff;
    --sidebar: #0f172a;
    --sidebar-line: #22304a;
    --shadow: 0 24px 70px rgba(16, 24, 40, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 56% 16%, rgba(219, 234, 254, 0.75) 0, transparent 34%),
        linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
    overflow: hidden;
}

button,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 302px minmax(0, 1fr);
}

.sidebar {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 14px 10px 18px;
    color: #1f2937;
    background: #f4f5f7;
    border-right: 1px solid #e8ebf0;
    overflow: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 8px 18px;
    border: 0;
    text-align: left;
    background: transparent;
    color: inherit;
    border-radius: 12px;
}

.brand:hover .brand-title {
    color: var(--accent-dark);
}

.brand:hover .brand-logo {
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.22);
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #fff;
}

.brand-title {
    font-weight: 760;
    font-size: 17px;
}

.brand-subtitle {
    margin-top: 3px;
    color: #6b7280;
    font-size: 12px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.section-label {
    margin: 18px 8px 6px;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-pill,
.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    color: #374151;
    background: transparent;
    text-align: left;
    font-size: 14px;
    font-weight: 650;
    transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.nav-pill {
    margin-top: 4px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.nav-pill svg,
.nav-item svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    color: #64748b;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-item:hover,
.nav-pill:hover,
.nav-item.active,
.nav-pill.active {
    color: #111827;
    background: #fff;
    transform: translateX(1px);
}

.nav-item.active,
.nav-pill.active {
    box-shadow: inset 0 0 0 1px #dbeafe, 0 8px 20px rgba(37, 99, 235, 0.08);
}

.nav-item.active svg,
.nav-pill.active svg,
.nav-item:hover svg,
.nav-pill:hover svg {
    color: var(--accent);
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-grid li {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 78px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
}

.history-grid li:hover,
.history-grid li.active {
    border-color: #bfdbfe;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.10);
}

.history-file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: var(--accent);
    background: var(--accent-soft);
}

.history-file-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.history-file-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 680;
}

.workspace {
    min-width: 0;
    height: 100vh;
    overflow: auto;
}

.start-view {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 48px;
}

.history-view {
    min-height: 100%;
    padding: 48px;
}

.history-page {
    max-width: 1160px;
    margin: 0 auto;
}

.history-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.history-page-header h1 {
    margin: 6px 0 8px;
    font-size: 36px;
    line-height: 1.15;
}

.history-page-header p {
    margin: 0;
    color: var(--muted);
}

.page-kicker {
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 780;
}

.hero-card {
    width: min(980px, 100%);
    padding: 48px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 28px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.10);
    backdrop-filter: blur(18px);
}

.hero-brand {
    border: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 760;
}

.hero-brand:hover {
    background: #dbe8ff;
}

.hero-brand img {
    width: 24px;
    height: 24px;
    border-radius: 7px;
}

.hero-card h1 {
    margin: 18px 0 12px;
    max-width: 760px;
    font-size: clamp(38px, 5vw, 64px);
    line-height: 1.05;
    letter-spacing: 0;
}

.hero-copy {
    max-width: 760px;
    margin: 0 0 28px;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.7;
}

.input-console {
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 18px 46px rgba(16, 24, 40, 0.08);
}

#manual-text {
    width: 100%;
    min-height: 190px;
    padding: 18px;
    resize: vertical;
    border: 0;
    outline: none;
    color: var(--ink);
    font-size: 16px;
    line-height: 1.7;
}

#manual-text::placeholder {
    color: #98a2b3;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.file-picker {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 0 16px;
    color: var(--accent-dark);
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #b9cdfb;
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 10px 24px rgba(37, 99, 235, 0.12);
    font-size: 15px;
    font-weight: 760;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.input-console.file-only {
    padding: 14px;
}

.input-console.file-only .input-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    padding-top: 0;
    border-top: 0;
}

.input-console.file-only .file-picker {
    min-height: 168px;
    justify-content: center;
    flex-direction: column;
    color: #475467;
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
}

.input-console.file-only .file-picker-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
}

.input-console.text-only .input-actions {
    justify-content: flex-end;
}

.file-picker:hover {
    border-color: #7aa2f7;
    background: linear-gradient(135deg, #e0edff 0%, #cfe0ff 100%);
}

.file-picker input {
    display: none;
}

.file-picker-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    color: #fff;
    background: var(--accent);
    font-size: 18px;
    line-height: 1;
}

#custom-upload-btn,
.primary-action,
.ghost-action,
.header-actions button,
.panel-toggle,
.panel-actions button,
.button-link,
#fullscreen-mindmap-btn {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 14px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
}

.primary-action {
    min-width: 120px;
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 760;
}

.primary-action:hover {
    background: var(--accent-dark);
}

.ghost-action {
    margin-bottom: 14px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-color: #c7d7fe;
}

.format-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.format-row span {
    padding: 7px 10px;
    color: #344054;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 13px;
}

.status-message {
    min-height: 20px;
    margin-top: 12px;
    color: #475467;
    font-size: 14px;
}

.status-message.error {
    color: #dc2626;
}

.status-message.success {
    color: #15803d;
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.process-view {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 42px 128px;
}

.process-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 0 14px;
    margin-bottom: 14px;
    background: linear-gradient(180deg, var(--bg) 0%, rgba(246, 247, 251, 0.94) 72%, rgba(246, 247, 251, 0) 100%);
    backdrop-filter: blur(10px);
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

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

.timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: #d0d5dd;
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 14px;
}

.timeline-dot {
    z-index: 1;
    width: 28px;
    height: 28px;
    margin-top: 18px;
    border: 7px solid #edf2ff;
    border-radius: 50%;
    background: var(--accent);
}

.timeline-dot.active {
    animation: pulseDot 1.2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.22);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(37, 99, 235, 0);
    }
}

.timeline-card {
    min-width: 0;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 14px 36px rgba(16, 24, 40, 0.08);
}

.stream-card {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    max-width: 100%;
    padding: 11px 14px;
    color: #1f2937;
    background: #fff;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.10);
    font-size: 13px;
    font-weight: 700;
}

.stream-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    animation: blink 0.9s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 0.35;
        transform: scale(0.86);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--soft);
}

.panel-header.compact {
    border-bottom: 0;
}

.panel-header h2 {
    margin: 0;
    font-size: 16px;
}

.panel-state {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

#apply-md-btn,
#fullscreen-mindmap-btn,
.button-link {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 700;
}

#fullscreen-mindmap-btn:hover,
#apply-md-btn:hover,
.button-link:hover {
    background: var(--accent-dark);
}

#apply-md-btn:disabled,
.primary-action:disabled,
.panel-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.step-list {
    margin: 0;
    padding: 0 18px 18px 42px;
    color: #344054;
}

.step-list li {
    padding: 8px 0;
}

.step-list li:last-child {
    color: var(--accent-dark);
    font-weight: 700;
}

.step-highlight {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 4px 10px;
    border: 1px solid rgba(47, 94, 255, 0.16);
    border-radius: 999px;
    color: var(--accent-dark);
    background: rgba(47, 94, 255, 0.08);
    font-weight: 700;
    line-height: 1.4;
}

.text-surface {
    width: 100%;
    min-height: 0;
    max-height: 430px;
    margin: 0;
    padding: 18px;
    overflow: auto;
    border: 0;
    outline: none;
    resize: vertical;
    color: #111827;
    background: #fff;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.markdown-editor {
    height: auto;
    min-height: 0;
}

.mindmap-card {
    min-height: 640px;
}

.mindmap-frame-wrap {
    height: 580px;
    background: #fff;
}

.link-surface {
    display: block;
    margin: 0;
    padding: 18px;
    color: var(--accent-dark);
    background: #fff;
    border-top: 1px solid var(--line);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    line-height: 1.7;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.link-surface:hover {
    text-decoration: underline;
}

#mindmap-frame,
.mindmap-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.mindmap-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #fff;
}

.mindmap-fullscreen iframe {
    width: 100vw;
    height: 100vh;
    border: 0;
    display: block;
}

.close-fullscreen-btn {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1001;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 999px;
    padding: 10px 14px;
    color: #111827;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

body.fullscreen-open {
    overflow: hidden;
}

.timeline-item.collapsed .text-surface {
    min-height: 112px;
    max-height: 112px;
    resize: none;
    overflow: hidden;
}

.timeline-item.collapsed .markdown-editor {
    min-height: 132px;
    max-height: 132px;
}

.timeline-item.collapsed .step-list {
    max-height: 132px;
    overflow: hidden;
}

@media (max-width: 960px) {
    body {
        overflow: auto;
    }

    .app-shell {
        display: block;
        height: auto;
    }

    .sidebar {
        min-height: 280px;
        max-height: none;
    }

    .workspace {
        height: auto;
    }

    .start-view,
    .history-view,
    .process-view {
        padding: 24px;
    }

    .hero-card {
        padding: 28px;
    }

    .input-actions,
    .process-header,
    .history-page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .history-grid {
        grid-template-columns: 1fr;
    }
}
