:root {
  --bg: #ffffff;
  --surface: #f5f6f8;
  --line: #e4e7ec;
  --line-strong: #cfd4dc;
  --ink: #12151a;
  --ink-2: #4b5563;
  --ink-3: #838c99;
  --accent: #0b4fd8;
  --accent-press: #0940b1;
  --accent-soft: #eef3fe;
  --on-accent: #ffffff;
  --danger: #b3261e;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;

  --radius: 8px;
  --radius-sm: 6px;
  --tap: 44px;
  --tabbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  overscroll-behavior-y: none;
}

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

/* ---------- shell ---------- */
.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--s4) calc(var(--s6) + var(--tabbar-h) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: var(--s3) 0;
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--s4);
}

.trip-title {
  margin: 0;
  font-size: 19px;
  font-weight: 640;
  letter-spacing: -0.015em;
}

.trip-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.flightbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
  margin-top: var(--s3);
}

.flightcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--s2) var(--s3);
}

.flightcard span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: 2px;
}

.flightcard strong {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- day tabs ---------- */
.days {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
  padding: var(--s4) 0 0;
}

.pill {
  min-height: var(--tap);
  padding: var(--s2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  text-align: center;
  cursor: pointer;
}

.pill b {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.pill small {
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.3;
}

.pill[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.pill[aria-selected="true"] small {
  color: rgba(255, 255, 255, 0.85);
}

/* ---------- section head ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin: var(--s5) 0 var(--s3);
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  min-width: 0;
}

.count {
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ---------- list ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: var(--s3);
}

.card-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: var(--s3);
  align-items: start;
}

.time {
  font-size: 15px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.act {
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}

.chip {
  display: inline-block;
  margin-top: var(--s2);
  padding: 2px var(--s2);
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 550;
  line-height: 1.5;
}

/* Baris chip di kartu itinerary: transport, estimasi perjalanan, jarak.
   Wrap supaya di layar sempit chip turun baris, bukan memaksa kartu melebar. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  margin-top: var(--s2);
}

/* Margin atas sudah dipegang .chips, kalau tidak dinolkan tiap chip menambah
   jarak sendiri dan barisnya jadi renggang tidak rata. */
.chips .chip {
  margin-top: 0;
}

.chip-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-3);
}

.chip-meta svg {
  flex: none;
  opacity: 0.75;
}

.field-hint {
  margin: calc(var(--s1) * -1) 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-3);
}

.actions {
  display: flex;
  gap: var(--s1);
  margin: -6px -6px -6px 0;
}

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

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

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

.note-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  line-height: 1.4;
}

/* Tab Tips dan Catatan menampilkan isi apa adanya: pre-wrap menjaga paragraf
   dan baris kosong yang diketik user, tanpa clamp supaya tidak ada yang
   terpotong. */
.note-card p {
  margin: var(--s1) 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.note-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s3);
  align-items: start;
}

.empty {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--s5) var(--s4);
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap);
  padding: 0 var(--s4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
}

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

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

.btn-sm {
  min-height: 34px;
  padding: 0 var(--s3);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
}

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  border: 0;
  background: transparent;
  height: var(--tabbar-h);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-3);
  cursor: pointer;
}

