/* ============================================================
   文本差异对比工具 · 专属样式
   依赖 ../../style.css 的全局变量（--primary / --border 等）
   ============================================================ */

.td-section { padding: 48px 0 80px; background: var(--bg-warm); }

/* ===== 本地运行提示条 ===== */
.td-notice {
    display: flex; align-items: flex-start; gap: 14px;
    background: linear-gradient(135deg, #e8f1ff 0%, #f0f5ff 100%);
    border: 1.5px solid rgba(26,110,255,0.15);
    border-radius: var(--radius);
    padding: 20px 24px; margin-bottom: 28px;
}
.td-notice-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--primary); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.td-notice-icon svg { width: 22px; height: 22px; color: #fff; }
.td-notice h4 { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.td-notice p { font-size: 13px; color: var(--text-secondary); line-height: 1.7; margin: 0; }

/* ===== 输入区 ===== */
.td-input-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;
}
.td-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    display: flex; flex-direction: column;
    transition: var(--transition);
}
.td-panel:focus-within { border-color: rgba(26,110,255,0.4); box-shadow: var(--shadow); }
.td-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border);
    background: var(--bg-warm);
}
.td-panel-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.td-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.td-dot-a { background: #1a6eff; }
.td-dot-b { background: #ff6b35; }
.td-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.td-textarea {
    width: 100%; min-height: 280px; border: none; outline: none; resize: vertical;
    padding: 16px 18px; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px; line-height: 1.7; color: var(--text); background: #fff;
    white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
.td-textarea::placeholder { color: var(--text-light); font-family: inherit; }
.td-textarea.td-dragover { background: var(--primary-light); box-shadow: inset 0 0 0 2px rgba(26,110,255,0.4); }
.td-panel-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 10px 18px; border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-light); background: var(--bg-warm);
}

/* ===== 按钮 ===== */
.td-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px; border-radius: 10px; border: none; cursor: pointer;
    font-family: inherit; font-size: 14px; font-weight: 600;
    transition: var(--transition); white-space: nowrap;
}
.td-btn-primary {
    background: var(--primary-gradient); color: #fff;
    box-shadow: 0 4px 16px rgba(26,110,255,0.3);
}
.td-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(26,110,255,0.4); }
.td-btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }
.td-btn-ghost {
    background: #fff; color: var(--text-secondary); border: 1.5px solid var(--border);
}
.td-btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.td-btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }

/* ===== 工具栏 ===== */
.td-toolbar {
    position: sticky; top: 84px; z-index: 90;
    display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
    background: rgba(255,255,255,0.95); backdrop-filter: blur(12px);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 18px; margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(26,110,255,0.06);
}
.td-toolbar-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.td-toolbar-label { font-size: 13px; font-weight: 600; color: var(--text-light); flex-shrink: 0; }
.td-toolbar-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.td-seg { display: inline-flex; background: #f1f5f9; border-radius: 10px; padding: 3px; gap: 2px; }
.td-seg-btn {
    border: none; background: transparent; cursor: pointer;
    padding: 6px 14px; border-radius: 8px; font-family: inherit;
    font-size: 13px; font-weight: 500; color: var(--text-secondary); transition: var(--transition);
}
.td-seg-btn:hover { color: var(--primary); }
.td-seg-btn.active { background: #fff; color: var(--primary); font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.td-seg-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.td-seg-btn:disabled:hover { color: var(--text-secondary); }

.td-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text-secondary); user-select: none; }
.td-check input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

.td-select {
    font-family: inherit; font-size: 13px; color: var(--text);
    border: 1.5px solid var(--border); border-radius: 8px;
    padding: 7px 12px; background: #fff; cursor: pointer; outline: none;
}
.td-select:focus { border-color: var(--primary); }

