/* Layout: one mobile-first column; a dark "kiswa" band with a gold geometric belt holds the key tag. */
:root {
  --bg: #f3f6f3;
  --surface: #ffffff;
  --surface-2: #eaf0ec;
  --ink: #0f1b17;
  --muted: #56665f;
  --line: #d9e2dd;
  --emerald: #0b6b4c;
  --emerald-hover: #095a40;
  --on-emerald: #ffffff;
  --gold: #a57a1f;
  --gold-bright: #c9a04a;
  --gold-soft: #f4ead0;
  --band: #0d1613;
  --band-ink: #f1ede2;
  --band-muted: #a9b5ae;
  --tag: #fbf7ec;
  --tag-ink: #1d1608;
  --danger: #b3412e;
  --ok: #0b6b4c;
  --shadow: 0 1px 2px rgb(15 27 23 / .06), 0 8px 24px rgb(15 27 23 / .06);

  --f-display: "Reem Kufi", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090e0c; --surface: #111916; --surface-2: #17211d; --ink: #e8eeea; --muted: #93a29b;
    --line: #22302a; --emerald: #25a877; --emerald-hover: #2fc28b; --on-emerald: #04140d;
    --gold: #d8b25c; --gold-bright: #e9c877; --gold-soft: #2a2414; --band: #040706; --band-ink: #f1ede2;
    --band-muted: #93a29b; --tag: #1b1710; --tag-ink: #f3e7c8; --danger: #e2735f; --ok: #25a877;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #090e0c; --surface: #111916; --surface-2: #17211d; --ink: #e8eeea; --muted: #93a29b;
  --line: #22302a; --emerald: #25a877; --emerald-hover: #2fc28b; --on-emerald: #04140d;
  --gold: #d8b25c; --gold-bright: #e9c877; --gold-soft: #2a2414; --band: #040706; --band-ink: #f1ede2;
  --band-muted: #93a29b; --tag: #1b1710; --tag-ink: #f3e7c8; --danger: #e2735f; --ok: #25a877;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.55 var(--f-body);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
a { color: var(--emerald); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0; }
h2 { font-size: 1.35rem; }
.wrap {
  width: 100%; max-width: 640px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.mono { font-family: var(--f-mono); }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; }
[dir="rtl"] .eyebrow { letter-spacing: 0; text-transform: none; font-size: .85rem; }

/* Top bar */
.top { background: var(--band); color: var(--band-ink); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; color: var(--gold-bright); flex: none; }
.brand-name { font-family: var(--f-display); font-size: 1.3rem; line-height: 1; }
.brand-name small { display: block; font-size: .72rem; color: var(--band-muted); font-family: var(--f-body); margin-top: 3px; }
.pill-btn {
  border: 1px solid rgb(255 255 255 / .18); background: transparent; color: var(--band-ink);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: .9rem;
}
.pill-btn:hover { border-color: var(--gold-bright); }

/* The band */
.band { position: relative; background: var(--band); color: var(--band-ink); overflow: hidden; }
.band::before {
  content: ""; position: absolute; inset: 0; background: var(--gold-bright); opacity: .11;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.2'%3E%3Crect x='14' y='14' width='28' height='28'/%3E%3Crect x='14' y='14' width='28' height='28' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='6'/%3E%3Cpath d='M0 0l8 8M56 0l-8 8M0 56l8-8M56 56l-8-8'/%3E%3C/g%3E%3C/svg%3E") repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.2'%3E%3Crect x='14' y='14' width='28' height='28'/%3E%3Crect x='14' y='14' width='28' height='28' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='6'/%3E%3Cpath d='M0 0l8 8M56 0l-8 8M0 56l8-8M56 56l-8-8'/%3E%3C/g%3E%3C/svg%3E") repeat;
}
.band::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 70% at 50% 0%, transparent 30%, var(--band) 85%);
}
.band .wrap { position: relative; z-index: 1; padding-block: 6px 34px; display: grid; gap: 18px; }
.band h1 { font-size: clamp(1.55rem, 5.5vw, 2.1rem); }
.band .lede { color: var(--band-muted); margin: 6px 0 0; max-width: 46ch; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { border: 1px solid rgb(255 255 255 / .1); border-radius: var(--r-md); padding: 10px 12px; background: rgb(255 255 255 / .03); }
.stat b { display: block; font: 600 1.25rem/1.1 var(--f-mono); color: var(--band-ink); font-variant-numeric: tabular-nums; }
.stat span { font-size: .76rem; color: var(--band-muted); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--emerald-hover); margin-inline-end: 5px; vertical-align: 1px; box-shadow: 0 0 0 0 var(--emerald-hover); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* The key tag: the one bold element */
.tag {
  position: relative; background: var(--tag); color: var(--tag-ink);
  border-radius: var(--r-lg); padding: 22px 20px 18px; box-shadow: 0 18px 40px rgb(0 0 0 / .35);
  border: 1px solid var(--gold);
}
.tag::before { /* the punched hole of a key tag */
  content: ""; position: absolute; top: 16px; inset-inline-end: 18px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--band); box-shadow: inset 0 0 0 2px var(--gold);
}
.tag .eyebrow { color: var(--gold); }
.code-big {
  font: 600 clamp(1.7rem, 8.4vw, 2.5rem)/1.1 var(--f-mono); letter-spacing: .04em; margin: 8px 0 6px;
  direction: ltr; text-align: start; word-break: break-all; unicode-bidi: isolate;
}
.code-meta { font-size: .88rem; color: color-mix(in srgb, var(--tag-ink) 62%, transparent); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.code-meta .dot { opacity: .5; }
.tag-actions { display: grid; gap: 10px; margin-top: 18px; }
.tag-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tag-foot { margin-top: 14px; padding-top: 12px; border-top: 1px dashed color-mix(in srgb, var(--gold) 55%, transparent); display: flex; justify-content: space-between; gap: 10px; font-size: .85rem; flex-wrap: wrap; }
.tag-foot b { font-family: var(--f-mono); }
.tag.swap .code-big { animation: swap .45s ease; }
@keyframes swap { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-md); border: 1px solid transparent; padding: 12px 14px; min-height: 46px;
  font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .06s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--emerald); color: var(--on-emerald); font-size: 1.05rem; min-height: 54px; }
