:root {
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --bg: linear-gradient(135deg, #eef2ff 0%, #ffffff 50%, #faf5ff 100%);
  --text: #1e293b;
  --muted: #64748b;
  --card: #fff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

html[dir="rtl"] body { font-family: "Vazirmatn", system-ui, sans-serif; }
html[dir="ltr"] body { font-family: "Nunito", system-ui, sans-serif; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 1rem; }
.main { padding: 1.5rem 1rem 3rem; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid #e0e7ff;
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .85rem 1rem;
}

.logo { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; }
.logo-emoji { font-size: 1.8rem; }
.logo strong { display: block; color: var(--brand); font-size: 1.15rem; }
.logo small { color: #818cf8; font-size: .7rem; }

.header-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.user-chip {
  font-size: .85rem; font-weight: 700; color: #475569;
  background: #f1f5f9; padding: .35rem .7rem; border-radius: 999px;
}

.nav-row {
  display: flex; gap: .75rem; padding: 0 1rem .75rem;
  overflow-x: auto;
}
.nav-row a {
  font-weight: 800; font-size: .9rem;
  background: #eef2ff; color: var(--brand);
  padding: .4rem .85rem; border-radius: 999px;
  text-decoration: none; white-space: nowrap;
}
.nav-row a:hover { background: #e0e7ff; }

.site-footer {
  border-top: 1px solid #e0e7ff;
  background: rgba(255,255,255,.7);
  padding: 1.25rem 0;
  margin-top: auto;
}
.footer-inner { text-align: center; }
.muted { color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; cursor: pointer; font-weight: 800; font-size: .9rem;
  padding: .55rem 1rem; border-radius: 999px; text-decoration: none;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
.btn-ghost { background: #eef2ff; color: var(--brand); }
.btn-success { background: #22c55e; color: #fff; }
.btn-warn { background: #fbbf24; color: #78350f; }
.btn-danger { background: #f87171; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.hero { text-align: center; padding: 2.5rem 0 1rem; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 3rem); color: #312e81; margin: .5rem 0; }
.hero p { color: var(--muted); max-width: 36rem; margin: 0 auto 1.5rem; font-size: 1.05rem; }
.hero-emoji { font-size: 4.5rem; margin: 0; }
.cta-row { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }
.cta-row .btn { padding: .9rem 1.5rem; font-size: 1.05rem; }
.btn-emerald { background: #059669; color: #fff; }
.btn-emerald:hover { background: #047857; text-decoration: none; }

.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: var(--card); border: 2px solid #e0e7ff; border-radius: 1.25rem;
  padding: 1.25rem; box-shadow: 0 1px 2px rgba(79,70,229,.06);
}
.card h2, .card h3 { margin-top: 0; color: #312e81; }
.level-card { transition: transform .15s ease; }
.level-card:hover { transform: translateY(-3px); text-decoration: none; display: block; color: inherit; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 800;
  padding: .25rem .6rem; border-radius: 999px; background: #eef2ff; color: var(--brand);
}

.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab {
  border: 1px solid #e2e8f0; background: #fff; color: #475569;
  padding: .45rem 1rem; border-radius: 999px; font-weight: 800; cursor: pointer;
}
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.ide-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.ide-grid { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .ide-grid { grid-template-columns: 1fr 1fr; } }

.ide-label {
  font-size: .7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; color: var(--brand); margin-bottom: .25rem;
}
.ide-code {
  width: 100%; min-height: 260px; font-family: ui-monospace, Consolas, monospace;
  font-size: .9rem; border: 2px solid #c7d2fe; border-radius: .75rem; padding: .75rem;
  resize: vertical; direction: ltr; text-align: left;
}
.ide-console {
  min-height: 8rem; background: #0f172a; color: #4ade80;
  border-radius: .75rem; padding: .75rem; font-family: ui-monospace, Consolas, monospace;
  font-size: .85rem; overflow: auto; white-space: pre-wrap;
}
.ide-console.error { border: 2px solid #f87171; color: #fca5a5; }
.turtle-box {
  background: #fff; border: 2px solid #c7d2fe; border-radius: .75rem;
  min-height: 300px; overflow: hidden;
}
.turtle-box canvas { display: block; max-width: 100%; }
.hint-box {
  background: #fffbeb; border: 2px solid #fde68a; color: #92400e;
  border-radius: .75rem; padding: .75rem; margin: .5rem 0; font-weight: 600;
}
.success-box {
  background: #dcfce7; color: #166534; border-radius: .75rem;
  padding: .85rem; text-align: center; font-weight: 800; margin-top: .75rem;
}

.lab-item { margin-bottom: 1rem; }
.lab-head {
  width: 100%; text-align: start; background: #fff; border: 2px solid #e0e7ff;
  border-radius: 1rem; padding: 1rem 1.15rem; cursor: pointer; font: inherit;
}
.lab-item.open .lab-head { border-color: #818cf8; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.lab-body {
  display: none; border: 2px solid #818cf8; border-top: 0;
  border-radius: 0 0 1rem 1rem; padding: 1rem 1.15rem 1.25rem; background: #fff;
}
.lab-item.open .lab-body { display: block; }

.form { max-width: 28rem; margin: 0 auto; }
.form label { display: block; font-weight: 800; margin: .75rem 0 .35rem; }
.form input, .form select, .form textarea {
  width: 100%; padding: .65rem .75rem; border: 2px solid #e2e8f0;
  border-radius: .75rem; font: inherit;
}
.alert {
  padding: .75rem 1rem; border-radius: .75rem; margin-bottom: 1rem; font-weight: 700;
}
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { border-bottom: 1px solid #e2e8f0; padding: .55rem .4rem; text-align: start; }
.table th { font-weight: 800; color: #4338ca; }

.steps { padding-inline-start: 1.2rem; }
.steps li { margin: .35rem 0; }

.stat-grid {
  display: grid;
  gap: .85rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: 1rem 0;
}
.stat-card {
  background: #fff;
  border: 2px solid #e0e7ff;
  border-radius: 1rem;
  padding: 1rem;
  text-align: center;
}
.stat-card .num {
  font-size: 1.75rem;
  font-weight: 900;
  color: #3730a3;
  line-height: 1.1;
}
.stat-card .lbl {
  font-size: .8rem;
  font-weight: 700;
  color: #64748b;
  margin-top: .35rem;
}
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1rem 0 1.25rem;
}
.bar-row {
  display: grid;
  grid-template-columns: 7rem 1fr 3rem;
  gap: .5rem;
  align-items: center;
  margin: .4rem 0;
  font-size: .9rem;
}
.bar-track {
  background: #eef2ff;
  border-radius: 999px;
  height: .65rem;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #4f46e5);
  border-radius: 999px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: end;
  margin-bottom: 1rem;
}
.filters label { margin: 0; font-size: .8rem; }
.filters input, .filters select {
  padding: .45rem .6rem;
  border: 2px solid #e2e8f0;
  border-radius: .65rem;
  font: inherit;
}

.contact-hero {
  padding: 1rem 0 2rem;
}
.contact-panel {
  max-width: 40rem;
  margin: 0 auto;
  background: #fff;
  border: 2px solid #e0e7ff;
  border-radius: 1.5rem;
  padding: 1.75rem 1.5rem 2rem;
  box-shadow: 0 12px 40px rgba(79, 70, 229, 0.08);
}
.contact-panel h1 {
  margin: .5rem 0 .35rem;
  color: #312e81;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}
.contact-panel .lead {
  color: #64748b;
  margin: 0 0 1.25rem;
  line-height: 1.7;
}
.contact-form label {
  display: block;
  font-weight: 800;
  margin: .85rem 0 .35rem;
  color: #3730a3;
}
.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: .75rem .9rem;
  border: 2px solid #e2e8f0;
  border-radius: .9rem;
  font: inherit;
  background: #f8fafc;
  transition: border-color .15s ease, background .15s ease;
}
.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: #818cf8;
  background: #fff;
}
.contact-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .contact-grid { grid-template-columns: 1fr 1fr; }
}
.contact-actions {
  margin-top: 1.25rem;
}
.btn-lg {
  padding: .85rem 1.5rem;
  font-size: 1.05rem;
}
