:root {
    --wx5-bg: #f6f7f9;
    --wx5-surface: #ffffff;
    --wx5-surface-soft: #fbfcfe;
    --wx5-ink: #101828;
    --wx5-text: #344054;
    --wx5-muted: #667085;
    --wx5-subtle: #98a2b3;
    --wx5-line: #e5e7eb;
    --wx5-line-strong: #d0d5dd;
    --wx5-green: #16a34a;
    --wx5-blue: #1f5bff;
    --wx5-blue-soft: #edf4ff;
    --wx5-warning: #b45309;
    --wx5-danger: #dc2626;
    --wx5-radius: 18px;
    --wx5-radius-sm: 12px;
    --wx5-shadow: 0 18px 50px rgba(16, 24, 40, .08);
}

.wechat-editor-loading {
    display: grid;
    place-items: center;
    min-height: 360px;
    color: var(--wx5-muted);
}

.wechat-editor-loading strong,
.wechat-editor-loading span {
    display: block;
    text-align: center;
}

.wechat-editor-v5.wechat-article-panel {
    width: 100%;
    min-height: 100vh;
    padding: 0 !important;
    overflow: hidden !important;
    background: var(--wx5-bg) !important;
    color: var(--wx5-ink);
}

.wx5-shell {
    display: grid;
    grid-template-rows: auto 1fr;
    width: 100%;
    height: 100vh;
    min-height: 720px;
    background:
        radial-gradient(circle at 18% 12%, rgba(31, 91, 255, .08), transparent 28%),
        linear-gradient(180deg, #fbfcff 0%, var(--wx5-bg) 44%, #f2f4f7 100%);
}

.wx5-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 76px;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(208, 213, 221, .75);
    background: rgba(255, 255, 255, .78);
    backdrop-filter: blur(18px);
}

