:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --border-color: #e8ecf1;
    --border-focus: #5b8def;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: #ffffff;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* ========== Header ========== */
.site-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.92);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.header-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #5b8def 0%, #3b6fd4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0;
}

.header-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    background: #f0f4ff;
    color: #5b8def;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

/* ========== Main Container ========== */
.main-container {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 24px 40px;
    width: 100%;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .tool-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .header-inner {
        padding: 0 16px;
    }

    .main-container {
        padding: 16px 16px 32px;
    }

    .header-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .header-badge {
        align-self: flex-start;
    }

    .panel-label {
        font-size: 0.85rem;
    }
}

/* ========== Panels ========== */
.panel {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
    min-height: 520px;
}

.panel:focus-within {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(91, 141, 239, 0.06);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: #fafbfc;
    gap: 12px;
    flex-wrap: wrap;
}

.panel-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.panel-label-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-editor {
    background: #5b8def;
}

.dot-preview {
    background: #34c759;
}

.panel-body {
    flex: 1;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ========== Editor ========== */
.md-editor {
    flex: 1;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text-primary);
    background: #ffffff;
    min-height: 440px;
    tab-size: 2;
    -moz-tab-size: 2;
}

.md-editor::placeholder {
    color: #c5cad3;
    font-style: italic;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    letter-spacing: 0.1px;
}

.md-editor::-webkit-scrollbar {
    width: 5px;
}

.md-editor::-webkit-scrollbar-track {
    background: transparent;
}

.md-editor::-webkit-scrollbar-thumb {
    background: #dde1e7;
    border-radius: 10px;
}

.md-editor::-webkit-scrollbar-thumb:hover {
    background: #c5cad3;
}

/* ========== Preview ========== */
.preview-area {
    flex: 1;
    padding: 20px 22px;
    overflow-y: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 440px;
    background: #ffffff;
    color: var(--text-primary);
}

.preview-area::-webkit-scrollbar {
    width: 5px;
}

.preview-area::-webkit-scrollbar-track {
    background: transparent;
}

.preview-area::-webkit-scrollbar-thumb {
    background: #dde1e7;
    border-radius: 10px;
}

.preview-area::-webkit-scrollbar-thumb:hover {
    background: #c5cad3;
}

/* 预览区富文本样式 */
.preview-area h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 1.2em 0 0.6em;
    padding-bottom: 0.4em;
    border-bottom: 2px solid #eef1f5;
    color: #1a1a2e;
    letter-spacing: -0.5px;
    line-height: 1.3;
}
.preview-area h1:first-child {
    margin-top: 0;
}
.preview-area h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 1em 0 0.5em;
    color: #1a1a2e;
    letter-spacing: -0.3px;
    line-height: 1.35;
}
.preview-area h2:first-child {
    margin-top: 0;
}
.preview-area h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0.85em 0 0.4em;
    color: #2c303a;
    letter-spacing: -0.2px;
    line-height: 1.4;
}
.preview-area h3:first-child {
    margin-top: 0;
}
.preview-area h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.7em 0 0.35em;
    color: #3a3f4a;
    letter-spacing: -0.1px;
    line-height: 1.45;
}
.preview-area h4:first-child {
    margin-top: 0;
}
.preview-area p {
    margin: 0.55em 0;
    line-height: 1.75;
}
.preview-area ul,
.preview-area ol {
    margin: 0.5em 0;
    padding-left: 1.6em;
}
.preview-area li {
    margin: 0.25em 0;
    line-height: 1.7;
}
.preview-area code {
    background: #f4f5f7;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: #c0392b;
    border: 1px solid #eef0f3;
}
.preview-area pre {
    background: #f7f8fa;
    border: 1px solid #eef1f5;
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    overflow-x: auto;
    margin: 0.7em 0;
    line-height: 1.6;
}
.preview-area pre code {
    background: none;
    padding: 0;
    border: none;
    color: #2c303a;
    font-size: 0.85rem;
}
.preview-area blockquote {
    border-left: 3px solid #5b8def;
    margin: 0.7em 0;
    padding: 8px 16px;
    background: #f8faff;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: #4a5568;
}
.preview-area blockquote p {
    margin: 0.3em 0;
}
.preview-area table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.7em 0;
    font-size: 0.9rem;
}
.preview-area table th,
.preview-area table td {
    border: 1px solid #e8ecf1;
    padding: 8px 12px;
    text-align: left;
}
.preview-area table th {
    background: #fafbfc;
    font-weight: 600;
}
.preview-area a {
    color: #5b8def;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
}
.preview-area a:hover {
    border-bottom-color: #5b8def;
}
.preview-area img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 0.5em 0;
}
.preview-area hr {
    border: none;
    border-top: 1px solid #eef1f5;
    margin: 1.2em 0;
}
.preview-area strong {
    font-weight: 600;
    color: #1a1a2e;
}

