:root {
    --bg: #f4f7fc;
    --bg-glow: rgba(49, 110, 255, 0.14);
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --surface-muted: #f8fbff;
    --stroke: #d8e1f0;
    --stroke-strong: #c5d1e6;
    --text: #15213b;
    --text-soft: #53627f;
    --text-muted: #7987a4;
    --navy: #0a1530;
    --navy-strong: #061022;
    --accent: #1d63f0;
    --accent-strong: #0e4ecf;
    --accent-soft: rgba(29, 99, 240, 0.12);
    --success: #2d9a4b;
    --success-soft: rgba(45, 154, 75, 0.14);
    --shadow-lg: 0 20px 60px rgba(9, 22, 53, 0.08);
    --shadow-md: 0 10px 25px rgba(18, 36, 77, 0.08);
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --font-sans: "Plus Jakarta Sans", "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

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

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text);
    background:
        radial-gradient(circle at top center, var(--bg-glow), transparent 28%),
        linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

code {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(135deg, var(--navy-strong), var(--navy));
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 16px 40px rgba(4, 12, 31, 0.28);
}

.app-header-inner {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #f5f8ff;
    font-size: 1.04rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(180deg, #86e34d, #69bd27);
    color: #103000;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.brand-mark svg {
    width: 20px;
    height: 20px;
}

.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.github-link,
.version-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
    color: #f3f7ff;
    font-size: 0.94rem;
    font-weight: 600;
}

.github-link svg {
    width: 18px;
    height: 18px;
}

.version-pill {
    padding-inline: 13px;
    color: #c9d5f8;
}

.app-shell {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 28px;
}

.hero {
    padding: 10px 2px 8px;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 2.35rem);
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.hero p {
    margin: 14px 0 0;
    color: var(--text-soft);
    font-size: 1.12rem;
}

.stack-lg {
    display: grid;
    gap: 18px;
}

.panel {
    margin-top: 16px;
    padding: 18px 18px 20px;
    background: var(--surface);
    border: 1px solid rgba(216, 225, 240, 0.88);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.section-heading h2 {
    margin: 0;
    color: var(--accent);
    font-size: 1.12rem;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.status-banner {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    font-weight: 600;
}

.status-banner-error {
    background: rgba(219, 71, 71, 0.12);
    border: 1px solid rgba(219, 71, 71, 0.18);
    color: #b03636;
}

.status-banner-icon {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(219, 71, 71, 0.16);
}

.input-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.82fr) minmax(440px, 1.18fr);
    gap: 18px;
}

.upload-panel,
.editor-panel {
    min-height: 182px;
    padding: 16px;
    border: 1px solid var(--stroke);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.96));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.field-label {
    display: block;
    margin-bottom: 14px;
    font-size: 1rem;
    font-weight: 700;
}

.field-hint {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.file-dropzone {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--stroke-strong);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.file-dropzone:hover {
    border-color: #8fb2ff;
    box-shadow: 0 0 0 4px rgba(29, 99, 240, 0.08);
}

.file-dropzone.has-file {
    border-color: rgba(45, 154, 75, 0.4);
}

.file-dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.file-dropzone-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--stroke-strong);
    border-radius: 10px;
    background: #fdfefe;
    color: var(--text);
    font-weight: 600;
}

.file-dropzone-button svg {
    width: 16px;
    height: 16px;
}

