:root {
  /* Telegram WebView and browser "auto dark" must not recolor light cards. */
  color-scheme: only light;
  --cream: #f7f4ed;
  --paper: rgba(255, 255, 255, 0.96);
  --ink: #20211f;
  --muted: #777a73;
  --line: rgba(37, 43, 34, 0.09);
  --sage: #dce9dc;
  --sage-strong: #42684c;
  --peach: #f6dfcf;
  --peach-strong: #9a5f3d;
  --lavender: #e8e1f3;
  --blue: #dceaf4;
  --danger: #b94343;
  --shadow: 0 12px 34px rgba(46, 54, 42, 0.09);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 15px;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color-scheme: only light;
  background: var(--cream) !important;
  forced-color-adjust: none;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink) !important;
  background:
    radial-gradient(circle at 12% 4%, rgba(222, 235, 216, 0.75), transparent 27rem),
    radial-gradient(circle at 92% 18%, rgba(246, 223, 207, 0.72), transparent 24rem),
    var(--cream) !important;
  forced-color-adjust: none;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(86px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: var(--safe-top) 18px 10px;
  color: var(--ink);
  background: rgba(247, 244, 237, 0.97) !important;
  border-bottom: 1px solid rgba(35, 39, 32, 0.04);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  background: var(--sage-strong);
  border-radius: 13px 13px 16px 16px;
  box-shadow: 0 6px 14px rgba(66, 104, 76, 0.2);
}

.environment-pill,
.status-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  color: var(--sage-strong);
  background: var(--sage);
  border: 1px solid rgba(66, 104, 76, 0.1);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.environment-pill::before,
.status-pill::before {
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
  content: "";
}

.main-content {
  padding: 16px 16px 28px;
}

.surface {
  color: var(--ink);
  background: var(--paper) !important;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.boot-state {
  display: grid;
  min-height: 330px;
  margin-top: 28px;
  padding: 34px;
  place-items: center;
  align-content: center;
  text-align: center;
}

.boot-state h1 {
  margin: 18px 0 6px;
}

.boot-state p {
  margin: 0;
  color: var(--muted);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid var(--sage);
  border-top-color: var(--sage-strong);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 2px 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--sage-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 8vw, 42px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: -0.025em;
}

h3 {
  margin: 0;
  font-size: 16px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.avatar-stack {
  display: flex;
  flex-shrink: 0;
  padding-top: 3px;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  margin-left: -9px;
  place-items: center;
  color: #3a493c;
  background: var(--sage);
  border: 3px solid var(--cream);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}

.avatar:first-child {
  margin-left: 0;
}

.avatar:nth-child(2n) {
  background: var(--peach);
}

.avatar:nth-child(3n) {
  background: var(--lavender);
}

.section {
  margin-top: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 10px;
}

.section-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  background: rgba(70, 76, 65, 0.08);
  border-radius: 14px;
}

.segment {
  min-height: 40px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 11px;
  font-weight: 700;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.segment.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 3px 12px rgba(33, 40, 30, 0.09);
}

.summary-strip {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 15px 17px;
  background: var(--sage);
  border: 1px solid rgba(66, 104, 76, 0.1);
  border-radius: var(--radius-md);
}

.summary-strip strong {
  display: block;
  font-size: 14px;
}

.summary-strip span {
  color: #627067;
  font-size: 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 17px;
  border: 0;
  border-radius: 15px;
  font-weight: 760;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.primary-button {
  color: #fff;
  background: var(--sage-strong);
  box-shadow: 0 8px 18px rgba(66, 104, 76, 0.2);
}

.secondary-button {
  color: var(--sage-strong);
  background: var(--sage);
}

.ghost-button {
  min-height: 42px;
  color: var(--ink);
  background: rgba(61, 70, 56, 0.07);
}

.danger-button {
  color: var(--danger);
  background: #f9e4e1;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.tab-button:active {
  transform: scale(0.98);
}

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

.button-wide {
  width: 100%;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.97), rgba(255, 253, 247, 0.92)),
    var(--paper);
  touch-action: pan-y;
}

.hero-card::after {
  position: absolute;
  top: -42px;
  right: -45px;
  width: 150px;
  height: 150px;
  background: var(--peach);
  border-radius: 50%;
  content: "";
  opacity: 0.55;
}

.dish-art {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 126px;
  place-items: center;
  margin: -4px 0 14px;
}

.plate {
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  background: #fff;
  border: 10px solid #edf0e9;
  border-radius: 50%;
  box-shadow: 0 12px 24px rgba(48, 55, 44, 0.1);
  font-size: 43px;
}

.dish-copy {
  position: relative;
  z-index: 2;
}

