:root {
    --radius: 12px;
    --workspace: #f4f6f8;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-strong: rgba(255, 255, 255, 0.98);
    --surface-soft: rgba(246, 248, 251, 0.94);
    --foreground: #05080b;
    --foreground-soft: #344054;
    --muted: #f6f8fb;
    --muted-foreground: #667085;
    --border: #e3e8ef;
    --border-strong: #d7dee8;
    --primary: #05080b;
    --primary-strong: #05080b;
    --primary-foreground: #ffffff;
    --success: #05080b;
    --warning: #f59e0b;
    --danger: #f87171;
    --shadow: 0 14px 30px -24px rgba(15, 23, 42, 0.18);
    --shadow-strong: 0 20px 42px -30px rgba(15, 23, 42, 0.22);
    --font-sans:
        "Space Grotesk",
        "IBM Plex Sans",
        "Inter Variable",
        "Segoe UI Variable Text",
        "Segoe UI",
        "PingFang SC",
        "Microsoft YaHei",
        sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

body {
    margin: 0;
    position: relative;
    background: #f4f6f8;
    color: var(--foreground);
    font-family: var(--font-sans);
}

body::before,
body::after {
    display: none;
}

body::before {
    content: none;
}

body::after {
    content: none;
}

button,
textarea,
input {
    font: inherit;
}

.page-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    padding: 18px;
}

.workspace {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
    height: 100%;
}

.panel {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.05), transparent);
}

.panel-header,
.panel-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
}

.panel-header {
    border-bottom: 1px solid var(--border);
}

.panel-footer {
    border-top: 1px solid var(--border);
    color: var(--muted-foreground);
    font-size: 13px;
}

.panel-header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--foreground);
}

.panel-header p {
    margin: 6px 0 0;
    color: var(--muted-foreground);
    font-size: 13px;
    line-height: 1.65;
}

.panel-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.editor-body,
.preview-body {
    min-height: 0;
    padding: 18px;
    overflow: hidden;
}

.editor-body,
.preview-body {
    display: flex;
}

#markdownInput {
    flex: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    resize: none;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--foreground);
    padding: 22px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.82;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

#markdownInput::placeholder {
    color: #a1a1aa;
}

#markdownInput:focus {
    border-color: #cfc8c1;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        0 0 0 3px rgba(5, 199, 139, 0.1);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.btn,
.segment-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--foreground);
    cursor: pointer;
    transition:
        transform 0.16s ease,
        border-color 0.16s ease,
        background 0.16s ease,
        color 0.16s ease,
        box-shadow 0.16s ease;
}

.btn:hover,
.segment-btn:hover {
    transform: translateY(-1px);
    border-color: #d7d1cb;
    background: #fafafa;
    box-shadow: 0 12px 22px -20px rgba(15, 23, 42, 0.12);
}

.btn:active,
.segment-btn:active {
    transform: translateY(0);
}

.btn-primary {
    border-color: #111111;
    background: #111111;
    color: #ffffff;
    box-shadow: 0 16px 28px -24px rgba(15, 23, 42, 0.22);
}

.btn-primary:hover {
    border-color: #111111;
    background: #1a1a1a;
    color: #ffffff;
}

.btn-ghost {
    background: #ffffff;
    color: var(--foreground);
}

.segment {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--muted);
}

.segment-btn {
    min-width: 72px;
    min-height: 34px;
    padding: 0 12px;
    border-color: transparent;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
}

.segment-btn.active {
    border-color: #d7d1cb;
    background: #ffffff;
    color: var(--foreground);
    box-shadow: 0 8px 16px -16px rgba(15, 23, 42, 0.18);
}

.view {
    display: none;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
}

.view.active {
    display: block;
}

.wechat-stage {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.wechat-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: #f6f8fb;
    color: var(--muted-foreground);
    font-size: 12px;
    letter-spacing: 0.02em;
}

.wechat-canvas {
    flex: 1;
    height: auto;
    min-height: 0;
    overflow: auto;
    padding: 28px;
    background: #f4f6f8;
}

.wechat-preview {
    max-width: 780px;
    margin: 0 auto;
}

.html-output {
    flex: 1;
    height: 100%;
    min-height: 0;
    margin: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #080b0f;
    color: #f5f5f5;
    padding: 22px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stats span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #ffffff;
}

.status-text,
.hint {
    line-height: 1.6;
}

.status-text {
    color: var(--foreground-soft);
    font-weight: 600;
}

.status-text.success {
    color: #05080b;
}

.status-text.warn {
    color: #fbbf24;
}

.status-text.error {
    color: #fca5a5;
}

.hint {
    color: var(--muted-foreground);
}

.hint code {
    padding: 2px 6px;
    border-radius: 8px;
    background: var(--muted);
    color: var(--foreground);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.42);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(125, 142, 164, 0.58);
}

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

@media (max-width: 840px) {
    .page-shell {
        padding: 14px;
    }

    .panel-header,
    .panel-footer {
        padding: 16px;
    }

    .panel-header,
    .panel-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar {
        justify-content: flex-start;
    }

    .wechat-canvas,
    .editor-body,
    .preview-body {
        padding: 14px;
    }
}