.wx5-titlebar {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.wx5-back,
.wx5-topmeta button,
.wx5-card-head button,
.wx5-market-tabs button,
.wx5-filters button,
.wx5-variant-tabs button,
.wx5-ghost,
.wx5-primary {
    border: 1px solid var(--wx5-line);
    border-radius: 999px;
    background: #fff;
    color: var(--wx5-text);
    font: inherit;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.wx5-back {
    min-height: 36px;
    padding: 0 13px;
    font-size: 13px;
}

.wx5-back:hover,
.wx5-topmeta button:hover,
.wx5-card-head button:hover,
.wx5-filters button:hover,
.wx5-market-tabs button:hover,
.wx5-variant-tabs button:hover,
.wx5-ghost:hover {
    transform: translateY(-1px);
    border-color: var(--wx5-line-strong);
    box-shadow: 0 10px 24px rgba(16, 24, 40, .08);
}

.wx5-titlebar span,
.wx5-market-head span,
.wx5-card-head span,
.wx5-side-card span {
    display: block;
    color: var(--wx5-blue);
    font-size: 11px;
    font-weight: 760;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.wx5-titlebar h3 {
    margin: 2px 0 0;
    color: var(--wx5-ink);
    font-size: 22px;
    line-height: 1.2;
    font-weight: 780;
    letter-spacing: 0;
}

.wx5-topmeta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.wx5-topmeta span {
    max-width: 180px;
    overflow: hidden;
    color: var(--wx5-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wx5-topmeta button {
    min-height: 36px;
    padding: 0 13px;
    font-size: 13px;
    font-weight: 650;
}

.wx5-primary,
.wx5-topmeta .wx5-primary {
    border-color: #111827;
    background: #111827;
    color: #fff;
    box-shadow: 0 12px 28px rgba(17, 24, 39, .16);
}

.wx5-primary:disabled {
    cursor: wait;
    opacity: .7;
    transform: none;
}

.wx5-body {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr) 270px;
    gap: 16px;
    min-height: 0;
    padding: 16px 18px 18px;
}

.wx5-rail,
.wx5-main,
.wx5-side {
    min-width: 0;
    min-height: 0;
}

.wx5-rail {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--wx5-line);
    border-radius: var(--wx5-radius);
    background: rgba(255, 255, 255, .82);
    box-shadow: var(--wx5-shadow);
}

.wx5-rail-brand b {
    display: block;
    color: var(--wx5-ink);
    font-size: 17px;
    line-height: 1.2;
}

.wx5-rail-brand span {
    display: block;
    margin-top: 4px;
    color: var(--wx5-muted);
    font-size: 12px;
}

.wx5-rail-actions {
    display: grid;
    gap: 8px;
}

.wx5-rail-actions button {
    display: grid;
    gap: 4px;
    padding: 12px 13px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--wx5-text);
    text-align: left;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}

.wx5-rail-actions button:hover,
.wx5-rail-actions button.is-active {
    border-color: var(--wx5-line);
    background: #fff;
}

.wx5-rail-actions strong {
    color: var(--wx5-ink);
    font-size: 14px;
}

.wx5-rail-actions span,
.wx5-rail-note span {
    color: var(--wx5-muted);
    font-size: 12px;
    line-height: 1.5;
}

.wx5-rail-note {
    margin-top: auto;
    padding: 14px;
    border-radius: 14px;
    background: var(--wx5-blue-soft);
}

.wx5-rail-note b {
    display: block;
    margin-bottom: 4px;
    color: #1945b8;
    font-size: 13px;
}

.wx5-main {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 12px;
}

.wx5-progress {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 6px;
    border: 1px solid var(--wx5-line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 12px 34px rgba(16, 24, 40, .05);
}

.wx5-progress button {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    min-height: 54px;
    padding: 9px 10px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: var(--wx5-muted);
    text-align: left;
    cursor: pointer;
}

.wx5-progress button.is-active,
.wx5-progress button.is-done {
    background: #fff;
    color: var(--wx5-ink);
    box-shadow: 0 10px 24px rgba(16, 24, 40, .06);
}

.wx5-progress i {
    display: grid;
    place-items: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #edf2ff;
    color: var(--wx5-blue);
    font-style: normal;
    font-weight: 760;
    font-size: 12px;
}

.wx5-progress button.is-done i {
    background: #dcfce7;
    color: var(--wx5-green);
}

.wx5-progress b,
.wx5-progress small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wx5-progress b {
    font-size: 13px;
}

.wx5-progress small {
    margin-top: 2px;
    color: var(--wx5-muted);
    font-size: 11px;
}

.wx5-stage {
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--wx5-line);
    border-radius: var(--wx5-radius);
    background: rgba(255, 255, 255, .88);
    box-shadow: var(--wx5-shadow);
}

.wx5-card,
.wx5-content-step,
.wx5-market,
.wx5-preview-step,
.wx5-history,
.wx5-empty {
    padding: 22px;
}

.wx5-card-head,
.wx5-market-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.wx5-card-head h4,
.wx5-market-head h4,
.wx5-empty h4,
.wx5-history h4 {
    margin: 2px 0 4px;
    color: var(--wx5-ink);
    font-size: 22px;
    line-height: 1.2;
}

.wx5-card-head p,
.wx5-market-head p,
.wx5-empty p {
    margin: 0;
    color: var(--wx5-muted);
    font-size: 13px;
    line-height: 1.6;
}

.wx5-card-head button {
    min-height: 36px;
    padding: 0 14px;
}

.wx5-field {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--wx5-text);
    font-size: 13px;
    font-weight: 650;
}

.wx5-field input,
.wx5-field textarea {
    width: 100%;
    border: 1px solid var(--wx5-line);
    border-radius: 14px;
    background: #fff;
    color: var(--wx5-ink);
    font: inherit;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.wx5-field input {
    min-height: 44px;
    padding: 0 14px;
}

.wx5-field textarea {
    min-height: 250px;
    padding: 14px;
    line-height: 1.65;
    resize: vertical;
}

.wx5-field input:focus,
.wx5-field textarea:focus {
    border-color: rgba(31, 91, 255, .55);
    box-shadow: 0 0 0 4px rgba(31, 91, 255, .08);
}

.wx5-import-grid {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 14px;
}

.wx5-upload {
    display: grid;
    align-content: center;
    gap: 8px;
    min-height: 150px;
    padding: 18px;
    border: 1px dashed #b9c3d4;
    border-radius: 16px;
    background: #fbfdff;
    color: var(--wx5-ink);
    font-weight: 760;
    cursor: pointer;
}

.wx5-upload input {
    display: none;
}

.wx5-upload span {
    color: var(--wx5-muted);
    font-size: 12px;
    line-height: 1.5;
    font-weight: 500;
}

.wx5-image-list {
    display: grid;
    gap: 8px;
    max-height: 240px;
    overflow: auto;
}

.wx5-image-list > p {
    display: grid;
    place-items: center;
    min-height: 150px;
    margin: 0;
    border-radius: 16px;
    background: var(--wx5-surface-soft);
    color: var(--wx5-muted);
    font-size: 13px;
}

.wx5-image-item {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) 96px auto;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--wx5-line);
    border-radius: 14px;
    background: #fff;
}

