/* Trip Made Easy - mobile-first, clean */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #17202a;
  --muted: #66707d;
  --line: #e4e8ee;
  --accent: #0f766e;
  --accent-soft: #dcefec;
  --warn: #b45309;
  --warn-bg: #fdf0dd;
  --bad: #b91c1c;
  --bad-bg: #fde8e8;
  --good: #15803d;
  --good-bg: #e3f3e8;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.app-header nav { display: flex; gap: 6px; }
.app-header nav a {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 6px 10px; border-radius: 999px;
}
.app-header nav a.active { color: var(--accent); background: var(--accent-soft); }
.app-main { max-width: 760px; margin: 0 auto; padding: 16px 14px 80px; }
.app-footer {
  padding: 18px 16px 28px; text-align: center; color: var(--muted);
  font-size: 12.5px; border-top: 1px solid var(--line); background: var(--card);
}

/* generic */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 8px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
input[type="text"], input[type="date"], input[type="search"], select {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.banner {
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid #f3ddba;
}
.banner code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 5px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.spinner { color: var(--muted); font-size: 14px; padding: 10px 4px; }
.error-box { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 8px 0; }

/* home */
.home-hero { margin: 6px 0 18px; }
.home-hero h1 { font-size: 24px; margin: 0 0 4px; }
.home-hero p { margin: 0; color: var(--muted); }
.new-trip { padding: 16px; margin-bottom: 20px; }
.new-trip h2 { margin: 0 0 10px; font-size: 17px; }
.new-trip .row { display: flex; gap: 8px; }
.new-trip .row input { flex: 1; }
.import-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.section-title { font-size: 15px; font-weight: 700; margin: 20px 4px 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.trip-list { display: grid; gap: 10px; }
.trip-card { display: block; padding: 14px 16px; text-decoration: none; color: var(--ink); }
.trip-card h3 { margin: 0 0 4px; font-size: 17px; }
.trip-card .meta { color: var(--muted); font-size: 13.5px; }
.trip-card .badge { float: right; font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }

/* trip view */
.trip-head { margin-bottom: 14px; }
.trip-head .back { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 600; }
.trip-head h1 { font-size: 22px; margin: 8px 0 2px; }
.trip-head .meta { color: var(--muted); font-size: 14px; }
.trip-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.add-stop { padding: 14px; margin-bottom: 18px; }
.add-stop h2 { margin: 0 0 10px; font-size: 16px; }
.add-stop .search-row { position: relative; }
.search-results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  max-height: 260px; overflow: auto;
}
.search-results .sr-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-results .sr-item:last-child { border-bottom: 0; }
.search-results .sr-item:hover { background: var(--bg); }
.search-results .sr-item .name { font-weight: 600; font-size: 14.5px; }
.search-results .sr-item .addr { color: var(--muted); font-size: 13px; }
.pending-stop { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.pending-stop .label { font-size: 14px; font-weight: 600; }
.pending-stop input[type="date"] { width: auto; }

/* day cards */
.day-card { margin-bottom: 18px; overflow: hidden; }
.day-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.day-head .day-title { font-size: 16px; font-weight: 700; }
.day-head .day-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.day-load { margin-top: 10px; }
.load-bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.load-bar > div { height: 100%; background: var(--good); border-radius: 999px; transition: width .3s; }
.load-bar.over > div { background: var(--bad); }
.load-label { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.load-label.over { color: var(--bad); font-weight: 700; }
.overpack-warn {
  margin: 10px 16px 0; padding: 10px 12px; border-radius: 10px;
  background: var(--bad-bg); color: var(--bad); font-size: 13.5px; font-weight: 600;
}
.day-body { padding: 6px 16px 14px; }
.day-map { height: 220px; border-radius: 12px; margin: 10px 0; background: #e9edf2; overflow: hidden; }
.day-map.placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-size: 13px; padding: 12px;
}

/* stop cards */
.stop-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.stop-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.stop-top h4 { margin: 0; font-size: 16px; }
.stop-top .remove { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
}
.chip.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.unknown { color: var(--muted); }
.chip a { color: inherit; }
.stop-address { color: var(--muted); font-size: 13px; margin-top: 6px; }
.stop-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.reviews { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.reviews h5 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.review { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.review:last-child { border-bottom: 0; }
.review .r-head { display: flex; justify-content: space-between; font-size: 13px; gap: 8px; }
.review .r-author { font-weight: 600; }
.review .r-when { color: var(--muted); white-space: nowrap; }
.review .r-text { font-size: 13.5px; color: #333c47; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.parking-list { margin-top: 10px; }
.parking-list .park-item { font-size: 13.5px; padding: 5px 0; color: #333c47; }
.parking-list .park-item .dist { color: var(--muted); font-size: 12.5px; }

/* leg chip */
.leg {
  display: flex; align-items: center; gap: 8px; margin: 10px 0 0 8px; padding-left: 14px;
  border-left: 2px dashed var(--line); color: var(--muted); font-size: 13.5px; min-height: 28px;
}
.leg b { color: var(--ink); }

/* detour rail */
.detour h5 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.rail { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.rail::-webkit-scrollbar { height: 0; }
.detour-card {
  min-width: 190px; max-width: 190px; scroll-snap-align: start;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff;
}
.detour-card .name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.detour-card .meta { font-size: 12.5px; color: var(--muted); }
.detour-card .add-btn { margin-top: 8px; }

/* video rail */
.videos { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.videos h5 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.video-filters { display: flex; gap: 6px; margin-bottom: 8px; }
.video-filters .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.video-card { min-width: 220px; max-width: 220px; scroll-snap-align: start; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.video-card .thumb { position: relative; width: 100%; aspect-ratio: 16/9; background: #111; cursor: pointer; border: 0; padding: 0; display: block; }
.video-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-card .thumb .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 28px; text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.video-card .thumb .dur {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.75); color: #fff;
  font-size: 11.5px; padding: 1px 6px; border-radius: 6px;
}
.video-card .v-meta { padding: 8px 10px; }
.video-card .v-title { font-size: 13px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-card .v-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.video-card iframe { width: 100%; aspect-ratio: 16/9; border: 0; display: block; }

/* explore */
.explore-wrap { position: relative; }
.explore-map { height: calc(100vh - 170px); min-height: 380px; border-radius: var(--radius); overflow: hidden; background: #e9edf2; }
.explore-map.placeholder { display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: 14px; padding: 20px; }
.explore-panel { margin-top: 14px; }
.explore-panel .stop-card { margin-top: 0; }
.explore-hint { color: var(--muted); font-size: 14px; margin: 8px 2px 12px; }

@media (min-width: 700px) {
  .app-main { padding-top: 24px; }
  .home-hero h1 { font-size: 28px; }
  .trip-list { grid-template-columns: 1fr 1fr; }
  .explore-panel { display: grid; grid-template-columns: 1fr; }
}
