:root {
  --terra-green: #245c3a;
  --terra-green-dark: #164228;
  --terra-green-soft: #e7f2e9;
  --terra-beige: #f6f1e6;
  --terra-gold: #b78338;
  --ink: #213129;
  --muted: #657269;
  --line: #dbe4da;
  --paper: #ffffff;
  --danger: #a93d32;
  --warning: #9a651e;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #e7f2e9 0, var(--terra-beige) 470px, #fbfaf6 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
.auth-backdrop { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: rgba(18, 44, 28, .72); backdrop-filter: blur(6px); }
.auth-backdrop[hidden] { display: none; }
.auth-card { width: min(420px, 100%); border-radius: 22px; padding: 26px; background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, .28); text-align: center; }
.auth-card h2 { margin: 12px 0 8px; color: var(--terra-green-dark); }
.auth-card p { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.auth-provider { width: 100%; margin-top: 10px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: #88928b; font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 14px; padding: 3px; border-radius: 11px; background: var(--terra-green-soft); }
.auth-tabs button { border: 0; border-radius: 8px; padding: 8px; color: var(--muted); background: transparent; font-weight: 700; }
.auth-tabs button.active { color: var(--terra-green-dark); background: #fff; box-shadow: 0 2px 8px rgba(24,63,38,.1); }
.auth-card form { display: grid; gap: 7px; text-align: left; }
.auth-card form label { margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.auth-card form input { width: 100%; border: 1px solid #cbd9cd; border-radius: 10px; padding: 11px 12px; color: var(--ink); background: #fff; }
.auth-card form input:focus { outline: 2px solid rgba(36,92,58,.18); border-color: var(--terra-green); }
.auth-link { border: 0; margin-top: 12px; padding: 5px; color: var(--terra-green); background: transparent; font-size: 12px; font-weight: 750; text-decoration: underline; }
.auth-error { min-height: 20px; margin-top: 14px !important; color: var(--danger) !important; font-size: 12px; }
.auth-user { position: fixed; z-index: 30; top: 12px; right: 12px; border: 1px solid #cbd9cd; border-radius: 999px; padding: 7px 11px; color: var(--terra-green-dark); background: rgba(255,255,255,.94); font-size: 12px; font-weight: 700; box-shadow: 0 4px 16px rgba(24,63,38,.12); }

.shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 18px 96px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  margin: 0 -18px;
  padding: 10px 18px;
  border-bottom: 1px solid #d9e5d8;
  background: rgba(246, 241, 230, .93);
  backdrop-filter: blur(16px);
}

.brand { display: flex; min-width: 0; align-items: center; gap: 10px; }
.brand-logo {
  width: 50px;
  height: 50px;
  flex: none;
  border: 2px solid #fff;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 3px 9px rgba(22, 66, 40, .22);
}
.brand strong { display: block; font-size: 16px; letter-spacing: -.2px; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-badge {
  flex: none;
  border: 1px solid #bdd1bd;
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--terra-green);
  background: #f8fcf8;
  font-size: 10px;
  font-weight: 750;
}

main { padding-top: 22px; }
.hero { max-width: 590px; margin: 0 auto; padding: 25px 0 27px; text-align: center; }
.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 11px;
  color: var(--terra-green-dark);
  background: #d5e9d7;
  font-size: 12px;
  font-weight: 750;
}
.hero h1 {
  margin: 14px 0 10px;
  font-size: clamp(29px, 8vw, 42px);
  line-height: 1.08;
  letter-spacing: -1.6px;
}
.hero p, .intro { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 0 0 25px; }
.feature, .card {
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 4px 13px rgba(26, 56, 37, .06);
}
.feature { min-height: 102px; border-radius: 16px; padding: 13px 6px; color: #46554b; text-align: center; font-size: 11px; font-weight: 700; }
.feature b { display: grid; width: 36px; height: 36px; margin: 0 auto 8px; place-items: center; border-radius: 11px; color: var(--terra-green); background: var(--terra-green-soft); font-size: 18px; }

.upload { border: 1.5px dashed #8db696; border-radius: 21px; padding: 29px 17px 22px; background: rgba(255, 255, 255, .77); text-align: center; transition: .2s ease; }
.upload.over { border-color: var(--terra-green); background: #edf8ee; transform: translateY(-1px); }
.upload-mark { display: grid; width: 48px; height: 48px; margin: 0 auto; place-items: center; border-radius: 50%; background: var(--terra-green-soft); font-size: 23px; }
.upload h2 { margin: 12px 0 6px; font-size: 18px; }
.upload p { max-width: 420px; margin: 0 auto 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.upload-note { display: block; max-width: 450px; margin: 16px auto 0; color: #738176; font-size: 11px; line-height: 1.4; }

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.button { border: 1px solid var(--terra-green); border-radius: 12px; padding: 11px 15px; color: #fff; background: var(--terra-green); font-size: 13px; font-weight: 750; transition: .16s ease; }
.button:hover { border-color: var(--terra-green-dark); background: var(--terra-green-dark); }
.button.secondary { color: var(--terra-green); background: #fff; }
.button.secondary:hover { background: var(--terra-green-soft); }

.recent { margin-top: 27px; }
.recent h2, .page-title { margin: 0 0 8px; font-size: 21px; letter-spacing: -.5px; }
.history-item { display: flex; gap: 12px; margin: 11px 0; border-radius: 17px; padding: 11px; cursor: pointer; transition: .16s ease; }
.history-item:hover { border-color: #a7c5aa; transform: translateY(-1px); }
.history-copy { min-width: 0; flex: 1; }
.thumb { display: block; width: 76px; height: 76px; flex: none; border-radius: 12px; background: #e9f3e9; object-fit: cover; }
.thumb-placeholder { display: grid; place-items: center; font-size: 29px; }
.history-item h3 { overflow: hidden; margin: 0; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.history-item p { display: -webkit-box; overflow: hidden; margin: 3px 0; color: var(--muted); font-size: 12px; line-height: 1.33; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-item .latin { color: #829087; font-style: italic; }
.history-item .history-date { color: #89958b; font-size: 10px; }

.status { display: inline-block; float: right; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; }
.healthy { color: #176b37; background: #d9f1df; }
.attention { color: #875719; background: #fbebc7; }
.problem { color: #9a342c; background: #f9dcd7; }
.inconclusive { color: #536159; background: #e8ece8; }

.bottom { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: flex; justify-content: center; border-top: 1px solid #d9e5d8; background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px); }
.bottom nav { display: grid; width: min(720px, 100%); grid-template-columns: repeat(3, 1fr); padding: 7px 14px; }
.nav { border: 0; border-radius: 10px; padding: 5px; color: #839087; background: transparent; font-size: 10px; }
.nav i { display: block; margin-bottom: 1px; font-size: 19px; font-style: normal; }
.nav.active { color: var(--terra-green); background: #eff7ef; font-weight: 800; }

.guide { padding-top: 6px; }
.guide .intro { margin-bottom: 17px; }
.search { width: 100%; margin: 4px 0 7px; border: 1px solid #cbdacb; border-radius: 12px; padding: 12px 13px; outline: none; color: var(--ink); background: #fff; }
.search:focus { border-color: #58946a; box-shadow: 0 0 0 3px rgba(88, 148, 106, .16); }
.empty { padding: 52px 20px; color: var(--muted); text-align: center; }
.empty-icon { display: grid; width: 62px; height: 62px; margin: 0 auto 12px; place-items: center; border-radius: 16px; background: #edf2ed; font-size: 28px; }
.empty p { margin: 5px 0; font-size: 13px; }
.disease { margin: 13px 0; border-radius: 17px; padding: 16px; }
.disease summary { cursor: pointer; list-style: none; font-size: 15px; font-weight: 800; }
.disease summary::-webkit-details-marker { display: none; }
.disease summary::after { float: right; color: var(--terra-green); content: '+'; font-size: 19px; }
.disease[open] summary::after { content: '–'; }
.disease p, .disease li { color: var(--muted); font-size: 13px; line-height: 1.5; }
.disease h4 { margin: 15px 0 4px; font-size: 13px; }
.disease ul { margin: 5px 0 0; padding-left: 20px; }

.loading { max-width: 440px; margin: 50px auto; text-align: center; }
.loading h2 { margin: 17px 0 8px; font-size: 20px; }
.spinner { width: 39px; height: 39px; margin: auto; border: 4px solid #cde7d1; border-top-color: var(--terra-green); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { padding-top: 3px; }
.back { border: 0; padding: 6px 0 15px; color: var(--terra-green); background: transparent; font-size: 13px; font-weight: 750; }
.result-image { display: block; width: 100%; max-height: 340px; border-radius: 20px; background: #e7f2e9; object-fit: cover; }
.reference-notice { margin-top: 13px; border-left: 4px solid var(--terra-gold); border-radius: 10px; padding: 11px 13px; background: #fff8e8; }
.reference-notice b { color: #73531d; font-size: 12px; }
.reference-notice p { margin: 4px 0 0; color: #685b43; font-size: 12px; line-height: 1.43; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 18px 0 11px; }
.result-head h1 { margin: 0; font-size: 27px; letter-spacing: -.7px; }
.latin { margin: 4px 0; color: #7d8b80; font-size: 13px; font-style: italic; }
.result-grid { display: grid; grid-template-columns: 1.55fr .75fr; gap: 10px; }
.result-grid .card { min-height: 92px; border-radius: 15px; padding: 14px; }
.result-grid small, .product-card small { display: block; color: #78867c; font-size: 10px; font-weight: 800; letter-spacing: .25px; text-transform: uppercase; }
.result-grid strong { display: block; margin-top: 5px; font-size: 14px; line-height: 1.35; }
.section, .reassessment, .product-card { margin-top: 12px; border-radius: 17px; padding: 16px; }
.section h3, .reassessment h3, .product-card h3 { margin: 0 0 9px; font-size: 15px; }
.section ul { margin: 0; padding-left: 20px; }
.section li { margin: 7px 0; color: #415148; font-size: 13px; line-height: 1.42; }
.actions { border-color: #b8d4bb; background: #f6fbf6; }
.actions h3 { color: var(--terra-green-dark); }
.reassessment p, .product-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.46; }
.product-card { border-color: #c9dabc; background: #fcfffa; }
.product-card.product-relevant { border-color: #8caf87; background: #f2f9ed; }
.product-card h3 { margin-top: 5px; color: var(--terra-green-dark); }
.product-card div { margin-top: 12px; padding-top: 11px; border-top: 1px solid #dce8da; }
.product-card b, .product-card span { display: block; }
.product-card b { margin-bottom: 3px; color: #3a573f; font-size: 12px; }
.product-card span { color: var(--muted); font-size: 12px; line-height: 1.42; }
.chat { margin-top: 12px; border-color: #bfd8c2; border-radius: 17px; padding: 16px; background: #fcfffb; }
.chat-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.chat-heading h3 { margin: 0; font-size: 16px; }
.chat-heading p { max-width: 410px; margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.42; }
.chat-heading span { flex: none; border-radius: 999px; padding: 5px 7px; color: var(--terra-green-dark); background: #e5f3e7; font-size: 9px; font-weight: 800; }
.chat-messages { display: grid; gap: 9px; max-height: 410px; margin: 14px 0; overflow-y: auto; padding: 2px; scroll-behavior: smooth; }
.chat-message { max-width: 91%; border-radius: 14px; padding: 10px 12px; background: #edf4ed; }
.chat-message.user { justify-self: end; color: #fff; background: var(--terra-green); }
.chat-message small { display: block; margin-bottom: 3px; color: #638069; font-size: 10px; font-weight: 800; }
.chat-message.user small { color: #d8eedb; }
.chat-message p { margin: 0; font-size: 13px; line-height: 1.46; white-space: pre-wrap; }
.chat-empty { border: 1px dashed #c4d8c5; border-radius: 13px; padding: 14px; color: #516458; background: #f5faf5; }
.chat-empty b { color: var(--terra-green-dark); font-size: 13px; }
.chat-empty p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.chat-pending { width: fit-content; border-radius: 999px; padding: 8px 11px; color: #5c6e61; background: #eef3ee; font-size: 12px; }
.chat-form { border-top: 1px solid #dce8dc; padding-top: 13px; }
.chat-form label { display: block; margin-bottom: 7px; color: #405445; font-size: 12px; font-weight: 800; }
.chat-form textarea { display: block; width: 100%; min-height: 78px; resize: vertical; border: 1px solid #c6d7c7; border-radius: 12px; padding: 10px 11px; outline: none; color: var(--ink); background: #fff; font-size: 13px; line-height: 1.4; }
.chat-form textarea:focus { border-color: #58946a; box-shadow: 0 0 0 3px rgba(88, 148, 106, .16); }
.chat-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 9px; }
.chat-actions small { max-width: 300px; color: #758078; font-size: 10px; line-height: 1.35; }
.chat-buttons { display: flex; flex: none; gap: 8px; }
.voice-button.is-listening { border-color: var(--danger); color: var(--danger); background: #fff1ef; }
.chat-form.is-pending .button { cursor: wait; opacity: .72; }
.chat-form .button:disabled { cursor: wait; opacity: .72; }
.consult-note { margin: 14px 3px; color: #6f6657; font-size: 11px; line-height: 1.45; text-align: center; }
.result-actions { margin-top: 18px; }

.toast { position: fixed; z-index: 50; top: 86px; left: 50%; width: min(calc(100% - 36px), 480px); transform: translateX(-50%); border-radius: 12px; padding: 12px 15px; color: #fff; background: #263c2c; box-shadow: 0 12px 30px rgba(21, 48, 30, .24); font-size: 13px; text-align: center; }

@media (max-width: 390px) {
  .shell { padding-right: 13px; padding-left: 13px; }
  .top { margin-right: -13px; margin-left: -13px; padding-right: 13px; padding-left: 13px; }
  .brand-badge { display: none; }
  .result-grid { grid-template-columns: 1fr; }
  .chat-heading { display: block; }
  .chat-heading span { display: inline-block; margin-top: 8px; }
  .chat-actions { align-items: flex-end; }
  .chat-actions small { max-width: 180px; }
  .chat-buttons { gap: 6px; }
}

@media (min-width: 640px) {
  .shell { padding-right: 28px; padding-left: 28px; }
  .top { margin-right: -28px; margin-left: -28px; padding-right: 28px; padding-left: 28px; }
  .hero { padding-top: 35px; }
  .feature { padding-top: 16px; }
}
