:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --ink: #14201c;
  --muted: #4b5a54;
  --card: #fffdf8;
  --line: #d7d0c4;
  --mint: #1f8a62;
  --navy: #13202a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10181d;
    --ink: #eef3f0;
    --muted: #a8b4ae;
    --card: #182229;
    --line: #2a3a42;
    --mint: #3dcaa0;
    --navy: #d7e4dc;
  }
}

* { box-sizing: border-box; }

sup { font-size: 0.65em; }

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  overflow-wrap: break-word;
  word-break: normal;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-bottom: 96px;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header, main, footer {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}

header {
  padding-top: 36px;
  padding-bottom: 12px;
}

header a {
  color: var(--navy);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
}

nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 0 8px;
  font-size: 15px;
}

nav a { color: var(--mint); }

h1 { font-size: 2rem; margin: 12px 0 16px; }
h2 { font-size: 1.2rem; margin-top: 28px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  margin: 16px 0;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
}

a { color: var(--mint); }

.muted, footer { color: var(--muted); font-size: 15px; }
footer { padding: 28px 20px calc(48px + env(safe-area-inset-bottom)); }

ul { padding-left: 20px; }
li { margin: 8px 0; }

nav a[aria-current="page"] {
  font-weight: 700;
}

body.app main {
  max-width: 760px;
  overflow-x: hidden;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 { margin-top: 0; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

label {
  display: block;
  margin: 12px 0;
  font-size: 15px;
  font-weight: 600;
}

input, button, select {
  font: inherit;
}

select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}

input:not([type="checkbox"]) {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}

input[type="datetime-local"],
input[type="date"],
input[type="time"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

input.plain {
  margin-top: 0;
  padding: 6px 0;
  border: none;
  background: transparent;
  color: inherit;
  font-weight: 700;
}

.row, .pair, .toggles {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.pair > label { flex: 1 1 140px; }

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
  margin: 8px 0;
}

.check input { width: auto; margin: 0; }

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline input {
  width: 88px;
  margin: 0;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
}

button.primary {
  background: var(--mint);
  color: #fff;
  font-weight: 700;
}

button.wheel-chip {
  color: var(--ink);
  font-weight: 600;
}

button.secondary, button.add, button.add-inline, a.secondary {
  background: transparent;
  color: var(--mint);
  border: 1px solid var(--mint);
}

a.secondary {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 12px;
}

details {
  margin: 0;
}

details summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

details summary::-webkit-details-marker { display: none; }

details summary .muted {
  display: block;
  font-weight: 500;
  margin-top: 4px;
}

button.add, button.add-inline {
  display: block;
  width: 100%;
  margin: 12px 0;
}

button.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  padding: 4px 10px;
  min-width: 36px;
}

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

.stop-card, .chip {
  display: block;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: break-word;
}

.stops {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.field {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.field.tight {
  width: min(13rem, 52vw);
  flex: 0 0 auto;
}

.date-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  max-width: min(16rem, 58vw);
  flex: 0 0 auto;
}

.date-chip-text {
  white-space: nowrap;
}

.date-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
}

.stop-card .date-chip {
  background: rgb(255 255 255 / 0.9);
  color: #14201c;
}

.wheel-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.25rem;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 16px;
  font-weight: 600;
  flex: 0 0 auto;
}

.wheel-chip-text { pointer-events: none; }

.wheel-chip select {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  font-size: 16px;
}

.call-log {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  font-size: 14px;
}
.call-log li { margin: 8px 0; }
.call-log span { color: var(--muted); }

.here-leg {
  margin: 8px 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.auth-block,
.auth-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin: 8px 0;
}

.auth-block .secondary,
.auth-block .fine {
  text-align: center;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
  white-space: normal;
  word-spacing: normal;
}

.setting:last-child { border-bottom: 0; }

.setting > span:first-child,
.setting > label {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  overflow-wrap: break-word;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.setting input:not([type="checkbox"]),
input.compact {
  display: inline-block;
  width: 4.75rem;
  max-width: 42vw;
  margin: 0;
  padding: 8px;
  text-align: center;
}

.setting input.time,
.setting input[type="time"] {
  width: 8.75rem;
  max-width: 46vw;
}

.setting input[type="datetime-local"] {
  width: 100%;
  max-width: 100%;
  margin: 0;
  text-align: left;
}

.setting input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  flex: 0 0 auto;
}

.stop-card .setting {
  border-bottom-color: rgb(0 0 0 / 0.14);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
}

.stack button {
  width: 100%;
}

.stop-head, .chip-top, .icon-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.stop-head label { flex: 1; margin: 0; min-width: 0; overflow: hidden; }
.icon-row { flex-shrink: 0; }