.dish-meta,
.chips,
.actions,
.member-macros {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dish-meta {
  margin: 10px 0 16px;
}

.chip,
.macro-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 6px 10px;
  color: #5b6259;
  background: rgba(74, 86, 67, 0.07);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.macro-chip:nth-child(2) {
  background: var(--peach);
}

.macro-chip:nth-child(3) {
  background: var(--lavender);
}

.macro-chip:nth-child(4) {
  background: var(--blue);
}

.portion-list,
.plain-list,
.shopping-list,
.family-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.portion-row,
.family-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  background: rgba(72, 80, 68, 0.05);
  border-radius: 15px;
}

.portion-row strong,
.family-row strong {
  display: block;
  font-size: 14px;
}

.portion-row small,
.family-row small {
  color: var(--muted);
}

.mini-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: var(--lavender);
  border-radius: 13px;
  font-weight: 800;
}

.list-card {
  padding: 17px;
}

.shopping-group + .shopping-group {
  margin-top: 14px;
}

.shopping-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.shopping-group h3 span {
  color: var(--muted);
  font-size: 11px;
}

.shopping-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  padding: 8px 3px;
  border-top: 1px solid var(--line);
}

.shopping-item:first-of-type {
  border-top: 0;
}

.round-check {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  color: transparent;
  background: #fff;
  border: 2px solid #ccd2c8;
  border-radius: 50%;
}

.shopping-item.is-checked {
  color: var(--muted);
  text-decoration: line-through;
}

.shopping-item.is-checked .round-check {
  color: #fff;
  background: var(--sage-strong);
  border-color: var(--sage-strong);
}

.shopping-amount {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.mini-link {
  display: block;
  min-height: 26px;
  margin: 3px 0 0 auto;
  padding: 2px 0;
  color: var(--sage-strong);
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 750;
}

.empty-card {
  padding: 30px 22px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  place-items: center;
  background: var(--blue);
  border-radius: 24px;
  font-size: 30px;
}

.empty-card p {
  max-width: 360px;
  margin: 9px auto 20px;
  color: var(--muted);
  line-height: 1.48;
}

.scan-card {
  margin-bottom: 16px;
  padding: 18px;
}

.scan-head,
.scan-copy {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.scan-head p,
.scan-copy p,
.privacy-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.scan-icon {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  background: var(--blue);
  border-radius: 16px;
  font-size: 22px;
}

.scan-button {
  width: 100%;
  margin-top: 14px;
}

.fridge-preview {
  width: 100%;
  max-height: 260px;
  margin-top: 14px;
  object-fit: cover;
  border-radius: 16px;
}

.scan-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  color: var(--sage-strong);
  background: var(--sage);
  border-radius: 14px;
  font-weight: 700;
}

.scan-progress .spinner {
  width: 24px;
  height: 24px;
  border-width: 3px;
}

.detected-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.detected-product {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(72, 80, 68, 0.05);
  border: 1px solid transparent;
  border-radius: 13px;
  text-align: left;
}

.detected-product::before {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: transparent;
  background: #fff;
  border: 1px solid rgba(47, 55, 43, 0.14);
  border-radius: 9px;
  content: "✓";
}

.detected-product.is-selected {
  background: rgba(220, 233, 220, 0.62);
  border-color: rgba(66, 104, 76, 0.18);
}

.detected-product.is-selected::before {
  color: #fff;
  background: var(--sage-strong);
}

.detected-confidence {
  color: var(--muted);
  font-size: 11px;
}

.scan-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.notice {
  margin: 12px 0;
  padding: 12px 14px;
  color: #655d42;
  background: #f6edcf;
  border: 1px solid rgba(125, 106, 43, 0.12);
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
}

.notice.danger {
  color: #7f3636;
  background: #f9e4e1;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label {
  color: #61655f;
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.inline-input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(47, 55, 43, 0.13);
  border-radius: 13px;
  outline: none;
}

.field input:focus,
.inline-input:focus {
  border-color: var(--sage-strong);
  box-shadow: 0 0 0 3px rgba(66, 104, 76, 0.1);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  margin-top: 12px;
}

.ban-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  color: #7f3636;
  background: #f9e4e1;
  border: 1px solid rgba(185, 67, 67, 0.09);
  border-radius: 999px;
  font-size: 13px;
}

.ban-chip button {
  width: 22px;
  height: 22px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
}

.loading-card {
  min-height: 340px;
  padding: 35px 22px;
  text-align: center;
}

.loading-orbit {
  position: relative;
  width: 118px;
  height: 118px;
  margin: 8px auto 24px;
  background: var(--sage);
  border-radius: 40px;
  animation: breathe 1.8s ease-in-out infinite;
}