.wx5-image-item img {
    width: 56px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
}

.wx5-image-item b,
.wx5-image-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wx5-image-item b {
    color: var(--wx5-ink);
    font-size: 13px;
}

.wx5-image-item span {
    color: var(--wx5-muted);
    font-size: 12px;
}

.wx5-image-item select {
    min-height: 32px;
    border: 1px solid var(--wx5-line);
    border-radius: 10px;
    background: #fff;
}

.wx5-image-item button {
    border: 0;
    background: transparent;
    color: var(--wx5-danger);
    cursor: pointer;
}

.wx5-status {
    min-height: 20px;
    margin-top: 12px;
    color: var(--wx5-muted);
    font-size: 13px;
    line-height: 1.5;
}

.wx5-status.success {
    color: var(--wx5-green);
}

.wx5-status.warning {
    color: var(--wx5-warning);
}

.wx5-status.error {
    color: var(--wx5-danger);
}

.wx5-ai-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    margin-bottom: 16px;
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(135deg, #111827 0%, #20346c 100%);
    color: #fff;
}

.wx5-ai-summary span {
    display: block;
    color: #9cc0ff;
    font-size: 12px;
    font-weight: 760;
}

.wx5-ai-summary h4 {
    margin: 4px 0 8px;
    font-size: 24px;
    line-height: 1.25;
}

.wx5-ai-summary p {
    margin: 0;
    color: #dbeafe;
    font-size: 13px;
    line-height: 1.65;
}

.wx5-ai-metrics {
    display: grid;
    grid-template-columns: repeat(3, 74px);
    align-content: center;
    gap: 8px;
    text-align: center;
}

.wx5-ai-metrics b {
    display: block;
    color: #fff;
    font-size: 19px;
}

.wx5-ai-metrics span {
    color: #c7d2fe;
    font-size: 11px;
    font-weight: 500;
}

.wx5-block-list {
    display: grid;
    gap: 10px;
}

.wx5-block-review {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--wx5-line);
    border-radius: 15px;
    background: #fff;
}

.wx5-block-review > span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--wx5-blue-soft);
    color: var(--wx5-blue);
    font-weight: 760;
    font-size: 12px;
}

.wx5-block-review b {
    display: block;
    color: var(--wx5-ink);
    font-size: 14px;
}

.wx5-block-review p {
    margin: 4px 0 0;
    color: var(--wx5-muted);
    font-size: 13px;
    line-height: 1.55;
}

.wx5-block-review small {
    color: var(--wx5-subtle);
    font-size: 11px;
}

