:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1d1b18;
  --muted: #6f6a62;
  --line: #e6e1d8;
  --accent: #0f7a5c;
  --accent-text: #ffffff;
  --accent-soft: #e3f2ec;
  --warn: #b4442f;
  --warn-soft: #f8e6e1;
  --copy: #2563c9;
  --hero: linear-gradient(180deg, #fbe9c9 0%, var(--bg) 100%);
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412;
    --surface: #1e1d1a;
    --text: #f1eee8;
    --muted: #a49e94;
    --line: #2f2d29;
    --accent: #35b58a;
    --accent-text: #0b1a14;
    --accent-soft: #17302689;
    --warn: #e07a64;
    --warn-soft: #3a201a;
    --copy: #6ea4ff;
    --hero: linear-gradient(180deg, #2b2416 0%, var(--bg) 100%);
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #141412; --surface: #1e1d1a; --text: #f1eee8; --muted: #a49e94; --line: #2f2d29;
  --accent: #35b58a; --accent-text: #0b1a14; --accent-soft: #17302689; --warn: #e07a64;
  --warn-soft: #3a201a; --copy: #6ea4ff; --hero: linear-gradient(180deg, #2b2416 0%, var(--bg) 100%); --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "IBM Plex Sans Arabic", system-ui, sans-serif;
}
.hero { background: var(--hero); padding: 32px 16px 20px; }
.hero, main, footer { max-width: 560px; margin-inline: auto; }
.eyebrow { margin: 0; color: var(--muted); font-size: 14px; }
h1 { margin: 4px 0 6px; font-size: 24px; line-height: 1.35; }
h2 { margin: 0 0 12px; font-size: 18px; }
.sub { margin: 0; color: var(--muted); }
main { padding: 0 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.take { text-align: center; }

.promo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0f5c46, #1b8a68);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}
.promo:active { transform: scale(.99); }
.promo-ic { width: 48px; height: 48px; border-radius: 12px; flex: none; background: #fff; object-fit: cover; }
.promo-text { flex: 1; min-width: 0; display: grid; font-size: 13px; line-height: 1.5; }
.promo-text b { font-size: 16px; }
.promo-text span { opacity: .9; }
.promo-cta { flex: none; background: #fff; color: #0f5c46; font-weight: 700; padding: 8px 14px; border-radius: 999px; font-size: 14px; }

.share { text-align: center; }
.btn.share-btn { background: #2563c9; color: #fff; border-color: transparent; font-weight: 700; }
.share-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.sh {
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
}
.sh.wa { border-color: #25d366; color: #128c4b; }
.sh.tg { border-color: #229ed9; color: #1a7fb0; }
.sh.fb { border-color: #1877f2; color: #1360c4; }
.sh.copy-link { border-color: var(--copy); color: var(--copy); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sh.wa { color: #4ade80; }
  :root:not([data-theme="light"]) .sh.tg { color: #5cc3f0; }
  :root:not([data-theme="light"]) .sh.fb { color: #6ea4ff; }
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
  display: grid;
}
.stat b { font-size: 22px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; line-height: 1.4; }

.item.pinned { border-color: #d9a13b; }
.tag.pin { background: #f7ead0; color: #8a5a07; }
.hint { margin: 12px 0 0; color: var(--muted); font-size: 14px; }

.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 700; }
.btn.big { width: 100%; padding: 16px; font-size: 19px; border-radius: 16px; display: flex; gap: 10px; justify-content: center; align-items: center; }
.btn:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

form { display: flex; gap: 8px; }
input {
  flex: 1;
  min-width: 0;
  font: 500 17px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
}
.msg { min-height: 1.6em; margin: 8px 0 0; font-size: 14px; }
.msg.ok { color: var(--accent); }
.msg.err { color: var(--warn); }

.list-head { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 0; }
.muted { color: var(--muted); font-size: 14px; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  align-items: center;
}
.item.used { opacity: .55; }
.item.mine { border-color: var(--accent); }
.code { font: 600 18px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; direction: ltr; text-align: left; overflow-wrap: anywhere; }
.actions { display: flex; gap: 6px; }
.btn.copy { border: 2px solid var(--copy); color: var(--copy); font-weight: 700; }
.meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--muted); font-size: 13px; }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-weight: 500; }
.votes { margin-inline-start: auto; display: flex; gap: 6px; }
.vote { padding: 4px 10px; font-size: 13px; border-radius: 999px; }
.vote.on.good { background: var(--accent-soft); border-color: var(--accent); }
.vote.on.bad { background: var(--warn-soft); border-color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }

footer { padding: 24px 16px 40px; text-align: center; }

.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: 20px;
  max-width: 420px;
  margin-inline: auto;
  background: var(--text);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: 14px;
  text-align: center;
  font-weight: 500;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
