:root {
  --bg: #f5f2eb;
  --ink: #1f1b16;
  --card: #fffdf7;
  --line: #d8d0c3;
  --brand: #0f6a4d;
  --brand-2: #1a8b66;
  --muted: #6a6052;
  --review-icon-url: url("./assets/new-roots-logo.png");
  --review-icon-empty: #a3aab6;
  --review-icon-filled: #000000;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f3f4f7;
}

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem; border-bottom: 1px solid #e5e8ef; background: #ffffff; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.brand-home { display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 0; background: transparent; }
.brand h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.35rem; }
.layout { padding: 1rem; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.auth-card { grid-column: span 4; }
.directory-card { grid-column: span 8; }
.business-card { grid-column: span 4; }
.location-card { grid-column: span 8; }
.rating-card { grid-column: span 8; }
.tools-card { grid-column: span 4; }
.theme-card { grid-column: span 12; }

.card { background: #fff; border: 1px solid #e5e8ef; border-radius: 12px; padding: 1rem; box-shadow: 0 2px 8px rgba(21, 34, 50, 0.06); }
h1, h2, h3 { margin: 0; }
h2 { font-size: 1.1rem; margin-bottom: 0.7rem; }
h3 { font-size: 0.95rem; margin: 0.9rem 0 0.5rem; }

.grid2 { display: grid; grid-template-columns: 1fr; gap: 0.55rem; }
input, button { padding: 0.62rem 0.72rem; border-radius: 8px; border: 1px solid #d5dbe7; font: inherit; }
button {
  background: linear-gradient(180deg, #dcefe6, #c9e4d8);
  color: var(--ink);
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
}
button:hover { filter: brightness(1.05); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.actions.compact { margin-top: 0; }
.center-actions { justify-content: center; }

.out { margin-top: 0.8rem; background: #121212; color: #98f0be; padding: 0.65rem; border-radius: 9px; min-height: 105px; white-space: pre-wrap; overflow-x: auto; }
.api-base-wrap { display: flex; gap: 0.5rem; align-items: center; }
.api-base-wrap input { min-width: 300px; }
.row { display: flex; }
.row.between { justify-content: space-between; }
.row.center { align-items: center; }
.row.gap-sm { gap: 0.5rem; }
.search-center { justify-content: center; margin-top: 0.3rem; }
.search-center input { width: min(680px, 100%); text-align: center; }
.directory-hero {
  display: flex;
  justify-content: center;
  margin-bottom: 0.65rem;
}
.directory-brand {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}
.directory-brand h1 {
  font-size: 1.25rem;
  margin: 0;
  text-align: center;
}
.directory-brand .brand-logo {
  width: 250px;
  height: 250px;
}
.search-options {
  margin-top: 0.65rem;
}
.search-options .row {
  justify-content: center;
  margin-top: 0.35rem;
}
.search-options select {
  min-width: 260px;
  max-width: 100%;
}
.alpha-chips {
  margin-top: 0.3rem;
}
.auth-inline-msg {
  margin-top: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #e1b8b8;
  background: #fff0f0;
  color: #8e2020;
  font-size: 0.9rem;
}

.list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.6rem; margin-top: 0.7rem; }
.list.small { grid-template-columns: 1fr; }
.item { border: 1px solid #e3e7ef; background: #fff; border-radius: 10px; padding: 0.65rem; cursor: pointer; }
.item:hover { border-color: #c7d2e4; }
.item.active { border-color: var(--brand); background: #eef8f3; }
.item-title { font-weight: 700; margin-bottom: 0.35rem; }
.item-sub { color: var(--muted); font-size: 0.9rem; }
.muted { color: var(--muted); }

.list.featured-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.featured-card {
  padding: 0;
  overflow: hidden;
  display: grid;
  gap: 0;
  border-radius: 12px;
}

.featured-card-media {
  aspect-ratio: 4 / 3;
  background: #eef2f8;
}

.featured-card-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.featured-card-body {
  padding: 0.58rem 0.62rem 0.62rem;
  display: grid;
  gap: 0.22rem;
}

.featured-card-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.featured-card .item-title {
  font-size: 0.92rem;
  line-height: 1.2;
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.featured-card .item-sub {
  font-size: 0.79rem;
  line-height: 1.25;
}

.featured-card .rating-row {
  gap: 0.35rem;
  margin-top: 0.05rem;
}

.featured-card .logo-token {
  width: 16px;
  height: 16px;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.logo-rating {
  display: inline-flex;
  gap: 0.2rem;
}

.logo-token {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 20px;
}

.logo-token::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--review-icon-empty);
  -webkit-mask-image: var(--review-icon-url);
  mask-image: var(--review-icon-url);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.logo-token::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--review-icon-filled);
  -webkit-mask-image: var(--review-icon-url);
  mask-image: var(--review-icon-url);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  clip-path: inset(0 calc(100% - var(--fill, 0%)) 0 0);
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.chip { font-size: 0.8rem; border: 1px solid #d8cfbe; color: #5f5342; padding: 0.2rem 0.5rem; border-radius: 999px; background: #faf6ea; }
.chip.active { border-color: var(--brand); color: #0f4e39; background: #e8f5ef; }

.review-feed {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.review-card {
  border: 1px solid #e3e7ef;
  border-radius: 10px;
  background: #fff;
  padding: 0.65rem;
}

.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.review-user {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #eff3fb;
  color: #394d67;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.review-meta {
  color: #687487;
  font-size: 0.78rem;
}

.review-text {
  margin-top: 0.45rem;
  font-size: 0.92rem;
  line-height: 1.4;
}

.reply-card {
  margin-top: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border-left: 3px solid var(--brand);
  background: #f1f7f4;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.media-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #d9dfe9;
  background: #eef2f8;
}

.media-link {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  display: block;
  width: 100%;
}
.media-link.active .media-thumb {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.overlay {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  width: 100vw;
  min-height: 100dvh;
  height: 100dvh;
  background: rgba(16, 20, 28, 0.65);
  z-index: 2000;
  display: grid;
  place-items: center;
  align-items: center;
  justify-items: center;
  padding: 1rem;
  overflow: auto;
}

.overlay-card {
  width: min(920px, 96vw);
  max-height: 92vh;
  overflow: auto;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #dce3ef;
  padding: 1rem;
  margin: auto;
}

.page-loading-overlay {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  width: 100vw;
  min-height: 100dvh;
  height: 100dvh;
  z-index: 2500;
  background: rgba(245, 244, 247, 0.88);
  display: grid;
  place-items: center;
  align-items: center;
  justify-items: center;
  padding: 1rem;
  overflow: hidden;
}

.page-loading-card {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
}

.page-loading-logo {
  width: 112px;
  height: 112px;
  object-fit: contain;
  animation: page-loading-spin 1.4s linear infinite;
}

.page-loading-text {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-transform: uppercase;
}

@keyframes page-loading-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.overlay-body {
  margin-top: 0.6rem;
}

.image-card {
  width: min(1200px, 96vw);
}

.lightbox-image {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 10px;
  background: #0f1012;
}

.factor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.6rem; margin-bottom: 0.75rem; }
.slider-item { border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem; background: #fffaf1; }
.slider-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; font-size: 0.9rem; }

.factor-logo-input {
  display: inline-flex;
  gap: 0.22rem;
  user-select: none;
}

.factor-logo-input .logo-token {
  width: 26px;
  height: 26px;
  cursor: pointer;
}

.factor-help {
  margin-top: 0.25rem;
  font-size: 0.76rem;
  color: #687487;
}

.review-secondary-panel {
  margin-top: 0.4rem;
  border-top: 1px solid #e7dfd2;
  padding-top: 0.75rem;
}

.review-auth-gate {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
  background: #fffaf1;
}

.secondary-review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.65rem;
}

.range-field {
  display: grid;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: #fffaf1;
}

.range-field input[type="range"] {
  width: 100%;
  padding: 0;
  border: 0;
}

.range-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #5f5342;
}

.binary-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin-top: 0.7rem;
}

.binary-field {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: #fffaf1;
}

.binary-label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
}

.binary-options {
  display: flex;
  gap: 0.45rem;
}

.binary-btn {
  flex: 1 1 0;
  min-width: 0;
}

.binary-btn.active {
  background: #0f6a4d;
  color: #1f1b16;
}

.review-food-fields {
  margin-top: 0.85rem;
}

.toast-host { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 0.45rem; z-index: 30; }
.toast { min-width: 240px; max-width: 360px; color: var(--ink); border-radius: 9px; padding: 0.55rem 0.65rem; font-size: 0.88rem; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18); }
.toast.ok { background: #0f6a4d; }
.toast.err { background: #a02626; }

@media (max-width: 1200px) {
  .list.featured-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .auth-card, .directory-card, .business-card, .location-card, .rating-card, .tools-card, .theme-card { grid-column: span 12; }
  .topbar { flex-direction: column; align-items: stretch; }
  .api-base-wrap { flex-wrap: wrap; }
  .api-base-wrap input { min-width: 0; width: 100%; }
  .list.featured-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.38rem; }
  .featured-card-media { aspect-ratio: 4 / 5; }
  .featured-card-body { padding: 0.48rem 0.5rem 0.54rem; gap: 0.18rem; }
  .featured-card .item-title { font-size: 0.84rem; }
  .featured-card .item-sub { font-size: 0.74rem; }
  .featured-card .logo-token { width: 14px; height: 14px; }
}

@media (max-width: 680px) {
  .list.featured-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.review-toolbar {
  margin-top: 0.6rem;
}

select {
  border-radius: 8px;
  border: 1px solid #d5dbe7;
  padding: 0.35rem 0.45rem;
  font: inherit;
  background: #fff;
}

.review-pager {
  margin-top: 0.65rem;
  gap: 0.6rem;
}

.business-pager {
  margin-top: 0.65rem;
  gap: 0.6rem;
}

.review-pager button {
  min-width: 96px;
}

.business-pager button {
  min-width: 96px;
}

.compact-header h1 {
  font-size: 1.05rem;
}

.hidden {
  display: none !important;
}

.link-chip {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
}

.business-page .profile-hero { grid-column: span 12; }
.business-page .profile-left { grid-column: span 8; }
.business-page .profile-right { grid-column: span 4; }
.business-page .profile-full { grid-column: span 12; }
.business-page .layout { align-items: start; }
.business-page #section-overview,
.business-page #section-hours,
.business-page #section-location {
  grid-column: span 4;
  aspect-ratio: 1 / 1;
  overflow: auto;
}
.add-business-card { grid-column: span 12; }
.hero-grid { margin-top: 0.7rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.business-page .hero-grid .media-thumb { aspect-ratio: 16 / 9; }
.featured-media {
  margin-top: 0.7rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #d9dfe9;
  background: #eef2f8;
}
.featured-image {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
}
.business-page .hero-grid {
  margin-top: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.business-page .hero-grid .media-thumb {
  aspect-ratio: 4 / 3;
}

.section-anchor {
  scroll-margin-top: 150px;
}

.action-launchers {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.action-launcher-row {
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
}

.action-launcher-row button {
  min-width: 220px;
  justify-content: center;
  text-align: center;
}

.embed-mode .layout {
  padding: 0.6rem;
}

.embed-mode .topbar {
  justify-content: flex-end;
}

.admin-layout {
  grid-template-columns: 2fr 3fr;
  align-items: start;
}

.admin-right-stack {
  grid-column: 2;
  display: grid;
  gap: 1rem;
}

.admin-sidebar {
  grid-column: 1;
  position: sticky;
  top: 84px;
}

.admin-list,
.admin-detail {
  grid-column: auto;
}

.admin-business-tools {
  margin-top: 0.9rem;
  border-top: 1px solid #e5e8ef;
  padding-top: 0.8rem;
}

#adminBusinessEditor {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.5rem;
}

@media (max-width: 1100px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar,
  .admin-right-stack {
    grid-column: span 12;
  }

  .admin-sidebar {
    position: static;
  }
}

.embed-mode .auth-card,
.embed-mode .directory-card,
.embed-mode .business-card,
.embed-mode .location-card {
  grid-column: span 12;
}

.embed-mode .theme-card {
  grid-column: span 12;
}

.embed-mode .out {
  display: none;
}

@media (max-width: 920px) {
  .business-page .profile-left,
  .business-page .profile-right,
  .business-page .profile-full,
  .business-page .profile-hero { grid-column: span 12; }
  .business-page #section-overview,
  .business-page #section-hours,
  .business-page #section-location {
    grid-column: span 12;
    aspect-ratio: auto;
    overflow: visible;
  }

  .overlay,
  .page-loading-overlay {
    padding:
      max(0.85rem, env(safe-area-inset-top))
      max(0.85rem, env(safe-area-inset-right))
      max(0.85rem, env(safe-area-inset-bottom))
      max(0.85rem, env(safe-area-inset-left));
  }

  .overlay-card {
    width: min(100%, 100vw - 1.7rem);
    max-height: calc(100dvh - 1.7rem);
  }

  .image-card {
    width: min(100%, 100vw - 1.7rem);
  }

  .page-loading-logo {
    width: 96px;
    height: 96px;
  }
}
