:root {
  color-scheme: light;
  --green: #245944;
  --ink: #183e32;
  --muted: #647060;
  --cream: #f7f8f2;
  --line: #e3e7dc;
  --pale: #e6ebdc;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--cream);
  color: var(--ink);
  font:
    14px/1.6 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

button,
input {
  font: inherit;
}

button,
a,
input,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  border: 0;
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

button:hover:not(:disabled),
.button:hover {
  filter: brightness(0.96);
}

:focus-visible {
  outline: 3px solid #9db78b;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 43px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -1.7px;
  overflow-wrap: break-word;
}

h2 {
  font-size: 18px;
  line-height: 1.4;
  font-weight: 700;
  color: #233d30;
}

h3 {
  font-size: 16px;
  line-height: 1.4;
}

p {
  color: var(--muted);
  white-space: pre-line;
}

a {
  color: var(--green);
}

.shell {
  height: 100dvh;
  max-width: 620px;
  margin: auto;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  padding-top: calc(18px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -1px;
}

.wordmark img {
  display: block;
  border-radius: 12px;
}

.header-start {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.back-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 44px;
  border-radius: 12px;
  background: var(--pale);
  color: var(--green);
  font-size: 23px;
}

.language-switch {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--pale);
  border-radius: 14px;
}

.language-switch button {
  padding: 0 13px;
  min-height: 40px;
  border-radius: 10px;
  background: transparent;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.language-switch button[aria-pressed='true'] {
  background: var(--green);
  color: white;
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  scrollbar-width: thin;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 0;
  margin-bottom: 16px;
}

.eyebrow {
  color: #5b725d;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.subtitle {
  font-size: 16px;
  line-height: 1.6;
}

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

.tags {
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  background: var(--pale);
  color: var(--green);
  border-radius: 20px;
  padding: 7px 13px;
  font-size: 11px;
  line-height: 1.5;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 13px;
  background: white;
  padding: 20px;
  border: 1px solid #e7e9df;
  border-radius: 23px;
}

.primary,
.secondary,
.button {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 13px 16px;
  border-radius: 14px;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
  text-decoration: none;
}

.primary {
  background: var(--green);
  color: white;
}

.secondary {
  background: #eef1e7;
  color: var(--ink);
}

.equal > * {
  flex: 1;
  min-width: 0;
}

.file-upload {
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.file-upload input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload:focus-within {
  outline: 3px solid #9db78b;
  outline-offset: 3px;
}

.file-upload:has(input:disabled) {
  opacity: 0.45;
  cursor: wait;
}

.row input {
  flex: 1;
  width: 0;
}

.row button {
  flex-shrink: 0;
}

input {
  min-width: 0;
  width: 100%;
  padding: 14px;
  min-height: 48px;
  border: 1px solid #dfe5d8;
  background: white;
  color: #233d30;
  border-radius: 13px;
}

.label {
  display: block;
  font-size: 10px;
  color: #7b8678;
  font-weight: 700;
  letter-spacing: 1px;
  margin: 6px 0 10px;
}

.error {
  padding: 14px;
  border-radius: 12px;
  background: #fff0e7;
  color: #9b4a24;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.catalogue {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.small {
  color: #76836e;
  font-size: 10px;
  letter-spacing: 0.4px;
  line-height: 1.6;
}

.filters {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 3px 0;
  scrollbar-width: thin;
}

.filters button {
  flex-shrink: 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--pale);
  color: var(--green);
  font-size: 12px;
  min-height: 44px;
}

.filters button[aria-pressed='true'] {
  background: var(--green);
  color: white;
}

.product-row {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 12px 0;
  background: transparent;
  border-bottom: 1px solid var(--line);
  text-align: left;
  color: var(--ink);
}

.product-row .info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.product-row .tag {
  align-self: flex-start;
}

.product-icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 17px;
  overflow: hidden;
}

.product-icon img {
  width: 60px;
  height: 52px;
  object-fit: contain;
}

.product-icon .emoji {
  font-size: 28px;
}

.arrow {
  font-size: 24px;
  color: var(--green);
}

.note {
  padding: 20px;
  background: #e9efdc;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

footer {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 30px 0 12px;
}

footer p:last-child {
  text-align: center;
}

.bottom-nav {
  flex-shrink: 0;
  display: flex;
  background: white;
  border-top: 1px solid var(--line);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}

.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 56px;
  padding: 5px;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: #8d9787;
}

.bottom-nav button[aria-current='page'] {
  color: var(--green);
}

.nav-icon {
  font-size: 25px;
  line-height: 1.2;
}

#photo-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.photo {
  width: 100%;
  height: 160px;
  object-fit: contain;
  border-radius: 14px;
  background: #f0f2eb;
}

progress {
  width: 100%;
  height: 9px;
  accent-color: var(--green);
}

#photo-search-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#photo-text {
  max-height: 160px;
  overflow: auto;
}

#photo-brands {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

dialog {
  border: 0;
  padding: 24px;
  background: var(--cream);
  color: var(--ink);
  width: min(100%, 620px);
  max-width: 620px;
  height: 100dvh;
  max-height: 100dvh;
  margin: auto;
  overflow: auto;
}

dialog::backdrop {
  background: #183e3266;
}

#product-detail,
.camera-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.detail-art {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 210px;
  border-radius: 28px;
  overflow: hidden;
}

.detail-art img {
  width: 80%;
  height: 185px;
  object-fit: contain;
}

.detail-art .emoji {
  font-size: 90px;
}

.detail-title {
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -1px;
}

#camera-video {
  width: 100%;
  min-height: 280px;
  max-height: 50dvh;
  object-fit: cover;
  border-radius: 24px;
  background: #183e32;
}

#camera-device-field label {
  display: block;
  margin-bottom: 8px;
}

#camera-device {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

@media (max-width: 380px) {
  main,
  dialog {
    padding: 20px;
  }
  header {
    padding-left: 20px;
    padding-right: 20px;
  }
  .card {
    padding: 18px;
  }
  h1 {
    font-size: 38px;
  }
  .product-row {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button,
  .button {
    transition:
      background 0.18s,
      filter 0.18s,
      transform 0.18s;
  }
  button:active:not(:disabled),
  .button:active {
    transform: scale(0.97);
  }
  .page:not([hidden]) {
    animation: page-enter 0.28s ease-out both;
  }
  dialog[open] {
    animation: dialog-enter 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
  dialog[open]::backdrop {
    animation: backdrop-enter 0.25s ease-out both;
  }
  .product-row {
    animation: row-enter 0.3s ease-out both;
  }
  .product-row:nth-child(2) {
    animation-delay: 25ms;
  }
  .product-row:nth-child(3) {
    animation-delay: 50ms;
  }
  .product-row:nth-child(4) {
    animation-delay: 75ms;
  }
  .product-row:nth-child(5) {
    animation-delay: 100ms;
  }
  .product-row .arrow,
  .nav-icon {
    transition: transform 0.18s;
  }
  .product-row:hover .arrow {
    transform: translate(3px, -3px);
  }
  .bottom-nav button[aria-current='page'] .nav-icon {
    transform: translateY(-2px);
  }
  #photo-panel:not([hidden]),
  .error:not([hidden]) {
    animation: page-enter 0.25s ease-out both;
  }
  @keyframes page-enter {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  @keyframes dialog-enter {
    from {
      opacity: 0;
      transform: translateY(18px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  @keyframes row-enter {
    from {
      opacity: 0;
      transform: translateY(5px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  @keyframes backdrop-enter {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}
