:root {
  color-scheme: light;
  --green-950: #102f28;
  --green-900: #173f35;
  --green-800: #205448;
  --green-100: #e8f0ed;
  --cream: #f7f3ea;
  --paper: #fffdf8;
  --ink: #202823;
  --muted: #68726d;
  --line: #dce2de;
  --gold: #d99b3d;
  --gold-dark: #a96b16;
  --danger: #a53a36;
  --shadow: 0 10px 30px rgba(16, 47, 40, 0.1);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--cream);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 100% 0, rgba(217, 155, 61, 0.13), transparent 26rem),
    var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  min-height: 74px;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
  border-bottom: 1px solid rgba(23, 63, 53, 0.08);
  background: rgba(247, 243, 234, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--green-900);
  color: white;
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, serif;
  font-size: 22px;
  line-height: 1;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.icon-button,
.install-button {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
}

.icon-button {
  width: 42px;
  margin-right: 8px;
  background: white;
  color: var(--green-900);
  font-size: 24px;
}

.install-button {
  margin-left: auto;
  padding: 0 14px;
  background: var(--green-100);
  color: var(--green-900);
  font-size: 13px;
  font-weight: 800;
}

main {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 22px 18px calc(102px + env(safe-area-inset-bottom));
  outline: none;
}

.page-header {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

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

h1,
h2 {
  font-family: Georgia, serif;
  color: var(--green-950);
}

h1 {
  max-width: 580px;
  margin-bottom: 8px;
  font-size: clamp(30px, 8vw, 46px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--green-800);
  font-size: 13px;
  font-weight: 800;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  margin-top: 9px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.sync-state.online {
  background: #e1f2e7;
  color: #28633c;
}

.sync-state.offline {
  background: #fff0d7;
  color: #85540e;
}

.product-grid {
  display: grid;
  gap: 13px;
}

.product-card {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 112px;
  align-items: center;
  gap: 16px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(23, 63, 53, 0.1);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 4px 16px rgba(16, 47, 40, 0.05);
  color: inherit;
  text-align: left;
}

.product-card::after {
  position: absolute;
  right: -28px;
  bottom: -46px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--green-100);
  content: "";
}

.product-card:active {
  transform: scale(0.985);
}

.product-icon,
.ingredient-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 16px;
  background: var(--green-100);
  color: var(--green-900);
  font-weight: 900;
}

.product-icon {
  width: 58px;
  height: 58px;
  font-family: Georgia, serif;
  font-size: 25px;
}

.product-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--green-950);
  font-size: 18px;
}

.product-card small {
  color: var(--muted);
  font-size: 14px;
}

.product-arrow {
  z-index: 1;
  margin-left: auto;
  color: var(--green-800);
  font-size: 25px;
}

.add-card {
  min-height: 84px;
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.add-card::after {
  display: none;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}

.section-title h2 {
  margin: 0;
}

.section-title a,
.text-button {
  border: 0;
  background: transparent;
  color: var(--green-800);
  font-weight: 800;
  text-decoration: none;
}

.card {
  padding: 18px;
  border: 1px solid rgba(23, 63, 53, 0.1);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 4px 16px rgba(16, 47, 40, 0.05);
}

.form-stack {
  display: grid;
  gap: 16px;
}

label,
.label {
  display: block;
  margin-bottom: 7px;
  color: var(--green-950);
  font-size: 14px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid #cfd7d2;
  border-radius: 13px;
  outline: none;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green-800);
  box-shadow: 0 0 0 3px rgba(32, 84, 72, 0.12);
}

.auto-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auto-field {
  padding: 12px;
  border-radius: 13px;
  background: var(--green-100);
}

.auto-field small,
.auto-field strong {
  display: block;
}