.loading-orbit::before,
.loading-orbit::after {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.loading-orbit::before {
  top: 26px;
  left: 29px;
  width: 61px;
  height: 61px;
  background: #fff;
  box-shadow: 0 10px 20px rgba(53, 64, 50, 0.12);
}

.loading-orbit::after {
  top: 48px;
  left: 51px;
  width: 17px;
  height: 17px;
  background: var(--peach-strong);
}

.progress-steps {
  display: grid;
  gap: 7px;
  max-width: 300px;
  margin: 18px auto 0;
  color: var(--muted);
  text-align: left;
}

.progress-step {
  padding: 10px 12px;
  border-radius: 12px;
}

.progress-step.is-active {
  color: var(--sage-strong);
  background: var(--sage);
  font-weight: 700;
}

.tabbar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 760px);
  min-height: calc(70px + var(--safe-bottom));
  margin: 0 auto;
  padding: 7px 10px var(--safe-bottom);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(36, 40, 33, 0.08);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 30px rgba(42, 48, 39, 0.08);
}

.tab-button {
  display: grid;
  min-height: 52px;
  padding: 4px 2px;
  place-items: center;
  color: #90938d;
  background: transparent;
  border: 0;
  border-radius: 13px;
  font-size: 10px;
  font-weight: 700;
}

.tab-icon {
  display: grid;
  width: 29px;
  height: 27px;
  place-items: center;
  border-radius: 10px;
  font-size: 19px;
}

.tab-button.is-active {
  color: var(--sage-strong);
}

.tab-button.is-active .tab-icon {
  background: var(--sage);
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  align-items: end;
  padding-top: max(20px, env(safe-area-inset-top));
  background: rgba(29, 32, 27, 0.34);
}

.modal-sheet {
  width: min(100%, 760px);
  max-height: 92vh;
  margin: 0 auto;
  padding: 12px 18px calc(20px + var(--safe-bottom));
  overflow: auto;
  background: var(--cream);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -16px 40px rgba(29, 32, 27, 0.18);
  animation: sheet-in 220ms ease-out;
}

.sheet-handle {
  width: 42px;
  height: 5px;
  margin: 0 auto 18px;
  background: #ced0ca;
  border-radius: 999px;
}

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

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  color: var(--ink);
  background: rgba(55, 62, 51, 0.07);
  border: 0;
  border-radius: 50%;
  font-size: 20px;
}

.cooking-screen {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: var(--safe-top) 18px var(--safe-bottom);
  color: var(--ink);
  background: var(--cream);
}

.cooking-top,
.cooking-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wake-pill {
  color: var(--sage-strong);
  font-size: 12px;
  font-weight: 700;
}

.cooking-body {
  display: grid;
  flex: 1;
  padding: 24px 4px;
  place-items: center;
  text-align: center;
}

.step-number {
  margin-bottom: 15px;
  color: var(--sage-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-title {
  max-width: 600px;
  margin: 0 auto;
  font-size: clamp(28px, 7vw, 44px);
  line-height: 1.08;
}

.step-meta {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0;
}

.step-meta span {
  padding: 7px 10px;
  color: var(--sage-strong);
  background: var(--sage);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.step-copy {
  max-width: 560px;
  margin: 16px auto 0;
  color: #4f554e;
  font-size: clamp(17px, 4.5vw, 21px);
  font-weight: 540;
  line-height: 1.52;
}

.step-tip {
  max-width: 560px;
  margin: 18px auto 0;
  padding: 13px 15px;
  color: #655d42;
  background: #f6edcf;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
}

.step-tip strong {
  display: block;
  margin-bottom: 3px;
}

.cooking-footer button {
  flex: 1;
}

.offline-banner {
  position: sticky;
  z-index: 80;
  top: 0;
  padding: 8px 12px;
  color: #6d5728;
  background: #f4dfab;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: calc(88px + var(--safe-bottom));
  left: 16px;
  max-width: 480px;
  margin: 0 auto;
  padding: 13px 16px;
  color: #fff;
  background: rgba(35, 38, 33, 0.94);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(20, 22, 19, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

@keyframes breathe {
  50% { transform: scale(1.04) rotate(2deg); }
}

@keyframes sheet-in {
  from { transform: translateY(22px); opacity: 0; }
}

@media (min-width: 620px) {
  .main-content {
    padding: 22px 24px 34px;
  }

  .topbar {
    padding-right: 26px;
    padding-left: 26px;
  }

  .hero-card {
    display: grid;
    grid-template-columns: 155px 1fr;
    gap: 20px;
    align-items: center;
  }

  .dish-art {
    margin: 0;
  }
}

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