/* =====================================================
   Technical Reference Page (protocols.html) Styles
   ===================================================== */

/* ----- Hero ----- */
.ref-hero {
    position: relative;
    min-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    background: #0a0a0a;
    padding-top: 64px;
}

.ref-hero-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 65% 50% at 50% 0%, rgba(124,58,237,0.35) 0%, transparent 65%),
        radial-gradient(ellipse 50% 40% at 80% 90%, rgba(16,185,129,0.18) 0%, transparent 60%),
        radial-gradient(ellipse 45% 35% at 15% 70%, rgba(0,82,217,0.2) 0%, transparent 55%),
        linear-gradient(135deg, #0a0a0a 0%, #111827 100%);
    animation: refHeroBgPulse 12s ease-in-out infinite alternate;
}

@keyframes refHeroBgPulse {
    0%   { opacity: 1; }
    100% { opacity: 0.8; }
}

.ref-hero-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 44px 44px;
}

.ref-hero-content {
    position: relative;
    z-index: 2;
    padding: 60px 20px 64px;
    max-width: 800px;
    margin: 0 auto;
}

.ref-hero-label {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 5px 16px;
    border-radius: 20px;
    margin-bottom: 22px;
}

.ref-hero-title {
    font-size: 46px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
    margin-bottom: 16px;
    line-height: 1.15;
}

.ref-hero-desc {
    font-size: 16px;
    color: rgba(255,255,255,0.6);
    font-weight: 300;
    line-height: 1.8;
    margin-bottom: 34px;
}

.ref-hero-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.ref-hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.ref-hero-btn:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.6);
    transform: translateY(-2px);
    color: #fff;
}

/* ----- Page Layout ----- */
.ref-layout {
    display: flex;
    align-items: flex-start;
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    gap: 0;
}

.ref-layout > * {
    min-width: 0;
}

/* ----- Sidebar ----- */
.ref-sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 32px 0 32px 0;
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}

.ref-sidebar::-webkit-scrollbar {
    width: 4px;
}
.ref-sidebar::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 4px;
}

.ref-sidebar-inner {
    padding-right: 20px;
    border-right: 1px solid #e5e7eb;
}

.ref-sidebar-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #9ca3af;
    margin-bottom: 16px;
    padding-left: 4px;
}

.ref-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ref-nav-group {
    margin-bottom: 8px;
}

.ref-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.ref-nav-item:hover {
    background: #f3f4f6;
    color: #374151;
}

.ref-nav-item.active {
    background: #eff6ff;
    color: #0052d9;
    font-weight: 600;
}

.ref-nav-item-h2 {
    font-size: 13.5px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
}

.ref-nav-item-h2.active {
    color: #0052d9;
    background: #eff6ff;
}

.ref-nav-item-h2 i {
    font-size: 12px;
    width: 14px;
    text-align: center;
}

.ref-nav-item-h3 {
    padding-left: 28px;
    font-size: 12.5px;
    color: #9ca3af;
}

.ref-nav-item-h3.active {
    color: #0052d9;
    background: #eff6ff;
}

.ref-sidebar-cta {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ref-sidebar-cta-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #e5e7eb;
    color: #374151;
    background: #fff;
    transition: all 0.2s ease;
}

.ref-sidebar-cta-btn:hover {
    border-color: #9ca3af;
    background: #f9fafb;
    color: #111827;
}

.ref-sidebar-cta-btn-dl {
    background: #0052d9;
    border-color: #0052d9;
    color: #fff;
}

.ref-sidebar-cta-btn-dl:hover {
    background: #0047c2;
    border-color: #0047c2;
    color: #fff;
}

/* ----- Main Content ----- */
.ref-content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding: 40px 0 80px 48px;
}

/* ----- Sections ----- */
.ref-section {
    padding: 0 0 64px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 64px;
    min-width: 0;
}

.ref-section:last-child {
    border-bottom: none;
}

.ref-section-alt {
    /* no extra styling needed — relies on parent background */
}

