:root {
  --background: #f8f9fa;
  --surface: #ffffff;
  --foreground: #5c6166;
  --heading: #2f353b;
  --muted: #686868;
  --dim: #8a9199;
  --border: #d8dde3;
  --border-soft: #e9edf1;
  --blue: #3199e1;
  --bright-blue: #399ee6;
  --blue-soft: #eaf5fd;
  --accent: #ffaa33;
  --accent-soft: #fff6e6;
  --green: #86b300;
  --green-soft: #f1f8e7;
  --red: #f07171;
  --cyan: #46ba94;
  --magenta: #9e75c7;
  --shadow: 0 1px 2px rgba(47, 53, 59, .04), 0 8px 30px rgba(47, 53, 59, .05);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; }
button { color: inherit; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 72px;
  padding: 0 max(28px, calc((100vw - 1180px) / 2));
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}
.brand { color: var(--heading); text-decoration: none; display: flex; align-items: center; gap: 11px; font-family: Manrope, sans-serif; font-weight: 800; font-size: 18px; letter-spacing: -.35px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; color: var(--blue); background: var(--blue-soft); display: grid; place-items: center; }
.brand-mark svg { width: 23px; height: 23px; stroke-width: 2.1; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.preview-badge { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--accent-soft); border: 1px solid #f7e4bd; padding: 7px 10px; border-radius: 99px; }
.preview-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(255, 170, 51, .14); }
.preview-badge.live { color: #668c00; background: var(--green-soft); border-color: #dcecc5; }
.preview-badge.live .preview-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(134,179,0,.12); }
.preview-badge.loading .preview-dot { animation: status-pulse 1.1s ease-in-out infinite; }
.preview-badge.fallback { color: var(--muted); }
@keyframes status-pulse { 50% { opacity: .35; transform: scale(.8); } }
.icon-button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); display: grid; place-items: center; background: var(--surface); cursor: pointer; transition: .2s; }
.icon-button:hover { border-color: var(--blue); color: var(--blue); }
.icon-button svg { width: 18px; height: 18px; }

main { max-width: 1180px; margin: 0 auto; padding: 58px 28px 70px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 30px; }
.eyebrow, .section-label { margin: 0 0 8px; font-size: 11px; line-height: 1; font-weight: 800; color: var(--blue); letter-spacing: 1.35px; }
h1, h2 { font-family: Manrope, sans-serif; color: var(--heading); margin: 0; }
h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.1; letter-spacing: -1.8px; }
h2 { font-size: 20px; letter-spacing: -.5px; }
.intro-copy { margin: 10px 0 0; color: var(--dim); font-size: 15px; }
.updated { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; padding-bottom: 5px; }
.updated > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(134,179,0,.10); }

