/* MCS Travel — calm, map-first planner. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --line: #e6e3da;
  --line-strong: #d4d0c4;
  --ink: #1f2a30;
  --ink-2: #46525a;
  --muted: #7b8388;
  --accent: #1d5c73;
  --accent-ink: #ffffff;
  --accent-soft: #e5eef1;
  --ok: #2f6b4f;
  --ok-soft: #e4f0e9;
  --warn: #8a5410;
  --warn-soft: #fbf1e2;
  --danger: #a3392b;
  --danger-soft: #f8e7e4;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(31, 42, 48, 0.06), 0 6px 20px rgba(31, 42, 48, 0.08);
  --shadow-lg: 0 10px 40px rgba(31, 42, 48, 0.18);
  --topbar-h: 52px;
  --left-w: 368px;
  --right-w: 384px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

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

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.icon {
  flex: none;
  display: block;
}

.num,
.mono {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

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

.small {
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- layout ---------- */

.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "top top top"
    "left map right";
}

.app[data-left="closed"] {
  --left-w: 0px;
}

.app[data-right="closed"] {
  --right-w: 0px;
}

.app[data-left="closed"] .panel-left,
.app[data-right="closed"] .panel-right {
  display: none;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 10;
  min-width: 0;
  min-height: var(--topbar-h);
  height: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background:
    radial-gradient(circle at 70% 30%, #ffffff 0 2.5px, transparent 3px),
    linear-gradient(135deg, var(--accent), #2d7f8f);
}

.trip-switch {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--line);
}

.trip-switch-title {
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trip-switch-dates,
.trip-switch-empty {
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
}

.trip-switch select {
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 2px 6px;
  font-size: 12px;
}

.topbar-spacer {
  flex: 1;
}

.privacy-chip,
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 42vw;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.account-chip {
  cursor: pointer;
}

.account-chip.cloud-error,
.account-chip.cloud-conflict {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.account-note {
  margin: 0 0 10px;
  color: var(--ink-2);
  font-size: 13px;
}

.panel {
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  overscroll-behavior: contain;
}

.panel-left {
  grid-area: left;
  border-right: 1px solid var(--line);
}

.panel-right {
  grid-area: right;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.map-stage {
  grid-area: map;
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #e9ecec;
}

.map {
  position: absolute;
  inset: 0;
}

.mobile-nav,
.mobile-only {
  display: none;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--surface-2);
  border-color: #c4bfb1;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.map-tool:focus-visible,
.section-chip:focus-visible,
.context-tab:focus-visible,
.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: #174c60;
  border-color: #174c60;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-ghost-danger {
  color: var(--danger);
}

.btn-small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-tiny {
  min-height: 24px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 6px;
}

.btn[disabled],
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn.small {
  width: 26px;
  height: 26px;
}

.icon-btn[disabled] {
  opacity: 0.3;
  cursor: default;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
}

.btn-row,
.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

/* ---------- chips & badges ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 550;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}

.chip.phase-research {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}

.chip.status-preferred {
  border-style: solid;
  color: var(--accent);
  border-color: #b8d0d8;
}

.chip.status-planned {
  background: var(--accent-soft);
  border-color: #c9dbe1;
  color: var(--accent);
}

.chip.status-booked,
.chip.status-confirmed,
.chip.booking-confirmed {
  background: var(--ok-soft);
  border-color: #c7dfd1;
  color: var(--ok);
}

.chip.status-rejected,
.chip.booking-cancelled {
  text-decoration: line-through;
  color: var(--muted);
}

.chip.provider-active {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #c7dfd1;
}

.chip.provider-needs-consent,
.chip.provider-invalid-url {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #efdcbd;
}

.badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 550;
  vertical-align: 1px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.badge-fresh,
.badge-timeless {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #c7dfd1;
}

.badge-aging {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #efdcbd;
}

.badge-stale,
.badge-expired,
.badge-unverified {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #efcdc7;
}

.warn {
  margin: 8px 0;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12.5px;
}

.ok {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-size: 13px;
}

/* ---------- plan panel ---------- */

.trip-head {
  padding: 18px 18px 12px;
}

.trip-title {
  font-size: 19px;
  line-height: 1.25;
}

.trip-head.is-empty .trip-title {
  font-size: 18px;
}

.trip-head p {
  margin: 4px 0 0;
}

.trip-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.next-step {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}

.next-step span {
  flex: 1;
}

.section-nav {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section-nav::-webkit-scrollbar {
  display: none;
}

@media (min-width: 761px) {
  .section-nav {
    flex-wrap: wrap;
    overflow: visible;
    gap: 2px 4px;
  }

  .section-chip {
    padding: 4px 9px;
  }
}

.section-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.section-chip:hover {
  background: var(--surface-2);
}

.section-chip.is-active {
  background: var(--ink);
  color: #fff;
}

.section-body {
  padding: 4px 18px 28px;
}

.section-title {
  font-size: 15px;
  margin: 14px 0 2px;
}

.sub-heading {
  font-size: 15px;
  margin: 26px 0 4px;
}

.list-heading {
  margin: 18px 0 6px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.empty-state {
  margin: 18px 0 8px;
  padding: 26px 22px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  text-align: center;
}

.empty-state h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.empty-state > p {
  margin: 0 auto 18px;
  max-width: 34ch;
  color: var(--ink-2);
}

.empty-visual {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.capability-list {
  list-style: none;
  margin: 22px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  text-align: left;
  display: grid;
  gap: 10px;
}

.capability-list li {
  display: flex;
  gap: 10px;
  color: var(--ink-2);
  font-size: 13px;
}

.capability-list .icon {
  margin-top: 2px;
  color: var(--accent);
}

.empty-hint {
  margin: 12px 0;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13px;
}

.empty-hint p {
  margin: 0 0 8px;
}

.empty-hint .empty-title {
  font-weight: 600;
  color: var(--ink);
}

.rows,
.plain-list,
.day-list,
.ranking,
.notes,
.changesets,
.ops,
.segments {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin: 0 -10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-2);
}

.row:hover {
  background: var(--surface-2);
}

.row.is-selected {
  background: var(--accent-soft);
  color: var(--accent);
}

.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.row-title {
  color: var(--ink);
  font-weight: 520;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 12px;
  color: var(--muted);
}

.row-actions {
  display: flex;
  opacity: 0.4;
}

.row:hover .row-actions {
  opacity: 1;
}

.plain-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 13px;
}

.day {
  margin: 10px 0 14px;
}

.day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.day-num {
  font-weight: 650;
}

.day-date,
.day-stay {
  color: var(--muted);
  font-size: 12.5px;
}

.day-stay {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.day-empty {
  margin: 6px 0;
}

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

.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.card {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.card-head h3 {
  font-size: 13.5px;
}

.continuity {
  margin: 0 0 6px;
  font-weight: 550;
}

.continuity-continuous {
  color: var(--ok);
}

.continuity-zig-zag {
  color: var(--danger);
}

.kv {
  margin: 8px 0;
  display: grid;
  gap: 5px;
}

.kv > div {
  display: grid;
  grid-template-columns: minmax(110px, 38%) 1fr;
  gap: 10px;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.table-scroll {
  overflow-x: auto;
}

.budget-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0;
}

.budget-table th:first-child {
  width: 22%;
}

.budget-table th.num,
.budget-table td.num {
  width: 15.6%;
}

.budget-table tbody th {
  white-space: normal;
  min-width: 0;
  overflow-wrap: anywhere;
}

.budget-table th,
.budget-table td {
  padding: 6px 3px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.budget-table td.num,
.budget-table th.num {
  text-align: right;
}

.budget-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.budget-table tfoot th,
.budget-table tfoot td {
  font-weight: 650;
  border-bottom: 0;
}

.budget-table.is-preview td {
  color: var(--line-strong);
}

.task-row .check {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  color: #fff;
  padding: 0;
}

.task-row .check.is-checked {
  background: var(--ok);
  border-color: var(--ok);
}

.task-row.is-done .row-title {
  text-decoration: line-through;
  color: var(--muted);
}

.pref-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.pref-row select,
.provider-config input,
.weight input {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  padding: 4px 6px;
  font-size: 12.5px;
}

.pref-row select {
  max-width: 150px;
}

.pref-row select.is-hard {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 550;
}

.weights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-bottom: 12px;
}

.weight {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.weight input {
  width: 64px;
  text-align: right;
}

.provider-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.provider-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.provider-row .row-sub {
  margin: 3px 0;
}

.provider-config {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.switch,
.consent,
.check-line,
.radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.consent {
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- context panel ---------- */

.context-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.context-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 2px 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.context-tab:hover {
  color: var(--ink);
}

.context-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.context-tab .count {
  position: absolute;
  top: 4px;
  right: 10px;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--warn);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
}

.context-body {
  padding: 14px 18px 28px;
  flex: 1;
}

.detail-head h2 {
  font-size: 17px;
  margin-bottom: 2px;
}

.detail-head p {
  margin: 0;
}

.status-control {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--muted);
}

.status-control select {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 4px 6px;
  background: var(--surface);
}

.segments li {
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--line);
}

.seg-mode {
  font-weight: 600;
}

.compare-title {
  font-size: 14px;
  margin: 2px 0 10px;
}

.rank-item {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px 8px;
}

.rank-item.eligibility-excluded {
  opacity: 0.6;
}

.rank-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.rank-num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.rank-name {
  flex: 1;
  font-weight: 560;
}

.rank-score {
  font-size: 18px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

details summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--accent);
}

.constraints {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: grid;
  gap: 4px;
  font-size: 12.5px;
}

.constraints li {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.constraint-pass .icon {
  color: var(--ok);
}

.constraint-fail .icon {
  color: var(--danger);
}

.constraint-unknown .icon {
  color: var(--warn);
}

.score-table,
.weights-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.score-table th {
  text-align: left;
  font-weight: 500;
  padding: 5px 6px 0 0;
  white-space: nowrap;
}

.score-table td {
  padding: 5px 0 0 6px;
}

.score-table tr.is-unknown th {
  color: var(--muted);
  font-style: italic;
}

.evidence-row td {
  padding: 0 0 4px !important;
  color: var(--muted);
  font-size: 11.5px;
  border-bottom: 1px solid var(--line);
}

.bar-cell {
  width: 40%;
}

.bar {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--v), var(--line) var(--v));
}

.weights-table th {
  text-align: left;
  font-weight: 400;
  padding: 3px 0;
  color: var(--ink-2);
}

.weights-table td {
  text-align: right;
}

.criteria-explainer {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.criteria-explainer h3 {
  font-size: 13.5px;
}

.notes .note {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.note-head {
  display: flex;
  gap: 6px;
  align-items: center;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.notes p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-2);
  white-space: pre-wrap;
}

.note.is-closed {
  opacity: 0.6;
}

.assistant .agent-status {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--accent);
}

.assistant .agent-status p {
  margin: 3px 0 0;
}

.assistant .agent-status strong {
  color: var(--ink);
}

.import-proposal {
  margin: 12px 0;
  cursor: pointer;
}

.rules li {
  flex-wrap: nowrap;
  align-items: flex-start;
}

.rules li .icon {
  margin-top: 3px;
  color: var(--accent);
}

.tools code,
.op code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  padding: 0 4px;
  border-radius: 4px;
}

.composer {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--surface-2);
}

.changeset {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.changeset.origin-agent {
  border-color: #cdb9e0;
}

.cs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.ops .op {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.op-verb {
  font-weight: 600;
}

.op-target {
  grid-column: 2 / 3;
}

.op-state {
  grid-column: 3;
  grid-row: 1;
  color: var(--muted);
  font-size: 11px;
}

.op-field {
  color: var(--muted);
}

.op-diff,
.op-why,
.op-src,
.op-issue,
.op-actions {
  grid-column: 1 / -1;
}

.op-diff del {
  color: var(--danger);
}

.op-diff ins {
  color: var(--ok);
  text-decoration: none;
}

.op-issue {
  color: var(--warn);
}

.op-why {
  color: var(--ink-2);
  font-style: italic;
}

.op-actions {
  display: flex;
  gap: 6px;
}

.op-reverted,
.op-rejected {
  opacity: 0.55;
}

.op-blocked {
  background: var(--danger-soft);
}

.cs-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
}

.cs-actions:empty {
  display: none;
}

/* ---------- map overlays ---------- */

.map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-overlay > * {
  pointer-events: auto;
}

.map-search {
  position: absolute;
  top: 12px;
  left: 12px;
  width: min(420px, calc(100% - 76px));
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 12px;
  color: var(--muted);
}

.search-form input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-msg {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: min(50vh, 360px);
  overflow: auto;
  border-top: 1px solid var(--line);
}

.search-results li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
}

.search-results li.is-focused {
  background: var(--accent-soft);
}

.result-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 7px 12px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.result-name {
  font-weight: 550;
}

.result-label {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-attrib {
  margin: 0;
  padding: 4px 12px 6px;
  color: var(--muted);
  font-size: 11px;
}

.map-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-tool {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

.map-tool:last-child {
  border-bottom: 0;
}

.map-tool:hover {
  background: var(--surface-2);
  color: var(--ink);
}

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

.layers-popover {
  position: absolute;
  top: 12px;
  right: 62px;
  width: 260px;
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 6px;
}

.layers-popover h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 4px;
}

.layers-popover p {
  margin: 2px 0 4px;
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-2);
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lg {
  display: inline-block;
  width: 22px;
  height: 0;
  border-top: 3px solid #34495e;
}

.lg-water {
  border-top: 3px dashed #1f7a8c;
}

.lg-air {
  border-top: 3px dashed #6b5b95;
}

.lg-dotted {
  border-top: 3px dotted #5d6d4e;
}

.lg-faint {
  opacity: 0.4;
}

.lg-strong {
  border-top-width: 5px;
}

.map-banner {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  white-space: nowrap;
  max-width: calc(100% - 24px);
}

.map-banner .btn {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.map-banner.is-error {
  background: var(--danger);
  white-space: normal;
}

.map-note {
  position: absolute;
  top: 64px;
  left: 12px;
  max-width: min(420px, calc(100% - 76px));
  padding: 8px 12px;
  border: 1px solid #1f7a8c;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
  z-index: 1;
}

/* ---------- dialog & toast ---------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(31, 42, 48, 0.32);
}

.dialog {
  position: fixed;
  z-index: 41;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(660px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.dialog-form {
  padding: 0 22px;
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 10px;
  background: var(--surface);
}

.dialog-head h2 {
  font-size: 17px;
}

.dialog-intro {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 13px;
}

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

.form-heading {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.form-note {
  grid-column: 1 / -1;
  font-size: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

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

.field label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
}

.field .req {
  color: var(--danger);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}

.field .hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
}

.error {
  margin: 0;
  font-size: 12px;
  color: var(--danger);
}

.form-error {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
}

.money-input {
  display: flex;
  gap: 6px;
}

.money-input input:first-child {
  flex: 1;
}

.money-input .currency {
  width: 76px;
  text-transform: uppercase;
}

.dialog-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding: 12px 0 18px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.toast-root {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: min(560px, calc(100vw - 32px));
}

.toast .btn {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ---------- medium screens ---------- */

@media (max-width: 1180px) {
  :root {
    --left-w: 330px;
    --right-w: 340px;
  }
}

@media (max-width: 1180px) and (min-width: 841px) {
  .app {
    grid-template-columns: var(--left-w) minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "left map";
  }

  .panel-right {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: 360px;
    z-index: 20;
    box-shadow: var(--shadow-lg);
  }

  .trip-switch-dates {
    display: none;
  }
}

/* ---------- phones ---------- */

@media (max-width: 840px) {
  :root {
    --topbar-h: 50px;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) calc(58px + env(safe-area-inset-bottom));
    grid-template-areas:
      "top"
      "main"
      "nav";
  }

  .desktop-only,
  .trip-switch-dates,
  .brand-name {
    display: none !important;
  }

  .mobile-only {
    display: block;
  }

  .topbar {
    padding: 0 8px 0 12px;
  }

  .trip-switch {
    border-left: 0;
    padding-left: 0;
  }

  .map-stage,
  .panel-left,
  .panel-right {
    grid-area: main;
  }

  .panel-left,
  .panel-right,
  .app[data-left="closed"] .panel-left,
  .app[data-right="closed"] .panel-right {
    display: none;
    position: relative;
    z-index: 5;
    border: 0;
  }

  .app[data-mobile-tab="plan"] .panel-left,
  .app[data-mobile-tab="bookings"] .panel-left,
  .app[data-mobile-tab="assistant"] .panel-right {
    display: flex;
    flex-direction: column;
  }

  .app[data-mobile-tab="plan"] .panel-left,
  .app[data-mobile-tab="bookings"] .panel-left {
    display: block;
  }

  .app[data-mobile-tab="map"][data-sheet="open"] .panel-right {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    /* End at the top of the bottom navigation, never underneath it. */
    bottom: calc(58px + env(safe-area-inset-bottom));
    max-height: 62%;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(31, 42, 48, 0.18);
  }

  .sheet-close {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 3;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
  }

  .app:not([data-sheet="open"]) .sheet-close {
    display: none;
  }

  .app[data-sheet="open"] .context-tabs {
    padding-right: 40px;
  }

  .mobile-nav {
    grid-area: nav;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 10;
  }

  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
  }

  .mobile-tab.is-active {
    color: var(--accent);
    font-weight: 600;
  }

  .map-search {
    top: 8px;
    left: 8px;
    width: calc(100% - 64px);
  }

  .map-tools {
    top: 8px;
    right: 8px;
  }

  .layers-popover {
    top: 8px;
    right: 56px;
    width: min(260px, calc(100% - 72px));
  }

  .app[data-mobile-tab="search"] .search-results {
    max-height: 55dvh;
  }

  .map-banner {
    bottom: 16px;
    white-space: normal;
  }

  .map-note {
    top: 58px;
    left: 8px;
    max-width: calc(100% - 72px);
    font-size: 12px;
  }

  .context-tab span {
    font-size: 10px;
  }

  .dialog {
    top: auto;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 16px 16px 0 0;
  }

  .dialog-form {
    padding: 0 16px;
  }

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

  .toast-root {
    bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .section-body,
  .trip-head {
    padding-left: 16px;
    padding-right: 16px;
  }

  .row-actions {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}


/* ---------- cloud sign-in ---------- */

.cloud-signin {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--surface-2);
}

.cloud-signin-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.cloud-signin-card h1 {
  margin: 0 0 8px;
}

.cloud-signin-card p {
  margin: 0 0 18px;
}

.cloud-signin-status {
  min-height: 4.8em;
}

.cloud-signin-status.is-error {
  color: var(--danger);
}

.cloud-signin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