/* ===== 结果区 ===== */
.td-stats-row {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 16px;
}
.td-stat {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px 12px; text-align: center;
}
.td-stat-num { font-size: 26px; font-weight: 900; line-height: 1; }
.td-stat-sm { font-size: 13px; font-weight: 700; line-height: 1.4; word-break: break-all; }
.td-stat-label { font-size: 12px; color: var(--text-light); margin-top: 8px; }
.td-stat-add .td-stat-num { color: #16a34a; }
.td-stat-del .td-stat-num { color: #dc2626; }
.td-stat-mod .td-stat-num { color: #ff6b35; }
.td-stat-sim .td-stat-num { color: var(--primary); }
.td-stat-meta .td-stat-num { color: var(--text-secondary); }

.td-result-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.td-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.td-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.td-lg { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.td-lg-ins { background: #dcfce7; border: 1px solid #86efac; }
.td-lg-del { background: #fee2e2; border: 1px solid #fca5a5; }
.td-lg-mod { background: #ffedd5; border: 1px solid #fdba74; }
.td-lg-eq  { background: #f1f5f9; border: 1px solid #e2e8f0; }

.td-result-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.td-search { display: flex; align-items: center; gap: 6px; }
.td-search input {
    font-family: inherit; font-size: 13px; padding: 7px 12px;
    border: 1.5px solid var(--border); border-radius: 8px; outline: none; width: 180px;
}
.td-search input:focus { border-color: var(--primary); }
.td-search-count { font-size: 12px; color: var(--text-light); min-width: 52px; }
.td-search-btn {
    width: 30px; height: 30px; border: 1.5px solid var(--border); background: #fff;
    border-radius: 8px; cursor: pointer; color: var(--text-secondary);
    font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.td-search-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ===== 差异卡片 ===== */
.td-diff-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.td-diff-head {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    background: var(--bg-warm); font-size: 14px; font-weight: 700;
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.td-diff-head .td-diff-meta { font-size: 12px; font-weight: 500; color: var(--text-light); }
.td-diff-body { max-height: 72vh; overflow: auto; }

/* --- 并排视图 --- */
.td-ss { display: grid; grid-template-columns: 56px minmax(0,1fr) 56px minmax(0,1fr); min-width: 720px; font-family: 'SFMono-Regular', Consolas, Menlo, monospace; font-size: 13px; line-height: 1.7; }
.td-ss-scroll { overflow: auto; }
.td-ss-head {
    display: contents;
}
.td-ss-head > div {
    position: sticky; top: 0; z-index: 5;
    background: #f8fafc; border-bottom: 1px solid var(--border);
    font-family: 'Noto Sans SC', sans-serif; font-weight: 700; font-size: 13px;
    color: var(--text-secondary); padding: 8px 12px;
}
.td-ss-head .td-hl-a { color: #1a6eff; }
.td-ss-head .td-hl-b { color: #ff6b35; }

.td-ln {
    padding: 1px 10px; text-align: right; color: #94a3b8; user-select: none;
    background: #f8fafc; border-right: 1px solid var(--border);
    position: sticky; left: 0; z-index: 2;
}
.td-ln-b { position: sticky; left: 56px; }
.td-code { padding: 1px 12px; white-space: pre-wrap; word-break: break-word; min-width: 0; }
.td-empty { background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 6px, #f4f6f9 6px, #f4f6f9 12px); }
.td-ln-empty { background: #f4f6f9; }

.td-eq  { background: #fff; color: var(--text); }
.td-del { background: #fef2f2; }
.td-ins { background: #f0fdf4; }
.td-mod { background: #fff7ed; }

mark.td-hl-del { background: rgba(220,38,38,0.18); color: inherit; border-radius: 2px; padding: 0 1px; }
mark.td-hl-ins { background: rgba(22,163,74,0.20); color: inherit; border-radius: 2px; padding: 0 1px; }

/* --- 统一视图 --- */
.td-un { display: grid; grid-template-columns: 30px 70px minmax(0,1fr); min-width: 520px; font-family: 'SFMono-Regular', Consolas, Menlo, monospace; font-size: 13px; line-height: 1.7; }
.td-un .td-sign {
    text-align: center; font-weight: 700; user-select: none;
    border-right: 1px solid var(--border);
}
.td-un .td-sign-del { color: #dc2626; background: #fef2f2; }
.td-un .td-sign-ins { color: #16a34a; background: #f0fdf4; }
.td-un .td-sign-eq  { color: #cbd5e1; background: #fff; }
.td-un .td-sign-mod { color: #ff6b35; background: #fff7ed; }
.td-un .td-ln { position: static; text-align: right; }
.td-un-head { display: contents; }
.td-un-head > div {
    position: sticky; top: 0; z-index: 5; background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-family: 'Noto Sans SC', sans-serif; font-weight: 700; font-size: 13px;
    color: var(--text-secondary); padding: 8px 12px;
}

/* --- 折叠行 --- */
.td-fold-btn {
    grid-column: 1 / -1; text-align: center; padding: 5px 12px;
    font-size: 12px; color: var(--text-light); background: #f8fafc;
    border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border);
    cursor: pointer; user-select: none; transition: var(--transition);
    font-family: 'Noto Sans SC', sans-serif;
}
.td-fold-btn:hover { color: var(--primary); background: var(--primary-light); }
.td-fold { display: none; grid-column: 1 / -1; }
.td-fold.open { display: contents; }
.td-fold > .td-fold { display: none; }
.td-fold.open > .td-fold { display: contents; }

/* --- 流式视图（词/字符级） --- */
.td-flow { display: grid; grid-template-columns: 1fr 1fr; min-width: 640px; }
.td-flow-pane { padding: 18px 20px; white-space: pre-wrap; word-break: break-word; font-family: 'SFMono-Regular', Consolas, Menlo, monospace; font-size: 13px; line-height: 1.9; }
.td-flow-pane-a { border-right: 1px solid var(--border); }
.td-flow-title { font-family: 'Noto Sans SC', sans-serif; font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.td-flow-title .a { color: #1a6eff; }
.td-flow-title .b { color: #ff6b35; }

/* --- 搜索命中 --- */
.td-code.td-sel, .td-flow-pane span.td-sel { outline: 2px solid rgba(26,110,255,0.5); outline-offset: -2px; background: #e8f1ff !important; }

/* ===== 使用说明 ===== */
.td-help { margin-top: 40px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.td-help h3 { font-size: 18px; font-weight: 800; margin-bottom: 20px; }
.td-help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.td-help-item strong { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.td-help-item strong::before { content: ''; display: inline-block; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.td-help-item p { font-size: 13px; color: var(--text-secondary); line-height: 1.8; margin: 0; }

/* ===== Toast ===== */
.td-toast {
    position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
    background: var(--text); color: #fff; font-size: 14px; font-weight: 500;
    padding: 12px 24px; border-radius: 100px; box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    opacity: 0; visibility: hidden; transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
    z-index: 9999; max-width: calc(100vw - 48px); text-align: center;
}
.td-toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .td-stats-row { grid-template-columns: repeat(3, 1fr); }
    .td-help-grid { grid-template-columns: 1fr; }
    .td-toolbar { top: 80px; }
}

@media (max-width: 768px) {
    .td-section { padding: 32px 0 60px; }
    .td-notice { flex-direction: column; gap: 12px; padding: 16px 18px; }
    .td-input-grid { grid-template-columns: 1fr; }
    .td-textarea { min-height: 200px; white-space: pre-wrap; }
    .td-panel-head { flex-wrap: wrap; }
    .td-toolbar { position: static; gap: 12px; padding: 14px; }
    .td-toolbar-actions { margin-left: 0; width: 100%; }
    .td-toolbar-actions .td-btn-primary { flex: 1; justify-content: center; }
    .td-stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .td-stat { padding: 12px 8px; }
    .td-stat-num { font-size: 20px; }
    .td-result-bar { flex-direction: column; align-items: stretch; }
    .td-result-actions { width: 100%; }
    .td-search { flex: 1; }
    .td-search input { flex: 1; width: auto; }
    .td-diff-body { max-height: 65vh; }
    .td-help { padding: 22px 18px; }
    .td-flow { grid-template-columns: 1fr; }
    .td-flow-pane-a { border-right: none; border-bottom: 1px solid var(--border); }
}

@media (max-width: 480px) {
    .td-stats-row { grid-template-columns: repeat(2, 1fr); }
    .td-btn { padding: 9px 14px; font-size: 13px; }
    .td-seg-btn { padding: 6px 10px; font-size: 12px; }
    .td-panel-actions { width: 100%; }
    .td-panel-actions .td-btn { flex: 1; justify-content: center; }
}

/* ============================================================
   移动端导航 / 页脚适配
   规则照抄官网首页（index.html）内联 <style> 中的媒体查询，
   仅补充 @media 规则，不重写 .navbar/.logo/.footer 桌面端样式
   ============================================================ */
@media (max-width: 1024px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    /* 顶部导航：汉堡菜单 + 纵向下拉（与官网 drill.html / index.html 一致） */
    .nav-links {
        display: none;
        position: absolute;
        top: 72px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 16px 24px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
        gap: 4px;
        border-bottom: 1px solid var(--border);
        z-index: 999;
    }
    .nav-links.active { display: flex; }
    .mobile-toggle { display: flex; }

    /* 底部页脚：单列排列 */
    .footer-grid { grid-template-columns: 1fr; gap: 32px; }
}
