:root {
  --cream: #F5F0E8;
  --bark: #3D2B1F;
  --moss: #4A6741;
  --sage: #7A9E6F;
  --fern: #A8C49A;
  --soil: #7C5C3E;
  --gold: #C4963A;
  --rust: #B85C38;
  --white: #FEFCF8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--bark);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(ellipse 80% 60% at 20% 10%, rgba(74, 103, 65, .08) 0%, transparent 60%), radial-gradient(ellipse 60% 80% at 80% 90%, rgba(168, 196, 154, .12) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 20px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(61, 43, 31, .1);
  background: rgba(245, 240, 232, .9);
  backdrop-filter: blur(8px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-logo-img {
  display: block;
  width: min(210px, 46vw);
  height: auto;
}

.main-logo-img--small {
  width: min(132px, 34vw);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--moss);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.logo-text span {
  color: var(--moss);
}

nav {
  display: flex;
  gap: 4px;
  background: rgba(61, 43, 31, .08);
  border-radius: 12px;
  padding: 4px;
}

nav button {
  background: none;
  border: none;
  padding: 7px 14px;
  border-radius: 9px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--bark);
  cursor: pointer;
  transition: all .2s;
  opacity: .6;
}

nav button.active {
  background: var(--white);
  opacity: 1;
  box-shadow: 0 1px 4px rgba(61, 43, 31, .15);
}

.login-pill {
  background: var(--moss);
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-link {
  color: var(--soil);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.header-link:hover,
.header-link.active {
  color: var(--moss);
}

main {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
  animation: fadeUp .35s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }

}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.2;
}

.section-sub {
  font-size: 14px;
  color: var(--soil);
  margin-bottom: 24px;
  font-weight: 300;
}

.welcome-card,
.camera-card,
.add-plant-card,
.result-card,
.loading-card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(61, 43, 31, .1);
}

.welcome-card {
  padding: 32px;
}

.welcome-card h1 {
  font-family: 'Playfair Display', serif;
  font-size: 34px;
  margin-bottom: 10px;
}

.welcome-card p {
  color: var(--soil);
  margin-bottom: 20px;
}

.policy-page {
  line-height: 1.65;
}

.policy-page h2 {
  margin: 22px 0 8px;
  font-family: 'Playfair Display', serif;
  font-size: 21px;
}

.policy-page p {
  margin-bottom: 12px;
}

.camera-card {
  overflow: hidden;
  margin-bottom: 20px;
}

.camera-area {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #1a1a1a;
  overflow: hidden;
  cursor: pointer;
}

#videoEl,
#previewImg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#previewImg {
  display: none;
  position: absolute;
  inset: 0;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #fff;
  gap: 12px;
  background: rgba(26, 26, 26, .75);
  transition: opacity .3s;
}

.camera-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.camera-overlay .icon {
  font-size: 48px;
}

.guide-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(168, 196, 154, .8);
  border-style: solid;
  border-width: 0;
}

.guide-corner.tl {
  top: 12px;
  left: 12px;
  border-top-width: 3px;
  border-left-width: 3px;
}

.guide-corner.tr {
  top: 12px;
  right: 12px;
  border-top-width: 3px;
  border-right-width: 3px;
}

.guide-corner.bl {
  bottom: 12px;
  left: 12px;
  border-bottom-width: 3px;
  border-left-width: 3px;
}

.guide-corner.br {
  bottom: 12px;
  right: 12px;
  border-bottom-width: 3px;
  border-right-width: 3px;
}

.plant-selector-row,
.camera-controls {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.plant-selector-row {
  padding-bottom: 0;
}

.plant-selector-row label {
  font-size: 13px;
  color: var(--soil);
  white-space: nowrap;
  font-weight: 500;
}

.plant-selector-row select {
  flex: 1;
}

.btn {
  border: none;
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}

.btn-primary {
  background: var(--moss);
  color: #fff;
  padding: 11px 20px;
  font-size: 14px;
}

.btn-primary:hover {
  background: var(--bark);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(61, 43, 31, .08);
  color: var(--bark);
  padding: 11px 16px;
  font-size: 13px;
}

.btn-danger {
  background: rgba(184, 92, 56, .1);
  color: var(--rust);
  padding: 11px 16px;
  font-size: 13px;
}

.upload-zone {
  border: 2px dashed rgba(74, 103, 65, .3);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: rgba(168, 196, 154, .05);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--moss);
  background: rgba(74, 103, 65, .12);
  transform: translateY(-1px);
}

.camera-card.drag-over {
  outline: 3px dashed rgba(74, 103, 65, .45);
  outline-offset: 6px;
}

.upload-zone p {
  font-size: 13px;
  color: var(--soil);
  margin-top: 8px;
}

.upload-zone .icon {
  font-size: 32px;
}

#fileInput,
canvas {
  display: none;
}

