/* ---------- Tokens ---------- */
:root {
  --bg: #f4ecdc;
  --bg-grad: #efe3cb;
  --surface: #fffaf0;
  --surface-2: #f1e7d2;
  --text: #2d2a22;
  --muted: #72695a;
  --olive: #5f7a3a;
  --olive-strong: #4a6129;
  --olive-soft: #e3e8cd;
  --on-olive: #fffaf0;
  --sand-deep: #c9a86a;
  --good: #3f8a3a;
  --good-soft: #dcefd3;
  --bad: #c0533a;
  --bad-soft: #f8ddd4;
  --border: rgba(70, 58, 30, 0.12);
  --shadow: 0 1px 2px rgba(70, 55, 20, 0.06), 0 6px 20px rgba(70, 55, 20, 0.08);
  --shadow-lg: 0 2px 4px rgba(70, 55, 20, 0.06), 0 14px 40px rgba(70, 55, 20, 0.14);
  --radius: 22px;
  --radius-sm: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ar: "Tajawal", "Cairo", "Noto Kufi Arabic", "Geeza Pro", sans-serif;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1e16;
    --bg-grad: #20241a;
    --surface: #262a1f;
    --surface-2: #30352a;
    --text: #efe8d6;
    --muted: #aaa38f;
    --olive: #a5bf70;
    --olive-strong: #c0d590;
    --olive-soft: #36422a;
    --on-olive: #1b1e16;
    --sand-deep: #d6b77a;
    --good: #8cc970;
    --good-soft: #2d4127;
    --bad: #ec8a70;
    --bad-soft: #4a2b23;
    --border: rgba(240, 230, 200, 0.1);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 14px 40px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1e16;
  --bg-grad: #20241a;
  --surface: #262a1f;
  --surface-2: #30352a;
  --text: #efe8d6;
  --muted: #aaa38f;
  --olive: #a5bf70;
  --olive-strong: #c0d590;
  --olive-soft: #36422a;
  --on-olive: #1b1e16;
  --sand-deep: #d6b77a;
  --good: #8cc970;
  --good-soft: #2d4127;
  --bad: #ec8a70;
  --bad-soft: #4a2b23;
  --border: rgba(240, 230, 200, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 14px 40px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-grad) 100%) fixed;
  background-color: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.ar {
  font-family: var(--font-ar);
  direction: rtl;
  unicode-bidi: isolate;
  font-weight: 700;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---------- Top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: center;
  padding: 10px 12px 4px;
  min-height: 60px;
}
.topbar-title {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.01em;
}
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--text);
  transition: background 0.2s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--surface-2); outline: none; }
#backBtn { grid-column: 1; }
.logo { grid-column: 1; grid-row: 1; width: 40px; height: 40px; border-radius: 11px; box-shadow: var(--shadow); }
#themeBtn { }
.top-actions { grid-column: 3; grid-row: 1; display: flex; justify-content: flex-end; gap: 4px; }
.lang-btn { font-family: var(--font-ar); font-size: 18px; font-weight: 700; }
:root[dir="rtl"] .lang-btn { font-family: var(--font); font-size: 14px; }
.logo, #backBtn { justify-self: start; }
#backBtn { grid-row: 1; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

/* ---------- Views ---------- */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 16px 24px;
  outline: none;
}
.view-enter { animation: viewIn 0.35s var(--ease); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px;
  padding: 0 22px;
  border: 0;
  border-radius: 18px;
  font-weight: 600;
  font-size: 17px;
  transition: transform 0.15s var(--ease), background 0.2s, box-shadow 0.2s;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--olive); outline-offset: 2px; }
.btn-primary { background: var(--olive); color: var(--on-olive); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--olive-strong); }
.btn-soft { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.btn-good { background: var(--good-soft); color: var(--good); }
.btn-bad { background: var(--bad-soft); color: var(--bad); }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }

