/* Greeny — design tokens from the Greeny design system
   Theme 1 "Fresh Greenhouse" (default) · Theme 2 "Botanical Editorial" */

:root,
[data-theme="theme1"] {
  --surface-100: #f2faf4;
  --surface-raised: #ffffff;
  --surface-sunken: #e7f5ea;
  --ink: #163420;
  --ink-muted: #4d6b58;
  --brand: #2f9e54;
  --brand-strong: #1f7a3d;
  --accent: #ff8a5c;
  --signal-warning: #e2a33d;
  --signal-error: #d6534a;
  --border: #d6ecdd;
  --on-brand: #ffffff;
}

[data-theme="theme2"] {
  --surface-100: #faf7f1;
  --surface-raised: #ffffff;
  --surface-sunken: #f1ead9;
  --ink: #28211a;
  --ink-muted: #6b6050;
  --brand: #3c6b46;
  --brand-strong: #274f30;
  --accent: #b5793a;
  --signal-warning: #c08a2e;
  --signal-error: #b8463d;
  --border: #e4d9bf;
  --on-brand: #ffffff;
}

:root {
  --space-4: 4px;  --space-8: 8px;   --space-12: 12px;
  --space-16: 16px; --space-24: 24px; --space-32: 32px; --space-48: 48px;
  --radius-sm: 6px; --radius-md: 12px; --radius-lg: 20px; --radius-pill: 999px;
  --display: "Poppins", "Segoe UI", system-ui, sans-serif;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: #dfe9e2;
}

/* ---------- device shell ---------- */

#shell {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#device {
  position: relative;
  width: 390px;
  height: 844px;
  background: var(--surface-100);
  border-radius: 44px;
  overflow: hidden;
  box-shadow: 0 0 0 11px #11231a, 0 26px 60px rgba(14, 40, 25, 0.35);
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease;
}

@media (max-width: 480px) {
  #shell { padding: 0; }
  #device {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* ---------- screens ---------- */

#screens { position: relative; flex: 1; overflow: hidden; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--surface-100);
}

.screen.is-active { display: flex; animation: screenIn 0.3s cubic-bezier(0.22, 0.9, 0.3, 1); }
.screen.is-back { animation: screenBack 0.3s cubic-bezier(0.22, 0.9, 0.3, 1); }

@keyframes screenIn   { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes screenBack { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }

.body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.pad { padding: 0 16px; }

/* ---------- type ---------- */

h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.4px; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
p  { margin: 0; }

.display-lg { font-family: var(--display); font-size: 36px; font-weight: 700; line-height: 40px; letter-spacing: -0.8px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 1.4px; color: var(--ink-muted); }
.muted { color: var(--ink-muted); }
.body-sm { font-size: 13px; line-height: 18px; }
.section-label { font-size: 12px; font-weight: 600; letter-spacing: 1.2px; color: var(--ink-muted); margin: 20px 0 10px; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 10px;
  flex-shrink: 0;
}
.topbar .title { font-family: var(--display); font-weight: 600; font-size: 17px; flex: 1; }

.icon-btn {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  border-radius: var(--radius-pill);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; color: var(--ink);
  transition: transform 0.12s ease, background 0.15s ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.plain { border: none; background: none; }

/* ---------- buttons ---------- */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  font-family: var(--sans); font-size: 16px; font-weight: 600;
  padding: 16px; border-radius: var(--radius-pill);
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--brand-strong); color: var(--on-brand); }
.btn-ghost { background: var(--surface-raised); color: var(--brand-strong); border-color: var(--border); }
.btn-text { background: none; color: var(--brand-strong); border: none; font-size: 15px; padding: 12px; }
.btn-row { display: flex; flex-direction: column; gap: 10px; padding: 16px; flex-shrink: 0; }

.chip {
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  padding: 11px 15px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-raised);
  color: var(--ink-muted); cursor: pointer; white-space: nowrap;
  transition: transform 0.12s ease;
}
.chip:active { transform: scale(0.95); }
.chip.is-on { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }

/* ---------- cards & fields ---------- */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px;
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.field .err { display: none; font-size: 12px; color: var(--signal-error); margin-top: 5px; font-weight: 500; }
.field.has-err input { border-color: var(--signal-error); }
.field.has-err .err { display: block; animation: shake 0.3s; }

@keyframes shake { 25% { transform: translateX(-4px) } 75% { transform: translateX(4px) } }