.wx5-market-tabs,
.wx5-filters,
.wx5-variant-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wx5-market-tabs button,
.wx5-filters button,
.wx5-variant-tabs button {
    min-height: 34px;
    padding: 0 13px;
    font-size: 13px;
}

.wx5-market-tabs button.is-active,
.wx5-filters button.is-active,
.wx5-variant-tabs button.is-active {
    border-color: var(--wx5-blue);
    background: var(--wx5-blue);
    color: #fff;
}

.wx5-filters {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--wx5-line);
}

.wx5-market-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
}

.wx5-template-card {
    display: grid;
    gap: 9px;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--wx5-line);
    border-radius: 16px;
    background: #fff;
    color: var(--wx5-text);
    text-align: left;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.wx5-template-card:hover,
.wx5-template-card.is-active {
    transform: translateY(-2px);
    border-color: rgba(31, 91, 255, .52);
    box-shadow: 0 16px 34px rgba(16, 24, 40, .10);
}

.wx5-template-card strong,
.wx5-template-card small,
.wx5-template-card em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wx5-template-card strong {
    color: var(--wx5-ink);
    font-size: 14px;
}

.wx5-template-card small {
    min-height: 34px;
    color: var(--wx5-muted);
    font-size: 12px;
    line-height: 1.45;
}

.wx5-template-card em {
    color: var(--wx5-subtle);
    font-size: 11px;
    font-style: normal;
    white-space: nowrap;
}

.wx5-template-thumb,
.wx5-component-thumb,
.wx5-svg-thumb {
    height: 112px;
    overflow: hidden;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--soft), #fff);
    border: 1px solid rgba(208, 213, 221, .7);
    position: relative;
}

.wx5-template-thumb i {
    position: absolute;
    inset: 12px 14px auto;
    height: 18px;
    border-radius: 10px;
    background: var(--accent);
}

.wx5-template-thumb b {
    position: absolute;
    left: 14px;
    top: 42px;
    width: 62%;
    height: 8px;
    border-radius: 99px;
    background: #111827;
    opacity: .82;
}

.wx5-template-thumb span {
    position: absolute;
    left: 14px;
    right: 14px;
    height: 6px;
    border-radius: 99px;
    background: rgba(52, 64, 84, .18);
}

.wx5-template-thumb span:nth-of-type(1) { top: 60px; }
.wx5-template-thumb span:nth-of-type(2) { top: 74px; right: 36px; }
.wx5-template-thumb span:nth-of-type(3) { top: 88px; right: 58px; }

.wx5-template-thumb strong {
    position: absolute;
    right: 14px;
    bottom: 12px;
    width: 32px;
    height: 24px;
    border-radius: 8px;
    background: var(--accent);
    opacity: .2;
}

.wx5-component-thumb {
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 20px;
    background: #fff;
}

.wx5-component-thumb i {
    width: 54%;
    height: 14px;
    border-radius: 99px;
    background: var(--accent);
}

.wx5-component-thumb span {
    height: 8px;
    border-radius: 99px;
    background: rgba(52, 64, 84, .16);
}

.wx5-svg-thumb {
    display: grid;
    place-items: center;
    background: radial-gradient(circle, rgba(31, 91, 255, .18), transparent 52%), #fff;
}

.wx5-svg-thumb b {
    color: var(--wx5-blue);
    font-size: 20px;
}

.wx5-preview-grid {
    display: grid;
    grid-template-columns: minmax(360px, 430px) minmax(220px, 1fr);
    gap: 18px;
    align-items: start;
    margin-top: 14px;
}

.wx5-phone {
    overflow: hidden;
    border: 1px solid var(--wx5-line);
    border-radius: 30px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(16, 24, 40, .12);
}

.wx5-phone-bar {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 14px 0 10px;
    border-bottom: 1px solid var(--wx5-line);
    background: #fff;
}

.wx5-phone-bar span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
}

.wx5-preview {
    max-height: calc(100vh - 250px);
    min-height: 520px;
    overflow: auto;
    padding: 0;
    background: #fff;
}