/* ---------- Home ---------- */
.home-hero {
  text-align: center;
  padding: 8px 0 20px;
}
.ring-wrap {
  position: relative;
  width: 200px; height: 200px;
  margin: 8px auto 14px;
}
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { stroke: var(--olive); opacity: 0.16; }
.ring-bar {
  stroke: var(--olive);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s var(--ease);
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-num { font-size: 46px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.ring-num small { font-size: 22px; font-weight: 500; color: var(--muted); }
.ring-label { margin-top: 6px; font-size: 14px; color: var(--muted); }
.home-sub { margin: 0; color: var(--muted); font-size: 15px; }
.home-sub .ar { font-weight: 500; }

.menu { display: grid; gap: 12px; }
.menu-item {
  display: flex; align-items: center; gap: 16px;
  width: 100%;
  min-height: 84px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: start;
  transition: transform 0.18s var(--ease), box-shadow 0.2s;
}
.menu-item:active { transform: scale(0.98); }
.menu-item:focus-visible { outline: 3px solid var(--olive); outline-offset: 2px; }
.menu-icon {
  flex: none;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--olive-soft);
  color: var(--olive-strong);
}
.menu-text { flex: 1; min-width: 0; }
.menu-title { display: block; font-size: 18px; font-weight: 600; }
.menu-desc { display: block; font-size: 14px; color: var(--muted); }
.menu-chev { color: var(--muted); }

/* ---------- Segmented filter ---------- */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border-radius: 16px;
}
.segmented button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ---------- Photo ---------- */
.photo {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
}
.photo img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.credit {
  margin: 6px 6px 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.credit a { color: inherit; }
.photo-dots {
  position: absolute; left: 0; right: 0; bottom: 10px;
  display: flex; justify-content: center; gap: 6px;
  pointer-events: none;
}
.photo-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.photo-dots span.on { background: #fff; }
.photo-tag {
  position: absolute; top: 10px; inset-inline-start: 10px;
  padding: 3px 10px;
  font-size: 12px; font-weight: 600;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.9);
  color: #3b4a23;
}

/* ---------- Flashcards ---------- */
.fc-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
  font-size: 14px; color: var(--muted);
}
.fc-stage {
  position: relative;
  flex: 1;
  min-height: 440px;
  perspective: 1400px;
  touch-action: pan-y;
}
.card {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--ease);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.card.flipped { transform: rotateY(180deg); }
.card-drag { position: absolute; inset: 0; transition: transform 0.35s var(--ease), opacity 0.35s; }
.card-drag.dragging { transition: none; }
.face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face-front .photo { flex: 1; }
.face-front .hint {
  padding: 12px 16px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.face-back {
  transform: rotateY(180deg);
  overflow-y: auto;
}
.face-back .photo { height: 34%; min-height: 130px; flex: none; }
.back-body { padding: 16px 18px 18px; }
.name-en { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.name-ar { margin: 2px 0 0; font-size: 30px; line-height: 1.35; color: var(--olive-strong); text-align: start; }
.name-sci { margin: 2px 0 10px; font-style: italic; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  padding: 4px 10px;
  font-size: 13px; font-weight: 600;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.chip-native { background: var(--olive-soft); color: var(--olive-strong); }
.chip-introduced { background: #f3e2c0; color: #8a5f16; }
:root[data-theme="dark"] .chip-introduced { background: #473a22; color: #e6c27e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip-introduced { background: #473a22; color: #e6c27e; }
}
.fact {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 15px;
}
.fact b { color: var(--olive-strong); }

.swipe-label {
  position: absolute; top: 18px;
  padding: 6px 14px;
  border-radius: 12px;
  font-weight: 700; font-size: 16px;
  opacity: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.1s;
}
.swipe-know { right: 18px; background: var(--good); color: #fff; transform: rotate(8deg); }
.swipe-learn { left: 18px; background: var(--bad); color: #fff; transform: rotate(-8deg); }

.fc-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 16px;
}

/* ---------- Quiz ---------- */
.q-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 8px;
}
.q-progress-bar {
  height: 100%;
  background: var(--olive);
  border-radius: 999px;
  transition: width 0.5s var(--ease);
}
.q-meta { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.q-body { display: flex; flex-direction: column; flex: 1; }
.q-in { animation: slideIn 0.4s var(--ease); }
.q-out { animation: slideOut 0.25s ease-in forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes slideOut { to { opacity: 0; transform: translateX(-40px); } }
.q-prompt { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--muted); }
.q-photo {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 3;
  max-height: 38vh;
  width: 100%;
}
.q-word {
  display: grid; place-items: center;
  min-height: 150px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}
.q-word-text { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.q-word-sci { display: block; margin-top: 6px; font-size: 15px; font-style: italic; color: var(--muted); font-weight: 400; }
.choices { display: grid; gap: 10px; margin-top: 14px; }
.choice {
  width: 100%;
  min-height: 58px;
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 17px; font-weight: 600;
  text-align: center;
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s;
}
.choice.ar { font-size: 22px; font-weight: 700; }
.choice:active { transform: scale(0.98); }
.choice:disabled { cursor: default; }
.choice.correct {
  background: var(--good-soft); border-color: var(--good); color: var(--good);
  animation: pop 0.45s var(--ease);
}
.choice.wrong {
  background: var(--bad-soft); border-color: var(--bad); color: var(--bad);
  animation: shake 0.45s;
}
.choice.dim { opacity: 0.5; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
}
.feedback {
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: viewIn 0.35s var(--ease);
}
.feedback-row { display: flex; gap: 12px; align-items: center; }
.feedback .photo { width: 96px; height: 96px; border-radius: 14px; flex: none; }
.feedback-title { font-weight: 700; margin: 0; }
.feedback-title.good { color: var(--good); }
.feedback-title.bad { color: var(--bad); }
.feedback-names { margin: 2px 0 0; font-size: 15px; }
.feedback-names .ar { font-size: 18px; color: var(--olive-strong); }
.q-next { margin-top: 14px; }

/* ---------- Score ---------- */
.score { text-align: center; padding-top: 12px; }
.score-big { font-size: 72px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; margin: 12px 0 4px; }
.score-big small { font-size: 30px; color: var(--muted); font-weight: 500; }
.score-msg { font-size: 20px; font-weight: 600; margin: 8px 0 4px; }
.score-sub { color: var(--muted); margin: 0 0 20px; }
.review-list { text-align: start; display: grid; gap: 8px; margin: 0 0 20px; }
.review-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.review-item .photo { width: 52px; height: 52px; border-radius: 12px; flex: none; }
.review-item .ar { color: var(--olive-strong); }
.score-actions { display: grid; gap: 10px; }

/* ---------- Progress ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.stat {
  padding: 14px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--muted); }
.section-title { margin: 18px 0 8px; font-size: 15px; font-weight: 600; color: var(--muted); }
.plant-list { display: grid; gap: 8px; }
.plant-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  text-align: start;
  min-height: 72px;
}
.plant-row .photo { width: 56px; height: 56px; border-radius: 14px; flex: none; }
.plant-row-text { flex: 1; min-width: 0; }
.plant-row-en { display: block; font-weight: 600; }
.plant-row-main { display: block; font-weight: 600; }
.plant-row-main .ar { font-size: 18px; }
.plant-row-sub { display: block; font-size: 15px; color: var(--olive-strong); }
.plant-row-sub .ar { font-size: 17px; }
.streak { display: flex; gap: 4px; flex: none; }
.streak i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); }
.streak i.on { background: var(--olive); border-color: var(--olive); }
.badge-mastered {
  flex: none;
  padding: 3px 9px;
  font-size: 12px; font-weight: 700;
  border-radius: 999px;
  background: var(--olive); color: var(--on-olive);
}
.note { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.danger-link {
  margin: 28px auto 0;
  display: block;
  border: 0; background: none;
  color: var(--muted); font-size: 14px; text-decoration: underline;
  min-height: 44px;
}

/* ---------- Plant detail ---------- */
.detail-photos {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.detail-photos::-webkit-scrollbar { display: none; }
.detail-photo { scroll-snap-align: start; }
.detail-photo .photo { aspect-ratio: 4 / 3; border-radius: var(--radius); box-shadow: var(--shadow); }
.detail-body { padding: 14px 4px 0; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.user-photo-label {
  position: absolute; top: 10px; inset-inline-end: 10px;
  padding: 3px 10px;
  font-size: 12px; font-weight: 600;
  border-radius: 999px;
  background: var(--olive); color: var(--on-olive);
}

/* ---------- Empty / misc ---------- */
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 22px; margin: 10px 0 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--text); color: var(--bg);
  font-size: 15px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  max-width: calc(100% - 32px);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; }

@media (min-height: 800px) {
  .fc-stage { min-height: 520px; }
}

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

/* ---------- Arabic interface ---------- */
:root[dir="rtl"] body { font-family: var(--font-ar); }
:root[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
:root[dir="rtl"] .menu-title, :root[dir="rtl"] .score-msg, :root[dir="rtl"] .q-prompt { font-weight: 700; }
:root[dir="rtl"] .q-in { animation-name: slideInRtl; }
:root[dir="rtl"] .q-out { animation-name: slideOutRtl; }
@keyframes slideInRtl { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
@keyframes slideOutRtl { to { opacity: 0; transform: translateX(40px); } }
[lang="en"], [lang="la"] { font-family: var(--font); }

/* ---------- Names + read aloud ---------- */
.names { margin-bottom: 10px; }
.names .name-en, .names .name-ar, .names .name-sci { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
:root[dir="rtl"] .names .name-en { justify-content: flex-end; }
.names .name-sci { margin: 4px 0 0; color: var(--muted); }
.say-guide { margin: 2px 0 0; font-size: 13px; color: var(--muted); text-align: start; }
.say-guide bdi { letter-spacing: 0.02em; font-family: var(--font); }
:root:not([dir="rtl"]) .names .name-ar { justify-content: flex-end; }
.say-guide span { font-weight: 600; }
.speak-btn {
  flex: none;
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  margin-inline-start: 2px;
  border: 0; border-radius: 50%;
  background: var(--olive-soft);
  color: var(--olive-strong);
  vertical-align: middle;
  transition: transform 0.15s var(--ease), background 0.2s;
}
.speak-btn:active { transform: scale(0.92); }
.speak-btn.speaking { animation: pulse 0.9s var(--ease); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(95, 122, 58, 0.45); } 100% { box-shadow: 0 0 0 12px rgba(95, 122, 58, 0); } }
.feedback-names .speak-btn { width: 30px; height: 30px; }
.feedback-names .speak-btn svg { width: 15px; height: 15px; }
.feedback-text { min-width: 0; }

/* ---------- Photo parts + thumbnails ---------- */
.photo-part {
  position: absolute; bottom: 10px; inset-inline-start: 10px;
  padding: 3px 10px;
  font-size: 12px; font-weight: 600;
  border-radius: 999px;
  background: rgba(27, 30, 22, 0.62);
  color: #fffaf0;
  backdrop-filter: blur(4px);
}
.photo-part.mine { background: var(--olive); color: var(--on-olive); }
.thumbs { display: flex; gap: 8px; margin: 10px 0 0; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.thumbs::-webkit-scrollbar { display: none; }
.thumb {
  flex: none; width: 58px; height: 58px; padding: 0;
  border: 2px solid transparent; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); opacity: 0.65;
  transition: opacity 0.2s, border-color 0.2s;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.on { opacity: 1; border-color: var(--olive); }
.del-btn { margin-top: 6px; }
.chip-tiny { font-size: 11px; padding: 1px 7px; }
.note-tight { margin: -4px 0 8px; }
.stats-detail { margin-top: 18px; }
.intro { margin: 0 0 14px; color: var(--muted); }
.fc-wrap, .q-shell { display: flex; flex-direction: column; flex: 1; }

/* ---------- Maps ---------- */
.mini-map, .big-map {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--surface-2);
  z-index: 0;
}
.mini-map { height: 210px; cursor: pointer; }
.big-map { height: 58vh; min-height: 340px; margin-bottom: 8px; }
.map-msg { margin: 0; padding: 40px 16px; text-align: center; color: var(--muted); }
.map-msg-float { position: absolute; inset: auto 12px 12px; padding: 8px 12px; border-radius: 12px; background: var(--surface); z-index: 500; }
.leaflet-container { font-family: inherit; background: var(--surface-2); direction: ltr; }
.mini-map, .big-map { direction: ltr; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.6); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.6); }
}
.leaflet-control-attribution { font-size: 10px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper { border-radius: 16px; }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--border); }
.spot-pin span {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--olive);
  color: var(--on-olive);
  font: 700 14px/1 var(--font);
  border: 3px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.spot-pin span:empty::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--on-olive); }
.sight-pin img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #f2c14e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.pop-title { margin: 0 0 8px; font-weight: 700; font-size: 15px; }
.pop-plants { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pop-plant { display: flex; align-items: center; gap: 6px; color: var(--text) !important; text-decoration: none; font-size: 13px; font-weight: 600; line-height: 1.2; }
.pop-plant img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none; }
.pop-sight img { width: 64px; height: 64px; border-radius: 12px; }
.place-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.note a { color: var(--olive-strong); font-weight: 600; }
.toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 6px; font-weight: 600; font-size: 15px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--olive); }
.focus-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; padding: 8px 8px 8px 14px; border-radius: 16px; background: var(--olive-soft); color: var(--olive-strong); font-weight: 600; }
.places { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.place-card {
  display: block; width: 100%; min-width: 0; overflow: hidden;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: start;
}
.place-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.place-name { font-weight: 600; }
.place-count { flex: none; font-size: 13px; color: var(--muted); }
.place-thumbs { display: flex; gap: 6px; overflow: hidden; }
.place-thumbs img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; }