.auto-field small {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.auto-field strong {
  color: var(--green-950);
}

.ingredient-list {
  display: grid;
  gap: 10px;
}

.ingredient-row {
  display: flex;
  min-height: 70px;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
}

.ingredient-icon {
  width: 44px;
  height: 44px;
  font-size: 17px;
}

.ingredient-row > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.ingredient-row strong,
.ingredient-row small {
  display: block;
}

.ingredient-row small {
  margin-top: 3px;
  color: var(--muted);
}

.camera-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 0;
  border-radius: 12px;
  background: var(--green-900);
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.camera-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.photo-card {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: #e8e9e5;
  aspect-ratio: 1;
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-label {
  position: absolute;
  right: 7px;
  bottom: 7px;
  left: 7px;
  padding: 6px 8px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(16, 47, 40, 0.86);
  color: white;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-photo {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--danger);
  font-weight: 900;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  width: 100%;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  border-radius: 15px;
  font-weight: 900;
}

.primary-button {
  border: 0;
  background: var(--green-900);
  box-shadow: 0 8px 20px rgba(23, 63, 53, 0.18);
  color: white;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.secondary-button {
  border: 1px solid var(--green-800);
  background: transparent;
  color: var(--green-900);
}

.danger-button {
  border: 1px solid #e0b8b5;
  background: #fff8f7;
  color: var(--danger);
}

.sticky-action {
  position: sticky;
  z-index: 10;
  bottom: calc(82px + env(safe-area-inset-bottom));
  margin-top: 20px;
  padding: 9px;
  border: 1px solid rgba(23, 63, 53, 0.1);
  border-radius: 19px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box input {
  padding-left: 44px;
}

.search-symbol {
  position: absolute;
  top: 50%;
  left: 15px;
  color: var(--muted);
  transform: translateY(-50%);
}

.filter-row {
  display: flex;
  gap: 8px;
  margin: -4px 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.filter-chip.active {
  border-color: var(--green-900);
  background: var(--green-900);
  color: white;
}

.date-group {
  margin-top: 22px;
}

.date-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--green-950);
  font-weight: 900;
}

.date-group-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-card {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(23, 63, 53, 0.1);
  border-radius: 15px;
  background: var(--paper);
  color: inherit;
  text-align: left;
}

.record-time {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  background: var(--green-100);
  color: var(--green-900);
  font-size: 13px;
  font-weight: 900;
}

.record-card > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.record-card strong,
.record-card small {
  display: block;
}

.record-card small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-count {
  color: var(--green-800);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.empty-state {
  padding: 36px 22px;
  border: 1px dashed #bcc9c2;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state-symbol {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 18px;
  background: var(--green-100);
  color: var(--green-800);
  font-size: 26px;
}

.empty-state h3 {
  color: var(--green-950);
}

.manage-list {
  display: grid;
  gap: 10px;
}

.manage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
}

.manage-row > div {
  min-width: 0;
  flex: 1;
}

.manage-row small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #4e9b6c;
}

.small-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--green-900);
  font-size: 13px;
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: calc(70px + env(safe-area-inset-bottom));
  padding: 7px max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
  border-top: 1px solid rgba(23, 63, 53, 0.12);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
}

.bottom-nav a {
  display: flex;
  min-width: 68px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  border-radius: 13px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.bottom-nav a.active {
  background: var(--green-100);
  color: var(--green-900);
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 18px;
  max-width: 460px;
  margin: auto;
  padding: 13px 16px;
  border-radius: 13px;
  background: var(--green-950);
  box-shadow: var(--shadow);
  color: white;
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.dialog-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px 0 0;
  background: rgba(7, 25, 20, 0.56);
}

.dialog {
  width: min(100%, 640px);
  max-height: 91dvh;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.dialog-header h2 {
  margin: 0;
}

.close-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--green-100);
  color: var(--green-900);
  font-size: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.detail-item {
  padding: 12px;
  border-radius: 13px;
  background: var(--green-100);
}

.detail-item small,
.detail-item strong {
  display: block;
}

.detail-item small {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-notes {
  margin: 18px 0;
  padding: 14px;
  border-left: 3px solid var(--gold);
  background: #fff8eb;
  color: #645033;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.button-row > * {
  flex: 1;
}

.is-hidden {
  display: none !important;
}

@media (min-width: 640px) {
  main {
    padding-top: 32px;
  }

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

  .photo-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .dialog-backdrop {
    align-items: center;
    padding: 24px;
  }

  .dialog {
    border-radius: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
