/* ==========================================================================
   DNS 递归解析与迭代解析对比演示 · 页面专属样式
   依赖 site_shell.css / site_ui.css；全部规则限定在 body.p-dns-modes。
   ========================================================================== */

body.p-dns-modes {
    --dm-recursive: #0d9488;
    --dm-iterative: #7048e8;
    --dm-query: #0b63ce;
    --dm-referral: #b8860b;
    --dm-answer: #2b8a3e;
}

body.p-dns-modes *,
body.p-dns-modes *::before,
body.p-dns-modes *::after {
    box-sizing: border-box;
}

body.p-dns-modes .info-panel {
    margin-top: 20px;
    padding: 22px 24px;
}

body.p-dns-modes .panel-title {
    margin-bottom: 16px;
    font-size: 14px;
    flex-wrap: wrap;
}

body.p-dns-modes .panel-title small {
    margin-left: 9px;
    color: var(--sh-muted);
    font-size: 11.5px;
    font-weight: 400;
}

/* ---------- 模式切换 ---------- */
body.p-dns-modes .segmented {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--sh-line-2);
    border-radius: 11px;
    background: #f3f7fb;
}

body.p-dns-modes .seg-btn {
    min-height: 34px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sh-ink-2);
    font: 600 12.5px/1 var(--sh-sans);
    cursor: pointer;
    transition: background .16s, color .16s, box-shadow .16s;
}

body.p-dns-modes .seg-btn:hover { background: #e7eef7; }
body.p-dns-modes .seg-btn.active {
    background: var(--dm-recursive);
    color: #fff;
    box-shadow: 0 2px 6px rgba(13, 148, 136, .28);
}
body.p-dns-modes .seg-btn[data-mode="iterative"].active {
    background: var(--dm-iterative);
    box-shadow: 0 2px 6px rgba(112, 72, 232, .28);
}

body.p-dns-modes .mode-note {
    margin: 14px 0 0;
    padding: 10px 13px;
    border-left: 3px solid var(--dm-recursive);
    border-radius: 8px;
    background: #f0faf8;
    color: var(--sh-ink-2);
    font-size: 12.5px;
    line-height: 1.75;
}
body.p-dns-modes .mode-note.iterative {
    border-left-color: var(--dm-iterative);
    background: #f6f2ff;
}

/* ---------- 控制条 ---------- */
body.p-dns-modes .simulation-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-top: 16px;
    color: var(--sh-ink-2);
    font-size: 12.5px;
}
body.p-dns-modes .simulation-controls label { font-weight: 600; }

body.p-dns-modes #domain-input {
    width: 190px;
    min-height: 38px;
    padding: 0 11px;
    border: 1px solid var(--sh-line-2);
    border-radius: 9px;
    background: #fff;
    color: var(--sh-ink);
    font: 12.5px/1 var(--sh-mono);
}
body.p-dns-modes #record-type {
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--sh-line-2);
    border-radius: 9px;
    background: #fff;
    color: var(--sh-ink);
    font: 12.5px/1 var(--sh-sans);
}
body.p-dns-modes #reset-modes.control-btn {
    border-color: var(--sh-line-2);
    background: #fff;
    color: var(--sh-ink-2);
    box-shadow: none;
}
body.p-dns-modes #reset-modes.control-btn:hover {
    border-color: var(--dm-recursive);
    background: #f4fbfa;
    color: var(--dm-recursive);
}
body.p-dns-modes #start-modes:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}
body.p-dns-modes .speed-control { display: flex; align-items: center; gap: 8px; }
body.p-dns-modes #speed-slider {
    width: 90px;
    accent-color: var(--dm-recursive);
    cursor: pointer;
}
body.p-dns-modes .speed-label,
body.p-dns-modes .modes-status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 10px;
    border: 1px solid var(--sh-line-2);
    border-radius: 999px;
    background: #f6f9fc;
    color: var(--sh-muted);
    font: 600 11px/1.4 var(--sh-sans);
    white-space: nowrap;
}
body.p-dns-modes .modes-status { margin-left: auto; }
body.p-dns-modes .modes-status.running {
    border-color: #99ded5;
    background: #eefaf8;
    color: var(--dm-recursive);
}
body.p-dns-modes .modes-status.running.iterative {
    border-color: #d0c0ff;
    background: #f6f2ff;
    color: var(--dm-iterative);
}
body.p-dns-modes .modes-status.done {
    border-color: #a7dfc4;
    background: #eaf7f1;
    color: var(--dm-answer);
}

