:root {
  --ink: #16211f;
  --muted: #63716e;
  --panel: #f8f5ef;
  --paper: #fffdf8;
  --line: #ded8cc;
  --forest: #1f4d3a;
  --moss: #6f8b48;
  --lake: #2b7585;
  --sun: #e7a83d;
  --clay: #ba6041;
  --shadow: 0 24px 70px rgba(30, 45, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.95), rgba(239, 244, 238, 0.96)),
    #eef2eb;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.planner-grid {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  min-height: calc(100vh - 48px);
  border: 1px solid rgba(22, 33, 31, 0.08);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.planner-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: clamp(24px, 4vw, 48px);
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.step-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.58);
}

.manual-controls {
  display: grid;
  gap: 24px;
}

.manual-controls[hidden] {
  display: none;
}

.planner-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  background: #fffaf1;
}

.planner-mode label {
  position: relative;
  display: block;
  min-height: 42px;
}

.planner-mode input {
  position: absolute;
  opacity: 0;
}

.planner-mode span {
  display: grid;
  place-items: center;
  height: 100%;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.planner-mode input:checked + span {
  color: white;
  background: var(--forest);
  border-color: var(--forest);
}

.step-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-heading span {
  display: grid;
  place-items: center;
  width: 28px;
  aspect-ratio: 1;
  color: white;
  background: var(--lake);
  font-size: 0.8rem;
  font-weight: 900;
}

.step-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.brand-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  color: white;
  background: var(--forest);
  font-weight: 800;
  font-size: 1.35rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--clay);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2.05rem, 4vw, 4.8rem);
  line-height: 0.95;
  max-width: 10ch;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  position: relative;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field input,
.prompt-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffaf1;
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

.field input {
  min-height: 48px;
}

.place-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  display: none;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 18px 36px rgba(22, 33, 31, 0.16);
}

.place-suggestions.show {
  display: grid;
}

.place-suggestions button {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
}

.place-suggestions button:hover,
.place-suggestions button:focus {
  background: #edf4ea;
}

.place-suggestions strong {
  font-size: 0.88rem;
}

.place-suggestions span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.prompt-box textarea {
  min-height: 84px;
  padding: 12px 14px;
  resize: vertical;
}

.ai-prompt-box textarea {
  min-height: 138px;
  font-size: 1rem;
  line-height: 1.5;
}

.field input:focus,
.prompt-box textarea:focus {
  border-color: var(--lake);
  box-shadow: 0 0 0 3px rgba(43, 117, 133, 0.15);
}

.prompt-box {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.prompt-box b {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 7px;
  background: #e7f2e3;
  color: var(--forest);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.quick-picks,
.form-actions,
.top-actions,
.toolbar,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-picks button,
.secondary-action,
.toolbar button,
.inline-actions button,
.add-stop,
.ad-box button,
.inline-ad button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fffaf1;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 800;
}

.quick-picks button:hover,
.secondary-action:hover,
.toolbar button:hover,
.inline-actions button:hover,
.add-stop:hover,
.ad-box button:hover,
.inline-ad button:hover {
  border-color: var(--forest);
}

.control-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.segmented,
.mode-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mode-bar {
  grid-template-columns: repeat(3, 1fr);
}

.segmented label,
.chip-grid label,
.mode-bar label {
  min-width: 0;
}

.segmented input,
.chip-grid input,
.mode-bar input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span,
.mode-bar span,
.chip-grid span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fffaf1;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

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

.chip-grid span {
  justify-items: start;
  padding: 0 12px;
}

.segmented input:checked + span,
.chip-grid input:checked + span,
.mode-bar input:checked + span {
  color: white;
  border-color: var(--forest);
  background: var(--forest);
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  border: 0;
  background: var(--sun);
  color: #21180b;
  font-weight: 900;
  cursor: pointer;
}

.form-actions .primary-action {
  flex: 1 1 220px;
}

.top-actions .primary-action {
  flex: 1 1 180px;
}

.secondary-action {
  flex: 0 0 110px;
  min-height: 54px;
}

.helper-text {
  margin: -10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.server-status {
  margin: -8px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fffaf1;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.server-status.live {
  color: #17382f;
  background: #e7f2e3;
  border-color: #c8dcc3;
}

.primary-action:hover {
  filter: brightness(0.97);
}

.map-panel {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  background: #23332f;
}

.map-panel img {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 48px);
  object-fit: cover;
  display: block;
}

.map-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(11, 24, 21, 0.58), rgba(11, 24, 21, 0.04) 58%),
    linear-gradient(0deg, rgba(11, 24, 21, 0.55), rgba(11, 24, 21, 0.02) 44%);
}