/* 预览区空状态 */
.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: #c5cad3;
    font-size: 0.9rem;
    text-align: center;
    padding: 40px 20px;
    user-select: none;
    pointer-events: none;
    flex-direction: column;
    gap: 8px;
}
.preview-placeholder .ph-icon {
    font-size: 2.5rem;
    letter-spacing: 2px;
    opacity: 0.5;
    line-height: 1;
}
.preview-placeholder .ph-text {
    font-size: 0.85rem;
    color: #cbd0d8;
    max-width: 260px;
    line-height: 1.5;
}

/* ========== Buttons ========== */
.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    background: #5b8def;
    color: #ffffff;
    letter-spacing: 0.2px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: var(--font-sans);
    box-shadow: 0 2px 8px rgba(91, 141, 239, 0.25);
    user-select: none;
    -webkit-user-select: none;
}

.btn-copy:hover {
    background: #4a7de0;
    box-shadow: 0 4px 16px rgba(91, 141, 239, 0.35);
    transform: translateY(-1px);
}
.btn-copy:active {
    background: #3e6fcf;
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(91, 141, 239, 0.2);
}
.btn-copy:disabled {
    background: #c5cad3;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    opacity: 0.7;
}
.btn-copy.copied {
    background: #34c759;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.25);
}
.btn-copy.copied:hover {
    background: #2db84e;
    box-shadow: 0 4px 16px rgba(52, 199, 89, 0.35);
}

.btn-clear {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid #dde1e7;
    background: #ffffff;
    color: #6b7280;
    letter-spacing: 0.1px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: var(--font-sans);
}
.btn-clear:hover {
    background: #f8f9fa;
    border-color: #c5cad3;
    color: #4a5568;
}
.btn-clear:active {
    background: #eef1f5;
}

/* ========== Toast ========== */
.custom-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    z-index: 9999;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 500;
    font-size: 0.88rem;
    letter-spacing: 0.2px;
    pointer-events: none;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
    white-space: nowrap;
    font-family: var(--font-sans);
    box-shadow: var(--shadow-lg);
}
.custom-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.custom-toast.success {
    background: #1a1a2e;
    color: #ffffff;
}
.custom-toast.error {
    background: #fff0f0;
    color: #c0392b;
    border: 1px solid #fdd;
}

/* ========== Footer ========== */
.site-footer {
    text-align: center;
    padding: 20px 24px;
    color: #b0b8c1;
    font-size: 0.78rem;
    border-top: 1px solid #f2f3f5;
    letter-spacing: 0.1px;
}
.site-footer a {
    color: #8b95a5;
    text-decoration: none;
    transition: color var(--transition-fast);
}
.site-footer a:hover {
    color: #5b8def;
}

/* ========== 响应式微调 ========== */
@media (max-width: 900px) {
    .panel {
        min-height: 380px;
    }
    .md-editor {
        min-height: 300px;
        font-size: 0.85rem;
        padding: 16px;
    }
    .preview-area {
        min-height: 300px;
        padding: 16px;
    }
    .btn-copy {
        padding: 10px 18px;
        font-size: 0.85rem;
    }
    .btn-clear {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
    .panel-header {
        padding: 12px 14px;
    }
}

@media (max-width: 480px) {
    .tool-grid {
        gap: 14px;
    }
    .panel {
        min-height: 300px;
        border-radius: var(--radius-md);
    }
    .md-editor {
        min-height: 240px;
        font-size: 0.8rem;
        padding: 14px;
    }
    .preview-area {
        min-height: 240px;
        padding: 14px;
        font-size: 0.88rem;
    }
    .btn-row {
        gap: 8px;
    }
    .btn-copy {
        padding: 9px 15px;
        font-size: 0.8rem;
        border-radius: 6px;
    }
    .btn-clear {
        padding: 7px 12px;
        font-size: 0.75rem;
        border-radius: 6px;
    }
    .custom-toast {
        top: 12px;
        padding: 10px 18px;
        font-size: 0.8rem;
        border-radius: 24px;
    }
}