/* =========================================================
   CodeCaps Converter — الهوية البصرية v3
   الفكرة: كبسولة CodeCaps هي "ممر التحويل"؛ الصيغة الأصلية بحدّ،
   والصيغة الناتجة مملوءة بالأخضر. كل أداة تُعرَّف بزوج صيغها.
   ========================================================= */

:root {
    --bg: #F3F7F4;
    --surface: #FFFFFF;
    --ink: #0E1F1A;
    --muted: #5B6B64;
    --line: #D9E4DE;
    --line-strong: #B9CBC1;
    --brand: #00A651;
    --brand-ink: #007A3D;
    --brand-soft: #E3F5EA;
    --on-brand: #FFFFFF;
    --danger: #B42318;
    --danger-soft: #FDECEA;
    --warn: #7A4E00;
    --warn-soft: #FFF4D6;
    --r-lg: 20px;
    --r: 12px;
    --r-sm: 8px;
    --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
    --shadow: 0 1px 2px rgba(14, 31, 26, .05), 0 8px 24px -12px rgba(14, 31, 26, .12);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0C1512;
        --surface: #13201B;
        --ink: #E7F0EB;
        --muted: #93A69D;
        --line: #22342C;
        --line-strong: #345044;
        --brand: #2FD47A;
        --brand-ink: #5FE39A;
        --brand-soft: #173828;
        --on-brand: #06140D;
        --danger: #FF8A80;
        --danger-soft: #3A1715;
        --warn: #F5C66B;
        --warn-soft: #33280F;
        --shadow: none;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
        --bg: #0C1512;
        --surface: #13201B;
        --ink: #E7F0EB;
        --muted: #93A69D;
        --line: #22342C;
        --line-strong: #345044;
        --brand: #2FD47A;
        --brand-ink: #5FE39A;
        --brand-soft: #173828;
        --on-brand: #06140D;
        --danger: #FF8A80;
        --danger-soft: #3A1715;
        --warn: #F5C66B;
        --warn-soft: #33280F;
        --shadow: none;
        color-scheme: dark;
    }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); }