.chip { font-size: 15px; }
.chip-arrive { margin-top: 6px; font-weight: 700; }
.chip-arrive.late, .error { color: #b42318; font-weight: 700; }
.ok { color: var(--mint); font-weight: 600; }
.fine { font-size: 13px; color: var(--muted); }

.stop-card .fine,
.stop-card .here-leg,
.stop-card .ok {
  color: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
}

.stop-card .error {
  font-size: 16px;
  line-height: 1.45;
}

header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

header .brand img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: block;
}

.hero-mark {
  aspect-ratio: 1 / 1;
  width: min(100%, 640px);
  margin-left: auto;
  margin-right: auto;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fffdf8;
  padding: 8% 5%;
  background-color: #071525;
  background-image:
    linear-gradient(rgb(8 16 28 / 0.28), rgb(8 16 28 / 0.4)),
    url("./icons/PlanigatorIcon.png");
  background-repeat: no-repeat;
  background-position: center, center;
  background-size: 100% 100%, contain;
}

.hero-mark h1 {
  margin: 0 0 0.35em;
  color: #fffdf8;
  text-align: center;
  font-size: 6.2cqi;
  line-height: 1.05;
  white-space: nowrap;
}

.pitch {
  margin: 0;
  padding-left: 1.15em;
  text-align: left;
}

.hero-copy {
  width: 100%;
  padding: 12px 14px 14px;
  border-radius: 12px;
  background: rgb(0 0 0 / 0.62);
  color: #fffdf8;
}

.hero-mark .pitch {
  width: 100%;
  font-size: 4.7cqi;
  line-height: 1.32;
}

.hero-mark .pitch li {
  margin: 0.22em 0;
  white-space: nowrap;
}

button.suggest {
  display: block;
  width: 100%;
  margin: 6px 0;
  text-align: left;
  background: #fffdf8;
  color: #14201c;
  border: 1px solid rgb(20 32 28 / 0.2);
}

.stop-card .add-inline,
.stop-card button.add-inline {
  background: #fffdf8;
  color: #14201c;
  font-weight: 700;
  border: 1px solid rgba(20, 32, 28, 0.35);
}

.when {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  flex: 0 1 auto;
  max-width: 100%;
}

.when input[type="date"] {
  width: auto;
  min-width: 9.5rem;
  margin: 0;
}

.time-picks {
  display: inline-flex;
  gap: 6px;
  flex: 0 0 auto;
}

.time-picks select {
  width: auto;
  min-width: 4.2rem;
  margin: 0;
  padding: 8px 6px;
  text-align: center;
}

body.app main { padding-top: 16px; }

.time-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgb(20 32 28 / 0.35);
}

.time-sheet-card {
  width: min(360px, 100%);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: calc(12px + env(safe-area-inset-bottom));
}

.time-wheels {
  display: flex;
  gap: 8px;
  height: 180px;
}

.time-col {
  flex: 1;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  padding: 72px 0;
  border-radius: 10px;
  background: var(--bg);
}

.time-opt {
  display: block;
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  scroll-snap-align: center;
  font-size: 18px;
}

.time-opt.on {
  font-weight: 700;
  background: var(--card);
}

.time-sheet-card .primary {
  width: 100%;
  margin-top: 12px;
}

.result dl {
  display: grid;
  gap: 10px;
}

.result dt { color: var(--muted); font-size: 13px; }
.result dd { margin: 0; font-weight: 700; }

.trips ul { list-style: none; padding: 0; }
.trips li {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.trips li button[data-load] {
  flex: 1;
  text-align: left;
  background: var(--bg);
  color: inherit;
}
.trips li button[data-load] span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}
.trips li.active button[data-load] { outline: 2px solid var(--mint); }

.hos h2, .origin h2, .actions h2, .result h2, .trips h2, .card h2 {
  margin-top: 0;
}

.card.stops > :first-child { margin-top: 0; }
.card.stops > :last-child { margin-bottom: 0; }

@media (max-width: 640px) {
  html, body { font-size: 16px; }
  header, main, footer {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }
  .card, .stop-card { padding: 14px; }
  .row button, .row a.secondary { width: 100%; }
  .pair {
    flex-direction: column;
    align-items: stretch;
  }
  .pair > label {
    flex: 1 1 auto;
    width: 100%;
  }
  input[type="datetime-local"],
  input[type="date"],
  input[type="time"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    font-size: 16px;
  }
  .stop-card {
    margin-left: 0;
    margin-right: 0;
  }
}

textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

a.primary {
  display: inline-block;
  background: var(--mint);
  color: #fff;
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
}
