/* =========================================================
   أثَر — 1970s environmental print aesthetic
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --paper: #f4e6c8;
  --paper-2: #efddb8;
  --card: #fbf2de;
  --ink: #3e2a1e;
  --ink-soft: #5a4636;
  --olive: #6e7b3f;
  --mustard: #d9a227;
  --burnt: #c2571b;
  --clay: #a8b37a;
}

html,
body {
  margin: 0;
  padding: 0;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button {
  font-family: inherit;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--ink-soft);
  opacity: 0.8;
}

/* ---------- paper grain ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.11;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}

/* ---------- shell ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--olive);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-text h1 {
  margin: 0;
  font-family: "Baloo Bhaijaan 2", "IBM Plex Sans Arabic", sans-serif;
  font-weight: 800;
  font-size: 30px;
  line-height: 1.05;
  color: var(--ink);
}

.brand-text p {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink-soft);
}

.icon-btn {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn.small {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  box-shadow: none;
}

.icon-btn.small svg {
  width: 18px;
  height: 18px;
}

.icon-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.icon-btn:focus-visible,
.level-chip:focus-visible,
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.btn-share:focus-visible,
.btn-danger:focus-visible,
.speak-btn:focus-visible,
.day-dot:focus-visible {
  outline: 3px solid var(--olive);
  outline-offset: 3px;
}

/* ---------- plant scene ---------- */
.plant-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bubble {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 22px;
  padding: 11px 14px;
  box-shadow: 4px 4px 0 var(--ink);
}

.bubble::after {
  content: "";
  position: absolute;
  bottom: -11px;
  left: 50%;
  width: 16px;
  height: 16px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--card);
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
}

.bubble p {
  flex: 1;
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
}

.speak-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  transition: transform 0.12s ease;
}

.speak-btn svg {
  width: 18px;
  height: 18px;
}

.speak-btn:active {
  transform: scale(0.92);
}

.plant-stage {
  position: relative;
  width: 100%;
  height: 196px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-top: 12px;
}

.plant-wrap {
  width: 158px;
  max-width: 56vw;
  --grow: 0.86;
}

.plant-scale {
  transform-origin: 50% 100%;
  transform: scale(var(--grow));
  transition: transform 0.7s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.plant-bob {
  transform-origin: 50% 92%;
  animation: sway 4.5s ease-in-out infinite;
}

.mood-sleepy .plant-bob {
  animation-duration: 7.5s;
}

.plant {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-1.7deg);
  }
  50% {
    transform: rotate(1.7deg);
  }
}

@keyframes hop {
  0% {
    transform: scale(var(--grow)) translateY(0) rotate(0deg);
  }
  22% {
    transform: scale(var(--grow)) translateY(-22px) rotate(-4deg);
  }
  48% {
    transform: scale(var(--grow)) translateY(0) rotate(0deg);
  }
  68% {
    transform: scale(var(--grow)) translateY(-10px) rotate(3deg);
  }
  100% {
    transform: scale(var(--grow)) translateY(0) rotate(0deg);
  }
}

.plant-wrap.celebrate .plant-scale {
  animation: hop 0.9s ease-in-out;
}

/* svg growth parts */
.leaves {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scale(0.25);
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.65s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.stage-1 .leaves,
.stage-2 .leaves {
  opacity: 1;
  transform: scale(1);
}

.stage-2 .leaves {
  transform: scale(1.06);
}

.flower {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scale(0.35);
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.65s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.stage-2 .flower {
  opacity: 1;
  transform: scale(1);
}

.eyes-closed,
.zzz {
  opacity: 0;
}

.mouth-happy {
  opacity: 0;
}

.mood-happy .eyes-open {
  opacity: 1;
}

.mood-happy .mouth-calm {
  opacity: 0;
}

.mood-happy .mouth-happy {
  opacity: 1;
}

.mood-sleepy .eyes-open {
  opacity: 0;
}

.mood-sleepy .eyes-closed {
  opacity: 1;
}

.mood-sleepy .zzz {
  opacity: 1;
  animation: zzzPulse 3.2s ease-in-out infinite;
}

@keyframes zzzPulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

/* leaf burst */
.leaf-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.leafbit {
  position: absolute;
  left: 50%;
  bottom: 42%;
  width: 13px;
  height: 13px;
  background: var(--olive);
  border: 2.5px solid var(--ink);
  border-radius: 50% 0 50% 50%;
  animation: fly 950ms ease-out both;
}

@keyframes fly {
  0% {
    transform: translate(-50%, 0) rotate(0deg) scale(0.5);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), var(--dy)) rotate(var(--rot)) scale(1);
    opacity: 0;
  }
}