.wx5-quality {
    padding: 18px;
    border: 1px solid var(--wx5-line);
    border-radius: 18px;
    background: #fff;
}

.wx5-quality h4 {
    margin: 0 0 14px;
    color: var(--wx5-ink);
    font-size: 17px;
}

.wx5-check-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--wx5-line);
}

.wx5-check-row b {
    color: var(--wx5-ink);
    font-size: 16px;
}

.wx5-check-row span {
    color: var(--wx5-muted);
    font-size: 12px;
}

.wx5-check-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.wx5-check-list p {
    margin: 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--wx5-surface-soft);
    color: var(--wx5-text);
    font-size: 12px;
    line-height: 1.55;
}

.wx5-side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--wx5-line);
    border-radius: var(--wx5-radius);
    background: rgba(255, 255, 255, .84);
    box-shadow: var(--wx5-shadow);
}

.wx5-side-card {
    padding: 16px;
    border-radius: 16px;
    background: var(--wx5-surface-soft);
}

.wx5-side-card h4 {
    margin: 4px 0 8px;
    color: var(--wx5-ink);
    font-size: 18px;
}

.wx5-side-card p {
    margin: 0;
    color: var(--wx5-muted);
    font-size: 13px;
    line-height: 1.6;
}

.wx5-wide {
    width: 100%;
    min-height: 42px;
    padding: 0 16px;
    font-weight: 700;
}

.wx5-ghost {
    min-height: 42px;
    padding: 0 16px;
    font-weight: 700;
}

.wx5-history {
    display: grid;
    gap: 10px;
}

.wx5-history button {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--wx5-line);
    border-radius: 14px;
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.wx5-history b {
    color: var(--wx5-ink);
}

.wx5-history span {
    color: var(--wx5-muted);
    font-size: 12px;
}

.wx5-empty {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: 420px;
    text-align: center;
}

@media (max-width: 1180px) {
    .wx5-body {
        grid-template-columns: 200px minmax(0, 1fr);
    }

    .wx5-side {
        display: none;
    }

    .wx5-market-grid {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }

    .wx5-preview-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .wx5-shell {
        height: auto;
        min-height: 100vh;
    }

    .wx5-topbar {
        position: sticky;
        top: 0;
        z-index: 20;
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .wx5-titlebar h3 {
        font-size: 19px;
    }

    .wx5-topmeta {
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 2px;
    }

    .wx5-topmeta span {
        display: none;
    }

    .wx5-body {
        display: block;
        padding: 10px;
    }

    .wx5-rail {
        margin-bottom: 10px;
        padding: 12px;
    }

    .wx5-rail-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .wx5-rail-actions button {
        padding: 10px;
    }

    .wx5-rail-actions span,
    .wx5-rail-note {
        display: none;
    }

    .wx5-main {
        gap: 10px;
    }

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

    .wx5-stage {
        max-height: none;
        overflow: visible;
    }

    .wx5-card,
    .wx5-content-step,
    .wx5-market,
    .wx5-preview-step,
    .wx5-history,
    .wx5-empty {
        padding: 14px;
    }

    .wx5-card-head,
    .wx5-market-head {
        display: grid;
    }

    .wx5-field textarea {
        min-height: 220px;
    }

    .wx5-import-grid,
    .wx5-ai-summary,
    .wx5-preview-grid {
        grid-template-columns: 1fr;
    }

    .wx5-ai-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .wx5-market-grid {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }

    .wx5-image-item {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .wx5-image-item select,
    .wx5-image-item button {
        grid-column: 2;
    }

    .wx5-phone {
        border-radius: 22px;
    }

    .wx5-preview {
        max-height: none;
        min-height: 420px;
    }
}

@media (max-width: 430px) {
    .wx5-market-grid {
        grid-template-columns: 1fr;
    }

    .wx5-progress {
        grid-template-columns: 1fr;
    }
}
