:root {
  --fox: #e67e22;
  --fox-dark: #c96a14;
  --fox-soft: #fff4e8;
  --ink: #1c1917;
  --muted: #6b635c;
  --line: #e8e0d6;
  --surface: #fffdf9;
  --card: #ffffff;
  --bg: #f7f1ea;
  --bg-glow: radial-gradient(ellipse 80% 55% at 50% 0%, #ffd9b0 0%, transparent 60%),
    linear-gradient(180deg, #fbe9d6 0%, var(--bg) 45%, #f3ebe3 100%);
  --zepto: #7c3aed;
  --instamart: #ea580c;
  --radius: 14px;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Author display rules must not override the hidden attribute */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

/* —— Landing (S0) —— */

.land {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
  background: var(--bg-glow);
  overflow: hidden;
}

.land__glow {
  position: absolute;
  inset: auto -20% 10% -20%;
  height: 40%;
  background: radial-gradient(ellipse at center, rgba(230, 126, 34, 0.18), transparent 70%);
  pointer-events: none;
}

.land__inner {
  position: relative;
  width: min(100%, 420px);
  text-align: center;
}

.land__logo {
  display: block;
  width: min(100%, 280px);
  height: auto;
  margin: 0 auto 1.25rem;
  filter: drop-shadow(0 12px 28px rgba(201, 106, 20, 0.22));
}

.land__brand {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.land__tagline {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--fox-dark);
}

.land__support {
  margin: 0 0 1.75rem;
  font-size: 1rem;
  color: var(--muted);
  max-width: 28ch;
  margin-left: auto;
  margin-right: auto;
}

.btn--cta {
  width: auto;
  min-width: 240px;
  padding: 0.9rem 1.5rem;
  font-size: 1.05rem;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(230, 126, 34, 0.35);
}

/* —— App shell —— */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1.15rem 3rem;
}

.app-header {
  margin-bottom: 1.25rem;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-header__logo {
  width: 56px;
  height: auto;
  flex-shrink: 0;
}

.app-header__name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.app-header__tag {
  margin: 0.1rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal--open {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.5);
}

.modal__panel {
  position: relative;
  width: min(100%, 480px);
  padding: 1.5rem;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.modal__title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.modal__subtitle {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.modal__status {
  margin: 1rem 0 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.modal__status--info,
.modal__status--loading {
  background: var(--fox-soft);
  color: var(--fox-dark);
}

.modal__status--error {
  background: #fef2f2;
  color: #991b1b;
}

.modal__actions {
  margin-top: 1.25rem;
}

.location-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.location-tab {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
}

.location-tab--active {
  background: var(--fox);
  border-color: var(--fox);
  color: #fff;
}

.location-mode {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.location-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.location-hint--warn {
  color: #92400e;
  background: #fffbeb;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

#places-input,
#manual-lat,
#manual-lng {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: #fff;
}

.manual-coords {
  display: grid;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line);
}

.btn {
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  width: 100%;
  background: var(--fox);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--fox-dark);
}

.btn--secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn--secondary:hover:not(:disabled) {
  background: #f0e8df;
}

.eta-bar {
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.eta-bar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.eta-bar__location {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: var(--ink);
  min-width: 0;
}

.eta-bar__pin {
  flex-shrink: 0;
}

#eta-location-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eta-bar__change {
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--fox-dark);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.eta-vendors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.eta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--ink);
}

.eta-chip strong {
  font-weight: 700;
}

.eta-chip--zepto {
  border-color: #ddd6fe;
  background: #f5f3ff;
}

.eta-chip--instamart {
  border-color: #fed7aa;
  background: #fff7ed;
}

.eta-chip--muted {
  color: var(--muted);
}

.eta-chip--unserviceable {
  opacity: 0.75;
}

.search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

#search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  background: #fff;
}

#search-input:focus {
  outline: none;
  border-color: var(--fox);
  box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.2);
}

#search-btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 12px;
  background: var(--fox);
  color: #fff;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

#search-btn:hover:not(:disabled) {
  background: var(--fox-dark);
}

#search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.status--loading {
  background: var(--fox-soft);
  color: var(--fox-dark);
}

.status--error {
  background: #fef2f2;
  color: #991b1b;
}

.status--warning {
  background: #fffbeb;
  color: #92400e;
}

.status--empty {
  background: #f3f4f6;
  color: #4b5563;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* —— Result cards (S3) —— */

.product-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.product-image-wrap {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-image--placeholder {
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: center;
  padding: 0.5rem;
}

.product-name {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.3;
}

.product-brand {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.vendor-prices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.vendor-price {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.vendor-price:hover,
.vendor-price:focus-visible {
  border-color: var(--fox);
  background: var(--fox-soft);
  outline: none;
}

.vendor-price--zepto {
  border-left: 3px solid var(--zepto);
}

.vendor-price--instamart {
  border-left: 3px solid var(--instamart);
}

.vendor-price--static {
  cursor: default;
}

.vendor-price--static:hover {
  border-color: var(--line);
  background: var(--surface);
}

.vendor-price__left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.vendor-mark {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.vendor-mark--zepto {
  background: var(--zepto);
}

.vendor-mark--instamart {
  background: var(--instamart);
}

.vendor-mark--unknown {
  background: #78716c;
}

.vendor-price__meta {
  min-width: 0;
}

.vendor-qty {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.2;
}

.vendor-price__right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.vendor-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.vendor-amount--missing {
  color: #9ca3af;
  font-weight: 500;
}

.vendor-lowest {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #166534;
  background: #dcfce7;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.meta {
  display: none;
}

@media (max-width: 540px) {
  .search-form {
    flex-direction: column;
  }

  .product-card {
    grid-template-columns: 96px 1fr;
    gap: 0.85rem;
  }

  .product-image-wrap {
    width: 96px;
    height: 96px;
  }

  .btn--cta {
    width: 100%;
    min-width: 0;
  }
}