.pill {
  font-size: 11px; font-weight: 600;
  padding: 5px 10px; border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.pill-ok   { background: var(--surface-sunken); color: var(--brand-strong); }
.pill-warn { background: var(--signal-warning); color: var(--ink); }
.pill-accent { background: var(--accent); color: var(--ink); }

/* ---------- bottom nav ---------- */

.nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface-raised);
  padding: 8px 0 14px;
  flex-shrink: 0;
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-decoration: none; color: var(--ink-muted);
  font-size: 11px; font-weight: 500;
  padding: 4px 0;
  transition: color 0.15s ease;
}
.nav a.is-on { color: var(--brand-strong); font-weight: 600; }
.nav a:active svg { transform: scale(0.88); }
.nav svg { transition: transform 0.12s ease; }

/* ---------- Greeny character ---------- */

.greeny-float { animation: gfloat 3.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.greeny-eyes  { animation: gblink 4.6s infinite; transform-box: fill-box; transform-origin: 50% 50%; }
.greeny-mouth { animation: gtalk 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0; }
.greeny-arm-l { animation: gwavel 3.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 100% 50%; }
.greeny-arm-r { animation: gwaver 3.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 0 50%; }

@keyframes gfloat { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
@keyframes gblink { 0%, 91%, 100% { transform: scaleY(1) } 94% { transform: scaleY(0.08) } 97% { transform: scaleY(1) } }
@keyframes gtalk  { 0%, 100% { transform: scaleY(1) } 50% { transform: scaleY(1.35) } }
@keyframes gwavel { 0%, 100% { transform: rotate(0) } 50% { transform: rotate(-9deg) } }
@keyframes gwaver { 0%, 100% { transform: rotate(0) } 50% { transform: rotate(9deg) } }

/* ---------- splash ---------- */

#splash {
  position: absolute; inset: 0; z-index: 40;
  background: var(--surface-sunken);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
  transition: opacity 0.45s ease, visibility 0.45s;
}
#splash.is-gone { opacity: 0; visibility: hidden; }
#splash .wordmark {
  font-family: var(--display); font-weight: 700; font-size: 34px;
  color: var(--brand-strong);
  animation: riseIn 0.7s 0.15s both;
}
#splash .tag { font-size: 13.5px; color: var(--ink-muted); animation: riseIn 0.7s 0.3s both; }
#splash .track { width: 150px; height: 5px; border-radius: 999px; background: var(--border); overflow: hidden; }
#splash .track i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--brand-strong); animation: loadbar 2s 0.2s ease-out forwards; }

@keyframes riseIn  { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@keyframes loadbar { to { width: 100% } }

/* ---------- misc animation ---------- */

.rise { animation: riseIn 0.45s both; }
.rise-1 { animation-delay: 0.05s } .rise-2 { animation-delay: 0.1s }
.rise-3 { animation-delay: 0.15s } .rise-4 { animation-delay: 0.2s }
.rise-5 { animation-delay: 0.25s } .rise-6 { animation-delay: 0.3s }

.spinner {
  width: 24px; height: 24px; border-radius: 999px;
  border: 3px solid var(--border); border-top-color: var(--brand-strong);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--border) 50%, var(--surface-sunken) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 10px;
}
@keyframes shimmer { to { background-position: -300% 0 } }

