/* =========================================================
   الأدوات المجانية والمقالات
   ========================================================= */
.tool-hero { --c: var(--indigo); }
.crumbs-hero { padding: 0 0 14px; }
.tool-privacy { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(46, 230, 197, .3); background: rgba(46, 230, 197, .06); color: var(--mint) !important; font-size: .88rem !important; }
.tool-privacy .ic { width: 16px; height: 16px; }
.tool-wrap { padding-bottom: 40px; }

/* بطاقات صفحة الأدوات */
.tool-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin-bottom: 48px; }
.tool-card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: border-color .2s, transform .2s; }
.tool-card::before { content: ''; position: absolute; width: 220px; height: 220px; border-radius: 50%; filter: blur(70px); opacity: .25; inset: -90px -60px auto auto; background: var(--c); pointer-events: none; }
.tool-card:hover { border-color: rgba(46, 230, 197, .45); transform: translateY(-3px); }
.tc-studio { --c: var(--pink); } .tc-subnet { --c: var(--mint); } .tc-qr { --c: var(--indigo); }
.tc-ic { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line2); color: var(--c); }
.tc-ic .ic { width: 28px; height: 28px; }
.tc-body { display: flex; flex-direction: column; gap: 4px; }
.tc-body b { font-size: 1.15rem; }
.tc-body small { color: var(--c); font-weight: 600; direction: rtl; }
.tc-body span { color: var(--muted); font-size: .94rem; }
.tc-go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--mint); font-weight: 600; font-size: .92rem; }
.tc-go .ic { width: 16px; height: 16px; }

/* التبويبات */
.seg { display: flex; gap: 6px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: .92rem; padding: 9px 16px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--bg); }
.seg-wrap { flex-wrap: wrap; overflow: visible; }
.panel .seg { background: var(--bg2); }

.tool-form { display: grid; gap: 0 16px; }
.row-ip { grid-template-columns: 1.4fr 1fr; }
.form-end { display: flex; align-items: flex-end; padding-bottom: 16px; }
.form-end .btn { width: 100%; }
@media (max-width: 640px) { .row-ip { grid-template-columns: 1fr; } }
input[dir=ltr] { text-align: left; }