.tab[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- sheet ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 21, 26, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  padding: var(--s4) var(--s4) 0;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet h2 {
  margin: 0 0 var(--s4);
  font-size: 16px;
  font-weight: 620;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
}

.field {
  margin-bottom: var(--s3);
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: var(--s1);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  outline: none;
}

.field textarea {
  min-height: 66px;
  resize: vertical;
}

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

.quick {
  display: flex;
  gap: var(--s1);
  margin-top: var(--s2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.quick::-webkit-scrollbar {
  display: none;
}

.quick button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.quick button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.sheet-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
  margin-top: var(--s4);
  padding: var(--s3) 0 calc(var(--s4) + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.alert {
  background: #fdf0ef;
  border: 1px solid #f1cfcc;
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: var(--s2) var(--s3);
  font-size: 13px;
  margin-bottom: var(--s3);
}

.loading {
  padding: var(--s6) 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

@media (min-width: 768px) {
  .tabbar {
    position: static;
    max-width: 720px;
    margin: 0 auto;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: repeat(4, auto);
    justify-content: start;
    padding: 0 var(--s4);
  }

  .tab {
    grid-auto-flow: column;
    align-items: center;
    height: 48px;
    gap: var(--s2);
    font-size: 14px;
  }

  .shell {
    padding-bottom: var(--s6);
  }

  .backdrop {
    align-items: center;
  }

  .sheet {
    border-radius: 12px;
  }
}

/* ---------- motion ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.view {
  animation: fade 180ms ease both;
}

.list > * {
  animation: rise 220ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.list > *:nth-child(1) {
  animation-delay: 0ms;
}
.list > *:nth-child(2) {
  animation-delay: 30ms;
}
.list > *:nth-child(3) {
  animation-delay: 60ms;
}
.list > *:nth-child(4) {
  animation-delay: 90ms;
}
.list > *:nth-child(5) {
  animation-delay: 120ms;
}
.list > *:nth-child(n + 6) {
  animation-delay: 150ms;
}

.backdrop {
  animation: fade 160ms ease both;
}

.sheet {
  animation: sheet-up 220ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.empty {
  animation: fade 220ms ease both;
}

.alert {
  animation: rise 180ms ease both;
}

.card {
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.card:hover {
  border-color: var(--line-strong);
}

.pill,
.btn,
.quick button,
.tab,
.icon-btn {
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease,
    transform 120ms ease;
}

.btn:active,
.quick button:active,
.pill:active {
  transform: scale(0.97);
}

.icon-btn:active {
  transform: scale(0.9);
}

.tab svg,
.icon-btn svg {
  transition: transform 160ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.tab[aria-current="page"] svg {
  transform: translateY(-1px) scale(1.06);
}

.field input,
.field textarea,
.field select {
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.card-leaving {
  animation: fade 140ms ease forwards reverse;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}

/* ---------- kartu sebagai tombol detail ---------- */
.card-btn {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.card-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.card-btn:active {
  transform: scale(0.995);
}

.card-go {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--ink-3);
}

.act-note {
  margin-top: var(--s1);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-3);
  display: -webkit-box;
  /* Preview 2 baris: catatan sekarang boleh multi baris, jadi 1 baris terlalu
     sedikit untuk memberi gambaran. Teks penuh tetap ada di sheet detail. */
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Newline dari user ikut tampil di preview, bukan dirapatkan jadi satu baris. */
  white-space: pre-wrap;
  /* URL panjang tanpa spasi tidak boleh mendorong lebar kartu. */
  overflow-wrap: anywhere;
}

/* ---------- detail ---------- */
.detail {
  margin: 0;
  display: grid;
  gap: var(--s3);
}

.detail dt {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 2px;
}

.detail dd {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}

.detail-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.detail-note {
  white-space: pre-wrap;
  /* Link panjang yang ditempel user harus ikut turun baris, bukan bikin sheet
     bisa digeser ke samping. */
  overflow-wrap: anywhere;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.detail-empty {
  color: var(--ink-3);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--line-strong);
}

.btn-danger:hover {
  background: #fdf0ef;
  border-color: #f1cfcc;
}

@keyframes flash {
  0% {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
  100% {
    background: var(--bg);
    border-color: var(--line);
  }
}

.card-flash {
  animation: flash 1100ms ease both;
}

/* ---------- grid konten ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s2);
}

.tile {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  animation: rise 220ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
  transition: border-color 140ms ease, transform 120ms ease;
}

.tile:hover {
  border-color: var(--line-strong);
}

.tile:active {
  transform: scale(0.99);
}

.tile-leaving {
  animation: fade 140ms ease forwards reverse;
  pointer-events: none;
}

.tile-media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-3);
}

.tile-tag {
  position: absolute;
  left: var(--s2);
  bottom: var(--s2);
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(18, 21, 26, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.tile-body {
  display: block;
  padding: var(--s2) 10px 10px;
}

.tile-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 550;
  word-break: break-word;
}

.tile-sub,
.tile-note {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-3);
}

.detail-thumb {
  width: 100%;
  max-height: 168px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: var(--s3);
  display: block;
}

.detail-url {
  font-size: 13px;
  color: var(--ink-3);
  word-break: break-all;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
  margin-top: var(--s4);
}

.detail-actions .btn {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.btn-quiet {
  color: var(--ink-2);
}
