:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #0b1f3a;
  --ink-2: #445069;
  --muted: #6b7793;
  --line: #e3e7ef;
  --brand: #0b1f3a;
  --brand-accent: #1b6fd0;
  --am: #2f6bd0;
  --pm: #a45300;
  --danger: #b13a2b;
  --ok: #16794b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11,31,58,.06), 0 4px 12px rgba(11,31,58,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: 6rem;
}

a { color: var(--brand-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--brand); color: #fff;
  padding-top: calc(.75rem + env(safe-area-inset-top));
}
.topbar .brand {
  color: #fff; font-weight: 700; letter-spacing: .3px; font-size: 1.15rem;
}
.topbar nav { display: flex; align-items: center; gap: .5rem; }
.topbar .nav-link { color: #cfd8ea; }
.editor-chip {
  background: rgba(255,255,255,.14);
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .82rem;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.auth-card { max-width: 420px; margin: 3rem auto; }
.auth-card h1 { margin: 0 0 .25rem; }

.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack.tight { gap: .25rem; }
.row { display: flex; gap: .75rem; align-items: stretch; flex-wrap: wrap; }
.row.baseline { align-items: baseline; }
.row > .grow { flex: 1 1 180px; }
.inline { display: inline-block; }
.right { margin-left: auto; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--ink-2); }
input, select, textarea {
  font: inherit;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
}
textarea { min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-accent);
  outline-offset: 1px;
}

.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid transparent;
  padding: .55rem .9rem; font-weight: 600; cursor: pointer;
  min-height: 44px;
}
.btn-primary { background: var(--brand-accent); color: #fff; }
.btn-primary:hover { background: #1461bd; }
.btn-primary.btn-lg { padding: .8rem 1.2rem; font-size: 1.05rem; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #eef2f8; text-decoration: none; }
.btn-ghost.small { padding: .35rem .65rem; min-height: 36px; font-size: .85rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger.small { padding: .35rem .65rem; min-height: 36px; font-size: .85rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.centered { text-align: center; }

.alert-err { background: #fdecea; color: #7a1e15; padding: .6rem .8rem; border-radius: 8px; margin-bottom: .8rem; }
.alert-info { background: #eef4fb; color: #10416d; padding: .6rem .8rem; border-radius: 8px; margin-bottom: .8rem; }

/* Week nav */
.week-nav {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: .5rem;
  padding: .5rem 0 1rem;
}
.week-title { text-align: center; }
.week-label { font-size: 1.15rem; font-weight: 700; }
.week-range { font-size: .85rem; }

.quick-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }

/* Days */
.days { display: flex; flex-direction: column; gap: 1rem; }
.day {
  background: var(--surface);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  box-shadow: var(--shadow);
}
.day h2 { margin: 0 0 .5rem; font-size: 1.05rem; }

.section-am, .section-pm { padding: .5rem 0; border-top: 1px solid var(--line); }
.section-am:first-of-type, .section-pm:first-of-type { border-top: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .35rem; }
.section-label {
  display: inline-block; font-weight: 700; font-size: .85rem;
  padding: .1rem .55rem; border-radius: 999px;
}
.section-am .section-label { background: #e3edfa; color: var(--am); }
.section-pm .section-label { background: #fbeadd; color: var(--pm); }

.trip-card {
  background: #fafbff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .55rem .7rem;
  margin-bottom: .5rem;
}
.trip-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.time { font-weight: 700; font-variant-numeric: tabular-nums; }
.pill {
  display: inline-block;
  font-size: .78rem; font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: #eef2f8; color: var(--ink-2);
}
.pax { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .2rem; }
.pax li { display: flex; gap: .4rem; align-items: baseline; flex-wrap: wrap; }
.notes { margin-top: .35rem; font-size: .85rem; color: var(--ink-2); font-style: italic; }
.empty { padding: .3rem 0; font-size: .9rem; }

/* Edit page */
.edit-header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.edit-header h1 { margin: 0; font-size: 1.15rem; }

.pax-picker { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  background: #eef2f8; color: var(--ink);
  border: 1px solid transparent; border-radius: 999px;
  padding: .35rem .8rem; font-weight: 600; cursor: pointer;
  min-height: 36px;
}
.chip.selected { background: var(--brand-accent); color: #fff; }

.pax-editor { display: flex; flex-direction: column; gap: .5rem; }
.pax-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .55rem;
  background: #fff;
}
.pax-row .name { grid-column: 1 / -1; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.pax-row .remove { background: transparent; border: none; color: var(--danger); cursor: pointer; padding: .2rem .4rem; font-size: .85rem; }

/* Sticky save bar */
.save-bar {
  position: sticky; bottom: 0;
  padding: .75rem 0;
  padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(246,247,251,0) 0%, var(--bg) 40%);
  display: flex; gap: .5rem; justify-content: flex-end; align-items: center;
}

/* Settings */
.people { width: 100%; border-collapse: collapse; margin-top: .8rem; }
.people th, .people td { padding: .5rem .3rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .9rem; vertical-align: middle; }
.people th { color: var(--muted); font-weight: 600; }
.inline-rename { display: flex; gap: .35rem; align-items: center; }
.inline-rename input { flex: 1; }

.token-list { list-style: none; padding: 0; margin: .8rem 0 0; display: flex; flex-direction: column; gap: .5rem; }
.token-list li {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.kv { display: grid; grid-template-columns: 140px 1fr; gap: .4rem .8rem; margin: .5rem 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
