:root {
    --paper: #f6f5f1;
    --surface: #ffffff;
    --ink: #121417;
    --ink-2: #2b2f36;
    --muted: #5b616b;
    --line: #e4e2db;
    --accent: #0d6b55;
    --accent-ink: #0a5443;
    --accent-soft: #e2f0ea;
    --danger: #b42318;
    --radius: 14px;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--paper); color: var(--ink);
    font-family: "Readex Pro", "Segoe UI", Tahoma, system-ui, sans-serif;
    font-size: 16px; line-height: 1.75; min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }
.wrap { width: min(1040px, 100% - 40px); margin-inline: auto; }
.narrow { width: min(480px, 100% - 32px); padding-block: 48px 72px; }

/* الشريط العلوي */
.bar { border-bottom: 1px solid var(--line); background: rgba(246, 245, 241, .92); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.bar-in { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.mark { font-family: var(--mono); font-weight: 700; font-size: 18px; color: var(--ink); direction: ltr; unicode-bidi: isolate; display: inline-block; letter-spacing: -.02em; }
.mark-tilde { color: var(--muted); font-weight: 500; }
.mark-dot { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 22px; font-size: 15px; }
.nav a { color: var(--ink-2); }
.nav a:hover { color: var(--accent); }
.nav form { margin: 0; }
.nav-cta { padding: 7px 16px; border: 1px solid var(--ink); border-radius: 999px; }
.nav-cta:hover { background: var(--ink); color: #fff !important; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); cursor: pointer; }
.linkish:hover { color: var(--accent); }
.linkish:disabled { color: var(--muted); cursor: default; }

.flash { margin: 20px 0 0; padding: 12px 16px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); border: 1px solid #c4e2d6; }

/* الواجهة */
.hero { padding-block: 88px 64px; }
.eyebrow { display: inline-block; margin: 0 0 18px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 14px; font-weight: 500; }
.hero h1 { margin: 0; font-size: clamp(40px, 7vw, 68px); line-height: 1.15; font-weight: 600; letter-spacing: -.01em; }
.lead { margin: 16px 0 0; font-size: clamp(18px, 2.4vw, 22px); color: var(--ink-2); font-weight: 300; max-width: 640px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.chip { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-size: 15px; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip svg { width: 17px; height: 17px; fill: currentColor; }

.section { padding-block: 40px; }
.section-head h1, .section-head h2 { margin: 0; font-size: 28px; font-weight: 600; }
.section-head p { margin: 6px 0 0; color: var(--muted); max-width: 640px; }
.section-head { margin-bottom: 24px; }
.section-head.sub { margin-top: 48px; }
.section-head.sub h2 { font-size: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; display: flex; flex-direction: column; }
.card-top { display: flex; align-items: center; justify-content: space-between; }
.code { font-family: var(--mono); font-weight: 700; font-size: 26px; letter-spacing: .02em; color: var(--ink); }
.tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; }
.tag-owned { background: var(--accent-soft); color: var(--accent-ink); }
.card h3 { margin: 14px 0 4px; font-size: 18px; font-weight: 500; }
.card p { margin: 0; color: var(--muted); font-size: 15px; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.price { font-weight: 600; font-size: 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 22px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 500; font-size: 16px; cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--accent-ink); color: #fff; }
.btn-ink { background: var(--ink); }
.btn-ink:hover { background: #000; }
.btn-block { width: 100%; margin-top: 18px; padding-block: 13px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; counter-reset: s; }
.steps li { counter-increment: s; padding: 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.steps li::before { content: counter(s); font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: 15px; }
.steps span { color: var(--muted); font-size: 15px; }

/* النماذج */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; }
.panel-title { margin: 6px 0 4px; font-size: 24px; font-weight: 600; }
.muted { color: var(--muted); margin: 0; }
.form { margin-top: 22px; }
.form label { display: block; font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.form input[type=tel], .form input[type=text] {
    width: 100%; font: inherit; font-size: 18px; padding: 12px 14px; border: 1px solid #cfccc3; border-radius: 10px; background: #fff; color: var(--ink); text-align: left;
}
.form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form input.invalid { border-color: var(--danger); }
.code-input { font-family: var(--mono) !important; font-size: 26px !important; letter-spacing: .5em; text-align: center !important; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 14px; margin: 14px 0 0; }
.row-between { display: flex; justify-content: space-between; margin-top: 18px; font-size: 15px; }
.row-between form { margin: 0; }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 400 !important; color: var(--ink-2); }
.check input { width: 20px; height: 20px; margin-top: 4px; accent-color: var(--accent); flex: none; }
.summary { margin: 22px 0 0; border-top: 1px solid var(--line); }
.summary div { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 500; }
.empty { color: var(--muted); padding: 28px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }

.prose h1 { font-size: 26px; font-weight: 600; }
.prose li { margin-bottom: 10px; color: var(--ink-2); }

.foot { border-top: 1px solid var(--line); margin-top: 40px; }
.foot-in { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-block: 22px; color: var(--muted); font-size: 14px; }
.foot-links { display: flex; gap: 18px; }
.foot-links a { color: var(--ink-2); }

/* العارض */
body.reading { background: #e9e8e3; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body.reading .bar { position: static; }
.reader-bar { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; }
.reader-bar-in { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.reader-bar .linkish { color: #d8dbe0; }
.reader-bar .linkish:hover { color: #fff; }
.reader-title { font-family: var(--mono); letter-spacing: .04em; }
.reader-tools { display: flex; align-items: center; gap: 8px; }
.pageno { font-family: var(--mono); font-size: 14px; color: #c9ccd2; min-width: 72px; text-align: center; }
.tool { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #3a3f47; background: transparent; color: #fff; font-size: 18px; cursor: pointer; }
.tool:hover { background: #2a2e35; }
.reader { --w: 860px; padding: 24px 12px 12px; }
.pages { width: min(var(--w), 100%); margin-inline: auto; display: flex; flex-direction: column; gap: 14px; }
.page { position: relative; background: #fff; aspect-ratio: 1 / 1.414; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; }
.page canvas { display: block; width: 100%; height: auto; pointer-events: none; }
.page .num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); color: #b9b6ad; font-size: 15px; }
.page[data-state=done] .num { display: none; }
.page.err .num::after { content: " · تعذر التحميل"; font-family: "Readex Pro", sans-serif; }
.reader-note { text-align: center; color: var(--muted); font-size: 14px; padding-bottom: 32px; }
.shield-msg { display: none; }
body.shielded .pages { filter: blur(22px); }
body.shielded .shield-msg { display: grid; place-items: center; position: fixed; inset: 0; z-index: 40; color: var(--ink); font-size: 18px; font-weight: 500; }
@media print {
    body * { display: none !important; }
    body::after { content: "الطباعة غير متاحة لهذا الملف."; display: block; padding: 40px; font-size: 20px; }
}

@media (max-width: 640px) {
    .hero { padding-block: 56px 40px; }
    .nav { gap: 14px; }
    .panel { padding: 26px 20px; }
    .reader { padding-inline: 4px; }
    .pages { gap: 8px; }
}

/* لوحة المالك */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; }
.stats span { color: var(--muted); font-size: 14px; }
.stats b { font-size: 24px; font-weight: 600; }
.form.compact { margin-top: 16px; }
.form.compact label { margin-top: 12px; }
.form.compact .btn { margin-top: 14px; }
.form textarea, .form input[type=file] { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid #cfccc3; border-radius: 10px; background: #fff; }
.form.upload { border-top: 1px dashed var(--line); padding-top: 6px; }
.tag-warn { background: #fdf0d5; color: #8a5a00; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; background: #faf9f6; }
.table tr:last-child td { border-bottom: 0; }