.direction-switch { max-width: 800px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 5px; margin-bottom: 22px; border-radius: 15px; background: #edf0f3; }
.direction-button { min-width: 0; border: 0; padding: 12px 14px; border-radius: 11px; background: transparent; display: grid; grid-template-columns: 34px minmax(62px, auto) 24px 34px minmax(62px, auto); align-items: center; gap: 9px; text-align: left; cursor: pointer; transition: .2s ease; }
.direction-button:hover { background: rgba(255,255,255,.55); }
.direction-button.is-active { background: var(--surface); box-shadow: 0 2px 8px rgba(47,53,59,.09); }
.direction-button strong, .direction-button small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.direction-button strong { color: var(--heading); font-size: 13px; }
.direction-button small { color: var(--dim); margin-top: 2px; font-size: 10px; }
.direction-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; }
.direction-icon svg { width: 17px; height: 17px; }
.home-icon { color: var(--blue); background: var(--blue-soft); }
.work-icon { color: #7f66b3; background: #f2edf8; }
.direction-arrow { width: 18px; height: 18px; color: #a0a6ac; }

.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(310px, 1fr); gap: 20px; }
.commute-card { overflow: hidden; }
.commute-main { padding: 28px 30px 24px; }
.card-heading-row, .card-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.time-readout { display: flex; align-items: baseline; gap: 7px; margin-top: 3px; color: var(--heading); font-family: Manrope, sans-serif; }
.time-readout > span { font-weight: 800; font-size: 57px; line-height: .98; letter-spacing: -3px; }
.time-readout small { font-size: 19px; font-weight: 700; color: var(--muted); }
.time-range { margin: 8px 0 0; font-size: 13px; color: var(--dim); }
.traffic-pill { display: flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.traffic-pill > span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.traffic-pill.light { background: var(--green-soft); color: #6c9500; }
.traffic-pill.moderate { background: var(--accent-soft); color: #c87a10; }
.traffic-pill.heavy { background: #fff0f0; color: #d95a5a; }
.route-visual { display: grid; grid-template-columns: 16px 1fr 16px; align-items: center; margin: 32px 4px 10px; }
.route-point { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; }
.route-point span { width: 6px; height: 6px; border-radius: 50%; background: white; }
.route-point.start { background: var(--blue); box-shadow: 0 0 0 5px rgba(49,153,225,.1); }
.route-point.end { background: var(--magenta); box-shadow: 0 0 0 5px rgba(158,117,199,.1); }
.route-line { position: relative; height: 2px; background: var(--border); margin: 0 5px; overflow: visible; }
.route-line:before, .route-line:after { content: ""; position: absolute; top: -2px; width: 6px; height: 6px; border-radius: 50%; background: #c7cdd3; }
.route-line:before { left: 31%; }.route-line:after { right: 28%; }
.route-line i { display: block; width: 64%; height: 2px; background: linear-gradient(90deg, var(--blue), var(--magenta)); }
.route-labels { display: flex; justify-content: space-between; gap: 30px; }
.route-labels > div:last-child { text-align: right; }
.route-labels strong, .route-labels span { display: block; }
.route-labels strong { color: var(--heading); font-size: 13px; }
.route-labels span { font-size: 11px; margin-top: 3px; color: var(--dim); }
.commute-footer { min-height: 82px; padding: 18px 24px 18px 30px; background: #fbfcfd; border-top: 1px solid var(--border-soft); display: flex; align-items: center; gap: 30px; }
.stat { display: flex; gap: 10px; align-items: center; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; color: var(--blue); background: var(--blue-soft); display: grid; place-items: center; }
.stat-icon svg { width: 16px; height: 16px; }
.stat small, .stat strong { display: block; white-space: nowrap; }
.stat small { color: var(--dim); font-size: 10px; }.stat strong { color: var(--heading); font-size: 12px; margin-top: 2px; }
.maps-link { margin-left: auto; text-decoration: none; color: var(--blue); display: flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 700; }
.maps-link svg { width: 15px; height: 15px; }
.refresh-button { border: 0; background: transparent; padding: 6px 0; cursor: pointer; }
.refresh-button:disabled { color: var(--dim); cursor: wait; }

.forecast-card { padding: 28px 26px 22px; }
.best-time { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 10px; color: #6e9700; background: var(--green-soft); padding: 6px 8px; border-radius: 8px; font-weight: 700; }
.best-time svg { width: 14px; height: 14px; }
.forecast-list { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.forecast-item { display: grid; grid-template-columns: 52px 1fr 46px; align-items: center; gap: 10px; font-size: 11px; }
.forecast-item > span:first-child { color: var(--muted); font-weight: 600; }
.forecast-item strong { color: var(--heading); font-size: 12px; text-align: right; }
.forecast-bar { height: 7px; border-radius: 99px; background: #edf0f3; overflow: hidden; }
.forecast-bar i { display: block; height: 100%; min-width: 16%; border-radius: inherit; background: var(--blue); opacity: .75; transition: width .5s ease; }
.forecast-item.is-best .forecast-bar i { background: var(--green); }
.forecast-item.is-worst .forecast-bar i { background: var(--accent); }
.forecast-note { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--border-soft); color: var(--dim); font-size: 11px; line-height: 1.5; display: flex; gap: 8px; }
.forecast-note > span { flex: 0 0 auto; width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: var(--accent); }

.trends-card { padding: 28px 30px 30px; margin-top: 20px; }
.trends-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.chart-subtitle { margin: 5px 0 0; color: var(--dim); font-size: 12px; }
.weekday-tabs { display: flex; padding: 4px; border-radius: 10px; background: #f0f2f4; }
.weekday-tab { min-width: 47px; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; color: var(--dim); }
.weekday-tab.is-active { color: var(--blue); background: white; box-shadow: 0 1px 4px rgba(47,53,59,.1); }
.trend-content { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 38px; margin-top: 22px; }
.chart-wrap { min-width: 0; display: grid; grid-template-columns: 42px 1fr; }
.chart-y-labels { height: 222px; margin-top: 5px; display: flex; flex-direction: column; justify-content: space-between; font-size: 9px; color: #9aa1a8; }
.trend-chart { width: 100%; height: 250px; overflow: visible; }
.trend-chart .grid-line { stroke: #e8ecf0; stroke-width: 1; }
.trend-chart .axis-label { font: 10px "DM Sans", sans-serif; fill: #8a9199; stroke: none; }
.trend-chart .area { stroke: none; fill: url(#areaGradient); }
.trend-chart .trend-line { stroke: var(--blue); stroke-width: 3; fill: none; }
.trend-chart .point-halo { fill: white; stroke: var(--blue); stroke-width: 3; }
.trend-chart .point-value { font: 700 10px "DM Sans", sans-serif; fill: #2f353b; stroke: none; }
.trend-summary { border-left: 1px solid var(--border-soft); padding-left: 28px; }
.summary-highlight { display: flex; align-items: center; gap: 12px; padding-bottom: 17px; margin-bottom: 6px; border-bottom: 1px solid var(--border-soft); }
.summary-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--blue-soft); color: var(--blue); }
.summary-icon svg { width: 20px; height: 20px; }
.summary-highlight small, .summary-highlight strong { display: block; }.summary-highlight small { color: var(--dim); font-size: 9px; letter-spacing: .6px; font-weight: 700; }.summary-highlight strong { margin-top: 3px; color: var(--heading); font-family: Manrope, sans-serif; font-size: 20px; }
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; font-size: 11px; color: var(--dim); }
.summary-row strong { color: var(--heading); }.summary-row strong.positive { color: #6e9700; }
.insight { margin: 12px 0 0; padding: 12px; background: var(--accent-soft); border-radius: 10px; font-size: 10px; color: var(--muted); line-height: 1.45; }
.insight span { color: #c47a16; font-weight: 800; display: block; margin-bottom: 3px; text-transform: uppercase; font-size: 8px; letter-spacing: .7px; }

.bottom-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; margin-top: 20px; }
.pattern-card { padding: 26px 28px; }
.day-comparison { margin-top: 22px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.day-cell { min-width: 0; padding: 14px 14px 12px; border: 1px solid var(--border-soft); border-radius: 12px; }
.day-cell.is-best { background: var(--green-soft); border-color: #dcecc5; }
.day-cell-top { display: flex; justify-content: space-between; align-items: center; }
.day-cell span { font-size: 10px; color: var(--dim); font-weight: 700; }.day-cell strong { display: block; color: var(--heading); margin-top: 8px; font-family: Manrope, sans-serif; font-size: 19px; }.day-cell small { display: block; color: var(--dim); font-size: 9px; margin-top: 2px; }
.day-rank { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
.day-cell.is-best .day-rank { background: var(--green); }
.route-card { overflow: hidden; }
.route-card-top { padding: 23px 25px 18px; display: flex; align-items: center; gap: 20px; }
.route-card-top > div:last-child { min-width: 0; }
.route-card-top p:last-child { color: var(--dim); margin: 7px 0 0; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-map { width: 130px; height: 88px; flex: 0 0 130px; border-radius: 12px; overflow: hidden; background: #f0f4f5; }
.mini-map svg { width: 100%; height: 100%; }
.map-road { stroke: #d8dfe2; stroke-width: 8; }.map-road.secondary { stroke-width: 4; }.map-route-shadow { stroke: white; stroke-width: 7; }.map-route { stroke: var(--blue); stroke-width: 3; stroke-dasharray: 5 4; }.map-start { stroke: white; stroke-width: 3; fill: var(--blue); }.map-end { stroke: white; stroke-width: 3; fill: var(--magenta); }
.route-action { display: flex; justify-content: space-between; align-items: center; padding: 13px 25px; border-top: 1px solid var(--border-soft); background: #fbfcfd; color: var(--blue); text-decoration: none; font-size: 11px; font-weight: 700; }.route-action svg { width: 16px; height: 16px; }
.private-route { color: var(--dim); }

footer { max-width: 1180px; margin: 0 auto; padding: 25px 28px 34px; border-top: 1px solid var(--border-soft); color: var(--dim); font-size: 10px; display: flex; justify-content: space-between; gap: 20px; }
footer p { margin: 0; }

.info-dialog { width: min(440px, calc(100% - 32px)); border: 0; padding: 34px; border-radius: 20px; box-shadow: 0 24px 80px rgba(47,53,59,.25); color: var(--foreground); }
.info-dialog::backdrop { background: rgba(47,53,59,.35); backdrop-filter: blur(3px); }
.info-dialog h2 { font-size: 24px; margin-bottom: 12px; }.info-dialog p:not(.section-label) { font-size: 13px; line-height: 1.65; color: var(--muted); }.dialog-close { position: absolute; top: 16px; right: 16px; border: 0; background: transparent; cursor: pointer; color: var(--dim); }.dialog-close svg { width: 20px; height: 20px; }.dialog-icon { width: 44px; height: 44px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); border-radius: 13px; margin-bottom: 20px; }.dialog-icon svg { width: 28px; height: 28px; }.primary-button { width: 100%; border: 0; border-radius: 10px; padding: 11px 18px; background: var(--blue); color: white; cursor: pointer; font-weight: 700; margin-top: 8px; }

@media (max-width: 900px) {
  .dashboard-grid, .bottom-grid { grid-template-columns: 1fr; }
  .trend-content { grid-template-columns: minmax(0,1fr); }
  .trend-summary { border-left: 0; border-top: 1px solid var(--border-soft); padding: 22px 0 0; display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 0 18px; align-items: start; }
  .summary-highlight { grid-row: span 2; border-bottom: 0; padding: 0; margin: 0; }.insight { grid-column: 2 / -1; margin-top: 2px; }
}

@media (max-width: 680px) {
  .topbar { height: 64px; padding: 0 18px; }.preview-badge { display: none; }
  main { padding: 38px 16px 50px; }.intro { align-items: flex-start; }.updated { display: none; }
  .direction-switch { grid-template-columns: 1fr; max-width: none; }
  .direction-button { grid-template-columns: 32px minmax(65px,1fr) 20px 32px minmax(65px,1fr); gap: 7px; }
  .direction-button small { max-width: 115px; }
  .commute-main, .forecast-card, .trends-card, .pattern-card { padding: 23px 20px; }
  .time-readout > span { font-size: 50px; }
  .commute-footer { padding: 16px 20px; gap: 18px; flex-wrap: wrap; }.maps-link { margin-left: 0; width: 100%; padding-top: 12px; border-top: 1px solid var(--border-soft); justify-content: space-between; }
  .trends-header { display: block; }.weekday-tabs { margin-top: 18px; }.weekday-tab { flex: 1; }
  .trend-content { margin-top: 20px; gap: 10px; }.chart-wrap { grid-template-columns: 32px 1fr; }.trend-chart { min-width: 0; }
  .trend-summary { display: block; }.summary-highlight { padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border-soft); }.insight { margin-top: 10px; }
  .day-comparison { grid-template-columns: 1fr 1fr; }
  .route-card-top { padding: 20px; }.mini-map { width: 105px; flex-basis: 105px; }
  footer { padding: 24px 18px 30px; display: block; line-height: 1.5; } footer p + p { margin-top: 5px; }
}

@media (max-width: 390px) {
  h1 { font-size: 34px; }.intro-copy { font-size: 13px; }
  .direction-button { padding: 10px 8px; }.direction-button small { max-width: 88px; }
  .route-labels span { max-width: 130px; }.route-labels > div:last-child span { margin-left: auto; }
  .stat:nth-child(2) { margin-left: auto; }
  .card-heading-row { gap: 8px; }.traffic-pill { padding: 6px 8px; }
  .route-card-top { display: block; }.mini-map { width: 100%; height: 90px; margin-bottom: 17px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