.loading-card {
  padding: 48px 24px;
  text-align: center;
  margin-top: 20px;
}

.leaf-spinner {
  font-size: 40px;
  display: inline-block;
  animation: spin 1.4s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }

}

.loading-card p {
  margin-top: 16px;
  font-size: 14px;
  color: var(--soil);
}

.loading-card .loading-sub {
  font-size: 12px;
  opacity: .6;
  margin-top: 6px;
}

.result-card {
  overflow: hidden;
  margin-top: 20px;
  animation: fadeUp .4s ease;
}

.result-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(61, 43, 31, .08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-body {
  padding: 20px 24px;
}

.result-section {
  margin-bottom: 20px;
}

.result-section:last-child {
  margin-bottom: 0;
}

.result-section-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--soil);
  margin-bottom: 10px;
  opacity: .7;
}

.result-section p {
  font-size: 14px;
  line-height: 1.65;
}

.result-actions {
  padding: 16px 24px;
  border-top: 1px solid rgba(61, 43, 31, .08);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.health-badge.good {
  background: rgba(74, 103, 65, .12);
  color: var(--moss);
}

.health-badge.fair {
  background: rgba(196, 150, 58, .12);
  color: var(--gold);
}

.health-badge.poor {
  background: rgba(184, 92, 56, .12);
  color: var(--rust);
}

.health-badge.unclear,
.health-badge.none {
  background: rgba(61, 43, 31, .08);
  color: var(--soil);
}

.result-timestamp {
  font-size: 11px;
  color: var(--soil);
  opacity: .7;
}

.quality-banner {
  margin: 16px 24px 0;
  padding: 14px 16px;
  background: rgba(196, 150, 58, .1);
  border: 1px solid rgba(196, 150, 58, .25);
  border-radius: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.quality-banner p {
  font-size: 13px;
  line-height: 1.55;
}

.action-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.55;
  padding: 10px 14px;
  background: rgba(74, 103, 65, .05);
  border-radius: 10px;
  border-left: 3px solid var(--sage);
}

.action-list li .num {
  font-weight: 700;
  color: var(--moss);
  min-width: 18px;
  font-size: 13px;
  padding-top: 1px;
}

.add-plant-card {
  padding: 24px;
  margin-bottom: 24px;
}

.add-plant-card.is-collapsed {
  padding: 14px 16px;
}

.add-plant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.add-plant-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  margin-bottom: 16px;
}

.add-plant-header h3 {
  margin-bottom: 0;
}

.add-plant-body {
  margin-top: 16px;
}

.add-plant-toggle {
  flex-shrink: 0;
  min-width: 64px;
}

.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--soil);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-group input,
.form-group select,
.form-group textarea,
.plant-selector-row select {
  border: 1.5px solid rgba(61, 43, 31, .15);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--cream);
  color: var(--bark);
}

.form-group textarea {
  resize: vertical;
  min-height: 70px;
}

.plants-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.plant-card {
  background: var(--white);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(61, 43, 31, .08);
  cursor: pointer;
  transition: all .2s;
}

.plant-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(61, 43, 31, .14);
}

.plant-card-header {
  padding: 16px 18px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.plant-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--fern), var(--sage));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.plant-info {
  flex: 1;
}

.plant-info h4 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 2px;
}

.plant-info .plant-species {
  font-size: 12px;
  color: var(--soil);
  font-style: italic;
}

.plant-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 18px 14px;
}

.meta-tag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(74, 103, 65, .08);
  color: var(--moss);
  font-weight: 500;
}

.plant-last-scan {
  padding: 12px 18px;
  border-top: 1px solid rgba(61, 43, 31, .06);
  font-size: 12px;
  color: var(--soil);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.health-dot.good {
  background: var(--sage);
}

.health-dot.fair {
  background: var(--gold);
}

.health-dot.poor {
  background: var(--rust);
}

.health-dot.none,
.health-dot.unclear {
  background: #ccc;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--soil);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
  max-width: 260px;
  margin: 0 auto;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 43, 31, .5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 32px 16px;
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn .2s;
}

.modal {
  background: var(--cream);
  border-radius: 24px;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 8px 0 32px;
  animation: slideUp .3s ease;
  box-shadow: 0 20px 80px rgba(61, 43, 31, .28);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }

}

@keyframes slideUp {
  from {
    transform: translateY(32px);
  }

  to {
    transform: translateY(0);
  }

}

.modal-handle {
  width: 40px;
  height: 4px;
  background: rgba(61, 43, 31, .2);
  border-radius: 2px;
  margin: 12px auto 20px;
}

.modal-header {
  position: sticky;
  top: 0;
  background: var(--cream);
  z-index: 2;
  padding: 0 24px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(61, 43, 31, .08);
}

.modal-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
}

.modal-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(61, 43, 31, .08);
  border: none;
  font-size: 18px;
  cursor: pointer;
}

