/* ---------- top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  position: sticky;
  top: 0;
  z-index: 5;
}

.board-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 4px 6px;
  background: transparent;
  min-width: 0;
  flex: 1 1 200px;
}
.board-title:hover, .board-title:focus { border-color: var(--line); }

.topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.setting { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.setting input { width: 4.5em; padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius); }
.setting select { padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }

/* Total of the shown options, for everyone or one person, with the currency beside it. */
.grand-total { padding: 3px 4px 3px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.grand-total strong { color: var(--text); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; cursor: default; }
.grand-total .currency { color: var(--muted); padding-right: 8px; }

/* ---------- travellers ---------- */
/* Each named traveller has a colour (--person) used on their tags. */
.people-list { display: flex; flex-wrap: wrap; gap: 6px; }
.person-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.setting .person-chip input.person-name { width: auto; border: 0; padding: 3px 2px 3px 6px; background: transparent; color: var(--text); }
/* Their colour as a round swatch (opens the colour picker), then "A" in their tag's look,
   which switches the text on it between white and black. */
.setting .person-chip input.person-color {
  width: 24px; height: 24px; margin-left: 3px; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer; flex: 0 0 auto;
}
.person-color::-webkit-color-swatch-wrapper { padding: 0; }
.person-color::-webkit-color-swatch { border: 1px solid rgb(0 0 0 / 0.15); border-radius: 50%; }
.person-color::-moz-color-swatch { border: 1px solid rgb(0 0 0 / 0.15); border-radius: 50%; }
.person-ink {
  flex: 0 0 auto; width: 24px; height: 24px; margin-left: 2px; padding: 0;
  border: 0; border-radius: 4px; background: var(--person); color: var(--person-fg, #fff);
  font-size: 12px; font-weight: 750; line-height: 24px; cursor: pointer;
}
.person-color:disabled, .person-ink:disabled { cursor: default; }
.person-remove { border: 0; background: none; color: var(--muted); padding: 0 6px; cursor: pointer; font-size: 12px; }
.person-remove:hover { color: var(--danger); }

.who-picker button { --person-ink: color-mix(in srgb, var(--person, #565a62) 75%, #000); } /* darker, so coloured text on white passes 4.5:1 */
.person-tag {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--person);
  color: var(--person-fg, #fff);
  font-size: 11px;
  font-weight: 650;
  line-height: 18px;
  white-space: nowrap;
}
.who { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.person-line { display: flex; align-items: center; gap: 6px; }
.person-line + .person-line { margin-top: 3px; }
.section-summary.per-person { flex-wrap: wrap; }
.section-summary.per-person .section-total small { display: inline; }
.everyone-label { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
/* Each traveller's share: pills in a grid that fills the width and wraps. */
.person-totals { flex: 1 1 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.person-total {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 6px;
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  font-variant-numeric: tabular-nums; min-width: 0;
}
.person-total strong { font-size: 15px; font-weight: 700; }
.person-span { flex: 1 1 100%; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.who-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.who-picker button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 3px 12px;
  cursor: pointer;
}
.who-picker button.person-option { border-color: var(--person); color: var(--person-ink); }
.who-picker button.active { background: var(--line-strong); color: #fff; }
.who-picker button.person-option.active { background: var(--person); color: var(--person-fg, #fff); }

.toggle { display: inline-flex; gap: 2px; padding: 3px; border-radius: calc(var(--radius) + 2px); background: #e9ebef; }
.toggle button {
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 4px 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.toggle button:hover { color: var(--text); }
.toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.save-status { color: var(--muted); font-size: 13px; min-width: 4.5em; }
.save-status.error { color: var(--danger); }
.viewers { color: var(--stay); font-size: 13px; white-space: nowrap; }

.hint { margin: 10px 16px 0; color: var(--muted); font-size: 13px; }

/* ---------- board ---------- */
.board { padding: 20px; display: flex; gap: 18px; align-items: flex-start; }
.board.columns { flex-direction: row; overflow-x: auto; min-height: calc(100vh - 110px); }

/* A section is one trip option; it is as wide as its grid of cards. */
.section {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.board.columns .section { flex: 0 0 auto; min-width: 298px; }

/* Columns layout: each board column stacks its trip options top to bottom. */
.board-col { display: flex; flex-direction: column; gap: 18px; flex: 0 0 auto; min-width: 120px; }
.board-col-new { display: none; }
.board-col:not(.board-col-new):empty { display: none; }
body.dragging-section .board-col-new {
  display: flex;
  align-self: stretch;
  min-height: 160px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
}
.section.dragging { opacity: 0.4; }

.section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 0 4px;
}

.handle {
  cursor: grab;
  color: var(--muted);
  padding: 2px 4px;
  user-select: none;
  line-height: 1;
  font-size: 16px;
}
.handle:active { cursor: grabbing; }

.section-check { margin: 0 2px; width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.section-check:disabled { cursor: default; }

/* Hidden (unchecked) option: just the header and total, greyed out. */
.section.collapsed { background: transparent; border-style: dashed; border-color: #c4c8cf; box-shadow: none; }
.section.collapsed .section-title,
.section.collapsed .section-total,
.section.collapsed .trip-span { color: var(--excluded-text); }
.section.collapsed .section-summary { border-bottom: 0; }
.section.collapsed .cheapest { display: none; }

.section-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 3px 5px;
  background: transparent;
}
.section-title:hover, .section-title:focus { border-color: var(--line); }

.section-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 2px 12px 10px 61px;
  border-bottom: 1px solid var(--line);
}
.trip-span { color: var(--muted); font-size: 13px; }
.section-total { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.section-total strong { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.section-total small { display: block; color: var(--muted); font-size: 12px; }
.cheapest {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--stay);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  vertical-align: 3px;
}

.hidden-note { color: var(--muted); font-size: 12px; padding: 0 10px 6px; }
.add-card { margin: 0 8px 8px; align-self: flex-start; }

/* ---------- grid of cards ---------- */
/* Columns get explicit widths; cards on the same row line up and share its height. */
.cards {
  display: grid;
  grid-auto-columns: 160px;
  justify-content: start;
  gap: 10px;
  padding: 10px;
  overflow-x: auto;
}

.cell { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cell > .card { flex: 1 0 auto; }

/* While a card is dragged every cell is a drop target, plus a new column and a new row. */
.cell.extra { display: none; min-height: 56px; }
body.dragging-card .cell.extra { display: flex; }
body.dragging-card .cell { outline: 1px dashed var(--line); outline-offset: 2px; border-radius: var(--radius); min-height: 56px; }

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--other);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.card.type-flight { border-left-color: var(--flight); }
.card.type-stay { border-left-color: var(--stay); }
.card.type-train { border-left-color: var(--train); }
.card.type-bus { border-left-color: var(--bus); }
.card.type-boat { border-left-color: var(--boat); }
.card.type-car { border-left-color: var(--car); }
.card.type-activity { border-left-color: var(--activity); }
.card:hover { box-shadow: var(--shadow-md); border-top-color: var(--border); border-right-color: var(--border); border-bottom-color: var(--border); }
.card.dragging { opacity: 0.4; }
.card.excluded { border-left-color: var(--excluded); background: #fafafb; box-shadow: none; }
.card.excluded .card-price { color: var(--excluded-text); text-decoration: line-through; }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-head { display: flex; flex-direction: column; min-width: 0; }
/* The card type as an icon in a round badge of the type's colour, left of the title. */
.card-title-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.type-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-top: -2px;
  border-radius: 50%;
  background: var(--other);
  color: #fff;
}
.type-icon svg { width: 15px; height: 15px; fill: currentColor; }
.type-icon.icon-flight { background: var(--flight); }
.type-icon.icon-stay { background: var(--stay); }
.type-icon.icon-train { background: var(--train); }
.type-icon.icon-bus { background: var(--bus); }
.type-icon.icon-boat { background: var(--boat); }
.type-icon.icon-car { background: var(--car); }
.type-icon.icon-activity { background: var(--activity); }
/* The plane points the way it flies: to the right. */
.icon-flight svg { transform: rotate(90deg); }
.card.excluded .type-icon { background: var(--excluded); }
/* The line under the title and the people tags line up with the title, not the icon. */
.card-head > .card-sub, .card-head > .who { margin-left: 32px; }

/* The same icons in the card editor's type buttons. */
.type-icon-inline { display: inline-flex; vertical-align: -3px; margin-right: 5px; }
.type-icon-inline svg { width: 16px; height: 16px; fill: currentColor; }
/* Eight types: the picker gets its own full-width row under the heading, names on one line. */
.type-picker { flex: 1 1 100%; }
.type-picker button { flex: 1 1 auto; white-space: nowrap; padding: 5px 4px; font-size: 13px; }
.type-picker .type-icon-inline { margin-right: 3px; }
.card-title { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.card-title .arrow { color: var(--muted); font-weight: 400; }
.card-sub { font-size: 13px; color: var(--muted); }

.card-meta { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; padding-top: 2px; text-align: right; }
.card-when { margin-top: 4px; font-size: 13px; line-height: 1.4; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-price { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price-basis { font-size: 12px; font-weight: 400; color: var(--muted); }
.price-note { font-size: 12px; color: var(--muted); white-space: nowrap; }

.card-facts { font-size: 14px; color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  line-height: 22px;
  padding: 0 9px 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
.chip.yes { background: var(--yes-bg); border-color: #b7dfb9; color: var(--yes-text); }
.chip.no { background: var(--no-bg); border-color: #f2b8b5; color: var(--no-text); }
.chip-icon { font-weight: 800; font-size: 14px; }
.chip.yes .chip-icon { color: var(--yes-icon); }
.chip.no .chip-icon { color: var(--no-icon); }
.chip-note { font-weight: 650; padding-left: 6px; border-left: 1px solid currentColor; }

.card-link { font-size: 14px; align-self: flex-start; margin-top: 2px; }
.card-desc { font-size: 14px; line-height: 1.45; color: #34363c; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.card-desc.clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.more { align-self: flex-start; border: 0; background: none; padding: 0; font-size: 13px; color: var(--link); cursor: pointer; }
.more:hover { text-decoration: underline; }

.card-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: auto; padding-top: 2px; }
.card-actions input { margin: 0; }
.card-actions label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-right: auto; cursor: pointer; }

/* Drag a card's right edge to resize its column; double-click resets. */
.resizer {
  position: absolute;
  top: 0;
  right: -6px;
  width: 11px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
  touch-action: none;
}
.resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 1px;
}
.resizer:hover::after, .resizer.active::after { background: var(--accent); width: 3px; left: 4px; }
body.resizing { cursor: col-resize; user-select: none; }

.placeholder {
  flex: 0 0 auto;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  min-height: 48px;
  background: rgba(11, 87, 208, 0.06);
}
.board.columns .section-placeholder { align-self: stretch; }

.empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }

.field-row { display: flex; gap: 12px; }
.field-row > label { flex: 1; min-width: 0; }
.field-row > label.narrow { flex: 0 0 7.5em; }
.date-time { display: flex; gap: 6px; }
.date-time input[type="date"] { flex: 1 1 auto; min-width: 0; }
.date-time input[type="time"] { flex: 0 0 auto; width: 6.5em; }
dialog input[type="time"] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 6px;
  background: var(--surface);
  font-size: 15px;
  color: var(--text);
}

.feature-list { display: flex; flex-direction: column; gap: 6px; }
.feature-row { display: grid; grid-template-columns: 9.5em auto 1fr; align-items: center; gap: 10px; }
.feature-name { font-size: 14px; color: var(--text); }
.feature-state button { min-width: 24px; min-height: 24px; padding: 3px 11px; font-weight: 700; color: var(--muted); }
.feature-state button.yes.active { background: var(--yes-icon); color: #fff; }
.feature-state button.no.active { background: var(--no-icon); color: #fff; }
.feature-state button.unknown.active { background: var(--muted); color: #fff; }
dialog .feature-row input { padding: 5px 8px; font-size: 14px; }
/* Own dates per person on a stay (folded away until someone needs it). */
.stay-dates-field summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.stay-dates-field summary small { font-weight: 400; font-size: 12px; color: var(--excluded-text); }
.stay-dates { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.stay-dates-row { display: grid; grid-template-columns: minmax(70px, max-content) minmax(0, 1fr) auto minmax(0, 1fr) 5.5em; align-items: center; gap: 6px; }
.stay-dates-row .person-tag { justify-self: start; }
.stay-dates-row .arrow { color: var(--muted); }
dialog .stay-dates-row input[type="date"] { padding: 4px 6px; min-width: 0; }
.stay-nights { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.dialog-actions { display: flex; gap: 8px; }
.spacer { flex: 1; }

/* ---------- view only ---------- */
body.readonly #add-section,
body.readonly .add-card,
body.readonly .handle,
body.readonly .resizer,
body.readonly [data-action="delete-section"],
body.readonly [data-action="edit-card"],
body.readonly [data-action="duplicate-card"],
body.readonly [data-action="duplicate-section"],
body.readonly #add-person,
body.readonly .person-remove,
body.readonly .person-ink,
body.readonly .hint { display: none; }
body.readonly .card { cursor: default; }
body.readonly .board-title,
body.readonly .section-title,
body.readonly .person-name { pointer-events: none; }
body.readonly .section-summary { padding-left: 40px; }
body.readonly .section-head { padding-left: 8px; }


@media (max-width: 600px) {
  .board.columns { flex-direction: column; align-items: stretch; }
  .board.columns .section { min-width: 0; flex: none; }
  .board-col { min-width: 0; }
  .cards { display: flex; flex-direction: column; }
  .cell:empty { display: none; }
  .resizer { display: none; }
  .field-row { flex-wrap: wrap; }
  .feature-row { grid-template-columns: 1fr auto; }
  .feature-row input { grid-column: 1 / -1; }
}


/* Plan view: a column per traveller with their cards in date order. */
.board.plan-view { flex-direction: row; overflow-x: auto; min-height: calc(100vh - 110px); }
.plan-col {
  flex: 0 0 auto;
  min-width: 322px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.plan-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.plan-who { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.plan-cards { display: flex; flex-direction: column; padding: 0 10px; }
/* Cells in a row are as tall as the row; cards stacked in a cell share its height but
   never get shorter than their content. */
.plan-row { display: flex; gap: 10px; align-items: stretch; }
.plan-cell { flex: 0 0 300px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.plan-cell.auto { flex: 1 0 300px; } /* no saved width: fills the column */
.plan-item { flex: 1 0 auto; display: flex; flex-direction: column; }
.plan-item > .card { flex: 1 0 auto; }
/* Between rows: spacing, and while a card is dragged a drop zone for a new row. */
.plan-gap { min-height: 10px; }
body.dragging-plan .plan-gap { min-height: 22px; margin: 2px 0; outline: 1px dashed var(--line); outline-offset: -2px; border-radius: var(--radius); }
body.dragging-plan .plan-cell { outline: 1px dashed var(--line); outline-offset: 2px; border-radius: var(--radius); }
.placeholder.plan-placeholder-side { flex: 0 0 40px; align-self: stretch; min-height: 60px; }
.placeholder.plan-placeholder-stack { flex: 0 0 48px; }
.placeholder.plan-placeholder-row { height: 60px; }
.plan-from { color: var(--muted); font-size: 12px; margin: 0 0 3px 2px; }
.plan-reset { padding: 0 4px; font-size: 12px; }
/* Card type filter above a Plan column: pressed buttons are the types shown. */
.type-filter { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; }
.type-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.type-chip:hover { color: var(--text); }
.type-chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.type-chip .type-icon-inline { margin-right: 3px; vertical-align: 0; }
.type-chip .type-icon-inline svg { width: 14px; height: 14px; }
.type-count { margin-left: 5px; font-size: 12px; font-variant-numeric: tabular-nums; opacity: 0.75; }
.section-total .filter-of { display: block; color: var(--muted); font-size: 12px; }
/* While resizing: the cells this one's width snapped to. */
.plan-cell.snap-match { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius); }
.plan-view [data-action="duplicate-card"],
body.readonly .plan-reset,
body.plan-mode #add-section { display: none; }

/* ---------- card details (read only) ---------- */
/* Wide on a computer: a header, then the details in titled groups, two side by side. */
.detail-dialog { width: min(820px, calc(100vw - 48px)); }
.detail-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  align-content: start;
  padding: 24px 28px 8px;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
}
.detail-head { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-head .card-title-row { gap: 12px; align-items: center; }
.detail-head .card-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.detail-head .type-icon { width: 36px; height: 36px; margin-top: 0; }
.detail-head .type-icon svg { width: 22px; height: 22px; }
.detail-head > .card-sub, .detail-meta { margin-left: 48px; }
.detail-head > .card-sub { font-size: 15px; }
.detail-meta { color: var(--muted); font-size: 13px; }

.detail-group { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; min-width: 0; }
.detail-group.wide { grid-column: 1 / -1; }
.detail-group h3 { margin: 0 0 10px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.detail-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.detail-list dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; line-height: 1.45; }
.detail-list dd.full, .detail-list > .full { grid-column: 1 / -1; }
.detail-price strong { font-size: 20px; font-weight: 700; }
.detail-shares { display: flex; flex-direction: column; gap: 4px; }
.detail-shares .person-line { justify-content: space-between; font-variant-numeric: tabular-nums; }

/* All the type's features, a few columns wide: ✓ included, ✗ not, – not known yet. */
.detail-features { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; }
.detail-features li { display: flex; align-items: baseline; gap: 6px; }
.detail-features .mark { flex: 0 0 1.2em; font-weight: 700; color: var(--muted); }
.detail-features .yes .mark { color: var(--yes-icon); }
.detail-features .no .mark { color: var(--no-icon); }
.detail-features .unknown { color: var(--muted); }
.detail-feature-note { font-weight: 600; color: var(--text); font-size: 13px; }
.detail-feature-note::before { content: "· "; color: var(--muted); font-weight: 400; }

/* When: two calendar leaves (start, end) joined by a line with how long it lasts. */
.when-timeline { display: flex; align-items: flex-end; gap: 14px; }
.date-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 0 0 auto; min-width: 84px; }
.date-tile-label { font-size: 12px; color: var(--muted); }
.date-tile-leaf {
  display: flex; flex-direction: column; align-items: center; width: 84px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.date-tile-weekday { align-self: stretch; text-align: center; padding: 2px 0; font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: #fff; background: var(--detail-accent, var(--line-strong)); }
.date-tile-day { font-size: 30px; font-weight: 750; line-height: 1.1; padding-top: 4px; font-variant-numeric: tabular-nums; }
.date-tile-month { font-size: 12.5px; color: var(--muted); padding-bottom: 6px; }
.date-tile-time { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; min-height: 1.3em; }
.when-span { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 60px; align-self: center; margin-top: 10px; }
.when-line { flex: 1 1 0; height: 2px; border-radius: 1px; background: repeating-linear-gradient(90deg, var(--border) 0 6px, transparent 6px 10px); }
.when-length { font-weight: 650; white-space: nowrap; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; }
.when-length:empty { display: none; }
.detail-head.type-flight ~ .detail-group { --detail-accent: var(--flight); }
.detail-head.type-stay ~ .detail-group { --detail-accent: var(--stay); }
.detail-head.type-train ~ .detail-group { --detail-accent: var(--train); }
.detail-head.type-bus ~ .detail-group { --detail-accent: var(--bus); }
.detail-head.type-boat ~ .detail-group { --detail-accent: var(--boat); }
.detail-head.type-car ~ .detail-group { --detail-accent: var(--car); }
.detail-head.type-activity ~ .detail-group { --detail-accent: var(--activity); }
.detail-head.type-other ~ .detail-group { --detail-accent: var(--other); }

/* A stay some join later or leave earlier: one bar per person over the stay's nights. */
.nights-chart { display: grid; grid-template-columns: max-content minmax(80px, 1fr) max-content; gap: 6px 10px; align-items: center; margin-top: 6px; }
.nights-row { display: contents; }
.nights-track { position: relative; height: 10px; border-radius: 5px; background: var(--line); }
.nights-bar { position: absolute; top: 0; bottom: 0; left: calc(var(--from) * 100%); width: calc(var(--len) * 100%); border-radius: 5px; background: var(--person); }
.nights-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.share-nights { margin-left: auto; font-size: 12px; color: var(--muted); }
.detail-shares .share-nights + .share-amount { min-width: 6.5em; text-align: right; }

/* Before / after: the neighbouring cards of the option, as buttons to their details. */
.detail-neighbour {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; text-align: left;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer;
}
.detail-neighbour:hover { border-color: var(--line-strong); }
.detail-neighbour .type-icon { margin-top: 0; }
.detail-neighbour-text { display: flex; flex-direction: column; min-width: 0; }
.detail-neighbour .card-title { font-size: 14px; }
.detail-neighbour-when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.detail-map { font-size: 14px; font-weight: 600; }

.detail-link a { font-weight: 600; }
.detail-url { margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; display: none; } /* ---------- Grey url in popup ---------- */
.detail-notes { white-space: pre-wrap; }
.detail-dialog .dialog-actions { align-items: center; padding: 14px 28px 20px; border-top: 1px solid var(--line); }
.detail-include { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text); cursor: pointer; }
.detail-include input { width: 18px; height: 18px; margin: 0; }

/* ---------- compact cards ---------- */
/* A card knows how wide it is: when its column or spot is made slim (or a phone splits a
   row), it turns compact instead of growing tall: text and icons at 85%, price and dates
   under the title, and the extras (feature boxes, link, notes, the grey second line, the
   price basis and breakdown) left for its details or editor. */
.cell, .plan-item { container: card / inline-size; }
@container card (max-width: 270px) {
  .card { padding: 8px 9px; gap: 3px; }
  .card-top { flex-direction: column; gap: 3px; }
  .card-meta { align-items: flex-start; text-align: left; padding-top: 0; }
  .card-title-row { gap: 6px; }
  .type-icon { width: 20px; height: 20px; margin-top: -1px; }
  .type-icon svg { width: 13px; height: 13px; }
  .card-title, .card-price { font-size: 12.75px; }
  .card-when, .card-facts { font-size: 11px; }
  .card-actions, .card-actions label { font-size: 10.5px; }
  .card-head > .who { margin-left: 0; }
  .person-tag { font-size: 9.5px; line-height: 15px; padding: 0 5px; }
  .card-price { white-space: normal; }
  .card-meta { min-width: 0; max-width: 100%; }
  .card-when { white-space: normal; overflow-wrap: anywhere; } /* dates wrap, never run off the card */
  .chips, .card-link, .card-desc, .card-desc.clamped, .more, .price-note, .price-basis,
  .card-head > .card-sub, [data-action="duplicate-card"] { display: none; }
}

/* ---------- phones, portrait ---------- */
@media (max-width: 600px) {
  /* iOS zooms in on fields with text under 16px; keep them at 16px. */
  input, select, textarea { font-size: 16px; }

  /* Top bar: scrolls away with the page and is laid out in clear rows:
     title · total · view switches · travellers · actions. */
  .topbar { position: static; padding: 10px 12px; gap: 8px; }
  .board-title { flex: 1 1 100%; font-size: 17px; padding: 2px 4px; }
  .topbar-right { width: 100%; gap: 8px; }

  .setting.grand-total { order: 1; flex: 1 1 100%; justify-content: space-between; padding: 4px 4px 4px 10px; }
  .setting.grand-total select { flex: 1 1 auto; min-width: 0; }
  .grand-total strong { font-size: 16px; }

  .view-toggle, .filter-toggle { order: 2; flex: 1 1 0; }
  .toggle button { flex: 1 1 0; padding: 8px 6px; }

  /* Travellers: one swipeable line instead of a wrapped block. */
  .setting.people { order: 3; flex: 1 1 100%; min-width: 0; }
  .setting.people > span:first-child { display: none; }
  .people-list { flex-wrap: nowrap; overflow-x: auto; min-width: 0; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .person-chip { flex: 0 0 auto; }
  #add-person { flex: 0 0 auto; padding: 6px 8px; }

  #add-section, .save-status, .viewers, #members-btn { order: 4; }
  #members-btn { margin-left: auto; }
  .btn { padding: 6px 12px; }

  /* More room for the cards. */
  .board { padding: 10px; gap: 10px; }
  .board-col { gap: 10px; }

  /* A trip option's summary: dates above, totals below, each on full lines. */
  .section-summary { flex-direction: column; align-items: stretch; gap: 8px; padding: 2px 12px 10px; }
  .trip-span { font-size: 14px; }
  .section-total { text-align: left; }
  .person-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .section-total small { font-size: 13px; }
  body.readonly .section-summary { padding-left: 12px; }

  /* Small grey text is hard to read on a phone. */
  .price-note, .price-basis, .plan-from { font-size: 13px; }
  .card-facts, .card-desc { font-size: 15px; }

  /* Plan view: one traveller per screen, swipe sideways between them; cards full width
     under each other (saved widths and side-by-side rows are for bigger screens). */
  .board.plan-view { scroll-snap-type: x mandatory; gap: 10px; }
  .plan-col { flex: 0 0 calc(100vw - 32px); min-width: 0; scroll-snap-align: start; }
  /* Rows keep their layout; cells share the width in proportion to their saved widths. */
  .plan-cards { padding: 0 6px; }
  .plan-row { gap: 6px; }
  .plan-cell { flex: var(--grow, 300) 1 0 !important; min-width: 0; gap: 6px; }
  .plan-gap { min-height: 6px; }
  .plan-head { padding: 10px; }
  /* Type filter: one line, swiped sideways. */
  .type-filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 8px 10px 0; }
  .type-chip { flex: 0 0 auto; padding: 6px 12px; }

  /* The card editor uses the whole screen width. */
  dialog { width: calc(100vw - 16px); max-width: none; margin: 8px auto; }
  /* Eight card types: the type buttons fill a line, icon above the name. */
  .type-picker { flex: 1 1 100%; }
  .type-picker button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 12px; }
  .type-picker .type-icon-inline { margin: 0; }
  /* Dates and times get a line each so the date is readable. */
  .field-row > label:has(.date-time) { flex: 1 1 100%; }
  .date-time input[type="time"] { width: 7.5em; }
  /* The travellers line scrolls by swiping, without a scrollbar. */
  .people-list { scrollbar-width: none; }
  .people-list::-webkit-scrollbar { display: none; }

  /* Compact cards so several fit side by side: smaller text, and the extras (feature
     boxes, link, notes, price breakdown) left for the card's details or editor.
     An option keeps its own columns, scaled to the screen in proportion to their widths. */
  .cards { display: grid; grid-template-columns: var(--cols-fr) !important; gap: 6px; padding: 6px; }
  .cell { gap: 6px; }
  .card { padding: 7px 8px; gap: 3px; }
  .card-top { flex-direction: column; gap: 3px; }
  .card-meta { align-items: flex-start; text-align: left; padding-top: 0; }
  .card-title-row { gap: 6px; }
  .type-icon { width: 17px; height: 17px; margin-top: 0; }
  .type-icon svg { width: 11px; height: 11px; }
  .card-title, .card-price { font-size: 11.5px; } /* owner 2026-10-12: smaller than 85% of a normal card */
  .card-title, .card-price, .section-total strong, .grand-total strong { font-weight: 600; }
  .card-when, .card-facts { font-size: 10.5px; }
  .card-actions, .card-actions label { font-size: 10.5px; }
  .price-basis { font-size: 11px; }
  /* Small cards: the icon and the route say enough; no basis ("total", "/ person") and no
     grey second line (airline, place). Both are in the card's details. */
  .card .price-basis, .card-head > .card-sub { display: none; }
  /* Plan view on a phone: no "in total" row on the cards; it is in the card's details. */
  .plan-view .card-actions { display: none; }
  /* On a phone the top bar is just the title, whose total (person, amount) and
     Options/Plan. Travellers, All/Checked, new options, status and log in/out are for
     the computer. */
  .setting.people,
  .filter-toggle,
  #add-section,
  .save-status,
  .viewers,
  #members-btn { display: none; }
  .card-price { white-space: normal; } /* narrow cells: "/ person" wraps instead of overflowing */
  .card-head > .card-sub, .card-head > .who { margin-left: 0; }
  .person-tag { font-size: 9.5px; line-height: 15px; padding: 0 5px; }
  .chips, .card-link, .card .card-desc, .card .card-desc.clamped, .card .more, .card .price-note,
  .card [data-action="duplicate-card"], .card [data-action="edit-card"] { display: none; }
  /* The card's details on a phone: one column, a smaller header. */
  .detail-body { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px 16px 6px; }
  .detail-head .card-title { font-size: 18px; }
  .detail-head .type-icon { width: 28px; height: 28px; }
  .detail-head .type-icon svg { width: 17px; height: 17px; }
  .detail-head > .card-sub, .detail-meta { margin-left: 40px; }
  .detail-dialog .dialog-actions { padding: 12px 16px 16px; flex-wrap: wrap; }
  /* A trip option's summary in smaller type too. */
  .section-summary { gap: 6px; }
  .trip-span { font-size: 12px; }
  .section-total strong { font-size: 15px; }
  .person-total strong { font-size: 13px; }
  .person-total { padding: 4px 6px; }
  /* The card's details: smaller calendar leaves; own-dates rows wrap under the name. */
  .date-tile, .date-tile-leaf { min-width: 64px; width: 64px; }
  .date-tile-day { font-size: 22px; }
  .when-timeline { gap: 8px; }
  .when-length { font-size: 12px; padding: 2px 7px; }
  .stay-dates-row { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; }
  .stay-dates-row .person-tag { grid-column: 1 / -1; }
  .person-line + .person-line { margin-top: 2px; }
}

/* Very narrow cards (three side by side on a phone): smaller still. After the phone rules
   so it wins over their sizes. */
@container card (max-width: 170px) {
  .card { padding: 6px 7px; }
  .card-title-row { gap: 5px; }
  .type-icon { width: 15px; height: 15px; margin-top: 0; }
  .type-icon svg { width: 9.5px; height: 9.5px; }
  .card-title, .card-price { font-size: 10.5px; }
  .card-when, .card-facts { font-size: 9.5px; }
  .card-actions, .card-actions label { font-size: 9.5px; }
  .person-tag { font-size: 8.5px; line-height: 13px; padding: 0 4px; }
  .who { gap: 3px; }
}

/* Notices under the header (not saved, lost rights, revoked, updating) */
.notices { display: flex; flex-direction: column; gap: 1px; }
.notices:empty { display: none; }
.notice {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px;
  padding: 8px 16px; background: var(--no-bg); color: var(--no-text);
}
.notice a { color: inherit; font-weight: 600; }
.notice .spacer { flex: 1; }
.notice button { color: inherit; }
.load-error { padding: 24px 16px; }
.load-error a { font-weight: 600; }

/* Share dialog (T37) */
.share-dialog { width: min(640px, calc(100vw - 24px)); }
.share-dialog h3 { font-size: 14px; margin: 14px 0 6px; }
.share-section ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.share-section li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share-section li .member-name, .share-section li > span:first-child { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.member-email, .member-role, .share-note { color: var(--muted); font-size: 13px; }
.share-note { margin: 4px 0; }
.invite-form { display: grid; grid-template-columns: max-content 1fr; gap: 6px 10px; align-items: center; }
.invite-form h3, .invite-form button { grid-column: 1 / -1; }
.invite-form button { justify-self: start; }
.link-once, .view-link { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.link-once .share-note { flex-basis: 100%; }
.link-once input, .view-link input { flex: 1 1 14rem; min-width: 0; }

/* Move buttons of a trip option (keyboard and touch alternative to the drag handle). */
.move-buttons { display: inline-flex; flex: 0 0 auto; }
.move-buttons .btn.ghost { padding: 2px 5px; }
@media (max-width: 600px) { .move-buttons .move-cols { display: none; } }
