:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-soft: #f2f6f3;
  --ink: #17211e;
  --muted: #5f6d68;
  --muted-soft: #7b8883;
  --line: #dbe2dc;
  --line-strong: #c9d4cc;
  --green: #1f7f5c;
  --green-dark: #135a41;
  --red: #9d3b2a;
  --blue: #315f9c;
  --shadow: 0 10px 24px rgba(22, 31, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  border-color: var(--green);
}

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

.shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 0 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 2.35rem;
  line-height: 1;
  letter-spacing: 0;
}

.topbar p {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
}

.search-box,
.control-group,
.location-panel,
.toggle-group,
.city-filter,
.drive-slider {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}

.search-box {
  order: 1;
  grid-column: span 4;
}

.control-group {
  grid-column: span 4;
}

.controls > .control-group:nth-of-type(1) {
  order: 3;
  grid-column: span 4;
}

.location-panel {
  order: 2;
  grid-column: span 8;
}

.toggle-group {
  order: 4;
  grid-column: span 4;
}

.drive-slider {
  order: 5;
  grid-column: span 4;
}

.city-filter {
  order: 6;
  grid-column: span 12;
}

.search-box,
.drive-slider {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.search-box span,
.location-panel span,
.control-group > span,
.toggle-group > span,
.city-filter-head span,
.drive-slider span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.search-box input,
.location-panel input,
.manual-save input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.location-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.location-panel > div:first-child {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.location-panel input {
  min-height: 34px;
  padding: 0;
}

.location-panel button {
  padding: 0 14px;
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.location-actions {
  display: flex;
  gap: 8px;
}

.control-group {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented button {
  flex: 1 1 76px;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segmented button.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.location-panel p {
  margin: 0;
  min-width: 0;
  color: var(--muted);
  line-height: 1.35;
}

.toggle-group {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.toggle-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 34px;
  padding: 0;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.2;
}

.saved-toggle input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.saved-toggle span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-slider input {
  width: 100%;
  accent-color: var(--green);
}

.city-filter {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.city-filter[hidden] {
  display: none;
}

.city-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.city-filter-head strong {
  color: var(--muted);
  font-size: 0.86rem;
}

.city-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.city-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.city-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.city-option strong {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}

.summary-grid div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.55rem;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.results,
.saved-section {
  min-width: 0;
}

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

.section-heading span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.section-heading h2 {
  margin: 3px 0 0;
  font-size: 1.08rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-heading strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 0.92rem;
}

.cards {
  display: grid;
  gap: 10px;
}

.food-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.distance-rail {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 14px 10px;
  background: var(--surface-soft);
  text-align: center;
}

.distance-rail strong {
  display: block;
  color: var(--green-dark);
  font-size: 1.2rem;
  line-height: 1;
}

.distance-rail span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.food-content {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
}

.food-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.food-title h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.food-title p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.42;
}

.badges,
.actions,
.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.badge.is-open {
  border-color: rgba(31, 127, 92, 0.28);
  background: #eaf7ef;
  color: var(--green-dark);
}

.badge.is-closed {
  border-color: rgba(157, 59, 42, 0.26);
  background: #fff1ec;
  color: var(--red);
}

.badge.is-saved {
  border-color: rgba(49, 95, 156, 0.28);
  background: #eef4ff;
  color: var(--blue);
}

.badge.is-visited {
  border-color: rgba(31, 127, 92, 0.28);
  background: #eaf7ef;
  color: var(--green-dark);
}

.badge.is-abui-star {
  border-color: rgba(157, 59, 42, 0.24);
  background: #fff6df;
  color: #8a4f00;
}

.meta-line {
  color: var(--muted);
  font-size: 0.88rem;
}

.personal-rating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.personal-rating > span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.rating-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rating-buttons button {
  min-width: 34px;
  min-height: 32px;
  padding: 0 9px;
  border-color: var(--line-strong);
  background: #fff;
  color: var(--muted);
}

.rating-buttons button.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.is-abui-rating .rating-buttons button.is-active {
  border-color: #b96d00;
  background: #b96d00;
}

.rating-buttons .clear-rating {
  color: var(--red);
}

.actions a,
.actions button,
.saved-item-actions a,
.saved-item-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
}

.actions a:hover,
.actions button:hover,
.saved-item-actions a:hover,
.saved-item-actions button:hover {
  border-color: var(--green);
}

.save-action.is-saved {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.dismiss-action,
.saved-item-actions button {
  color: var(--red);
}

.dismiss-action:hover,
.saved-item-actions button:hover {
  border-color: var(--red);
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

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

.saved-section {
  position: sticky;
  top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.saved-home-card {
  display: grid;
  gap: 12px;
}

.saved-home-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.saved-open-button {
  width: 100%;
}

.saved-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
}

.manual-save {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(31, 127, 92, 0.26);
  border-radius: 8px;
  background: #edf7f1;
}

.manual-save label {
  display: grid;
  gap: 6px;
}

.manual-save span {
  color: var(--green-dark);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.manual-save input {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.manual-save input:focus {
  border-color: var(--green);
}

.manual-save button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.saved-item,
.saved-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.saved-item {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.saved-item h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.saved-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.saved-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.saved-item-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.saved-empty {
  padding: 14px;
}

.saved-empty strong {
  display: block;
  margin-bottom: 6px;
}

.saved-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.location-dialog,
.saved-dialog {
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.location-dialog {
  width: min(420px, calc(100% - 28px));
}

.saved-dialog {
  width: min(1240px, calc(100% - 28px));
}

.location-dialog::backdrop,
.saved-dialog::backdrop {
  background: rgba(23, 33, 30, 0.42);
}

.location-dialog > div,
.saved-dialog > div {
  padding: 22px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.saved-dialog > div {
  display: grid;
  max-height: min(86vh, 820px);
  overflow: auto;
}

.saved-dialog .personal-rating {
  gap: 6px;
  padding: 6px 8px;
}

.saved-dialog .rating-buttons {
  gap: 4px;
}

.saved-dialog .rating-buttons button {
  min-width: 30px;
  min-height: 30px;
  padding: 0 8px;
}

.saved-dialog .saved-item-actions a,
.saved-dialog .saved-item-actions button {
  min-height: 34px;
}

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

.saved-dialog-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.saved-dialog-header button {
  padding: 0 12px;
}

.saved-search {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.saved-search span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.saved-search input {
  width: 100%;
  min-height: 38px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.location-dialog h2 {
  margin: 0;
  font-size: 1.35rem;
}

.location-dialog p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.dialog-actions button {
  flex: 1;
}

.primary-action {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

@media (max-width: 1180px) {
  .search-box,
  .location-panel,
  .toggle-group,
  .city-filter,
  .drive-slider {
    grid-column: span 6;
  }

  .control-group {
    grid-column: span 6;
  }

  .controls > .control-group:nth-of-type(1) {
    grid-column: span 6;
  }
}

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .saved-list {
    grid-template-columns: 1fr;
  }

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

  .saved-section {
    position: static;
    order: -1;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 560px);
    padding-top: 16px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 2rem;
  }

  .controls,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .search-box,
  .control-group,
  .location-panel,
  .toggle-group,
  .city-filter,
  .drive-slider {
    grid-column: span 1;
  }

  .controls > .control-group:nth-of-type(1) {
    grid-column: span 1;
  }

  .location-panel {
    grid-template-columns: 1fr;
  }

  .toggle-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .saved-toggle {
    min-height: 28px;
    gap: 5px;
  }

  .saved-toggle input {
    width: 16px;
    height: 16px;
  }

  .saved-toggle span {
    font-size: 0.86rem;
  }

  .food-card {
    grid-template-columns: 1fr;
  }

  .distance-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    text-align: left;
  }

  .food-title {
    flex-direction: column;
  }

  .actions a,
  .actions button {
    flex: 1 1 128px;
  }
}