/* نتائج */
.res-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 14px; }
.res-tag { padding: 5px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600; background: var(--surface2); border: 1px solid var(--line2); }
.tag-private { color: var(--mint); border-color: rgba(46, 230, 197, .4); }
.tag-public { color: #59b8ff; border-color: rgba(89, 184, 255, .4); }
.tag-loopback, .tag-linklocal, .tag-shared, .tag-doc, .tag-reserved, .tag-broadcast, .tag-multicast { color: var(--amber); border-color: rgba(255, 181, 71, .4); }
.res-cidr { margin-inline-start: auto; font-size: 1.3rem; font-weight: 600; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 18px; }
.res-cell { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg2); border: 1px solid var(--line); min-width: 0; }
.res-cell.wide { grid-column: span 2; }
@media (max-width: 560px) { .res-cell.wide { grid-column: auto; } }
.res-cell.accent { border-color: rgba(46, 230, 197, .35); background: linear-gradient(180deg, rgba(46, 230, 197, .06), transparent); }
.res-k { color: var(--muted); font-size: .82rem; }
.res-v { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 1.05rem; font-weight: 600; word-break: break-all; }
.res-note { color: var(--dim); font-size: .76rem; }
.copy-btn { flex: none; border: 1px solid var(--line2); background: none; color: var(--muted); font: inherit; font-size: .74rem; padding: 2px 8px; border-radius: 7px; cursor: pointer; }
.copy-btn:hover { color: var(--mint); border-color: var(--mint); }
.note-warn, .note-ok { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 10px; font-size: .92rem; }
.note-warn { background: rgba(255, 181, 71, .08); border: 1px solid rgba(255, 181, 71, .3); color: #ffd99a; }
.note-ok { background: rgba(52, 211, 153, .08); border: 1px solid rgba(52, 211, 153, .3); color: #9ff0cd; }
.panel h3 { font-size: 1rem; margin: 22px 0 10px; }

/* العرض الثنائي */
.bits-box { padding: 14px; border-radius: var(--radius-sm); background: var(--bg2); border: 1px solid var(--line); overflow-x: auto; }
.bits-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.bits-legend i { font-style: normal; display: inline-block; padding: 0 5px; border-radius: 4px; margin-inline-end: 4px; font-family: var(--mono); }
.bits-row { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 10px; padding: 3px 0; }
.bits-k { color: var(--muted); font-size: .82rem; }
.bits { font-family: var(--mono); font-size: .92rem; letter-spacing: .5px; white-space: nowrap; }
.bits i { font-style: normal; }
.nb { color: var(--mint); background: rgba(46, 230, 197, .1); }
.hb { color: #b7b3ff; background: rgba(111, 107, 255, .12); }
.bits .dot { color: var(--dim); background: none; padding: 0 2px; }

.code-box { position: relative; }
.code-box pre, .qr-payload-box pre { margin: 0; padding: 14px 16px; border-radius: var(--radius-sm); background: #050810; border: 1px solid var(--line); color: #c9f7ec; font-family: var(--mono); font-size: .86rem; overflow-x: auto; white-space: pre; }
.code-box .copy-btn { position: absolute; top: 10px; inset-inline-start: 10px; background: var(--surface); }

/* الجداول */
.tbl-scroll { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); margin: 10px 0; }
.wide-tbl { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
.wide-tbl th, .wide-tbl td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.wide-tbl th { background: var(--surface2); color: var(--muted); font-weight: 600; font-size: .82rem; position: sticky; top: 0; }
.wide-tbl tr:hover td { background: rgba(255, 255, 255, .02); }
.ref-tbl tr.oct td { background: rgba(46, 230, 197, .05); }
.ref-tbl tr.oct td:first-child { color: var(--mint); font-weight: 600; }
.tbl-actions { display: flex; justify-content: flex-end; margin-top: 6px; }

/* VLSM */
.v-head, .v-row { display: grid; grid-template-columns: 1.5fr 1fr 40px; gap: 10px; align-items: center; }
.v-head { color: var(--muted); font-size: .82rem; margin-bottom: 4px; }
.v-row input { margin: 0 0 8px; }
.icon-btn { width: 40px; height: 44px; margin-bottom: 8px; border-radius: 10px; border: 1px solid var(--line2); background: none; color: var(--muted); cursor: pointer; font: inherit; }
.icon-btn:hover { color: var(--danger); border-color: var(--danger); }
.v-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 10px 0 18px; }
.v-actions .check { margin: 0; }
.v-actions .btn-glow { margin-inline-start: auto; }
.usage-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); margin: 4px 0 8px; }
.usage-bar span { height: 100%; }
.seg-0 { background: #2ee6c5; } .seg-1 { background: #59b8ff; } .seg-2 { background: #6f6bff; } .seg-3 { background: #ff7ac6; } .seg-4 { background: #ffb547; } .seg-5 { background: #34d399; }
.tool-guide { margin-top: 18px; }
.tool-guide li { margin-bottom: 6px; }

/* مولد QR */
.qr-layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
.qr-layout .panel + .panel { margin-top: 0; }
@media (max-width: 900px) { .qr-layout { grid-template-columns: 1fr; } }
.qr-preview { position: sticky; top: 88px; text-align: center; }
@media (max-width: 900px) { .qr-preview { position: static; } }
.qr-stage { position: relative; width: min(340px, 100%); aspect-ratio: 1; margin: 0 auto 12px; border-radius: 18px; padding: 0; background:
  repeating-conic-gradient(rgba(255, 255, 255, .05) 0% 25%, transparent 0% 50%) 50% / 20px 20px; border: 1px solid var(--line); overflow: hidden; }
.qr-stage canvas { width: 100%; height: 100%; display: block; }
.qr-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-size: .92rem; padding: 20px; }
.qr-meta { color: var(--dim); font-size: .8rem; min-height: 1.2em; }
.qr-check { font-size: .86rem; font-weight: 600; min-height: 1.2em; margin: 4px 0 10px; }
.qr-check.ok { color: var(--ok); } .qr-check.bad { color: var(--amber); }
.qr-dl { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0 14px; }
.qr-payload-box { text-align: start; margin-bottom: 12px; }
.qr-payload-box summary, .qr-opts summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: .9rem; padding: 6px 0; }
.qr-payload-box pre { white-space: pre-wrap; word-break: break-all; margin-top: 8px; }
.qr-opts { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.qr-opts input[type=color] { height: 46px; padding: 4px; cursor: pointer; }
.qr-safe { text-align: start; padding-inline-start: 18px; margin: 0; }
.qr-safe li { margin-bottom: 4px; }
.check-mid { align-self: center; margin-top: 14px; }
#main [data-qr] .alert, #main [data-qr] .note-warn { text-align: start; }

/* استوديو التصاميم */
.studio-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.studio-layout .panel + .panel { margin-top: 0; }
@media (max-width: 960px) { .studio-layout { grid-template-columns: 1fr; } }
.studio-preview { position: sticky; top: 88px; text-align: center; }
@media (max-width: 960px) { .studio-preview { position: static; order: -1; } }
.st-stage { display: grid; place-items: center; padding: 12px; border-radius: 16px; background: repeating-conic-gradient(rgba(255, 255, 255, .04) 0% 25%, transparent 0% 50%) 50% / 22px 22px; border: 1px solid var(--line); }
.st-stage canvas { max-width: 100%; max-height: 68vh; width: auto; height: auto; border-radius: 6px; box-shadow: 0 18px 50px -18px rgba(0, 0, 0, .8); background: #fff; }
@media (max-width: 960px) { .st-stage canvas { max-height: 56vh; } }
.st-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.st-scale { display: inline-flex; align-items: center; gap: 10px; margin: 14px 0 6px; font-size: .9rem; }
.st-scale select { width: auto; margin: 0; padding: 8px 34px 8px 12px; }
.st-dl { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.st-dl .btn { min-width: 84px; }
.btn.loading { opacity: .6; pointer-events: none; }
.st-note { margin: 12px 0 0; }
.st-sec { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.st-sec > summary { cursor: pointer; font-weight: 700; padding: 4px 0 12px; list-style-position: inside; }
.st-sec > summary small { font-weight: 400; margin-inline-start: 6px; }
.st-chips { margin-bottom: 12px; }
.st-chips .chip { cursor: pointer; background: none; font: inherit; font-size: .84rem; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; max-height: 470px; overflow-y: auto; padding: 4px; margin: 0 -4px 10px; overscroll-behavior: contain; }
.tpl { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 12px; border: 2px solid transparent; background: var(--bg2); cursor: pointer; color: var(--muted); font: inherit; font-size: .72rem; line-height: 1.35; text-align: center; }
.tpl canvas { width: 100%; height: auto; border-radius: 6px; background: var(--surface2); }
.tpl:hover { border-color: var(--line2); color: var(--ink); }
.tpl.on { border-color: var(--mint); color: var(--ink); box-shadow: 0 0 0 4px rgba(46, 230, 197, .12); }
.x-sub { padding: 2px 0 6px 0; padding-inline-start: 30px; }
.field-help { margin: -8px 0 16px; }
.studio-controls textarea { min-height: 80px; }
.studio-controls input[type=color] { height: 46px; padding: 4px; cursor: pointer; }
.st-chips .chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
