* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #f2f3f5;
    color: #1f2329;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei",
        Arial, sans-serif;
}

.app-shell {
    display: grid;
    grid-template-columns: 360px minmax(620px, 1fr);
    gap: 24px;
    width: min(1220px, calc(100vw - 48px));
    margin: 28px auto;
    align-items: start;
}

.control-panel,
.keyword-panel,
.preview-panel {
    background: #ffffff;
    border: 1px solid #e4e6eb;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(31, 35, 41, 0.06);
}

.left-rail {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-panel,
.keyword-panel {
    padding: 20px;
}

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

.panel-header {
    margin-bottom: 18px;
}

.keyword-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.keyword-header p {
    margin: 4px 0 0;
    color: #646a73;
    font-size: 12px;
    line-height: 1.5;
}

.preview-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e4e6eb;
}

h1,
h2 {
    margin: 0;
    color: #111111;
    line-height: 1.3;
}

h1 {
    font-size: 20px;
}

h2 {
    font-size: 17px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: #f2f3f5;
    color: #4e5969;
    font-size: 12px;
    white-space: nowrap;
}

.status-pill.loading {
    background: #e8f7ee;
    color: #078f47;
}

.status-pill.error {
    background: #fff1f0;
    color: #cf1322;
}

.status-pill.success {
    background: #e8f7ee;
    color: #078f47;
}

label {
    display: block;
    color: #4e5969;
    font-size: 13px;
    line-height: 1.5;
}

textarea,
input,
select {
    width: 100%;
    margin-top: 7px;
    border: 1px solid #c9cdd4;
    border-radius: 6px;
    background: #ffffff;
    color: #1f2329;
    font: inherit;
    outline: none;
}

textarea {
    min-height: 160px;
    resize: vertical;
    padding: 12px;
    font-size: 14px;
    line-height: 1.7;
}

input,
select {
    height: 38px;
    padding: 0 10px;
}

textarea:focus,
input:focus,
select:focus {
    border-color: #07c160;
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

.compact-grid {
    margin-top: 12px;
}

.config-field {
    margin-top: 14px;
}

.reply-label {
    margin-top: 12px;
}

.keyword-panel textarea {
    min-height: 104px;
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
}

.primary-btn,
.ghost-btn {
    height: 42px;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
}

.primary-btn {
    border: 1px solid #07c160;
    background: #07c160;
    color: #ffffff;
}

.primary-btn:disabled,
.ghost-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.primary-btn:hover:not(:disabled) {
    background: #06ad56;
    border-color: #06ad56;
}

.primary-btn:active:not(:disabled) {
    background: #059c4d;
    border-color: #059c4d;
}

.ghost-btn {
    border: 1px solid #c9cdd4;
    background: #ffffff;
    color: #1f2329;
}

.ghost-btn.small {
    width: 68px;
    height: 32px;
    font-size: 13px;
}

.full-width-btn {
    width: 100%;
    margin-top: 16px;
}

.preview-panel {
    min-height: calc(100vh - 56px);
}

.wechat-body {
    width: 586px;
    min-height: 680px;
    margin: 0 auto;
    padding: 42px 4px 80px;
    outline: none;
    color: rgba(0, 0, 0, 0.9);
    font-family: mp-quote, "PingFang SC", system-ui, -apple-system,
        "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei UI",
        "Microsoft YaHei", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.6;
    letter-spacing: 0.578px;
    text-align: justify;
}

.wechat-body:focus {
    box-shadow: inset 0 0 0 1px rgba(7, 193, 96, 0.32);
}

.wechat-body p {
    margin: 0 0 16px;
    font-size: 17px;
    line-height: 1.8;
    color: rgba(0, 0, 0, 0.9);
    letter-spacing: 0.578px;
    text-align: justify;
}

.wechat-body strong,
.wechat-body b {
    font-weight: 700;
    color: rgba(0, 0, 0, 0.9);
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    z-index: 1000;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.78);
    color: #ffffff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.toast.show {
    opacity: 1;
}

@media (max-width: 980px) {
    .app-shell {
        display: block;
        width: min(680px, calc(100vw - 24px));
    }

    .left-rail {
        position: static;
        margin-bottom: 16px;
    }

    .preview-panel {
        overflow-x: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: none;
    }
}