.file-dropzone-name {
    min-width: 0;
    overflow: hidden;
    color: var(--text-soft);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-dropzone-state {
    width: 18px;
    height: 18px;
    color: var(--success);
}

.file-dropzone-state svg {
    width: 18px;
    height: 18px;
}

.json-editor {
    display: grid;
    grid-template-columns: 46px 1fr;
    min-height: 156px;
    max-height: 156px;
    overflow: hidden;
    border: 1px solid var(--stroke-strong);
    border-radius: 12px;
    background: #fff;
}

.json-editor-lines,
.json-editor textarea {
    margin: 0;
    padding: 14px 0 14px 0;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    line-height: 1.65;
}

.json-editor-lines {
    padding-inline: 0 12px;
    overflow: hidden;
    color: #96a1ba;
    text-align: right;
    user-select: none;
    background: linear-gradient(180deg, #f8fbff, #f4f7fc);
    border-right: 1px solid #e0e8f7;
}

.json-editor textarea {
    width: 100%;
    padding-inline: 16px 18px;
    border: 0;
    resize: none;
    color: #183469;
    background: transparent;
    outline: none;
    white-space: pre;
    overflow: auto;
}

.actions-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button svg {
    width: 18px;
    height: 18px;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: linear-gradient(180deg, #2171ff, var(--accent));
    color: #fff;
    box-shadow: 0 10px 18px rgba(29, 99, 240, 0.24);
}

.button-primary:hover {
    box-shadow: 0 14px 22px rgba(29, 99, 240, 0.28);
}

.button-secondary {
    background: #fff;
    border-color: var(--stroke-strong);
    color: var(--text);
}

.document-grid {
    display: grid;
    grid-template-columns: minmax(250px, 0.9fr) minmax(640px, 2.1fr);
    gap: 18px;
    align-items: stretch;
}

.doc-meta {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 6px 0 0;
}

.doc-meta div {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 12px;
    align-items: center;
}

.doc-meta dt {
    color: var(--text);
    font-weight: 700;
}

.doc-meta dd {
    margin: 0;
    color: var(--text-soft);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 700;
}

.status-pill-success {
    color: var(--success);
    background: var(--success-soft);
}

.status-pill-muted {
    color: var(--text-soft);
    background: #edf2fb;
}

.download-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 18px;
}

.download-card-form {
    display: contents;
}

.download-card {
    width: 100%;
    min-height: 108px;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 14px;
    padding: 20px;
    border: 1px solid var(--stroke);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow-md);
    text-align: left;
    cursor: pointer;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.download-card:hover:enabled {
    transform: translateY(-3px);
    border-color: #8fb2ff;
    box-shadow: 0 18px 32px rgba(18, 36, 77, 0.12);
}

.download-card:disabled {
    cursor: not-allowed;
    opacity: 0.56;
    box-shadow: none;
}

.download-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.04em;
}

.download-icon-markdown {
    background: linear-gradient(180deg, #56c37d, #2f9e58);
}

.download-icon-docx {
    background: linear-gradient(180deg, #4d88e4, #1d59ba);
}

.download-icon-pdf {
    background: linear-gradient(180deg, #ff7061, #ea4335);
    font-size: 0.96rem;
}

.download-icon-all {
    background: linear-gradient(180deg, #8a83ff, #5d56f0);
    font-size: 0.88rem;
}

.download-copy {
    display: grid;
    gap: 6px;
}

.download-copy strong {
    font-size: 1rem;
    line-height: 1.35;
}

.download-copy small {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.section-note {
    margin: -4px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.expand-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--stroke-strong);
    border-radius: 12px;
    background: #fff;
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
}

.expand-button svg {
    width: 17px;
    height: 17px;
}

.swagger-preview-shell {
    height: 50vh;
    min-height: 360px;
    max-height: 50vh;
    border: 1px solid var(--stroke);
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

#swagger-ui {
    height: 100%;
    min-height: 320px;
    overflow: auto;
}

#swagger-ui .swagger-ui {
    font-family: var(--font-sans);
}

#swagger-ui .swagger-ui .topbar {
    display: none;
}

#swagger-ui .swagger-ui .scheme-container {
    box-shadow: none;
}

#preview-panel.is-expanded .swagger-preview-shell {
    height: calc(100vh - 180px);
    max-height: calc(100vh - 180px);
}

.empty-preview {
    height: 50vh;
    min-height: 280px;
    max-height: 50vh;
    display: grid;
    place-items: center;
    gap: 16px;
    padding: 30px;
    text-align: center;
    border: 1px dashed var(--stroke-strong);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(250, 252, 255, 0.98), rgba(243, 247, 253, 0.95));
    color: var(--text-soft);
}

.empty-preview-icon {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
}

.empty-preview h3 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 1.15rem;
}

.empty-preview p {
    margin: 0;
    max-width: 520px;
}

.seo-content {
    margin-top: 16px;
    display: grid;
    gap: 18px;
    padding: 22px;
    border: 1px solid rgba(216, 225, 240, 0.88);
    border-radius: var(--radius-xl);
    background:
        linear-gradient(135deg, rgba(29, 99, 240, 0.08), transparent 42%),
        var(--surface);
    box-shadow: var(--shadow-lg);
}

.seo-content-grid,
.seo-list-grid {
    display: grid;
    gap: 18px;
}

.seo-content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.seo-list-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.seo-copy,
.seo-list-card {
    padding: 18px;
    border: 1px solid var(--stroke);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.78);
}

.seo-copy h2,
.seo-list-card h2 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: 1.08rem;
    letter-spacing: -0.02em;
}

.seo-copy p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.7;
}

.seo-list-card ul {
    margin: 0;
    padding-left: 20px;
    color: var(--text-soft);
    line-height: 1.8;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    place-items: center;
    padding: 24px;
    background: rgba(10, 21, 48, 0.42);
    backdrop-filter: blur(4px);
}

.is-download-loading .loading-overlay {
    display: grid;
}

.download-frame {
    position: absolute;
    width: 0;
    height: 0;
    border: 0;
    visibility: hidden;
}

.loading-dialog {
    width: min(360px, 100%);
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 24px 70px rgba(4, 12, 31, 0.22);
    color: var(--text);
    text-align: center;
}

.loading-dialog strong {
    font-size: 1.04rem;
}

.loading-dialog span:last-child {
    color: var(--text-soft);
    font-size: 0.95rem;
}

.loading-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(29, 99, 240, 0.18);
    border-top-color: var(--accent);
    border-radius: 999px;
    animation: spin 800ms linear infinite;
}

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

@media (max-width: 1200px) {
    .input-grid,
    .document-grid {
        grid-template-columns: 1fr;
    }

    .download-grid {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }

    .seo-content-grid,
    .seo-list-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-header-inner,
    .app-shell {
        width: min(100% - 20px, 1480px);
    }

    .app-header-inner {
        min-height: 64px;
        flex-wrap: wrap;
        padding: 12px 0;
    }

    .hero h1 {
        font-size: 1.85rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .panel {
        padding: 16px 14px 18px;
        border-radius: 18px;
    }

    .upload-panel,
    .editor-panel {
        padding: 14px;
    }

    .file-dropzone {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .file-dropzone-state {
        display: none;
    }

    .json-editor {
        grid-template-columns: 36px 1fr;
        min-height: 130px;
        max-height: 130px;
    }

    .swagger-preview-shell,
    .empty-preview {
        height: 46vh;
        min-height: 280px;
        max-height: 46vh;
    }

    #preview-panel.is-expanded .swagger-preview-shell {
        height: calc(100vh - 128px);
        max-height: calc(100vh - 128px);
    }

    .actions-row,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .button,
    .expand-button {
        width: 100%;
    }

    .doc-meta div {
        grid-template-columns: 1fr;
        gap: 6px;
    }

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

    .download-card {
        min-height: 92px;
        padding: 16px;
    }
}
