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

:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #e0e4ea;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --primary: #4f6df5;
    --primary-hover: #3b5de7;
    --add-bg: #e6f4ea;
    --add-text: #1e7e34;
    --add-marker: #28a745;
    --del-bg: #fde8e8;
    --del-text: #c82333;
    --del-marker: #dc3545;
    --mod-bg: #fff8e1;
    --mod-text: #856404;
    --mod-marker: #f0ad4e;
    --line-num-bg: #f8f9fb;
    --code-font: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* 三栏布局 */
.layout {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: calc(100vh - 60px);
}

.ad-sidebar {
    width: 200px;
    min-height: calc(100vh - 60px);
    flex-shrink: 0;
    position: sticky;
    top: 0;
}

/* 主内容区 */
.main-content {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 24px 60px;
    min-width: 0;
}

/* 屏幕宽度 ≤1200px 时隐藏左右广告栏 */
@media (max-width: 1200px) {
    .ad-sidebar { display: none; }
    .main-content { max-width: 100%; padding: 24px 16px 40px; }
}

/* 工具头部 */
.tool-header {
    text-align: center;
    margin-bottom: 28px;
}

.tool-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.tool-header .subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* 工具栏 */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
}

.btn {
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

/* 输入区 */
.input-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 600px) {
    .input-section { grid-template-columns: 1fr; }
}

.input-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.panel-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.text-input {
    width: 100%;
    min-height: 240px;
    padding: 12px 14px;
    border: none;
    outline: none;
    resize: vertical;
    font-family: var(--code-font);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--surface);
    tab-size: 4;
}

.text-input::placeholder { color: #c0c4cc; }

/* 结果区 */
.result-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

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

.result-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

.result-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.78rem;
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
}

.stat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.stat-dot.add { background: var(--add-marker); }
.stat-dot.del { background: var(--del-marker); }
.stat-dot.mod { background: var(--mod-marker); }

.diff-view {
    overflow-x: auto;
}

.diff-placeholder {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Diff 表头 */
.diff-thead {
    display: flex;
    background: #f0f2f5;
    border-bottom: 2px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.diff-thead > div {
    padding: 6px 8px;
    text-align: center;
}

.diff-thead .thead-num { width: 42px; flex-shrink: 0; border-right: 1px solid var(--border); }
.diff-thead .thead-marker { width: 24px; flex-shrink: 0; border-right: 1px solid var(--border); }
.diff-thead .thead-content { flex: 1; min-width: 0; text-align: left; }
.diff-thead .thead-content:first-of-type { border-right: 1px solid var(--border); }

/* Diff 行 */
.diff-row {
    display: flex;
    font-family: var(--code-font);
    font-size: 0.82rem;
    line-height: 1.8;
    border-bottom: 1px solid #f0f0f0;
}

.diff-row .line-num {
    flex-shrink: 0;
    width: 42px;
    padding: 0 6px;
    text-align: right;
    color: #adb5bd;
    background: var(--line-num-bg);
    border-right: 1px solid var(--border);
    user-select: none;
    min-width: 42px;
}

.diff-row .line-num.right {
    border-right: 1px solid var(--border);
    border-left: none;
}

.diff-row .line-marker {
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    font-weight: 700;
    user-select: none;
    background: var(--line-num-bg);
    border-right: 1px solid var(--border);
}

.diff-row .line-content-left,
.diff-row .line-content-right {
    flex: 1;
    padding: 0 10px;
    white-space: pre-wrap;
    word-break: break-all;
    min-width: 0;
}

.diff-row .line-content-left {
    border-right: 1px solid #eee;
}

/* 相同行：低对比度 */
.diff-row.equal {
    background: #fafbfc;
    color: #888;
}

.diff-row.equal .line-content-left,
.diff-row.equal .line-content-right {
    color: #999;
}

/* 新增行：绿色高亮 */
.diff-row.add {
    background: var(--add-bg);
}

.diff-row.add .line-marker {
    color: var(--add-marker);
    background: #d4edda;
}

.diff-row.add .line-content-right {
    color: var(--add-text);
}

.diff-row.add .line-content-left {
    background: rgba(0,0,0,0.02);
}

/* 删除行：红色高亮 */
.diff-row.del {
    background: var(--del-bg);
}

.diff-row.del .line-marker {
    color: var(--del-marker);
    background: #f8d7da;
}

.diff-row.del .line-content-left {
    color: var(--del-text);
}

.diff-row.del .line-content-right {
    background: rgba(0,0,0,0.02);
}

/* 修改行：黄色高亮 */
.diff-row.mod {
    background: var(--mod-bg);
}

.diff-row.mod .line-marker {
    color: var(--mod-marker);
    background: #fff3cd;
}

.diff-row.mod .line-content-left {
    color: var(--del-text);
    background: rgba(248, 215, 218, 0.4);
}

.diff-row.mod .line-content-right {
    color: var(--add-text);
    background: rgba(212, 237, 218, 0.4);
}

/* 字符级高亮：删除的字符 */
.diff-row del {
    background: #f5b7b1;
    color: #7b1c1c;
    text-decoration: line-through;
    text-decoration-color: #c0392b;
    border-radius: 2px;
    padding: 0 1px;
    font-weight: 600;
}

/* 字符级高亮：新增的字符 */
.diff-row ins {
    background: #abebc6;
    color: #145a32;
    text-decoration: none;
    border-radius: 2px;
    padding: 0 1px;
    font-weight: 600;
}

/* 空内容占位 */
.diff-row .line-empty {
    display: inline-block;
    width: 100%;
    color: transparent;
}

/* 底部 */
.site-footer { min-height: 60px; }

/* 移动端 */
@media (max-width: 600px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-group {
        justify-content: center;
    }

    .tool-header h1 { font-size: 1.4rem; }

    .diff-row .line-num {
        width: 32px;
        min-width: 32px;
        font-size: 0.7rem;
    }

    .diff-row .line-marker {
        width: 20px;
        font-size: 0.75rem;
    }

    .diff-row {
        font-size: 0.75rem;
    }
}

/* SEO 内容区 */
.seo-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px 40px;
    color: #374151;
    font-size: 0.9rem;
    line-height: 1.9;
}

.seo-content h2 {
    font-size: 1.05rem;
    color: #111827;
    margin: 22px 0 10px;
    padding-left: 10px;
    border-left: 3px solid #409eff;
}

.seo-content h2:first-child { margin-top: 0; }

.seo-content h3 {
    font-size: 0.9rem;
    color: #111827;
    margin: 14px 0 4px;
}

.seo-content ul,
.seo-content ol { padding-left: 22px; }

.seo-content li { margin-bottom: 4px; }
