/* ─────────────────────────────────────────
   CSS VARIABLES — matches IPv4 tool palette
───────────────────────────────────────── */
:root {
    --brand:          #4eb39a;
    --brand-dark:     #3a9b83;
    --brand-deep:     #0e2d27;
    --accent-light:   #e1f5ee;
    --accent-mid:     #b3e6d8;
    --text:           #1a2e2b;
    --text-muted:     #5f7a74;
    --text-subtle:    #94aaa6;
    --border-light:   rgba(78,179,154,0.15);
    --border-mid:     rgba(78,179,154,0.25);
    --border-strong:  rgba(78,179,154,0.4);
    --green:          #16a34a;
    --green-d:        rgba(22,163,74,0.08);
    --green-b:        rgba(22,163,74,0.22);
    --blue:           #2563eb;
    --blue-d:         rgba(37,99,235,0.08);
    --yellow:         #d97706;
    --yellow-d:       rgba(217,119,6,0.08);
    --red:            #dc2626;
    --red-d:          rgba(220,38,38,0.08);
    --purple:         #7c3aed;
    --purple-d:       rgba(124,58,237,0.08);
    --text0:          #1a2e2b;
    --text1:          #0e2d27;
    --text2:          #5f7a74;
    --text3:          #94aaa6;
    --bg0:            #f5f9f8;
    --bg1:            #ffffff;
    --bg2:            #f5f9f8;
    --bg3:            #eaf4f1;
    --bg4:            #e1f0ec;
    --border:         rgba(78,179,154,0.15);
    --border2:        rgba(78,179,154,0.3);
    --syne:           'DM Sans', sans-serif;
    --mono:           'DM Mono', monospace;
    --teal:           #0d9488;
}

.ipc-page {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: #f5f9f8;
    min-height: 100vh;
    color: var(--text);
}