.scan-history {
  padding: 20px 24px 0;
}

.scan-entry {
  padding: 14px;
  background: var(--white);
  border-radius: 14px;
  margin-bottom: 10px;
}

.scan-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.scan-entry p {
  font-size: 13px;
  line-height: 1.55;
}

.scan-date {
  font-size: 11px;
  color: var(--soil);
  opacity: .7;
}

.no-scans {
  text-align: center;
  padding: 32px 0;
  color: var(--soil);
  font-size: 14px;
  opacity: .7;
}

.profile-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.profile-user-row p {
  font-size: 13px;
  color: var(--soil);
}

.tiny-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--soil);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--bark);
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(61, 43, 31, .25);
  z-index: 200;
  font-size: 13px;
}

.ai-key-panel,
.quota-panel {
  margin: 18px 0;
  padding: 16px;
  border-radius: 16px;
  background: rgba(74, 103, 65, .06);
  border: 1px solid rgba(74, 103, 65, .12);
}

.ai-key-panel h4,
.quota-panel h4 {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  margin-bottom: 6px;
}

.ai-key-panel p,
.quota-panel p {
  font-size: 12px;
  color: var(--soil);
  line-height: 1.5;
  margin-bottom: 14px;
}

.key-status {
  font-size: 11px;
  color: var(--moss);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.key-clear-btn {
  margin-top: 8px;
  align-self: flex-start;
}

.quota-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(61, 43, 31, .1);
  overflow: hidden;
  margin: 10px 0;
}

.quota-fill {
  height: 100%;
  width: 0;
  background: var(--moss);
  border-radius: 999px;
}

.photo-tools {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.products-toolbar {
  margin-bottom: 16px;
}

.affiliate-note {
  font-size: 12px;
  color: var(--soil);
  line-height: 1.5;
}

.policy-card {
  padding: 16px;
  background: var(--white);
  border: 1px solid rgba(74, 103, 65, .12);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(61, 43, 31, .08);
}

.policy-card h3 {
  margin-bottom: 6px;
  font-family: 'Playfair Display', serif;
  font-size: 18px;
}

.policy-card p {
  color: var(--soil);
  font-size: 13px;
  line-height: 1.55;
  margin-top: 8px;
}

.products-grid {
  display: grid;
  gap: 14px;
}

.products-grid.compact {
  grid-template-columns: 1fr;
}

.product-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  background: var(--white);
  border: 1px solid rgba(61, 43, 31, .08);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(61, 43, 31, .08);
  overflow: hidden;
}

.product-image {
  width: 112px;
  height: 100%;
  min-height: 132px;
  object-fit: cover;
  background: rgba(74, 103, 65, .08);
}

.product-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--moss);
  font-size: 26px;
  font-weight: 700;
}

.product-content {
  padding: 14px 14px 14px 0;
}

.product-type {
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--moss);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.product-card h3 {
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1.3;
}

.product-card p {
  color: var(--soil);
  font-size: 13px;
  line-height: 1.5;
}

.product-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle-row {
  margin: 16px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(74, 103, 65, .06);
  border: 1px solid rgba(74, 103, 65, .12);
  cursor: pointer;
}

.toggle-row input {
  margin-top: 3px;
  accent-color: var(--moss);
}

.toggle-row span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.toggle-row small {
  color: var(--soil);
  font-size: 12px;
  line-height: 1.4;
}

.bad-scan-notice {
  margin-top: 20px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(184, 92, 56, .1);
  border: 1px solid rgba(184, 92, 56, .18);
  color: var(--rust);
  font-size: 14px;
  line-height: 1.5;
}

@media (max-width: 640px) {
  header {
    flex-wrap: wrap;
  }

  nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .header-actions {
    margin-left: auto;
  }

  .section-title {
    font-size: 24px;
  }

  .camera-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    justify-content: center;
  }

  .product-card {
    grid-template-columns: 88px 1fr;
  }

  .product-image {
    width: 88px;
    min-height: 148px;
  }

  .modal-overlay {
    padding: 16px 8px;
  }

  .modal {
    max-height: calc(100vh - 32px);
    border-radius: 18px;
  }

}

.followup-section {
  padding: 14px;
  background: rgba(61, 43, 31, .04);
  border: 1px solid rgba(61, 43, 31, .08);
  border-radius: 12px;
}

.followup-question-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.followup-detail {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--cream);
  border: 1px solid rgba(61, 43, 31, .1);
}

.followup-detail p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--soil);
  margin-bottom: 10px;
}

.followup-input {
  margin-bottom: 10px;
}

.followup-input input,
.followup-input textarea {
  width: 100%;
  border: 1.5px solid rgba(61, 43, 31, .15);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--white);
  color: var(--bark);
}

.followup-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.followup-confirmation {
  color: var(--moss) !important;
  font-weight: 500;
  margin: 0 !important;
}