.btn-primary:hover { background: var(--emerald-hover); }
.btn-ghost { background: transparent; border-color: color-mix(in srgb, var(--tag-ink) 18%, transparent); color: var(--tag-ink); font-size: .9rem; padding-inline: 8px; }
.btn-ghost:hover { border-color: var(--gold); }
.btn-ghost.danger { color: var(--danger); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn-outline { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--emerald); }
.btn-solid { background: var(--emerald); color: var(--on-emerald); }
.btn-solid:hover { background: var(--emerald-hover); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.empty { text-align: center; padding: 10px 0 4px; }
.empty p { margin: 6px 0 14px; }

/* Sections */
main { display: grid; gap: 14px; padding-block: 20px 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); }
.card > header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card > header p { margin: 0; color: var(--muted); font-size: .88rem; }
.muted { color: var(--muted); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; align-items: start; counter-increment: s; }
.steps li::before {
  content: counter(s); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold); font: 600 .9rem var(--f-mono);
}
.steps b { font-weight: 600; }
.note { margin: 14px 0 0; font-size: .88rem; color: var(--muted); background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .c { font: 600 1rem var(--f-mono); direction: ltr; unicode-bidi: isolate; }
.list .m { font-size: .8rem; color: var(--muted); }
.list .acts { display: flex; gap: 6px; }
.list li.used { opacity: .45; }
.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.badge.hidden { background: var(--surface-2); color: var(--muted); }

/* Share form */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
textarea, input[type="text"], input[type="password"], input[type="search"] {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-md); padding: 12px 14px; resize: vertical;
}
textarea:focus, input:focus { border-color: var(--emerald); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 20%, transparent); }
.detect { display: flex; align-items: center; gap: 8px; font-size: .88rem; min-height: 24px; }
.detect.ok { color: var(--ok); }
.detect.bad { color: var(--danger); }
.detect code { font: 600 .95rem var(--f-mono); direction: ltr; unicode-bidi: isolate; }
.howget { margin: 0 0 16px; padding-inline-start: 20px; font-size: .9rem; color: var(--muted); display: grid; gap: 4px; }

details { border-top: 1px solid var(--line); padding: 12px 0; }
details:first-of-type { border-top: 0; }
summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
summary::after { content: "+"; color: var(--gold); font: 600 1.1rem var(--f-mono); }
details[open] summary::after { content: "–"; }
summary::-webkit-details-marker { display: none; }
details p { margin: 8px 0 0; color: var(--muted); }

footer.site { padding-block: 10px 40px; font-size: .82rem; color: var(--muted); display: grid; gap: 8px; }
footer.site p { margin: 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg);
  padding: 11px 16px; border-radius: 999px; font-size: .92rem; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