/* ── HERO ── */
.ipc-hero {
    background: linear-gradient(145deg, #0e2d27 0%, #1a4a3d 60%, #0e3530 100%);
    border-bottom: 1px solid rgba(78,179,154,0.2);
    padding: 2.5rem 2rem 2rem;
    position: relative;
    overflow: hidden;
}
.ipc-hero::before {
    content: '';
    position: absolute;
    top: -60px; left: 50%;
    transform: translateX(-50%);
    width: 600px; height: 320px;
    background: radial-gradient(ellipse, rgba(78,179,154,0.1) 0%, transparent 70%);
    pointer-events: none;
}
.ipc-hero-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2.5rem;
    align-items: center;
    position: relative;
    z-index: 1;
}
.ipc-eyebrow {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    font-weight: 500;
    color: rgba(111,209,179,0.7);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 0.55rem;
    display: flex;
    align-items: center;
    gap: 7px;
}
.ipc-eyebrow::before { content: '//'; opacity: 0.5; }
.ipc-hero h1, .ipc-hero h2 {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}
.ipc-hero h1 em, .ipc-hero h2 em { font-style: normal; color: #6fd1b3; }
.ipc-hero > .ipc-hero-inner > div > p {
    font-size: 0.875rem;
    color: rgba(255,255,255,0.55);
    line-height: 1.8;
    max-width: 480px;
}
.ipc-feat-list { display: flex; flex-direction: column; gap: 4px; margin-top: 0.9rem; }
.ipc-feat {
    display: flex; align-items: center; gap: 7px;
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.45);
}
.ipc-feat::before { content: '▸'; color: #6fd1b3; font-size: 8px; }

/* Hero stat panel */
.ipc-stat-panel {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(78,179,154,0.25);
    border-radius: 10px;
    padding: 1.1rem 1.2rem;
    display: none;
}
.ipc-stat-panel.show { display: block; }
.isp-title {
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    color: rgba(111,209,179,0.6);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.65rem;
}
.isp-rows { display: flex; flex-direction: column; gap: 4px; }
.isp-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.isp-row:last-child { border-bottom: none; }
.isp-k { font-family: 'DM Mono', monospace; font-size: 0.7rem; color: rgba(255,255,255,0.4); }
.isp-v { font-family: 'DM Mono', monospace; font-size: 0.75rem; font-weight: 500; color: #fff; }
.isp-v.green  { color: #6fd1b3; }
.isp-v.blue   { color: #7eb8f4; }
.isp-v.yellow { color: #f9cb42; }
.isp-v.red    { color: #f87171; }

/* ── MAIN ── */
.ipc-main { max-width: 1200px; margin: 0 auto; padding: 1.75rem 2rem; }

.sec-title {
    display: flex; align-items: center; gap: 8px;
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem; font-weight: 600;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 0.75rem;
}
.sec-title::after { content: ''; flex: 1; height: 1px; background: rgba(78,179,154,0.15); }

/* ── INPUT CARD ── */
.input-card {
    background: #fff;
    border: 1px solid rgba(78,179,154,0.18);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.input-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.ic-head {
    background: #f5f9f8;
    padding: 0.8rem 1.4rem;
    border-bottom: 1px solid rgba(78,179,154,0.12);
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.ic-title {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.82rem; font-weight: 700; color: #0e2d27;
}
.ic-title svg { width: 14px; height: 14px; stroke: #3a9b83; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-body { padding: 1.25rem 1.4rem; }

.input-grid-v6 {
    display: grid;
    grid-template-columns: 1fr 160px auto;
    gap: 10px;
    margin-bottom: 1rem;
    align-items: end;
}
.input-group { display: flex; flex-direction: column; gap: 5px; }
.input-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem; color: var(--text-muted);
    letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600;
}
.ip-input {
    background: #f5f9f8;
    border: 1px solid rgba(78,179,154,0.25);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: 'DM Mono', monospace;
    font-size: 0.95rem; font-weight: 500; color: #0e2d27;
    outline: none; width: 100%;
    letter-spacing: 0.04em;
    transition: border-color 0.2s, background 0.2s;
}
.ip-input::placeholder { color: #94aaa6; font-size: 0.85rem; font-weight: 400; }
.ip-input:focus { border-color: #4eb39a; background: #fff; }
.ip-input.err { border-color: rgba(220,38,38,0.5); color: #dc2626; background: rgba(220,38,38,0.04); }

.btn-calc {
    background: #4eb39a; border: none; border-radius: 9px;
    padding: 10px 22px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem; font-weight: 700; color: #0e2d27;
    cursor: pointer;
    transition: background 0.15s, transform 0.14s;
    display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn-calc:hover { background: #3a9b83; transform: translateY(-1px); }
.btn-calc:active { transform: scale(0.98); }
.btn-calc svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; }

.preset-row {
    display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 0.75rem;
}
.preset-lbl {
    font-family: 'DM Mono', monospace; font-size: 0.65rem;
    color: var(--text-subtle); letter-spacing: 0.06em; font-weight: 600; text-transform: uppercase;
}
.preset-btn {
    font-family: 'DM Mono', monospace; font-size: 0.7rem;
    padding: 4px 10px; border-radius: 5px;
    border: 1px solid rgba(78,179,154,0.2);
    background: #f5f9f8; color: var(--text-muted);
    cursor: pointer; transition: all 0.15s;
}
.preset-btn:hover { border-color: #4eb39a; color: #3a9b83; background: #e1f5ee; }

.err-msg {
    font-family: 'DM Mono', monospace; font-size: 0.75rem;
    color: #dc2626; margin-top: 0.4rem; display: none;
}
.err-msg.show { display: block; }

/* ── RESULTS ── */
#ipc-results { display: none; }

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    margin-bottom: 1.5rem;
}
.res-card {
    background: #fff;
    border: 1px solid rgba(78,179,154,0.18);
    border-top: 2.5px solid var(--rc-accent, #4eb39a);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    position: relative; overflow: hidden;
    transition: box-shadow 0.15s;
}
.res-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.07); }
.rc-lbl {
    font-family: 'DM Mono', monospace; font-size: 0.6rem;
    color: var(--text-muted); letter-spacing: 0.07em;
    text-transform: uppercase; margin-bottom: 0.3rem; font-weight: 600;
}
.rc-val {
    font-family: 'DM Mono', monospace; font-size: 0.82rem; font-weight: 500;
    color: #0e2d27; line-height: 1.35; word-break: break-all;
}
.rc-sub {
    font-family: 'DM Mono', monospace; font-size: 0.65rem;
    color: var(--text-subtle); margin-top: 2px;
}
.copy-btn {
    position: absolute; top: 0.5rem; right: 0.5rem;
    background: #e1f5ee; border: 1px solid rgba(78,179,154,0.25);
    border-radius: 4px; padding: 2px 7px;
    font-family: 'DM Mono', monospace; font-size: 0.6rem;
    color: var(--text-muted); cursor: pointer; transition: all 0.15s; opacity: 0;
}
.res-card:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: #4eb39a; border-color: #4eb39a; color: #fff; }
.copy-btn.copied { color: #3a9b83; border-color: #4eb39a; background: #e1f5ee; }

/* ── IPv6 BINARY VISUALIZER (128-bit) ── */
.binary-card {
    background: #fff;
    border: 1px solid rgba(78,179,154,0.18);
    border-radius: 12px;
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.binary-row {
    display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.binary-row:last-child { margin-bottom: 0; }
.bin-lbl {
    font-family: 'DM Mono', monospace; font-size: 0.62rem;
    color: var(--text-muted); width: 65px; flex-shrink: 0;
    letter-spacing: 0.05em; text-transform: uppercase; font-weight: 600;
}
/* 128-bit — smaller bits */
.bit-row-128 { display: flex; gap: 1px; flex-wrap: nowrap; }
.bit-g { display: flex; gap: 1px; }
.bit-gsep { width: 4px; flex-shrink: 0; }
.bit-v6 {
    width: 13px; height: 20px; border-radius: 2px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'DM Mono', monospace; font-size: 0.55rem; font-weight: 500;
    flex-shrink: 0;
}
.bit-1-net  { background: rgba(78,179,154,0.18); color: #0e2d27;  border: 1px solid rgba(78,179,154,0.4); }
.bit-0-net  { background: #f5f9f8;                color: #94aaa6;  border: 1px solid rgba(78,179,154,0.12); }
.bit-1-host { background: rgba(37,99,235,0.10);  color: #1e40af;  border: 1px solid rgba(37,99,235,0.25); }
.bit-0-host { background: #f5f9f8;                color: #b3c8c4;  border: 1px solid rgba(78,179,154,0.08); }
.bit-legend { display: flex; gap: 14px; margin-top: 0.75rem; flex-wrap: wrap; }
.bleg { display: flex; align-items: center; gap: 5px; font-family: 'DM Mono', monospace; font-size: 0.65rem; color: var(--text-muted); }
.bleg-dot { width: 10px; height: 10px; border-radius: 2px; }
.prefix-label {
    font-family: 'DM Mono', monospace; font-size: 0.68rem;
    color: var(--text-muted); margin-top: 0.5rem;
    border-top: 1px solid rgba(78,179,154,0.1); padding-top: 0.5rem;
}

/* ── TYPE / SCOPE BADGE ── */
.type-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 5px;
    font-family: 'DM Mono', monospace; font-size: 0.72rem; font-weight: 600;
    border: 1px solid; letter-spacing: 0.04em; text-transform: uppercase;
}
.tb-private   { color: #16a34a; border-color: rgba(22,163,74,0.3);    background: rgba(22,163,74,0.08); }
.tb-public    { color: #2563eb; border-color: rgba(37,99,235,0.3);    background: rgba(37,99,235,0.08); }
.tb-loopback  { color: #7c3aed; border-color: rgba(124,58,237,0.3);   background: rgba(124,58,237,0.08); }
.tb-multicast { color: #d97706; border-color: rgba(217,119,6,0.3);    background: rgba(217,119,6,0.08); }
.tb-linklocal { color: #0891b2; border-color: rgba(8,145,178,0.3);    background: rgba(8,145,178,0.08); }
.tb-reserved  { color: #dc2626; border-color: rgba(220,38,38,0.3);    background: rgba(220,38,38,0.08); }
.tb-anycast   { color: #7c3aed; border-color: rgba(124,58,237,0.3);   background: rgba(124,58,237,0.08); }
.tb-unique    { color: #16a34a; border-color: rgba(22,163,74,0.3);    background: rgba(22,163,74,0.08); }

/* ── CLASS / TYPE CARD ── */
.class-card {
    background: #fff;
    border: 1px solid rgba(78,179,154,0.18);
    border-radius: 10px;
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.5rem;
}
.class-badge { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 0.65rem; }
.class-letter {
    font-family: 'DM Sans', sans-serif; font-size: 1.5rem; font-weight: 800;
    color: #3a9b83; line-height: 1;
}
.class-name { font-family: 'DM Mono', monospace; font-size: 0.72rem; color: var(--text-muted); }
.class-rows {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 4px;
}
.class-row {
    display: flex; justify-content: space-between;
    padding: 4px 0; border-bottom: 1px solid rgba(78,179,154,0.07);
}
.class-row:last-child { border-bottom: none; }
.cr-k { font-family: 'DM Mono', monospace; font-size: 0.7rem; color: var(--text-muted); }
.cr-v { font-family: 'DM Mono', monospace; font-size: 0.72rem; color: #0e2d27; font-weight: 500; }

/* ── SPLIT SUBNETS ── */
.split-card {
    background: #fff;
    border: 1px solid rgba(78,179,154,0.18);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.split-head {
    background: #f5f9f8;
    padding: 0.75rem 1.2rem;
    border-bottom: 1px solid rgba(78,179,154,0.12);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.5rem;
}
.split-head-title {
    font-family: 'DM Mono', monospace; font-size: 0.68rem; font-weight: 600;
    color: #0e2d27; letter-spacing: 0.08em; text-transform: uppercase;
}
.split-controls { display: flex; gap: 8px; align-items: center; }
.split-select {
    background: #fff; border: 1px solid rgba(78,179,154,0.25);
    border-radius: 6px; padding: 5px 10px;
    font-family: 'DM Mono', monospace; font-size: 0.75rem; color: #0e2d27;
    outline: none; cursor: pointer; transition: border-color 0.15s;
}
.split-select:focus { border-color: #4eb39a; }
.split-table-wrap { overflow-x: auto; max-height: 320px; overflow-y: auto; }
.split-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.split-table th {
    padding: 0.45rem 0.9rem; text-align: left;
    font-family: 'DM Mono', monospace; font-size: 0.62rem; font-weight: 600;
    letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted);
    background: #eaf4f1; border-bottom: 1px solid rgba(78,179,154,0.15);
    position: sticky; top: 0; z-index: 1;
}
.split-table td {
    padding: 0.4rem 0.9rem;
    font-family: 'DM Mono', monospace; font-size: 0.72rem; color: #1a2e2b;
    border-bottom: 1px solid rgba(78,179,154,0.06);
}
.split-table tr:hover td { background: rgba(78,179,154,0.04); }
.split-table tr:last-child td { border-bottom: none; }
.sn-idx { color: #94aaa6; font-size: 0.68rem; }
.sn-net { color: #3a9b83; font-weight: 600; }

/* ── REFERENCE TABLES ── */
.ref-table-wrap {
    background: #fff;
    border: 1px solid rgba(78,179,154,0.18);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0;
}
.ref-table { width: 100%; border-collapse: collapse; }
.ref-table th {
    padding: 0.45rem 0.9rem; text-align: left;
    font-family: 'DM Mono', monospace; font-size: 0.62rem; font-weight: 600;
    letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted);
    background: #f5f9f8; border-bottom: 1px solid rgba(78,179,154,0.12);
}
.ref-table td {
    padding: 0.4rem 0.9rem;
    font-family: 'DM Mono', monospace; font-size: 0.72rem; color: #1a2e2b;
    border-bottom: 1px solid rgba(78,179,154,0.06);
}
.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:hover td { background: rgba(78,179,154,0.03); }

/* ── TWO / THREE COL ── */
.two-col {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 12px; margin-bottom: 1.5rem;
}

/* ── SEO / FAQ ── */
.seo-block {
    background: #fff;
    border: 1px solid rgba(78,179,154,0.18);
    border-radius: 10px;
    padding: 1.75rem 2rem;
    margin-top: 2rem;
}
.seo-block h2 { font-size: 1.15rem; font-weight: 700; color: #0e2d27; margin-bottom: 0.5rem; }
.seo-block > p { font-size: 0.875rem; color: var(--text-muted); line-height: 1.8; }
.faq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 10px; margin-top: 1.25rem;
}
.faq-card {
    background: #f5f9f8;
    border: 1px solid rgba(78,179,154,0.15);
    border-radius: 10px;
    padding: 1rem 1.1rem;
}
.faq-q { font-size: 0.875rem; font-weight: 600; color: #0e2d27; margin-bottom: 0.3rem; }
.faq-a { font-size: 0.82rem; color: var(--text-muted); line-height: 1.7; }

/* ── TOAST ── */
.ipc-toast {
    position: fixed; bottom: 1.75rem; right: 1.75rem;
    background: #0e2d27; border: 1px solid rgba(78,179,154,0.35);
    border-radius: 7px; padding: 0.55rem 1rem;
    font-family: 'DM Mono', monospace; font-size: 0.75rem; color: #6fd1b3;
    z-index: 999; transform: translateY(50px); opacity: 0;
    transition: all 0.25s; pointer-events: none;
}
.ipc-toast.show { transform: translateY(0); opacity: 1; }

/* ── GROUP HIGHLIGHT (nybble groups) ── */
.grp-highlight { animation: grpPop 0.35s ease; }
@keyframes grpPop { 0%{transform:scaleY(0.8);opacity:0.5} 100%{transform:scaleY(1);opacity:1} }

@media (max-width: 768px) {
    .ipc-hero-inner { grid-template-columns: 1fr; }
    .ipc-main { padding: 1rem; }
    .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .input-grid-v6 { grid-template-columns: 1fr; }
    .ipc-hero { padding: 2rem 1.25rem 1.75rem; }
    .seo-block { padding: 1.25rem; }
}