/* ---------- 动态步骤条 ---------- */
body.p-dns-modes .step-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}
body.p-dns-modes .step-bar li {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 42px;
    padding: 6px 9px;
    border: 1px solid var(--sh-line-2);
    border-radius: 10px;
    background: #f8fbfe;
    color: var(--sh-muted);
    font-size: 11.5px;
    transition: border-color .2s, background .2s, color .2s;
}
body.p-dns-modes .step-bar .step-no {
    display: grid;
    place-items: center;
    flex: none;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: #e7eef6;
    color: var(--sh-muted);
    font: 600 10px/1 var(--sh-mono);
}
body.p-dns-modes .step-bar li.active {
    border-color: var(--dm-query);
    background: #eef5fd;
    color: var(--sh-accent-deep);
    font-weight: 600;
}
body.p-dns-modes .step-bar li.active .step-no { background: var(--dm-query); color: #fff; }
body.p-dns-modes .step-bar li.done {
    border-color: #a7dfc4;
    background: #eef9f4;
    color: var(--dm-answer);
}
body.p-dns-modes .step-bar li.done .step-no { background: var(--dm-answer); color: #fff; }

/* ---------- 拓扑 ---------- */
body.p-dns-modes .modes-diagram {
    position: relative;
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.15fr) minmax(190px, 1.2fr);
    grid-template-rows: repeat(3, auto);
    align-items: center;
    gap: 16px 26px;
    min-height: 380px;
    padding: 24px;
    border: 1px solid var(--sh-line-2);
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfdff, #f3f8fd);
    overflow: hidden;
}
body.p-dns-modes .m-node {
    position: relative;
    z-index: 2;
    padding: 14px 13px;
    border: 1px solid var(--sh-line-2);
    border-radius: 12px;
    background: #e9f4ff;
    box-shadow: var(--sh-shadow-1);
    text-align: center;
}
body.p-dns-modes .m-node strong {
    display: block;
    margin-bottom: 8px;
    color: var(--sh-ink);
    font-size: 13px;
}
body.p-dns-modes .m-node span {
    display: block;
    color: var(--sh-ink-2);
    font: 11px/1.6 var(--sh-mono);
    overflow-wrap: anywhere;
}
body.p-dns-modes .m-node .node-note { color: var(--sh-muted); font-family: var(--sh-sans); }
body.p-dns-modes .m-node.client { grid-column: 1; grid-row: 2; }
body.p-dns-modes .m-node.resolver { grid-column: 2; grid-row: 2; background: #e6f7f4; }
body.p-dns-modes .m-node.root { grid-column: 3; grid-row: 1; background: #f3f0d0; }
body.p-dns-modes .m-node.tld { grid-column: 3; grid-row: 2; background: #e4f5e8; }
body.p-dns-modes .m-node.auth { grid-column: 3; grid-row: 3; background: #dcecfb; }
body.p-dns-modes .m-node.active {
    border-color: var(--dm-query);
    box-shadow: 0 0 0 3px rgba(11, 99, 206, .18), var(--sh-shadow-2);
}
body.p-dns-modes .m-node.dimmed { opacity: .55; }
body.p-dns-modes .resolver-note {
    margin-top: 8px;
    padding: 5px 8px;
    border: 1px solid #b9e5dd;
    border-radius: 7px;
    background: rgba(255, 255, 255, .8);
    color: var(--dm-recursive);
    font: 10.5px/1.5 var(--sh-mono) !important;
}
body.p-dns-modes .iterative .resolver-note {
    border-color: #d0c0ff;
    color: var(--dm-iterative);
}

body.p-dns-modes .m-packet {
    position: absolute;
    z-index: 5;
    top: 0;
    left: 0;
    max-width: 90%;
    min-height: 32px;
    padding: 5px 11px;
    border: 1px solid var(--dm-query);
    border-radius: 999px;
    background: var(--dm-query);
    box-shadow: 0 4px 12px rgba(8, 25, 42, .2);
    color: #fff;
    font: 600 11px/1.5 var(--sh-mono);
    text-align: center;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}
body.p-dns-modes .m-packet.referral { background: var(--dm-referral); border-color: var(--dm-referral); }
body.p-dns-modes .m-packet.answer { background: var(--dm-answer); border-color: var(--dm-answer); }
body.p-dns-modes .m-packet.error { background: #d13b48; border-color: #d13b48; }

body.p-dns-modes .modes-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--sh-line);
    color: var(--sh-muted);
    font-size: 12px;
}
body.p-dns-modes .legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--dm-query);
}
body.p-dns-modes .legend-dot.referral { background: var(--dm-referral); }
body.p-dns-modes .legend-dot.answer { background: var(--dm-answer); }
body.p-dns-modes .legend-tip { flex-basis: 100%; color: var(--sh-faint); }

/* ---------- 问答对照 ---------- */
body.p-dns-modes .qa-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
body.p-dns-modes .qa-card {
    padding: 14px 16px;
    border: 1px solid var(--sh-line);
    border-radius: 12px;
    background: #f8fbfe;
}
body.p-dns-modes .qa-card.question { border-top: 3px solid var(--dm-query); }
body.p-dns-modes .qa-card.answer { border-top: 3px solid var(--dm-referral); }
body.p-dns-modes .qa-card.answer.answer-final { border-top-color: var(--dm-answer); }
body.p-dns-modes .qa-card.answer.answer-error { border-top-color: #d13b48; }
body.p-dns-modes .qa-card h3 {
    margin: 0 0 10px;
    color: var(--sh-ink);
    font-size: 13px;
    font-weight: 600;
}
body.p-dns-modes .qa-card dl {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 6px 10px;
    margin: 0;
    font-size: 12px;
}
body.p-dns-modes .qa-card dt { color: var(--sh-muted); }
body.p-dns-modes .qa-card dd {
    margin: 0;
    color: var(--sh-ink);
    font-family: var(--sh-mono);
    overflow-wrap: anywhere;
}
body.p-dns-modes .mode-counters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 14px;
    color: var(--sh-muted);
    font-size: 12px;
}
body.p-dns-modes .mode-counters strong {
    color: var(--dm-recursive);
    font-family: var(--sh-mono);
    font-size: 14px;
}
body.p-dns-modes.iterative .mode-counters strong { color: var(--dm-iterative); }

/* ---------- 路径时间线 ---------- */
body.p-dns-modes .modes-timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}
body.p-dns-modes .modes-timeline li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--sh-muted);
    transition: background .2s, color .2s;
}
body.p-dns-modes .modes-timeline li + li { margin-top: 5px; }
body.p-dns-modes .tl-seq {
    display: grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    border: 1px solid var(--sh-line-2);
    border-radius: 50%;
    background: #fff;
    font: 600 10px/1 var(--sh-mono);
}
body.p-dns-modes .modes-timeline strong {
    display: block;
    color: var(--sh-ink-2);
    font-size: 12.5px;
}
body.p-dns-modes .modes-timeline li span[data-detail] {
    display: block;
    margin-top: 2px;
    font: 11px/1.6 var(--sh-mono);
}
body.p-dns-modes .modes-timeline li.active {
    background: #eef5fd;
    color: var(--dm-query);
}
body.p-dns-modes .modes-timeline li.active .tl-seq {
    border-color: var(--dm-query);
    background: var(--dm-query);
    color: #fff;
}
body.p-dns-modes .modes-timeline li.done {
    background: #f2faf7;
    color: var(--dm-answer);
}
body.p-dns-modes .modes-timeline li.done .tl-seq {
    border-color: var(--dm-answer);
    background: var(--dm-answer);
    color: #fff;
}