#toast {
  position: absolute; left: 16px; right: 16px; bottom: 96px; z-index: 50;
  background: var(--ink); color: #fff;
  font-size: 14px; font-weight: 500;
  padding: 13px 16px; border-radius: var(--radius-md);
  opacity: 0; transform: translateY(14px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
#toast.is-on { opacity: 1; transform: none; }

.pop { animation: pop 0.34s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { 0% { transform: scale(1) } 45% { transform: scale(1.28) } 100% { transform: scale(1) } }

/* ---------- viewfinder ---------- */

.viewfinder {
  flex: 1; margin: 0 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; overflow: hidden;
  text-align: center;
}
.corner { position: absolute; width: 34px; height: 34px; border: 3px solid var(--brand); }
.corner.tl { top: 20px; left: 20px;  border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.corner.tr { top: 20px; right: 20px; border-left: 0;  border-bottom: 0; border-radius: 0 10px 0 0; }
.corner.bl { bottom: 20px; left: 20px;  border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.corner.br { bottom: 20px; right: 20px; border-left: 0;  border-top: 0; border-radius: 0 0 10px 0; }

.scanline {
  position: absolute; left: 0; right: 0; height: 3px;
  background: var(--accent);
  animation: sweep 2.4s ease-in-out infinite;
}
@keyframes sweep { 0%, 100% { top: 18% } 50% { top: 78% } }

.shutter {
  width: 74px; height: 74px; border-radius: 999px;
  background: var(--brand-strong);
  border: 4px solid var(--surface-raised);
  box-shadow: 0 0 0 2px var(--brand-strong);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; padding: 0;
  transition: transform 0.12s ease;
}
.shutter:active { transform: scale(0.9); }

/* ---------- progress steps ---------- */

.step { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.step .dot { width: 24px; height: 24px; border-radius: 999px; border: 2px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.step.done .dot { background: var(--brand-strong); border-color: var(--brand-strong); }
.step.done .dot svg { display: block; }
.step .dot svg { display: none; }
.step.active .dot { border: 3px solid var(--accent); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.step.pending span { color: var(--ink-muted); }

.bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--brand-strong); transition: width 0.4s ease; }

/* ---------- chat ---------- */

.msg { max-width: 285px; font-size: 15px; line-height: 22px; padding: 12px 14px; animation: riseIn 0.3s both; }
.msg.them { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 18px 18px 18px 4px; align-self: flex-start; }
.msg.me { background: var(--brand-strong); color: var(--on-brand); border-radius: 18px 18px 4px 18px; align-self: flex-end; max-width: 262px; }
.cite {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  background: var(--surface-sunken); font-size: 11px; font-weight: 500;
  padding: 5px 10px; border-radius: 999px;
}
.typing { display: flex; gap: 4px; align-items: center; padding: 14px; }
.typing i { width: 7px; height: 7px; border-radius: 999px; background: var(--ink-muted); animation: blip 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s } .typing i:nth-child(3) { animation-delay: 0.3s }
@keyframes blip { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0) } 30% { opacity: 1; transform: translateY(-4px) } }

/* ---------- OTP ---------- */

.otp { display: flex; gap: 9px; justify-content: space-between; }
.otp input {
  width: 48px; height: 58px; text-align: center;
  font-family: var(--display); font-size: 23px; font-weight: 600; color: var(--ink);
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-md); outline: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.otp input:focus { border-color: var(--brand); transform: translateY(-2px); }
.otp input.filled { border-color: var(--brand); background: var(--surface-sunken); }

/* ---------- strength meter ---------- */

.strength { display: flex; gap: 5px; margin-top: 8px; }
.strength i { flex: 1; height: 4px; border-radius: 999px; background: var(--border); transition: background 0.25s ease; }
.strength i.on-1 { background: var(--signal-error); }
.strength i.on-2 { background: var(--signal-warning); }
.strength i.on-3 { background: var(--brand); }

/* ---------- accordion ---------- */

.acc { border-bottom: 1px solid var(--border); }
.acc summary {
  list-style: none; cursor: pointer;
  padding: 15px 0; font-size: 14.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary svg { flex-shrink: 0; transition: transform 0.22s ease; color: var(--ink-muted); }
.acc[open] summary svg { transform: rotate(180deg); }
.acc p { font-size: 13.5px; line-height: 20px; color: var(--ink-muted); padding: 0 0 15px; animation: riseIn 0.25s both; }

/* ---------- rows ---------- */

.row {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px;
  text-decoration: none; color: var(--ink);
  margin-bottom: 9px;
  transition: transform 0.12s ease;
}
.row:active { transform: scale(0.985); }
.row .thumb {
  width: 52px; height: 52px; border-radius: 11px;
  background: var(--surface-sunken);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.row .main { flex: 1; min-width: 0; }
.row .main b { display: block; font-size: 15px; font-weight: 600; }
.row .main small { display: block; font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

.list-link {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 0; border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--ink); font-size: 15px;
  cursor: pointer;
}
.list-link svg:last-child { margin-left: auto; color: var(--ink-muted); }

/* ---------- switch ---------- */

.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; margin-left: auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 999px;
  transition: background 0.22s ease;
}
.switch span::before {
  content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 999px;
  transition: transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.switch input:checked + span { background: var(--brand-strong); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------- empty state ---------- */

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; padding: 48px 32px;
}

/* ---------- divider with text ---------- */

.or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--ink-muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

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