button, input, select, textarea { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- الهيدر ---------- */
.site-header {
    max-width: 1120px; margin: 0 auto; padding: 1.1rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.logo { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); }
.logo svg { flex: none; }
.logo-word { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.logo-word span { color: var(--muted); font-weight: 500; }
.site-nav { display: flex; gap: 1.4rem; font-size: 0.9rem; }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.site-nav a:hover { color: var(--ink); }

.page { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem 4rem; }

/* ---------- رقائق الصيغ: الهوية الأساسية ---------- */
.pair { display: inline-flex; align-items: center; gap: 0.35rem; direction: rtl; flex: none; }
.fmt {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2.6em; padding: 0.05em 0.45em;
    border: 1.5px solid var(--ink); border-radius: 6px;
    font-size: 0.72rem; font-weight: 700; line-height: 1.6; letter-spacing: 0.02em;
    direction: ltr; background: var(--surface);
}
.fmt.to { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.pair .arrow { color: var(--muted); font-size: 0.85rem; line-height: 1; }
.pair-lg .fmt { font-size: 0.95rem; border-width: 2px; border-radius: 8px; padding: 0.15em 0.6em; }
.pair-lg .arrow { font-size: 1.1rem; }

/* ---------- البطل ---------- */
.hero {
    display: grid; grid-template-columns: 1.15fr 1fr; gap: 3rem; align-items: center;
    padding: 3.5rem 0 3rem;
}
.hero h1 {
    font-size: clamp(2rem, 4.6vw, 3.2rem); line-height: 1.25; font-weight: 700; letter-spacing: -0.015em;
    max-width: 14ch;
}
.hero-sub { color: var(--muted); font-size: 1.08rem; margin-top: 1rem; max-width: 46ch; }
.hero .quota-bar { margin-top: 1.75rem; max-width: 420px; }

/* الكبسولة: ممر التحويل (العنصر المميز الوحيد المتحرك) */
.capsule-stage { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.capsule {
    position: relative; width: min(100%, 420px); aspect-ratio: 2.1 / 1;
    border: 3px solid var(--ink); border-radius: 999px; background: var(--surface);
    display: flex; align-items: center; justify-content: space-between; padding: 0 9%;
    direction: rtl; box-shadow: var(--shadow);
}
.capsule .fmt { font-size: clamp(1rem, 2.6vw, 1.4rem); padding: 0.2em 0.6em; border-width: 2.5px; border-radius: 10px; min-width: 3.4em; }
.capsule-track { flex: 1; display: flex; justify-content: center; gap: 9%; direction: rtl; }
.capsule-track i { width: 11px; height: 11px; border-radius: 50%; background: var(--brand); opacity: .25; }
.capsule-caption { color: var(--muted); font-size: 0.85rem; }
@media (prefers-reduced-motion: no-preference) {
    .capsule-track i { animation: flow 1.2s infinite; }
    .capsule-track i:nth-child(2) { animation-delay: .2s; }
    .capsule-track i:nth-child(3) { animation-delay: .4s; }
    .capsule .fmt { transition: opacity .25s ease; }
    .capsule.swap .fmt { opacity: 0; }
}
@keyframes flow { 0%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- قائمة الأدوات ---------- */
.tools-section { margin-top: 1rem; }
.section-title { font-size: 1.35rem; font-weight: 700; margin: 2.5rem 0 1rem; letter-spacing: -0.01em; }
.tool-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0.4rem 0 0; margin-bottom: 1.25rem; overflow: hidden; }
.tool-rows { display: grid; grid-template-columns: 1fr 1fr; }
.tool-group h3 { font-size: 0.9rem; font-weight: 600; color: var(--muted); padding: 0.75rem 1.25rem 0.25rem; }
.tool-row {
    display: grid; grid-template-columns: 8.2rem 1fr auto; align-items: center; gap: 1rem;
    padding: 0.85rem 1.25rem; text-decoration: none; color: inherit; border-top: 1px solid var(--line);
}
.tool-rows .tool-row:nth-child(odd) { border-inline-end: 1px solid var(--line); }
.tool-rows .tool-row:last-child:nth-child(odd) { grid-column: 1 / -1; border-inline-end: 0; }
.tool-row:hover { background: var(--brand-soft); }
.tool-row strong { display: block; font-weight: 600; font-size: 0.98rem; }
.tool-row .d { display: block; color: var(--muted); font-size: 0.82rem; line-height: 1.6; }
.pro-mark { font-size: 0.72rem; font-weight: 700; color: var(--brand-ink); border: 1.5px solid var(--brand); border-radius: 999px; padding: 0 0.55rem; }

/* ---------- المجاني وPro + الخصوصية ---------- */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 2.5rem; align-items: stretch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.5rem; }
.panel h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 1rem; }
.panel p, .panel li { font-size: 0.92rem; color: var(--ink); }
.panel ul, .panel ol { padding-inline-start: 1.25rem; display: grid; gap: 0.4rem; }
.plans { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 1.25rem; }
.plans th, .plans td { text-align: start; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--line); }
.plans thead th { font-weight: 600; color: var(--muted); font-size: 0.82rem; }
.plans thead th:last-child { color: var(--brand-ink); }
.plans td:first-child { color: var(--muted); }
.plans td:last-child { font-weight: 600; }
.privacy-list li::marker { color: var(--brand); }

/* ---------- شريط الرصيد ---------- */
.quota-bar {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    border: 1px solid var(--line); background: var(--surface); border-radius: var(--r);
    padding: 0.6rem 0.85rem; font-size: 0.86rem;
}
.quota-bar.is-empty { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.quota-label { flex: 1; }
.quota-meter { flex: 0 0 96px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.quota-meter span { display: block; height: 100%; background: var(--brand); }
.quota-bar.is-empty .quota-meter span { background: var(--danger); }
.plan-badge { font-weight: 700; font-size: 0.72rem; border-radius: 999px; padding: 0.05rem 0.6rem; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.plan-badge.is-pro { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* ---------- صفحة الأداة ---------- */
.tool-layout { max-width: 720px; margin: 1.5rem auto 0; }
.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.75rem; box-shadow: var(--shadow); }
.tool-head { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.25rem; }
.tool-head h1 { font-size: 1.55rem; line-height: 1.35; font-weight: 700; letter-spacing: -0.01em; }
.tool-head p { color: var(--muted); font-size: 0.95rem; }
.tool-card .quota-bar { margin-bottom: 1.25rem; background: var(--bg); }

.tabs { display: flex; gap: 0.25rem; margin-bottom: 0.85rem; background: var(--bg); border: 1px solid var(--line); padding: 0.25rem; border-radius: var(--r); }
.tabs button { flex: 1; border: 0; background: none; padding: 0.5rem; border-radius: var(--r-sm); font-weight: 600; font-size: 0.88rem; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(14,31,26,.08); }

.drop-zone {
    display: block; position: relative; text-align: center; cursor: pointer;
    border: 2px dashed var(--line-strong); border-radius: 16px; background: var(--bg);
    padding: 2.25rem 1rem; margin-bottom: 1rem; transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.dragover, .drop-zone:focus-within { border-color: var(--brand); background: var(--brand-soft); }
.file-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-icon {
    width: 48px; height: 48px; margin: 0 auto 0.75rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--brand-ink); border: 1px solid var(--line);
}
.drop-title { display: block; font-weight: 600; font-size: 1rem; word-break: break-word; }
.drop-subtitle { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 0.15rem; }

.text-input {
    width: 100%; min-height: 240px; border: 1px solid var(--line); border-radius: 16px; padding: 1rem;
    background: var(--bg); font-size: 0.92rem; line-height: 1.8; margin-bottom: 1rem;
    unicode-bidi: plaintext; text-align: start; resize: vertical; outline: none;
}
.text-input:focus { border-color: var(--brand); }

.file-list { list-style: none; margin: -0.25rem 0 1rem; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.file-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; font-size: 0.86rem; border-top: 1px solid var(--line); }
.file-list li:first-child { border-top: 0; }
.fl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-size { color: var(--muted); font-size: 0.78rem; direction: ltr; }
.fl-actions { display: inline-flex; gap: 0.25rem; }
.fl-actions button { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 0.8rem; color: var(--muted); }
.fl-actions button:hover:not(:disabled) { color: var(--ink); border-color: var(--line-strong); }
.fl-actions button:disabled { opacity: .35; cursor: default; }

.options {
    border: 1px solid var(--line); border-radius: var(--r); padding: 0.85rem 1rem 1rem; margin-bottom: 1.1rem;
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem;
}
.options-title { font-size: 0.82rem; font-weight: 600; color: var(--muted); padding: 0 0.35rem; }
.opt { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; cursor: pointer; }
.opt input[type="checkbox"] { accent-color: var(--brand); width: 17px; height: 17px; }
.opt-select, .opt-text { flex-direction: column; align-items: stretch; gap: 0.3rem; }
.opt-select span, .opt-text span { font-size: 0.8rem; color: var(--muted); }
.opt select, .opt input[type="text"] {
    font-size: 0.9rem; padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
}

.btn-primary {
    width: 100%; padding: 0.9rem 1.5rem; border: 0; border-radius: var(--r); cursor: pointer;
    background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 1rem;
    transition: filter .15s, transform .1s;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.995); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-primary-sm, .btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.65rem 1rem; border-radius: var(--r-sm); font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none;
}
.btn-primary-sm { background: var(--brand); color: var(--on-brand); border: 0; }
.btn-primary-sm:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-reset { display: block; margin: 0.85rem auto 0; background: none; border: 0; color: var(--muted); font-size: 0.88rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.btn-reset:hover { color: var(--ink); }
.btn-link { background: none; border: 0; color: var(--muted); font-size: 0.82rem; text-decoration: underline; cursor: pointer; }
.privacy-note { margin-top: 0.85rem; text-align: center; font-size: 0.82rem; color: var(--muted); }

.alert { margin-top: 1rem; border-radius: var(--r); padding: 0.75rem 1rem; font-size: 0.9rem; line-height: 1.7; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warning { margin: 0 0 0.85rem; background: var(--warn-soft); color: var(--warn); }

.progress-box { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.progress-bar-wrap { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 0.5rem; }
.progress-bar { width: 3%; height: 100%; background: var(--brand); border-radius: 3px; transition: width .25s ease; }
.progress-text { font-size: 0.85rem; color: var(--muted); text-align: center; }

.result-box { margin-top: 0.25rem; }
.result-header { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.75rem; }
.result-title { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-meta { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.result-textarea {
    width: 100%; height: 260px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg);
    padding: 0.9rem; font-family: var(--font); font-size: 0.88rem; line-height: 1.7;
    direction: rtl; unicode-bidi: plaintext; text-align: start; resize: vertical; outline: none; margin-bottom: 0.85rem;
}
.result-preview { width: 100%; height: 440px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 0.85rem; background: #fff; }
.result-files { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem; margin-bottom: 0.85rem; }
.result-files li { border: 1px solid var(--line); border-radius: var(--r); padding: 0.55rem; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.82rem; overflow: hidden; background: var(--bg); }
.result-files img { width: 100%; height: 110px; object-fit: contain; background: #fff; border-radius: 6px; }
.result-files a { font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.5rem; }
.muted { color: var(--muted); font-size: 0.84rem; }

/* ---------- قفل Pro والتفعيل ---------- */
.lock-box { border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; background: var(--bg); }
.lock-title { font-weight: 700; font-size: 1.1rem; }
.lock-box > .muted { margin-top: 0.25rem; }
.license-box { margin-top: 1rem; }
.license-head { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.85rem; }
.license-head strong { font-size: 1rem; }
.license-form { display: flex; gap: 0.5rem; }
.license-form input {
    flex: 1; min-width: 0; font-size: 0.82rem; padding: 0.65rem 0.75rem;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
}
.license-form .btn-secondary { flex: none; }
.license-msg { font-size: 0.86rem; min-height: 1.4em; margin-top: 0.5rem; color: var(--muted); }
.license-msg.is-error { color: var(--danger); }
.license-buy { margin-top: 0.5rem; }
.license-ok { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.license-ok strong { color: var(--brand-ink); }

/* ---------- محتوى صفحة الأداة ---------- */
.tool-help { margin-top: 1.25rem; }
.tool-help h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.75rem; }
.faq { margin-top: 1rem; }
.faq details { border-top: 1px solid var(--line); padding: 0.75rem 0; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.faq details p { margin-top: 0.35rem; color: var(--muted); font-size: 0.9rem; }
.more-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 2rem; }
.more-tools h2 { flex-basis: 100%; font-size: 1rem; font-weight: 700; margin-bottom: 0.25rem; }
.more-tools a {
    display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; text-decoration: none; color: var(--ink);
    border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.75rem 0.3rem 0.4rem; background: var(--surface);
}
.more-tools a:hover { border-color: var(--brand); }
.more-tools .fmt { font-size: 0.62rem; min-width: 0; }

.site-footer {
    max-width: 1120px; margin: 0 auto; padding: 2rem 1.25rem 2.5rem; border-top: 1px solid var(--line);
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem;
}
.site-footer a { color: var(--muted); }

.not-found { text-align: center; padding: 5rem 0; }
.not-found h1 { font-size: 2rem; }

@media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; gap: 2rem; padding-top: 1.5rem; }
    .hero h1 { max-width: none; }
    .capsule-stage { order: -1; }
    .tool-rows { grid-template-columns: 1fr; }
    .tool-rows .tool-row:nth-child(odd) { border-inline-end: 0; }
    .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .site-nav { display: none; }
    .tool-card { padding: 1.25rem; }
    .tool-row { grid-template-columns: 1fr auto; }
    .tool-row .pair { grid-column: 1 / -1; }
    .options { grid-template-columns: 1fr; }
    .license-form { flex-direction: column; }
}
.tool-head h1 .pro-mark { vertical-align: middle; font-size: 0.75rem; margin-inline-start: 0.35rem; }

/* زر الوضع الداكن/الفاتح */
.header-end { display: flex; align-items: center; gap: 1.25rem; }
.theme-toggle {
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
    color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--line-strong); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ===== الأسعار ===== */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
.plan {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 1.5rem; display: flex; flex-direction: column; gap: 0.85rem;
}
.plan-pro { border: 2px solid var(--brand); }
.plan h3 { font-size: 1.05rem; font-weight: 700; }
.plan-price { display: flex; align-items: baseline; gap: 0.4rem; min-height: 2.6rem; }
.plan-price strong { font-size: 2rem; font-weight: 700; line-height: 1; }
.plan-price span { color: var(--muted); font-size: 0.9rem; }
.plan ul { list-style: none; display: grid; gap: 0.45rem; font-size: 0.92rem; flex: 1; }
.plan li { padding-inline-start: 1.4rem; position: relative; }
.plan li::before { content: ''; position: absolute; inset-inline-start: 0; top: 0.55em; width: 0.7rem; height: 0.4rem; border-inline-start: 2px solid var(--brand); border-bottom: 2px solid var(--brand); transform: rotate(-45deg); }
.plan-btn { width: 100%; }
.activate-panel { margin-top: 1.25rem; }
.activate-panel .license-box { margin-top: 0; max-width: 640px; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

/* ===== لوحة التحكم ===== */
.admin-page { max-width: 980px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; margin: 1.5rem 0 1rem; }
.admin-top h1 { font-size: 1.5rem; }
.admin-login { max-width: 420px; margin: 2rem auto; }
.admin-page .panel { margin-bottom: 1.25rem; }
.admin-page label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.admin-page input, .admin-page select, .admin-page textarea {
    font-size: 0.95rem; padding: 0.6rem 0.7rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink);
}
.admin-login form { display: grid; gap: 0.85rem; }
.form-error { color: var(--danger); font-size: 0.88rem; min-height: 1.2em; }
.issue-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem 1rem; align-items: end; }
.issue-form .btn-primary { grid-column: 1 / -1; }
.issued { margin-top: 1rem; display: grid; gap: 0.5rem; }
.issued textarea { min-height: 90px; font-family: 'IBM Plex Mono', Consolas, monospace; font-size: 0.78rem; word-break: break-all; }
.issued-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.list-head h2 { margin: 0; }
.list-tools { display: flex; gap: 0.5rem; }
.list-tools input { min-width: 220px; }
.table-wrap { overflow-x: auto; }
.keys-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.keys-table th { text-align: start; color: var(--muted); font-weight: 600; font-size: 0.8rem; padding: 0.5rem; border-bottom: 1px solid var(--line); }
.keys-table td { padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.keys-table td strong { display: block; font-weight: 600; direction: ltr; text-align: end; }
.keys-table td .muted { display: block; }
.keys-table .actions { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: flex-end; }
.keys-table td:last-child { width: 1%; min-width: 340px; }
.keys-table .actions .btn-secondary { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.keys-table .actions .danger { color: var(--danger); }
.keys-table .empty { text-align: center; color: var(--muted); padding: 2rem 0.5rem; }
.status { display: inline-block; font-size: 0.75rem; font-weight: 700; border-radius: 999px; padding: 0.05rem 0.6rem; }
.st-on { background: var(--brand-soft); color: var(--brand-ink); }
.st-exp { background: var(--warn-soft); color: var(--warn); }
.st-off { background: var(--danger-soft); color: var(--danger); }
@media (max-width: 640px) {
    .issue-form { grid-template-columns: 1fr; }
    .list-tools { width: 100%; }
    .list-tools input { min-width: 0; flex: 1; }
}

/* ===== v6: الكبسولة كمنطقة إسقاط + بلاطات الصيغ ===== */
.capsule { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.capsule:hover, .capsule:focus-within { border-color: var(--brand); }
.capsule.dragover { border-color: var(--brand); border-style: dashed; transform: scale(1.03); box-shadow: 0 0 0 8px var(--brand-soft); }
.capsule.has-file .capsule-track i { animation: none; opacity: .25; }
.capsule.has-file .fmt.to { background: var(--surface); color: var(--muted); border-color: var(--line-strong); border-style: dashed; }
.capsule.aim .fmt.to { background: var(--brand); color: var(--on-brand); border-color: var(--brand); border-style: solid; transform: scale(1.1); }
.capsule.aim .capsule-track i { opacity: 1; }
.capsule .fmt { transition: opacity .25s ease, transform .15s ease, background .15s, color .15s; }
.capsule-caption { text-align: center; max-width: 420px; overflow-wrap: anywhere; }
.capsule-stage .alert { margin-top: 0; max-width: 420px; }

.targets { width: min(100%, 420px); text-align: center; }
.targets-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.6rem; }
.target-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.target {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
    min-height: 84px; padding: 0.6rem 0.4rem; cursor: pointer;
    background: var(--surface); color: var(--ink); border: 1.5px solid var(--line-strong); border-radius: 10px;
    transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
/* الزوايا الخارجية أوسع، فتبدو البلاطات كقطعة واحدة */
.target:first-child { border-start-start-radius: 34px; }
.target:nth-child(3), .target:last-child:nth-child(-n+3) { border-start-end-radius: 34px; }
.target:nth-child(3n+1):nth-last-child(-n+3) { border-end-start-radius: 34px; }
.target:last-child { border-end-end-radius: 34px; }
.target strong { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.01em; }
.target span { font-size: 0.72rem; color: var(--muted); transition: color .18s ease; }
.target em {
    position: absolute; top: 6px; inset-inline-end: 8px; font-style: normal; font-size: 0.6rem; font-weight: 700;
    color: var(--brand-ink); border: 1px solid var(--brand); border-radius: 999px; padding: 0 0.35rem; line-height: 1.5;
}
.target:hover, .target:focus-visible, .target.going {
    background: var(--brand); border-color: var(--brand); color: var(--on-brand);
    transform: scale(1.06); z-index: 1; box-shadow: 0 10px 22px -12px var(--brand);
}
.target:hover span, .target:focus-visible span, .target.going span { color: var(--on-brand); }
.target:hover em, .target:focus-visible em, .target.going em { color: var(--on-brand); border-color: var(--on-brand); }
.target:active { transform: scale(1.01); }
.target:disabled:not(.going) { opacity: .45; transform: none; }
.targets .btn-reset { margin-top: 0.75rem; }

/* صفوف الأدوات: الصيغة الناتجة تبرز عند الاقتراب */
.tool-row { transition: background .15s ease; }
.tool-row .fmt, .tool-row .arrow, .more-tools .fmt { transition: transform .18s ease; }
.tool-row:hover .fmt.to, .tool-row:focus-visible .fmt.to, .more-tools a:hover .fmt.to { transform: scale(1.14); }
.tool-row:hover .arrow { transform: translateX(-2px); }
.tool-row:hover strong { color: var(--brand-ink); }

/* صفحة الأداة: صيغة الناتج كبلاطات */
.opt-tiles { grid-column: 1 / -1; flex-direction: column; align-items: stretch; gap: 0.4rem; cursor: default; }
.opt-tiles > span { font-size: 0.8rem; color: var(--muted); }
.fmt-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.5rem; }
.fmt-tile { position: relative; cursor: pointer; }
.fmt-tile input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.fmt-tile span {
    display: flex; align-items: center; justify-content: center; text-align: center; min-height: 46px; padding: 0.4rem 0.6rem;
    border: 1.5px solid var(--line-strong); border-radius: 10px; background: var(--surface);
    font-size: 0.86rem; font-weight: 600; transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}
.fmt-tile:hover span { border-color: var(--brand); background: var(--brand-soft); transform: scale(1.03); }
.fmt-tile input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.fmt-tile input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .target, .fmt-tile span, .tool-row .fmt, .capsule { transition: none; }
    .target:hover, .target:focus-visible, .fmt-tile:hover span, .capsule.dragover { transform: none; }
}

/* ===== v7: وضوح الكبسولة، الخطوات، بتلات الأدوات، زر الرجوع ===== */
.capsule { box-shadow: 0 18px 40px -24px rgba(14, 31, 26, .35); }
.capsule::after {
    content: ''; position: absolute; inset: 10px; border-radius: 999px;
    border: 2px dashed var(--line-strong); pointer-events: none; transition: border-color .15s;
}
.capsule:hover { transform: translateY(-3px); }
.capsule:hover::after, .capsule.dragover::after { border-color: var(--brand); }
.capsule.has-file::after { border-color: transparent; }

.pick-btn {
    display: inline-flex; align-items: center; gap: 0.55rem;
    padding: 0.85rem 1.75rem; border: 0; border-radius: 999px; cursor: pointer;
    background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 1.05rem;
    box-shadow: 0 10px 24px -12px var(--brand); transition: transform .15s ease, filter .15s ease;
}
.pick-btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.pick-btn:active { transform: none; }

.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-top: 1.5rem; font-size: 0.92rem; color: var(--muted); }
.steps li { display: inline-flex; align-items: center; gap: 0.45rem; }
.steps b {
    display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
    background: var(--brand-soft); color: var(--brand-ink); font-size: 0.8rem;
}

/* الأدوات: مجموعات من 4 بتلات تشكّل معاً شكل الكبسولة */
.section-sub { color: var(--muted); margin: -0.5rem 0 1.5rem; }
.clusters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem 1.5rem; }
.cluster h3 { font-size: 0.95rem; font-weight: 600; color: var(--muted); margin-bottom: 0.75rem; text-align: center; }
.petals { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.petal {
    position: relative; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.55rem;
    padding: 0.9rem 0.6rem; text-align: center; text-decoration: none; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 1px 2px rgba(14, 31, 26, .05);
    transition: transform .2s ease, background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.petal:nth-child(1) { border-start-start-radius: 70%; }
.petal:nth-child(2) { border-start-end-radius: 70%; }
.petal:nth-child(3) { border-end-start-radius: 70%; }
.petal:nth-child(4) { border-end-end-radius: 70%; }
.petal:nth-child(1) { padding: 1.4rem 1.4rem 0.6rem 0.6rem; }
.petal:nth-child(2) { padding: 1.4rem 0.6rem 0.6rem 1.4rem; }
.petal:nth-child(3) { padding: 0.6rem 1.4rem 1.4rem 0.6rem; }
.petal:nth-child(4) { padding: 0.6rem 0.6rem 1.4rem 1.4rem; }
.petal strong { font-size: 0.92rem; font-weight: 600; line-height: 1.4; }
.petal em {
    position: static; font-style: normal; font-size: 0.62rem; font-weight: 700;
    color: var(--brand-ink); border: 1px solid var(--brand); border-radius: 999px; padding: 0 0.4rem; line-height: 1.5;
}
.petal .pair .fmt { transition: background .2s, color .2s, border-color .2s; }
.petal:hover, .petal:focus-visible {
    background: var(--brand); border-color: var(--brand); color: var(--on-brand);
    transform: scale(1.07); z-index: 1; box-shadow: 0 16px 30px -16px var(--brand);
}
.petal:hover .fmt, .petal:focus-visible .fmt { background: transparent; border-color: var(--on-brand); color: var(--on-brand); }
.petal:hover .fmt.to, .petal:focus-visible .fmt.to { background: var(--on-brand); color: var(--brand-ink); }
.petal:hover .arrow, .petal:focus-visible .arrow { color: var(--on-brand); }
.petal:hover em, .petal:focus-visible em { color: var(--on-brand); border-color: var(--on-brand); }

/* زر الرجوع في صفحات الأدوات */
.back-link {
    display: inline-flex; align-items: center; gap: 0.35rem; margin: 0 0 0.85rem;
    color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem;
    padding: 0.35rem 0.85rem 0.35rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
    transition: color .15s, border-color .15s;
}
.back-link:hover { color: var(--brand-ink); border-color: var(--brand); }

@media (max-width: 900px) {
    .clusters { grid-template-columns: 1fr; max-width: 380px; margin: 0 auto; }
}
@media (max-width: 560px) {
}
@media (prefers-reduced-motion: reduce) {
    .petal, .pick-btn, .capsule { transition: none; }
    .petal:hover, .pick-btn:hover, .capsule:hover { transform: none; }
}
@media (max-width: 420px) {
    .clusters { max-width: 330px; }
    .petal strong { font-size: 0.85rem; }
    .petal .pair .fmt { font-size: 0.62rem; min-width: 2.2em; }
}