.ref-section-header {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 40px;
}

.ref-section-header > div:last-child {
    flex: 1;
    min-width: 0;
}

.ref-section-header h2,
.ref-section-header p {
    overflow-wrap: break-word;
    word-break: normal;
}

.ref-section-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
    margin-top: 2px;
}

.ref-icon-blue   { background: linear-gradient(135deg, #0052d9, #60a5fa); }
.ref-icon-purple { background: linear-gradient(135deg, #7c3aed, #c084fc); }
.ref-icon-green  { background: linear-gradient(135deg, #059669, #34d399); }

.ref-section-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.ref-section-header p {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.65;
}

/* ----- Anchor targets ----- */
.ref-anchor {
    margin-bottom: 52px;
    scroll-margin-top: 100px;
}

.ref-anchor:last-child {
    margin-bottom: 0;
}

/* ----- Headings ----- */
.ref-h3 {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.ref-h3 i {
    font-size: 16px;
    color: #6b7280;
}

.ref-h4-title {
    font-size: 15px;
    font-weight: 700;
    color: #374151;
    margin: 28px 0 12px;
}

.ref-p {
    font-size: 14.5px;
    color: #4b5563;
    line-height: 1.75;
    margin-bottom: 18px;
    overflow-wrap: break-word;
    word-break: normal;
}

/* ----- Tip / Info Boxes ----- */
.ref-tip-box,
.ref-info-box {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border-radius: 10px;
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 13.5px;
    line-height: 1.65;
}

.ref-tip-box {
    background: #fefce8;
    border: 1px solid #fde68a;
    color: #78350f;
}

.ref-tip-box > i { color: #f59e0b; font-size: 15px; margin-top: 2px; flex-shrink: 0; }

.ref-tip-box > div,
.ref-info-box > div {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
}

.ref-tip-box code,
.ref-info-box code {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.ref-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.ref-info-box > i { color: #3b82f6; font-size: 15px; margin-top: 2px; flex-shrink: 0; }

.ref-tip-list {
    margin: 8px 0 0 4px;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ref-tip-list li {
    position: relative;
    padding-left: 14px;
    font-size: 13px;
    line-height: 1.65;
}

.ref-tip-list li::before {
    content: '·';
    position: absolute;
    left: 0;
    color: #f59e0b;
    font-weight: 700;
}

/* =====================================================
   ARCHITECTURE SECTION
   ===================================================== */

/* ----- Components ----- */
.arch-components {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.arch-component {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px;
    transition: box-shadow 0.25s ease;
    min-width: 0;
}

.arch-component:hover {
    box-shadow: 0 3px 14px rgba(0,0,0,0.07);
}

.arch-comp-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.arch-comp-body {
    flex: 1;
    min-width: 0;
}

.arch-comp-name {
    font-size: 14.5px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 5px;
    overflow-wrap: break-word;
}

.arch-comp-desc {
    font-size: 13.5px;
    color: #4b5563;
    line-height: 1.65;
    overflow-wrap: break-word;
    word-break: normal;
}

.arch-comp-desc code {
    font-family: 'Courier New', monospace;
    background: #e5e7eb;
    color: #1f2937;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    word-break: break-all;
}

/* ----- Flow Diagram ----- */
.flow-diagram {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 14px;
    padding: 12px;
    margin: 20px 0;
}

.flow-step {
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto auto;
    column-gap: 14px;
    row-gap: 3px;
    align-items: start;
    text-align: left;
    min-width: 0;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 10px;
}

.flow-step-icon {
    grid-row: 1 / span 2;
    grid-column: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: #fff;
    align-self: center;
    flex-shrink: 0;
}

.flow-step-app  .flow-step-icon { background: #6b7280; }
.flow-step-in   .flow-step-icon { background: #0052d9; }
.flow-step-dns  .flow-step-icon { background: #7c3aed; }
.flow-step-rule .flow-step-icon { background: #059669; }
.flow-step-out  .flow-step-icon { background: #dc2626; }

.flow-step-label {
    grid-column: 2;
    grid-row: 1;
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.35;
    overflow-wrap: break-word;
    word-break: normal;
}

.flow-step-sub {
    grid-column: 2;
    grid-row: 2;
    font-size: 12px;
    color: #64748b;
    line-height: 1.45;
    overflow-wrap: break-word;
    word-break: normal;
}

.flow-arrow {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 0;
    color: #94a3b8;
    font-size: 13px;
    flex-shrink: 0;
}

.flow-arrow i {
    transform: rotate(90deg);
}

@media (min-width: 1024px) {
    .flow-diagram {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-start;
        justify-content: center;
        gap: 6px;
        padding: 24px 16px;
    }

    .flow-step {
        display: flex;
        flex-direction: column;
        align-items: center;
        flex: 1 1 0;
        min-width: 0;
        max-width: 168px;
        padding: 0 4px;
        background: transparent;
        text-align: center;
        gap: 8px;
    }

    .flow-step-icon {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    .flow-step-label,
    .flow-step-sub {
        width: 100%;
    }

    .flow-arrow {
        align-self: center;
        padding: 0;
        margin-top: 12px;
    }

    .flow-arrow i {
        transform: none;
    }
}

/* ----- Mode Cards ----- */
.mode-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}

.mode-cards > *,
.dns-modes > *,
.rules-type-grid > *,
.proto-grid > *,
.transport-grid > * {
    min-width: 0;
}

.mode-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow 0.25s ease;
}

.mode-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.mode-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #f9fafb;
    border-bottom: 1px solid #f3f4f6;
}

.mode-card-name {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
}

.mode-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

.mode-badge-rec  { background: #d1fae5; color: #065f46; }
.mode-badge-adv  { background: #dbeafe; color: #1e40af; }
.mode-badge-test { background: #f3f4f6; color: #6b7280; }
.mode-badge-pro  { background: #fae8ff; color: #7c3aed; }

.mode-card-body {
    padding: 16px 18px;
}

.mode-card-body p {
    font-size: 13.5px;
    color: #4b5563;
    line-height: 1.65;
    margin-bottom: 12px;
    overflow-wrap: break-word;
    word-break: normal;
}

.mode-card-code {
    font-size: 12px;
}

.mode-card-code code {
    font-family: 'Courier New', monospace;
    background: #1e1e2e;
    color: #a6e3a1;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ----- DNS Modes ----- */
.dns-modes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.dns-mode {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px;
}

.dns-mode-name {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.dns-mode-name i { color: #6b7280; }

.dns-mode-desc {
    font-size: 13.5px;
    color: #4b5563;
    line-height: 1.6;
    overflow-wrap: break-word;
    word-break: normal;
}

/* =====================================================
   CODE BLOCKS
   ===================================================== */
.code-block {
    background: #1e1e2e;
    border-radius: 12px;
    overflow: hidden;
    margin: 16px 0;
    max-width: 100%;
    font-family: 'Courier New', 'Consolas', monospace;
}

.code-block-header {
    background: #2a2a3d;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.code-dots { display: flex; gap: 6px; }

.code-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-r { background: #ff5f57; }
.dot-y { background: #febc2e; }
.dot-g { background: #28c840; }

.code-filename {
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    font-family: inherit;
    margin-left: 4px;
}

.code-body {
    padding: 20px 24px;
    overflow-x: auto;
}

.code-body pre {
    margin: 0;
    font-size: 13px;
    line-height: 1.85;
    color: #cdd6f4;
    tab-size: 2;
}

/* YAML syntax highlighting classes */
.y-key    { color: #89dceb; }
.y-colon  { color: #cdd6f4; }
.y-str    { color: #a6e3a1; }
.y-bool   { color: #cba6f7; }
.y-num    { color: #fab387; }
.y-dash   { color: #f38ba8; }
.y-comment{ color: #6c7086; font-style: italic; }

/* ----- Comparison Table ----- */
.compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin: 16px 0;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.ref-table th {
    background: #f3f4f6;
    color: #374151;
    font-weight: 600;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: normal;
    line-height: 1.45;
    vertical-align: middle;
}

.ref-table td {
    padding: 13px 16px;
    color: #4b5563;
    border-top: 1px solid #f3f4f6;
    line-height: 1.55;
    vertical-align: middle;
    overflow-wrap: break-word;
    word-break: normal;
}

/* Three-column feature comparison table: balanced column widths for i18n long text */
.ref-table-compare {
    table-layout: fixed;
}

.ref-table-compare th {
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
}

.ref-table-compare th:first-child,
.ref-table-compare td:first-child {
    width: 26%;
    font-weight: 600;
    color: #374151;
}

.ref-table-compare td:first-child {
    background: #fafafa;
}

.ref-table-compare th:nth-child(2),
.ref-table-compare th:nth-child(3),
.ref-table-compare td:nth-child(2),
.ref-table-compare td:nth-child(3) {
    width: 37%;
}

/* Multi-column protocol comparison table: horizontal scroll within container without breaking layout */
.ref-table-wide {
    min-width: 640px;
}

.ref-table-wide th:nth-child(1),
.ref-table-wide td:nth-child(1) {
    min-width: 120px;
}

.ref-table-wide .rating,
.ref-table-wide .diff,
.ref-table-wide .rec-badge {
    white-space: nowrap;
}

.ref-table tr:hover td { background: #fafafa; }

.rating     { font-size: 13px; letter-spacing: 1px; }
.rating-5   { color: #f59e0b; }
.rating-4   { color: #10b981; }
.rating-3   { color: #6b7280; }
.rating-2   { color: #9ca3af; }

.diff {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
}

.diff-easy { background: #d1fae5; color: #065f46; }
.diff-med  { background: #fef3c7; color: #78350f; }
.diff-hard { background: #fee2e2; color: #991b1b; }

.rec-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

.rec-5 { background: #fae8ff; color: #7c3aed; }
.rec-4 { background: #dbeafe; color: #1e40af; }
.rec-3 { background: #f3f4f6; color: #374151; }

/* =====================================================
   RULES SECTION
   ===================================================== */

/* ----- Rule Format Diagram ----- */
.rule-format-diagram {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: #1e1e2e;
    border-radius: 12px;
    padding: 12px;
    margin: 20px 0;
}

.rule-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 10px;
    min-width: 0;
    text-align: center;
}

.rule-part-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: none;
    opacity: 0.75;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.35;
    overflow-wrap: break-word;
    word-break: normal;
}

.rule-part-value {
    font-size: 14px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    line-height: 1.45;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-all;
}

.rule-part-type    { background: rgba(139,92,246,0.2); }
.rule-part-type .rule-part-value   { color: #c084fc; }
.rule-part-payload { background: rgba(16,185,129,0.2); }
.rule-part-payload .rule-part-value { color: #34d399; }
.rule-part-policy  { background: rgba(251,146,60,0.2); }
.rule-part-policy .rule-part-value  { color: #fb923c; }

.rule-part-policy .rule-part-value {
    font-family: inherit;
    word-break: normal;
}

.rule-comma {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 0;
    font-size: 20px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.35);
    font-family: 'Courier New', monospace;
    line-height: 1;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .rule-format-diagram {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: stretch;
        gap: 8px;
        padding: 20px 18px;
    }

    .rule-part {
        padding: 16px 14px;
        justify-content: center;
    }

    .rule-part-value {
        font-size: 15px;
    }

    .rule-comma {
        padding: 0;
        align-self: center;
        font-size: 24px;
    }
}

/* ----- Rule Type Grid ----- */
.rules-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.rule-type-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 18px;
    transition: box-shadow 0.2s;
}

.rule-type-card:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,0.06);
}

.rule-type-card-match {
    grid-column: 1 / -1;
    border-color: #f59e0b;
    background: #fffbeb;
}

.rule-type-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.rule-type-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    letter-spacing: 0.3px;
}

.rt-domain { background: #dbeafe; color: #1e40af; }
.rt-ip     { background: #d1fae5; color: #065f46; }
.rt-geo    { background: #fae8ff; color: #7c3aed; }
.rt-proc   { background: #fef3c7; color: #92400e; }
.rt-net    { background: #f3f4f6; color: #374151; }
.rt-set    { background: #fee2e2; color: #991b1b; }
.rt-match  { background: #fef3c7; color: #92400e; }

.rule-type-name {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    font-family: 'Courier New', monospace;
}

.rule-type-desc {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.55;
    margin-bottom: 10px;
    overflow-wrap: break-word;
    word-break: normal;
}

.rule-type-example code {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #a6e3a1;
    background: #1e1e2e;
    padding: 4px 10px;
    border-radius: 6px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

/* ----- Group Cards ----- */
.group-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 8px;
}

.group-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px;
    transition: box-shadow 0.2s;
    min-width: 0;
}

.group-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.06); }

.group-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: #fff;
    flex-shrink: 0;
}

.group-icon-select  { background: linear-gradient(135deg,#0052d9,#60a5fa); }
.group-icon-urltest { background: linear-gradient(135deg,#059669,#34d399); }
.group-icon-fallback{ background: linear-gradient(135deg,#d97706,#fbbf24); }
.group-icon-lb      { background: linear-gradient(135deg,#7c3aed,#c084fc); }
.group-icon-relay   { background: linear-gradient(135deg,#be185d,#f472b6); }

.group-card-body {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
}

.group-card-name {
    font-size: 14.5px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.group-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #374151;
}

.group-badge-auto    { background: #d1fae5; color: #065f46; }
.group-badge-fallback{ background: #fef3c7; color: #92400e; }
.group-badge-lb      { background: #fae8ff; color: #7c3aed; }
.group-badge-relay   { background: #fee2e2; color: #991b1b; }

.group-card-desc {
    font-size: 13.5px;
    color: #4b5563;
    line-height: 1.65;
    margin-bottom: 10px;
    overflow-wrap: break-word;
    word-break: normal;
}

.group-card-code code {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: #1e1e2e;
    color: #a6e3a1;
    padding: 3px 10px;
    border-radius: 5px;
}

/* =====================================================
   PROTOCOLS SECTION
   ===================================================== */

/* ----- Protocol Grid ----- */
.proto-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}

.proto-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.25s ease, transform 0.2s ease;
}

.proto-card:hover {
    box-shadow: 0 4px 18px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.proto-card-primary {
    border-color: #c7d2fe;
}

.proto-card-new {
    border-color: #a7f3d0;
    background: #f0fdf4;
}

.proto-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0052d9, #60a5fa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
}

.proto-card-primary .proto-icon { background: linear-gradient(135deg, #0052d9, #60a5fa); }
.proto-card-new     .proto-icon { background: linear-gradient(135deg, #059669, #34d399); }
.proto-card:not(.proto-card-primary):not(.proto-card-new) .proto-icon {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
}

.proto-name {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
}

.proto-abbr {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    letter-spacing: 0.3px;
    margin-top: -4px;
}

.proto-desc {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.6;
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
}

.proto-features {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

.proto-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    background: #f3f4f6;
    color: #374151;
    border-radius: 6px;
}

.proto-card-new .proto-tag {
    background: #d1fae5;
    color: #065f46;
}

.proto-card-primary .proto-tag {
    background: #eff6ff;
    color: #1e40af;
}

/* ----- Transport Grid ----- */
.transport-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.transport-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
}

.transport-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
    font-family: 'Courier New', monospace;
}

.transport-desc {
    font-size: 12.5px;
    color: #6b7280;
    line-height: 1.55;
    overflow-wrap: break-word;
    word-break: normal;
}

/* ----- Bottom CTA ----- */
.ref-bottom-cta {
    background: linear-gradient(135deg, #0a0a0a, #1e1e3a);
    border-radius: 20px;
    overflow: hidden;
    margin-top: 20px;
}

.ref-bottom-cta-inner {
    padding: 48px 40px;
    text-align: center;
}

.ref-bottom-cta h2 {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
}

.ref-bottom-cta p {
    font-size: 15px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 28px;
}

.ref-bottom-cta-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.ref-cta-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: #0052d9;
    color: #fff;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s ease;
}

.ref-cta-primary:hover {
    background: #0047c2;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,82,217,0.4);
    color: #fff;
}

.ref-cta-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s ease;
}

.ref-cta-secondary:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
    color: #fff;
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 1100px) {
    .ref-sidebar {
        width: 220px;
    }
}

@media (max-width: 900px) {
    .ref-layout {
        flex-direction: column;
        padding: 0 16px;
    }

    .ref-sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-top: 1px solid #e5e7eb;
        padding: 20px 0 0;
        overflow: visible;
    }

    .ref-sidebar-inner {
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        padding-right: 0;
        padding-bottom: 20px;
    }

    .ref-sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .ref-nav-group {
        display: contents;
    }

    .ref-nav-item-h2 {
        font-size: 13px;
    }

    .ref-nav-item-h3 {
        display: none;
    }

    .ref-content {
        padding: 32px 0 60px;
    }

    .ref-sidebar-cta {
        flex-direction: row;
    }
}

@media (max-width: 768px) {
    .ref-hero-title { font-size: 30px; }
    .ref-hero-desc  { font-size: 14px; }

    .ref-section-header { gap: 14px; }
    .ref-section-header h2 { font-size: 22px; }

    .arch-component,
    .group-card {
        padding: 14px;
        gap: 12px;
    }

    .arch-comp-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .mode-cards { grid-template-columns: 1fr; }
    .dns-modes  { grid-template-columns: 1fr; }

    .rules-type-grid { grid-template-columns: 1fr; }
    .rule-type-card-match { grid-column: auto; }

    .rule-type-example code {
        white-space: pre-wrap;
        word-break: break-all;
    }

    .proto-grid { grid-template-columns: repeat(2, 1fr); }
    .transport-grid { grid-template-columns: repeat(2, 1fr); }

    .ref-bottom-cta-inner { padding: 36px 24px; }
    .ref-bottom-cta h2 { font-size: 20px; }

    .compare-table-wrap-stacked {
        overflow-x: visible;
        border: none;
        background: transparent;
    }

    .ref-table-compare {
        table-layout: auto;
    }

    .ref-table-compare thead { display: none; }

    .ref-table-compare tbody tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        overflow: hidden;
        background: #fff;
    }

    .ref-table-compare tbody tr:last-child { margin-bottom: 0; }
    .ref-table-compare tbody tr:hover td { background: transparent; }

    .ref-table-compare td {
        display: block;
        width: auto !important;
        padding: 10px 16px;
        border-top: none;
    }

    .ref-table-compare td + td {
        border-top: 1px solid #f3f4f6;
    }

    .ref-table-compare td:first-child {
        background: #f9fafb;
        font-size: 13.5px;
        padding: 14px 16px 10px;
    }

    .ref-table-compare td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 700;
        color: #9ca3af;
        letter-spacing: 0.3px;
        margin-bottom: 4px;
        line-height: 1.45;
        white-space: normal;
        text-transform: none;
    }
}

@media (max-width: 520px) {
    .ref-hero-title { font-size: 26px; }

    .ref-section-header {
        flex-direction: column;
        gap: 12px;
    }

    .ref-section-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
        margin-top: 0;
    }

    .proto-grid { grid-template-columns: 1fr; }
    .transport-grid { grid-template-columns: 1fr; }

    .ref-bottom-cta-btns { flex-direction: column; align-items: center; }

    .code-body {
        padding: 16px;
    }
}