.route-map-card {
  position: absolute;
  top: clamp(18px, 3vw, 34px);
  right: clamp(18px, 3vw, 34px);
  z-index: 1;
  width: min(360px, calc(100% - 36px));
  border: 1px solid rgba(255, 255, 255, 0.44);
  background: rgba(255, 253, 248, 0.9);
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(11, 24, 21, 0.2);
  backdrop-filter: blur(12px);
}

.route-map-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(22, 33, 31, 0.12);
}

.route-map-head span,
.selected-route span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.route-map-head a {
  color: var(--forest);
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
}

#routeSvg {
  display: block;
  width: 100%;
  height: 170px;
}

#routeSvg rect {
  fill: #eef2eb;
}

#routeSvg circle {
  fill: var(--forest);
  stroke: white;
  stroke-width: 4;
}

#endPin {
  fill: var(--clay);
}

.selected-route {
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
}

.selected-route div {
  display: grid;
  gap: 3px;
}

.selected-route strong {
  font-size: 0.92rem;
}

.selected-route p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.route-overlay {
  position: absolute;
  left: clamp(24px, 5vw, 64px);
  right: clamp(24px, 5vw, 64px);
  bottom: clamp(24px, 5vw, 56px);
  z-index: 1;
  color: white;
}

.route-overlay h2 {
  margin-bottom: 22px;
  font-size: clamp(2rem, 5vw, 5.6rem);
  line-height: 0.9;
  max-width: 11ch;
}

.route-line {
  display: grid;
  grid-template-columns: 18px 1fr 1fr 18px;
  align-items: center;
  max-width: 580px;
  margin-bottom: 20px;
}

.route-line span {
  width: 18px;
  aspect-ratio: 1;
  background: var(--sun);
  border: 3px solid white;
}

.route-line i {
  height: 3px;
  background: rgba(255, 255, 255, 0.78);
}

.quick-stats,
.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quick-stats div,
.summary-card {
  padding: 14px;
  background: rgba(255, 253, 248, 0.88);
  color: var(--ink);
  backdrop-filter: blur(14px);
}

dt,
dd {
  margin: 0;
}

dt,
.summary-card span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd,
.summary-card strong {
  display: block;
  margin-top: 5px;
  font-size: 1.25rem;
  font-weight: 900;
}

.results-section {
  padding: clamp(28px, 5vw, 64px) 0 16px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.toolbar {
  justify-content: flex-end;
}

.notice {
  display: none;
  margin-bottom: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  font-weight: 800;
}

.notice.good,
.notice.warning {
  display: block;
}

.notice.good {
  color: #17382f;
  background: #e7f2e3;
  border-color: #c8dcc3;
}

.notice.warning {
  color: #583118;
  background: #fff0d6;
  border-color: #e9c98e;
}

.ad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.ad-box,
.inline-ad {
  border: 1px dashed rgba(31, 77, 58, 0.45);
  background: #f3f6ee;
  padding: 16px;
}

.ad-box span,
.inline-ad span {
  display: block;
  margin-bottom: 8px;
  color: var(--clay);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ad-box strong,
.inline-ad strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.ad-box p,
.inline-ad p {
  color: var(--muted);
  line-height: 1.45;
}

.inline-ad {
  display: grid;
  gap: 2px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 3rem);
}

.summary-strip {
  margin-bottom: 22px;
}

.summary-card {
  border: 1px solid var(--line);
  background: var(--paper);
}

.results-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
}

