:root {
  color-scheme: dark;
  --bg: #0a111c;
  --surface: #111b2a;
  --surface-2: #172438;
  --text: #e6edf7;
  --muted: #8f9db3;
  --border: #22324a;
  --primary: #097ffc;
  --primary-text: #4da3ff;
  --primary-hover: #2b93ff;
  --primary-soft: #12305a;
  --accent: #f2a541;
  --danger: #f08a80;
  --danger-soft: #3a1f1c;
  --success: #6fcf8d;
  --success-soft: #19331f;
  --hero-glow: rgba(9, 127, 252, .18);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  --radius: 14px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

.container {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding-inline: 16px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.brand-icon { width: 28px; height: 28px; fill: var(--primary-text); stroke: none; }
.header-tag { font-size: .85rem; color: var(--muted); }

/* ---------- hero ---------- */
.hero { padding: 48px 0 28px; text-align: center; background: radial-gradient(ellipse 70% 100% at 50% 0%, var(--hero-glow), transparent 70%); }
.hero h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 5vw, 2.2rem); font-weight: 800; }
.lead { margin: 0 auto 24px; color: var(--muted); max-width: 520px; }

.search {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 6px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow); }
.search.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  letter-spacing: .06em;
  padding: 10px 12px;
  text-align: center;
}
.search input::placeholder { color: var(--muted); opacity: .7; letter-spacing: 0; direction: rtl; }

.search button {
  position: relative;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 10px 26px;
  cursor: pointer;
  transition: background .2s;
  min-width: 110px;
}
.search button:hover { background: var(--primary-hover); }
.search button:disabled { cursor: wait; opacity: .85; }
.spinner {
  display: none;
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}
.search button.loading .btn-label { display: none; }
.search button.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.hint { font-size: .85rem; color: var(--muted); margin: 10px 0 0; }
.hint.error { color: var(--danger); }

.recent { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; font-size: .85rem; }
.recent-title { color: var(--muted); }
.recent-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 12px;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
  direction: ltr;
}
.chip:hover { border-color: var(--primary); color: var(--primary-text); }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 24px;
  animation: rise .35s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.message {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 24px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}

/* skeleton */
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 14px; margin-bottom: 14px; }
.sk-title { height: 22px; width: 45%; }
.sk-line.short { width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* result */
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.label { font-size: .8rem; color: var(--muted); }
.code-row { display: flex; align-items: center; gap: 6px; }
.code-row strong { font-size: 1.05rem; letter-spacing: .05em; word-break: break-all; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 8px; display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); color: var(--primary-text); }
.icon-btn svg { width: 18px; height: 18px; }

.badge { font-size: .8rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-text); white-space: nowrap; }
.badge.done { background: var(--success-soft); color: var(--success); }

.latest { margin-top: 18px; padding: 14px 16px; background: var(--surface-2); border-radius: 12px; border-inline-start: 4px solid var(--primary); }
.latest .l-title { font-weight: 700; }
.latest .l-meta { font-size: .85rem; color: var(--muted); }

.info { list-style: none; padding: 0; margin: 14px 0 0; font-size: .9rem; color: var(--muted); }
.info:empty { display: none; }
.info li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.info li:last-child { border-bottom: 0; }

.timeline-title { font-size: 1rem; margin: 26px 0 12px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 28px 20px 0; }
.timeline li::before {
  content: "";
  position: absolute;
  right: 6px; top: 10px; bottom: -10px;
  width: 2px;
  background: var(--border);
}
.timeline li:last-child::before { display: none; }
.timeline li::after {
  content: "";
  position: absolute;
  right: 0; top: 6px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--border);
}
.timeline li:first-child::after { border-color: var(--primary); background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.t-desc { font-weight: 600; }
.t-meta { font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.t-meta span { display: inline-flex; align-items: center; gap: 4px; }
.t-meta svg { width: 14px; height: 14px; }

.result-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; font-size: .8rem; color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--primary-text); font: inherit; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- help ---------- */
.help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 12px auto 40px; }
.help-item { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.help-item svg { width: 22px; height: 22px; color: var(--primary-text); flex-shrink: 0; margin-top: 4px; }
.help-item h3 { margin: 0; font-size: .92rem; }
.help-item p { margin: 2px 0 0; font-size: .8rem; color: var(--muted); line-height: 1.7; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 18px 0; font-size: .8rem; color: var(--muted); text-align: center; }
.site-footer a { color: var(--primary-text); text-decoration: none; }

/* toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 8px 18px; border-radius: 999px; font-size: .85rem;
  opacity: 0; transition: .25s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .hero { padding-top: 32px; }
  .search { flex-direction: column; }
  .search button { width: 100%; padding: 12px; }
  .help { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
}