/* ---------- 日志 ---------- */
body.p-dns-modes .log-list {
    max-height: 440px;
    padding-right: 4px;
    overflow: auto;
}
body.p-dns-modes .log-empty {
    padding: 14px 16px;
    border: 1px dashed var(--sh-line-2);
    border-radius: 10px;
    background: #fbfdff;
    color: var(--sh-muted);
    font-size: 13px;
}
body.p-dns-modes .log-item {
    margin-bottom: 10px;
    padding: 12px 14px 12px 16px;
    border: 1px solid var(--sh-line);
    border-left: 3px solid var(--dm-query);
    border-radius: 10px;
    background: #fbfdff;
}
body.p-dns-modes .log-item.tag-init { border-left-color: #94a3b8; }
body.p-dns-modes .log-item.tag-query { border-left-color: var(--dm-query); }
body.p-dns-modes .log-item.tag-referral { border-left-color: var(--dm-referral); }
body.p-dns-modes .log-item.tag-answer { border-left-color: var(--dm-answer); }
body.p-dns-modes .log-item.tag-error { border-left-color: #d13b48; }
body.p-dns-modes .log-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
body.p-dns-modes .log-seq {
    display: grid;
    place-items: center;
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e7eef6;
    color: var(--sh-muted);
    font: 600 10px/1 var(--sh-mono);
}
body.p-dns-modes .log-phase { color: var(--dm-query); font-size: 12px; font-weight: 600; }
body.p-dns-modes .log-tag {
    padding: 1px 7px;
    border-radius: 4px;
    background: #edf3fa;
    color: var(--sh-muted);
    font: 10px/1.6 var(--sh-mono);
}
body.p-dns-modes .log-time {
    margin-left: auto;
    color: var(--sh-faint);
    font: 11px/1.5 var(--sh-mono);
}
body.p-dns-modes .log-title {
    margin: 6px 0 3px;
    color: var(--sh-ink);
    font-size: 13px;
    font-weight: 600;
}
body.p-dns-modes .log-detail {
    color: var(--sh-ink-2);
    font-size: 12.5px;
    line-height: 1.75;
}
body.p-dns-modes .log-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 6px;
    margin-top: 9px;
}
body.p-dns-modes .log-fields span {
    padding: 5px 8px;
    border: 1px solid var(--sh-line);
    border-radius: 6px;
    background: #fff;
    color: var(--sh-muted);
    font: 11px/1.5 var(--sh-mono);
}
body.p-dns-modes .log-fields b {
    margin-left: 6px;
    color: var(--sh-ink);
    font-weight: 600;
}

/* ---------- 结果与对比 ---------- */
body.p-dns-modes .result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 10px;
}
body.p-dns-modes .result-card {
    padding: 12px 14px;
    border: 1px solid var(--sh-line);
    border-radius: 10px;
    background: #f8fbfe;
}
body.p-dns-modes .result-wide { grid-column: 1 / -1; }
body.p-dns-modes .result-label {
    display: block;
    color: var(--sh-muted);
    font-size: 11.5px;
}
body.p-dns-modes .result-value {
    display: block;
    margin-top: 4px;
    color: var(--sh-ink);
    font: 600 12px/1.5 var(--sh-mono);
    overflow-wrap: anywhere;
}
body.p-dns-modes .modes-note,
body.p-dns-modes .compare-foot {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid #d9e8ff;
    border-radius: 10px;
    background: #f3f8ff;
    color: var(--sh-ink-2);
    font-size: 12.5px;
    line-height: 1.8;
}
body.p-dns-modes .modes-note strong { color: var(--sh-accent-deep); }
body.p-dns-modes .compare-foot { border-color: var(--sh-line); background: #f8fbfe; color: var(--sh-muted); }
body.p-dns-modes .table-scroll {
    overflow-x: auto;
    border: 1px solid var(--sh-line);
    border-radius: 10px;
}
body.p-dns-modes .compare-table {
    width: 100%;
    min-width: 700px;
    border-collapse: collapse;
    font-size: 12.5px;
}
body.p-dns-modes .compare-table th,
body.p-dns-modes .compare-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--sh-line);
    text-align: left;
    vertical-align: top;
}
body.p-dns-modes .compare-table th {
    background: #f3f7fb;
    color: var(--sh-ink);
    font-weight: 600;
}
body.p-dns-modes .compare-table th:nth-child(2) { color: var(--dm-recursive); }
body.p-dns-modes .compare-table th:nth-child(3) { color: var(--dm-iterative); }
body.p-dns-modes .compare-table td:first-child {
    color: var(--sh-ink);
    font-weight: 600;
    white-space: nowrap;
}
body.p-dns-modes .compare-table tr:last-child td { border-bottom: 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
    body.p-dns-modes .modes-diagram {
        grid-template-columns: minmax(140px, 1fr) minmax(160px, 1.1fr) minmax(170px, 1.15fr);
        gap: 12px 14px;
        padding: 18px;
    }
}
@media (max-width: 760px) {
    body.p-dns-modes .info-panel { padding: 18px 16px; }
    body.p-dns-modes .panel-title small {
        flex-basis: 100%;
        margin-left: 0;
        white-space: normal;
    }
    body.p-dns-modes #domain-input { width: 100%; }
    body.p-dns-modes .modes-status { margin-left: 0; }
    body.p-dns-modes .modes-diagram {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 12px;
        min-height: 0;
        padding: 16px;
    }
    body.p-dns-modes .m-node {
        grid-column: 1 !important;
        grid-row: auto !important;
    }
    body.p-dns-modes .qa-grid { grid-template-columns: 1fr; }
    body.p-dns-modes .m-packet { font-size: 10px; white-space: normal; }
}
