/* Shanghai Companion — dark, mobile-first */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #0f172a;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Noto Sans Thai", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body {
  padding-bottom: 96px;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: #38bdf8; text-decoration: none; }
a:active { color: #0ea5e9; }

/* Top header */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, #0f172a 85%, rgba(15,23,42,0.7));
  padding: env(safe-area-inset-top) 0 0 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.trip-title {
  padding: 14px 16px 6px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.trip-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.subtitle {
  color: #94a3b8;
  font-size: 13px;
}

/* Day tab strip */
.day-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}
.day-tab.active {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
}
.day-tab:active { transform: scale(0.97); }

/* Day view */
.day-view {
  padding: 14px 14px 32px;
}
.day-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.chip {
  font-size: 12px;
  padding: 4px 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #94a3b8;
}
.headline {
  font-size: 14px;
  color: #cbd5e1;
  margin: 4px 0 18px;
  padding: 10px 12px;
  background: #1e293b;
  border-left: 3px solid #38bdf8;
  border-radius: 6px;
}

/* Cards */
.card {
  background: #1e293b;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid #334155;
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  align-items: start;
}
.card.mode-meal { border-left: 3px solid #f59e0b; }
.card.mode-sightsee { border-left: 3px solid #a78bfa; }
.card.mode-metro, .card.mode-maglev { border-left: 3px solid #38bdf8; }
.card.mode-walk { border-left: 3px solid #64748b; }
.card.mode-didi { border-left: 3px solid #facc15; }
.card.mode-flight { border-left: 3px solid #ef4444; }
.card.mode-hotel { border-left: 3px solid #22c55e; }
.card.mode-rest { border-left: 3px solid #94a3b8; }
.card.mode-transit { border-left: 3px solid #64748b; }

.time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #38bdf8;
  font-size: 13px;
  line-height: 1.3;
}
.time .end {
  color: #64748b;
  font-weight: 400;
  display: block;
  font-size: 12px;
}
.body { min-width: 0; }
.title-line {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
}
.notes {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}
.card-meta a {
  display: inline-block;
  padding: 4px 10px;
  background: #0f172a;
  border-radius: 5px;
  border: 1px solid #334155;
}
.cost-tag {
  padding: 4px 8px;
  background: #0f172a;
  border-radius: 5px;
  border: 1px solid #334155;
  color: #facc15;
}
.restaurant-note {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 6px;
  font-size: 12px;
  color: #fcd34d;
}
.restaurant-note .strategy {
  color: #fde68a;
  font-weight: 500;
}

/* Branch divider */
.branch-divider {
  margin: 14px 0 6px;
  padding: 10px 12px;
  background: rgba(167, 139, 250, 0.1);
  border: 1px dashed #a78bfa;
  border-radius: 8px;
  text-align: center;
}
.branch-title {
  font-size: 13px;
  font-weight: 700;
  color: #c4b5fd;
  letter-spacing: 0.3px;
}
.branch-notes {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}
.card.branch-a { border-left-color: #f472b6 !important; }
.card.branch-b { border-left-color: #34d399 !important; }

/* Risks / Alternates section */
.section-block {
  margin-top: 22px;
  padding: 12px 14px;
  background: #1e293b;
  border-radius: 8px;
  border: 1px solid #334155;
}
.section-block.risks { border-left: 3px solid #ef4444; }
.section-block.alts { border-left: 3px solid #facc15; }
.section-block h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.section-block p {
  margin: 0;
  font-size: 13px;
  color: #94a3b8;
}

/* FAB */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #38bdf8;
  color: #0f172a;
  border: none;
  font-size: 30px;
  font-weight: 300;
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.4), 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  z-index: 20;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.92); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.15s ease-out;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #1e293b;
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  animation: slide-up 0.2s ease-out;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 28px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

.expense-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field > span {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input,
.field select {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 16px;
  color: #e2e8f0;
  outline: none;
  font-family: inherit;
}
.field input:focus,
.field select:focus {
  border-color: #38bdf8;
}
.submit {
  margin-top: 4px;
  background: #38bdf8;
  color: #0f172a;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.submit:active { background: #0ea5e9; }
.submit:disabled { opacity: 0.5; }
.form-msg {
  font-size: 13px;
  margin: 0;
  min-height: 1.4em;
}
.form-msg.error { color: #fca5a5; }
.form-msg.success { color: #86efac; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #334155;
  color: #f1f5f9;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  animation: fade-in 0.2s ease-out;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.toast[hidden] { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