.timeline {
  display: grid;
  gap: 14px;
}

.day-card,
.rail-block {
  border: 1px solid var(--line);
  background: var(--paper);
}

.day-card {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
}

.day-number {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 18px 12px;
  color: white;
  background: var(--forest);
}

.day-number strong {
  font-size: 2.2rem;
  line-height: 1;
}

.day-number span {
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.day-body {
  padding: 18px;
}

.day-body h3 {
  margin-bottom: 6px;
  font-size: 1.2rem;
}

.day-title-input,
.stop-name-input,
.stop-reason-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.day-title-input {
  margin-bottom: 8px;
  font-size: 1.2rem;
  font-weight: 900;
}

.stop-name-input {
  margin-bottom: 5px;
  font-weight: 900;
}

.stop-reason-input {
  min-height: 54px;
  color: var(--muted);
  line-height: 1.45;
  resize: vertical;
}

.day-title-input:focus,
.stop-name-input:focus,
.stop-reason-input:focus {
  border-color: var(--lake);
  background: #fffaf1;
  box-shadow: 0 0 0 3px rgba(43, 117, 133, 0.12);
}

.day-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.pill {
  padding: 6px 9px;
  color: #15302a;
  background: #e8efe3;
  font-size: 0.75rem;
  font-weight: 900;
}

.stop-list {
  display: grid;
  gap: 10px;
}

.stop-item {
  border-left: 4px solid var(--lake);
  padding-left: 12px;
}

.stop-item h4 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.stop-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.inline-actions {
  margin-top: 8px;
}

.inline-actions button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 0.78rem;
}

.add-stop {
  margin-top: 14px;
}

.side-rail {
  display: grid;
  gap: 14px;
}

.rail-block {
  padding: 18px;
}

.rail-block h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.mini-row,
.check-list label {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.mini-row:first-child,
.check-list label:first-child {
  border-top: 0;
}

.mini-row strong,
.check-list span {
  color: var(--ink);
  font-weight: 800;
}

.check-list label {
  justify-content: flex-start;
  align-items: center;
}

.check-list input {
  width: 18px;
  aspect-ratio: 1;
  accent-color: var(--forest);
}

.saved-list {
  display: grid;
  gap: 8px;
}

.saved-list button {
  display: grid;
  justify-items: start;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  background: #fffaf1;
  padding: 10px;
  text-align: left;
}

.saved-list span,
.empty-state {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state {
  margin-bottom: 0;
}

.progress-bar {
  height: 8px;
  margin-bottom: 10px;
  background: #e8e0d2;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--forest);
  transition: width 160ms ease;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  font-weight: 900;
  transition: 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media print {
  .planner-grid,
  .ad-grid,
  .inline-ad,
  .toolbar,
  .inline-actions,
  .add-stop,
  .toast {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .day-card,
  .rail-block,
  .summary-card {
    break-inside: avoid;
  }
}

@media (max-width: 980px) {
  .planner-grid,
  .results-layout {
    grid-template-columns: 1fr;
  }

  .planner-grid {
    min-height: 0;
  }

  .planner-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-panel,
  .map-panel img {
    min-height: 440px;
  }

  .route-map-card {
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    border-color: var(--line);
    box-shadow: none;
  }

  .side-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .field-grid,
  .summary-strip,
  .side-rail,
  .ad-grid {
    grid-template-columns: 1fr;
  }

  .segmented,
  .mode-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .day-number {
    grid-template-columns: auto auto;
    justify-content: start;
    padding: 12px 18px;
  }

  .section-heading {
    display: block;
  }

  .toolbar {
    justify-content: stretch;
    margin-top: 14px;
  }

  .toolbar button {
    flex: 1 1 120px;
  }

  .planner-panel {
    padding: 24px;
  }
}
