:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #17202a;
  --muted: #667085;
  --border: #d9e0e7;
  --accent: #176b52;
  --accent-soft: #e8f4ef;
  --accent-text: #ffffff;
  --danger: #a63a3a;
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #14181c;
    --surface: #1c2229;
    --surface-soft: #232a32;
    --text: #f1f4f7;
    --muted: #93a0ad;
    --border: #333d47;
    --accent: #4fbf94;
    --accent-soft: #1c332c;
    --accent-text: #0c1210;
    --danger: #e08080;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #14181c;
  --surface: #1c2229;
  --surface-soft: #232a32;
  --text: #f1f4f7;
  --muted: #93a0ad;
  --border: #333d47;
  --accent: #4fbf94;
  --accent-soft: #1c332c;
  --accent-text: #0c1210;
  --danger: #e08080;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background 160ms ease, color 160ms ease;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

.shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 96px;
}

.hero-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #c3c3c3;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.lang-button {
  border: 0;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

.lang-button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.hero {
  max-width: 720px;
  margin-bottom: 20px;
}

.eyebrow,
.step-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(1.5rem, 4.5vw, 3.15rem);
  line-height: 1;
  letter-spacing: -0.045em;
  color: #629b94;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  letter-spacing: -0.025em;
  color: #42869b;
}

h3 {
  margin-bottom: 16px;
}

.intro,
.muted {
  color: var(--muted);
}

.intro {
  font-size: 1.08rem;
  line-height: 1.6;
}

.safety-disclaimer {
  border-left: 3px solid var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  font-size: 0.9rem;
}

.planner,
.panel,
.result-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 160ms ease, border-color 160ms ease;
}

.planner {
  padding: 24px;
}

/* --- Resume banner & save-later --- */

.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.resume-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.button-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.draft-row {
  margin-top: 14px;
}

.link-button {
  border: 0;
  background: none;
  color: #83f1c766;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.draft-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.draft-panel input {
  flex: 1;
  min-width: 200px;
}

.draft-status {
  width: 100%;
  margin: 4px 0 0;
  font-size: 0.82rem;
}

/* --- Progress --- */

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.progress-segments {
  flex: 1;
  display: flex;
  gap: 4px;
}

.progress-segment {
  flex: 1;
  height: 8px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.progress-segment-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width 220ms ease;
}

#progressText {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* --- Question card & transition --- */

.question-card {
  min-height: 360px;
}

@keyframes stepFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.step-enter {
  animation: stepFadeIn 180ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .step-enter {
    animation: none;
  }
}

.question-heading {
  max-width: 680px;
  margin-bottom: 22px;
}

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

.option-card {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 76px;
  gap: 12px;
  padding: 16px 16px 16px 40px;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.option-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.option-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-card input {
  /* Visually hidden, not display:none — stays focusable/keyboard- and
     screen-reader-accessible. The card's own border/background already
     shows selection, so the native circle would just be redundant. */
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.option-card:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.option-key {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 700;
}

.option-icon {
  font-size: 1.35rem;
}

/* --- Live preview --- */

.live-preview {
  margin-top: 18px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 10px 14px;
}

.live-preview summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
}

.live-preview-content {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preview-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 650;
}

/* --- Actions & buttons --- */

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

/* --- Result section --- */

.result-section {
  padding: 24px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.summary-grid,
.result-grid {
  display: grid;
  gap: 14px;
}

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

.text-input-wrap {
  max-width: 360px;
  position: relative;
}

.location-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.location-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.location-suggestion {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-suggestion:hover {
  background: var(--surface-soft);
}

.location-suggestion + .location-suggestion {
  border-top: 1px solid var(--border);
}

.layout-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--page);
}

.layout-overlay.hidden {
  display: none;
}

.layout-overlay-frame {
  width: 100%;
  height: 100%;
  border: 0;
}

.layout-overlay-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2001;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.date-range-wrap {
  display: flex;
  gap: 16px;
  max-width: 480px;
  flex-wrap: wrap;
}

.date-range-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 160px;
}

.date-range-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.site-summary p {
  color: var(--muted);
  margin: 0 0 10px;
}

.site-snapshot {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.summary-card {
  padding: 16px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.summary-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.result-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.panel {
  margin-top: 14px;
  padding: 20px;
}

.product-row,
.adjust-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.product-row:last-child,
.adjust-row:last-child {
  border-bottom: 0;
}

.product-row p,
.adjust-row span {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.info-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.68rem;
  font-style: italic;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 4px;
}

.product-popover {
  position: absolute;
  z-index: 40;
  display: flex;
  gap: 10px;
  max-width: 260px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
  font-size: 0.82rem;
}

.product-popover.hidden {
  display: none;
}

.popover-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.product-popover p {
  margin: 4px 0 0;
  color: var(--muted);
}

.quantity-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 750;
}

#reasonList ul,
.tips-list {
  margin: 0;
  padding-left: 20px;
}

#reasonList li + li,
.tips-list li + li {
  margin-top: 10px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.stepper button {
  width: 42px;
  height: 40px;
  border: 0;
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 1.2rem;
}

.stepper output {
  min-width: 48px;
  text-align: center;
  font-weight: 750;
}

/* --- Map panel --- */

.map-panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.map-toolbar {
  position: relative;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.map-toolbar input {
  width: 100%;
}

.map-search-results {
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(100% - 4px);
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.map-search-item,
.map-search-empty {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
}

.map-search-item:hover {
  background: var(--accent-soft);
}

.map-canvas {
  height: 320px;
  width: 100%;
}

.map-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: var(--surface-soft);
  font-size: 0.85rem;
}

/* --- Form --- */

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

.form-grid label {
  display: grid;
  gap: 7px;
  font-weight: 650;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
}

textarea {
  resize: vertical;
}

.field-error {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 600;
}

.result-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--accent);
  font-weight: 700;
  text-align: right;
}

.hidden {
  display: none;
}

/* --- Mobile --- */

@media (max-width: 700px) {
  .shell {
    width: min(100% - 20px, 920px);
    padding-top: 16px;
    padding-bottom: 96px;
  }

  .planner,
  .result-section {
    padding: 18px;
  }

  .option-grid,
  .summary-grid,
  .result-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .question-card {
    min-height: 0;
  }

  .result-header,
  .product-row,
  .adjust-row {
    align-items: stretch;
    flex-direction: column;
  }

  .quantity-badge,
  .stepper {
    align-self: flex-start;
  }

  .actions {
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
    margin: 24px -4px 0;
    background: linear-gradient(to top, var(--page) 65%, transparent);
  }

  .actions .button {
    flex: 1;
  }

  .result-actions {
    position: static;
    background: none;
    margin: 24px 0 0;
    padding: 0;
  }

  .map-canvas {
    height: 240px;
  }
}
