:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --ink: #20211d;
  --muted: #6f716a;
  --line: #ded9ca;
  --panel: #fffdf7;
  --panel-strong: #ffffff;
  --accent: #256f6c;
  --accent-dark: #164d4b;
  --gold: #b8872d;
  --rose: #a95757;
  --shadow: 0 18px 50px rgba(46, 42, 31, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(37, 111, 108, 0.11), transparent 34rem),
    linear-gradient(315deg, rgba(184, 135, 45, 0.12), transparent 30rem),
    var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  min-height: 148px;
  padding: 26px;
  border: 1px solid rgba(222, 217, 202, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 253, 247, 0.95), rgba(255, 253, 247, 0.72)),
    repeating-linear-gradient(135deg, rgba(37, 111, 108, 0.08) 0 1px, transparent 1px 18px);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 720px;
  margin-bottom: 0;
  font-size: clamp(2.2rem, 5vw, 4.9rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.now-card {
  display: grid;
  align-content: center;
  justify-items: end;
  min-width: 172px;
  padding: 18px;
  border-left: 1px solid var(--line);
  color: var(--accent-dark);
}

.now-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.now-card strong {
  font-size: 1.7rem;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.15fr) minmax(230px, auto) minmax(220px, auto);
  gap: 14px;
  margin-top: 16px;
  align-items: end;
}

.search-box,
.control-group,
.location-panel,
.visited-panel {
  min-width: 0;
}

.search-box {
  display: grid;
  gap: 7px;
}

.search-box span,
.control-group > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  outline: none;
  padding: 10px 12px;
}

input:focus {
  border-color: rgba(37, 111, 108, 0.68);
  box-shadow: 0 0 0 3px rgba(37, 111, 108, 0.12);
}

.control-group {
  display: grid;
  gap: 7px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.72);
}

.segmented button {
  min-width: 72px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

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

.location-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 14px;
  border: 1px solid rgba(222, 217, 202, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.68);
}

.visited-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 14px;
  border: 1px solid rgba(222, 217, 202, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.68);
}

.visited-panel p,
.location-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 720;
}

.visited-panel button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 820;
}

.location-panel button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 820;
}

.exclude-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(222, 217, 202, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.68);
}

.exclude-panel legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.exclude-panel label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 6px 10px;
  font-size: 0.88rem;
  font-weight: 820;
}

.exclude-panel input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.drive-slider {
  grid-column: 1 / -1;
  display: grid;
  gap: 9px;
  min-height: 62px;
  padding: 12px 14px;
  border: 1px solid rgba(222, 217, 202, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.68);
}

.drive-slider span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.drive-slider strong {
  color: var(--accent-dark);
}

.drive-slider input {
  width: 100%;
  min-height: 24px;
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
  box-shadow: none;
}

.primary-action {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 0 18px;
  font-weight: 850;
}

.primary-action:hover {
  background: var(--accent-dark);
}

#locationStatus {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.location-dialog {
  width: min(420px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 0;
  box-shadow: var(--shadow);
}

.location-dialog::backdrop {
  background: rgba(32, 33, 29, 0.42);
}

.location-dialog > div {
  padding: 22px;
}

.location-dialog h2 {
  margin-bottom: 8px;
  font-size: 1.45rem;
}

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

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

.dialog-actions button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 850;
}

.pin-field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.pin-field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

#skipLocationButton {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.summary-grid > div {
  min-height: 82px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.74);
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  margin-top: 8px;
  color: var(--accent-dark);
  font-size: 1.6rem;
}

.results {
  margin-top: 16px;
}

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

.mass-card {
  display: grid;
  grid-template-columns: minmax(92px, 0.32fr) minmax(0, 1fr);
  gap: 16px;
  min-height: 172px;
  padding: 16px;
  border: 1px solid rgba(222, 217, 202, 0.9);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(46, 42, 31, 0.08);
}

.time-block {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding-right: 14px;
  border-right: 1px solid var(--line);
}

.time-block strong {
  color: var(--accent-dark);
  font-size: 2rem;
  line-height: 1;
}

.time-block span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.time-left {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  background: rgba(184, 135, 45, 0.16);
  color: #6c4a14;
  padding: 6px 9px;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: normal;
}

.mass-content {
  min-width: 0;
}

.mass-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mass-title h2 {
  margin-bottom: 4px;
  font-size: 1.08rem;
  line-height: 1.22;
  letter-spacing: 0;
}

.distance-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(37, 111, 108, 0.22);
  border-radius: 999px;
  background: rgba(37, 111, 108, 0.1);
  color: var(--accent-dark);
  padding: 5px 8px;
  font-size: 0.8rem;
  font-weight: 850;
  white-space: nowrap;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 12px;
}

.meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 760;
}

.meta .drive-time {
  border-color: rgba(169, 87, 87, 0.26);
  background: rgba(169, 87, 87, 0.09);
  color: #7d3434;
}

.meta .drive-time.is-loading,
.meta .drive-time.is-muted {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.meta .visited-badge {
  border-color: rgba(184, 135, 45, 0.28);
  background: rgba(184, 135, 45, 0.12);
  color: #755414;
}

.address {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.44;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.card-actions a,
.card-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 820;
  text-decoration: none;
}

.card-actions a:hover,
.card-actions button:hover {
  border-color: rgba(37, 111, 108, 0.45);
  color: var(--accent-dark);
}

.visited-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 820;
}

.visited-toggle input {
  width: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

.visited-toggle:has(input:checked) {
  border-color: rgba(184, 135, 45, 0.42);
  background: rgba(184, 135, 45, 0.12);
  color: #755414;
}

.schedule-panel {
  grid-column: 1 / -1;
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.schedule-panel.is-open {
  display: grid;
  gap: 7px;
}

.schedule-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.schedule-row strong {
  color: var(--ink);
}

.empty-state {
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 6px;
}

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

@media (max-width: 860px) {
  .topbar,
  .controls,
  .location-panel,
  .summary-grid,
  .cards {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .now-card {
    justify-items: start;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 9px;
  }

  .topbar {
    padding: 18px;
  }

  .controls {
    gap: 10px;
  }

  .search-box,
  .control-group {
    grid-template-columns: 74px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
  }

  .search-box {
    display: grid;
  }

  .search-box span,
  .control-group > span {
    font-size: 0.8rem;
  }

  .search-box input {
    min-height: 40px;
  }

  .segmented {
    display: flex;
    min-width: 0;
    min-height: 40px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .segmented::-webkit-scrollbar {
    display: none;
  }

  .segmented button {
    flex: 1 0 auto;
    min-width: 64px;
    min-height: 34px;
    padding: 0 9px;
    white-space: nowrap;
    font-size: 0.86rem;
  }

  .location-panel,
  .visited-panel,
  .exclude-panel,
  .drive-slider {
    padding: 10px;
  }

  .location-panel p,
  .visited-panel p {
    flex: 1 1 190px;
  }

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

  .time-block {
    grid-template-columns: auto auto 1fr;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 12px;
  }

  .time-block strong {
    font-size: 1.7rem;
  }

  .mass-title {
    display: grid;
  }

  .distance-pill {
    width: fit-content;
  }

  .summary-grid > div {
    min-height: 70px;
  }
}