/* ---------- Native range ---------- */
.range-card { padding: 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.range-map { display: block; width: 100%; height: auto; border-radius: 12px; background: #dfe8ea; }
.range-map path { fill: #efe6d2; stroke: #c9bb9c; stroke-width: 0.3; }
.range-map path.on { fill: var(--olive); stroke: #465c29; }
.riyadh-dot { fill: #c0533a; stroke: #fff; stroke-width: 0.6; }
.riyadh-label { fill: #7a2f1e; font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 0.8px; font-family: var(--font); }
:root[dir="rtl"] .riyadh-label { font-family: var(--font-ar); }
.range-text { margin: 8px 4px 2px; font-size: 15px; }
:root[data-theme="dark"] .range-map { background: #1f2a2d; }
:root[data-theme="dark"] .range-map path { fill: #3a3f33; stroke: #555c4a; }
:root[data-theme="dark"] .range-map path.on { fill: var(--olive); stroke: #c0d590; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .range-map { background: #1f2a2d; }
  :root:not([data-theme="light"]) .range-map path { fill: #3a3f33; stroke: #555c4a; }
  :root:not([data-theme="light"]) .range-map path.on { fill: var(--olive); stroke: #c0d590; }
}

/* ---------- Look-alikes ---------- */
.look-card { margin-bottom: 12px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.look-pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.look-side { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; text-align: center; min-width: 0; }
.look-side .photo { aspect-ratio: 1; border-radius: 14px; }
.look-side.current .photo { outline: 3px solid var(--olive); outline-offset: 2px; }
.look-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.look-sub { font-size: 13px; color: var(--muted); }
.look-vs { font-weight: 700; color: var(--muted); font-size: 13px; font-family: var(--font); }
.look-tip { margin: 10px 2px 0; font-size: 15px; }

/* ---------- Photo arrows ---------- */
.ph-nav {
  position: absolute; top: 50%; z-index: 4;
  width: 44px; height: 44px; margin-top: -22px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 250, 240, 0.88);
  color: #2d2a22;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s var(--ease);
}
.ph-nav:active { transform: scale(0.9); }
.ph-prev { left: 10px; }
.ph-next { right: 10px; }
.ph-count {
  position: absolute; bottom: 10px; right: 10px; z-index: 4;
  padding: 2px 9px; border-radius: 999px;
  font: 600 12px/1.6 var(--font);
  background: rgba(27, 30, 22, 0.62); color: #fffaf0;
}
.face-back .ph-count { bottom: auto; top: 10px; }
.strip-nav { position: relative; height: 0; }
.strip-nav .ph-nav { top: -150px; }
.strip-nav .ph-count { display: none; }
@media (min-width: 480px) { .strip-nav .ph-nav { top: -190px; } }

/* ---------- Care guide ---------- */
.care-card { padding: 6px 14px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.care-row { display: grid; grid-template-columns: 28px minmax(0, 0.9fr) minmax(0, 1.4fr); gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.care-ico { font-size: 18px; text-align: center; }
.care-label { color: var(--muted); font-weight: 600; font-size: 14px; }
.care-val { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meter { display: inline-flex; gap: 3px; }
.meter i { width: 10px; height: 10px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); }
.meter i.on { background: var(--olive); border-color: var(--olive); }
.care-bloom { grid-template-columns: 28px minmax(0, 1fr); }
.care-bloom .care-label { grid-column: 2; }
.bloom { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; }
.bloom span { text-align: center; font-size: 10px; padding: 5px 0; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.bloom span.on { background: #e9b949; color: #3b2a05; font-weight: 700; }
.care-tip { margin: 12px 0 0; font-size: 15px; line-height: 1.6; }
.care-warn { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-size: 14px; font-weight: 600; }
.types { display: grid; gap: 8px; }
.type-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.type-item.here { border-color: var(--olive); }
.type-item img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: none; }
.type-item p { margin: 0; font-size: 14px; }
.type-item a { color: var(--olive-strong); font-weight: 700; }
.sources { display: flex; flex-wrap: wrap; gap: 8px; }
.source-link { padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--olive-strong); font-weight: 600; font-size: 14px; text-decoration: none; }
.ref-list { padding-inline-start: 20px; display: grid; gap: 10px; }
.ref-list a { color: var(--olive-strong); font-weight: 600; }

/* ---------- Wiki ---------- */
.search {
  width: 100%; min-height: 48px; margin-bottom: 12px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.search:focus { outline: 3px solid var(--olive); outline-offset: 1px; }
.wiki-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 480px) { .wiki-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.wiki-card { display: flex; flex-direction: column; gap: 2px; padding: 0 0 10px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; text-align: start; }
.wiki-card .photo { aspect-ratio: 4 / 3; margin-bottom: 6px; }
.wiki-name, .wiki-sub, .wiki-icons { padding: 0 10px; }
.wiki-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.wiki-sub { font-size: 13px; color: var(--olive-strong); }
.wiki-icons { font-size: 12px; display: flex; gap: 8px; margin-top: 2px; }