.plant-caption {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 18px;
}

.card-title {
  margin: 0 0 12px;
  font-family: "Baloo Bhaijaan 2", "IBM Plex Sans Arabic", sans-serif;
  font-weight: 800;
  font-size: 19px;
  line-height: 1.2;
  color: var(--ink);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pill {
  display: inline-block;
  background: var(--clay);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 1px 12px 2px;
  font-family: "Baloo Bhaijaan 2", sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.5;
}

.date-small {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: end;
}

/* level chips */
.level-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.level-chip {
  flex: 1;
  min-height: 44px;
  padding: 0 6px;
  background: transparent;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 14px;
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.12s ease;
}

.level-chip[aria-pressed="true"] {
  background: var(--mustard);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.level-chip:active {
  transform: translateY(1px);
}

.level-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* challenge body */
.challenge-body {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  margin-top: 16px;
}

.ch-icon-wrap {
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--olive);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 3px 3px 0 var(--ink);
}

.ch-icon-wrap svg {
  width: 27px;
  height: 27px;
}

.challenge-text {
  min-width: 0;
}

.challenge-text h2 {
  margin: 0 0 3px;
  font-family: "Baloo Bhaijaan 2", "IBM Plex Sans Arabic", sans-serif;
  font-weight: 800;
  font-size: 21px;
  line-height: 1.3;
  color: var(--ink);
}

.challenge-text p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.impact-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.imp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 2px 11px 3px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

/* primary button */
.btn-primary {
  width: 100%;
  min-height: 56px;
  margin-top: 16px;
  padding: 10px 16px;
  background: var(--mustard);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 18px;
  font-family: "Baloo Bhaijaan 2", "IBM Plex Sans Arabic", sans-serif;
  font-weight: 800;
  font-size: 19px;
  line-height: 1.2;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary:active {
  transform: translate(4px, 4px);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn-sm {
  min-height: 46px;
  font-size: 15.5px;
  margin-top: 8px;
  box-shadow: 3px 3px 0 var(--ink);
}

.btn-ghost {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  padding: 8px 14px;
  background: transparent;
  color: var(--ink);
  border: 3px dashed var(--ink);
  border-radius: 16px;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.btn-ghost:active {
  background: var(--paper);
}

.btn-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 54px;
  background: var(--olive);
  color: #fbf2de;
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 5px 5px 0 var(--ink);
  font-family: "Baloo Bhaijaan 2", "IBM Plex Sans Arabic", sans-serif;
  font-weight: 800;
  font-size: 17px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-share svg {
  width: 21px;
  height: 21px;
}

.btn-share:active {
  transform: translate(4px, 4px);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn-danger {
  width: 100%;
  min-height: 50px;
  padding: 8px 14px;
  background: var(--burnt);
  color: #fbf2de;
  border: 3px solid var(--ink);
  border-radius: 16px;
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.12s ease;
}

.btn-danger:active {
  transform: translateY(2px);
}

/* done badge */
.done-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--clay);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 18px;
}

.check-ic {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 4px;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  color: var(--olive);
}

.done-text strong {
  display: block;
  font-family: "Baloo Bhaijaan 2", sans-serif;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.3;
}

.done-text span {
  display: block;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* AI panel */
.ai-panel {
  margin-top: 12px;
  padding: 13px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 18px;
}

.ai-msg {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
}

.ai-fine {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.ai-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.ai-sug {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-sug strong {
  font-family: "Baloo Bhaijaan 2", sans-serif;
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
}

.ai-sug span {
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* ---------- streak ---------- */
.streak-stats {
  display: flex;
  gap: 10px;
}

.stat {
  flex: 1;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 7px 8px 9px;
  text-align: center;
}

.stat-num {
  display: block;
  font-family: "Baloo Bhaijaan 2", sans-serif;
  font-weight: 800;
  font-size: 30px;
  line-height: 1.1;
  color: var(--ink);
}

.stat-lbl {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.week-strip {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: 14px;
}

.day-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.day-dot {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 50%;
}

.day-dot svg {
  width: 18px;
  height: 18px;
}

.day-dot.is-done {
  background: var(--olive);
  color: #fbf2de;
}

.day-dot.is-miss {
  background: var(--paper-2);
  border-style: dashed;
  color: var(--ink-soft);
}

.day-dot.is-today {
  background: var(--mustard);
  color: var(--ink);
  animation: pulseRing 2.2s ease-out infinite;
}

@keyframes pulseRing {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(217, 162, 39, 0.55);
  }
  55% {
    box-shadow: 0 0 0 7px rgba(217, 162, 39, 0);
  }
}

.ping {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  display: block;
}

.day-letter {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

.is-today-col .day-letter {
  color: var(--ink);
}

/* ---------- impact ---------- */
.impact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.impact-item {
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 9px 6px 10px;
  text-align: center;
}

.impact-num {
  display: block;
  font-family: "Baloo Bhaijaan 2", sans-serif;
  font-weight: 800;
  font-size: clamp(30px, 9.5vw, 44px);
  line-height: 1.02;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.impact-unit {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  font-weight: 700;
  color: var(--burnt);
}

.impact-lbl {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
}

.compare {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--paper-2);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.6;
}

.fine {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- footer ---------- */
.app-foot {
  text-align: center;
}

.app-foot p {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ---------- modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(62, 42, 30, 0.5);
}

.modal.hidden {
  display: none !important;
}

#confirmModal {
  z-index: 260;
}

.modal-panel {
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 18px;
  animation: popIn 0.22s ease-out;
}

@keyframes popIn {
  from {
    transform: scale(0.94);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-head h2 {
  margin: 0;
  font-family: "Baloo Bhaijaan 2", sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
}

.modal-panel h2 {
  font-family: "Baloo Bhaijaan 2", sans-serif;
  font-weight: 800;
  font-size: 20px;
  margin: 0 0 8px;
  color: var(--ink);
}

.hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 2px dashed rgba(62, 42, 30, 0.28);
}

.hist-row:last-child {
  border-bottom: 0;
}

.hist-date {
  flex: none;
  min-width: 66px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.hist-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: break-word;
}

.hist-imp {
  flex: none;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--burnt);
  white-space: nowrap;
}

.modal-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 3px solid var(--ink);
}

.conf-text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-soft);
}

.conf-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conf-actions .btn-ghost {
  margin-top: 0;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 300;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 11px 20px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  box-shadow: 4px 4px 0 rgba(62, 42, 30, 0.35);
}

.toast.hidden {
  display: none !important;
}

.toast.show {
  animation: toastIn 0.25s ease-out;
}

@keyframes toastIn {
  from {
    transform: translate(-50%, 14px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* ---------- small screens ---------- */
@media (max-width: 360px) {
  .app {
    padding: 14px 12px 34px;
    gap: 14px;
  }

  .card {
    padding: 15px;
    border-radius: 20px;
  }

  .brand-text h1 {
    font-size: 26px;
  }

  .challenge-text h2 {
    font-size: 19px;
  }

  .day-dot {
    width: 32px;
    height: 32px;
  }

  .impact-num {
    font-size: 30px;
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .plant-bob,
  .plant-wrap.celebrate .plant-scale,
  .day-dot.is-today,
  .mood-sleepy .zzz,
  .leafbit,
  .modal-panel,
  .toast.show {
    animation: none !important;
  }

  .plant-scale,
  .leaves,
  .flower {
    transition: none !important;
  }
}