/* ============================================================
   Ready, Set, Go! — Android Version
   Material Design 3 / Material You
   Dynamic color, elevation, ripple, M3 components
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* M3 Dark scheme — tonal palette */
  --md-bg: #111318;
  --md-surface: #1b1b1f;
  --md-surface-container: #211f26;
  --md-surface-container-high: #2b2930;
  --md-surface-container-highest: #36343b;
  --md-surface-variant: #49454f;
  --md-outline: #938f99;
  --md-outline-variant: #49454f;
  --md-on-surface: #e6e1e5;
  --md-on-surface-variant: #cac4d0;
  --md-primary: #a8c7fa;
  --md-on-primary: #062e6f;
  --md-primary-container: #1b4d95;
  --md-on-primary-container: #d3e3fd;
  --md-secondary: #c2e7ff;
  --md-tertiary: #efb8c8;
  --md-error: #f2b8b5;
  --md-green: #a8dab5;
  --md-green-bright: #57e28d;
  --md-yellow: #e8d44d;
  --md-orange: #f5a623;
  --md-red: #f28b82;
  --md-red-bright: #ff6b6b;
  --md-elevation-1: 0 1px 3px 1px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.3);
  --md-elevation-2: 0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.3);
  --md-elevation-3: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);
  --md-shape-sm: 8px;
  --md-shape-md: 12px;
  --md-shape-lg: 16px;
  --md-shape-xl: 28px;
}

body {
  font-family: 'Google Sans', 'Roboto', 'Segoe UI', sans-serif;
  background: var(--md-bg);
  color: var(--md-on-surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 100px;
  overflow-x: hidden;
}

a { color: var(--md-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Material Top App Bar ---- */
.m3-top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--md-surface);
  box-shadow: var(--md-elevation-1);
}

.bar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  max-width: 500px;
  margin: 0 auto;
}

.bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-emoji { font-size: 26px; }
.bar-icon-img { width: 28px; height: 28px; border-radius: 6px; }

.bar-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0;
}

.m3-green { color: var(--md-green-bright); }

.m3-icon-btn {
  background: none;
  border: none;
  color: var(--md-on-surface-variant);
  width: 40px;
  height: 40px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.m3-icon-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  transition: opacity 0.2s;
}

.m3-icon-btn:active::after { opacity: 0.12; }

/* ---- Status Chip ---- */
.m3-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 10px auto 0;
  padding: 6px 16px;
  background: var(--md-surface-container-high);
  border-radius: 20px;
  font-size: 13px;
  color: var(--md-on-surface-variant);
}

.m3-chip.hidden { display: none; }

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--md-green-bright);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---- Home Card ---- */
.home-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 16px;
  padding: 16px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.m3-card {
  background: var(--md-surface-container);
  border-radius: var(--md-shape-lg);
  box-shadow: var(--md-elevation-1);
}

.home-icon {
  font-size: 28px;
  color: var(--md-primary);
}

.home-text { flex: 1; min-width: 0; }
.home-title { font-size: 16px; font-weight: 500; }
.home-sub { font-size: 14px; color: var(--md-on-surface-variant); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.home-card.set .home-title { font-size: 12px; color: var(--md-on-surface-variant); }
.home-card.set .home-sub { color: var(--md-green); font-weight: 500; }

.m3-filled-tonal {
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.m3-filled-tonal::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.2s;
}

.m3-filled-tonal:active::after { opacity: 0.12; }

/* ---- Main / Empty ---- */
main {
  max-width: 500px;
  margin: 0 auto;
  padding: 8px 16px;
}

.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 56px; color: var(--md-outline); margin-bottom: 16px; }
.empty-title { font-size: 22px; font-weight: 500; }
.empty-sub { font-size: 14px; color: var(--md-on-surface-variant); margin-top: 6px; }

/* ---- Appointment List ---- */
.appt-list { display: flex; flex-direction: column; gap: 12px; }

/* ---- Appointment Card ---- */
.appt-card {
  background: var(--md-surface-container);
  border-radius: var(--md-shape-lg);
  overflow: hidden;
  box-shadow: var(--md-elevation-1);
  transition: transform 0.15s, box-shadow 0.15s;
}

.appt-card:active {
  transform: scale(0.98);
  box-shadow: var(--md-elevation-2);
}

.appt-urgency-bar {
  height: 4px;
  width: 100%;
  transition: background 0.5s;
}

.appt-body { padding: 16px; }

.appt-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.appt-name { font-size: 18px; font-weight: 500; }
.appt-dest { font-size: 13px; color: var(--md-on-surface-variant); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

.appt-actions { display: flex; gap: 0; }
.appt-actions button {
  background: none;
  border: none;
  color: var(--md-on-surface-variant);
  font-size: 18px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

.appt-actions button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  transition: opacity 0.2s;
}

.appt-actions button:active::after { opacity: 0.12; }

/* Countdown */
.appt-countdown { text-align: center; padding: 20px 0 16px; }

.countdown-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--md-on-surface-variant);
  margin-bottom: 8px;
}

.countdown-time {
  font-family: 'Google Sans Mono', 'Roboto Mono', monospace;
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  transition: color 0.5s;
}

.countdown-sub {
  font-size: 14px;
  color: var(--md-on-surface-variant);
  margin-top: 8px;
}

/* Urgency */
.urgency-chill .appt-urgency-bar { background: var(--md-green-bright); }
.urgency-chill .countdown-time { color: var(--md-green-bright); }

.urgency-soon .appt-urgency-bar { background: var(--md-yellow); }
.urgency-soon .countdown-time { color: var(--md-yellow); }

.urgency-warning .appt-urgency-bar { background: var(--md-orange); }
.urgency-warning .countdown-time { color: var(--md-orange); }
.urgency-warning .appt-card { animation: md-pulse 2s ease-in-out infinite; }

.urgency-go .appt-urgency-bar { background: var(--md-red-bright); animation: flash 0.7s ease-in-out infinite; }
.urgency-go .countdown-time { color: var(--md-red-bright); animation: flash 0.7s ease-in-out infinite; }

.urgency-late .appt-urgency-bar { background: var(--md-red); }
.urgency-late .countdown-time { color: var(--md-red); opacity: 0.6; }

.urgency-past { opacity: 0.4; }
.urgency-past .appt-urgency-bar { background: var(--md-outline); }

@keyframes flash { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }
@keyframes md-pulse {
  0%,100% { box-shadow: var(--md-elevation-1); }
  50% { box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.2), var(--md-elevation-2); }
}

/* Details */
.appt-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--md-outline-variant);
}

.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; color: var(--md-on-surface-variant); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.detail-val { font-size: 15px; font-weight: 500; }

.traffic-good { color: var(--md-green-bright); }
.traffic-moderate { color: var(--md-yellow); }
.traffic-heavy { color: var(--md-red-bright); }

.provider-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.ptag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface-variant);
}

/* ---- Material FAB ---- */
.m3-fab {
  position: fixed;
  bottom: 24px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: var(--md-shape-lg);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-elevation-3);
  cursor: pointer;
  z-index: 50;
  transition: transform 0.15s, box-shadow 0.15s;
  position: fixed;
  overflow: hidden;
}

.m3-fab .material-symbols-rounded { font-size: 24px; }

.m3-fab::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-on-primary-container);
  opacity: 0;
  transition: opacity 0.2s;
}

.m3-fab:active { transform: scale(0.95); }
.m3-fab:active::after { opacity: 0.12; }

/* ---- Material Bottom Sheet ---- */
.m3-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.m3-sheet.hidden { display: none; }

.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.sheet-surface {
  position: relative;
  background: var(--md-surface-container);
  border-radius: var(--md-shape-xl) var(--md-shape-xl) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--md-elevation-3);
  animation: sheet-up 0.3s cubic-bezier(0.05, 0.7, 0.1, 1);
}

.sheet-surface-full { max-height: 92vh; }

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-drag-handle {
  display: flex;
  justify-content: center;
  padding: 12px 0 0;
}

.drag-bar {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: var(--md-outline);
  opacity: 0.4;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 24px;
}

.sheet-title {
  font-size: 18px;
  font-weight: 500;
}

.sheet-body { padding: 0 24px 24px; }

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ---- Material Form Fields ---- */
.m3-field {
  position: relative;
  margin-bottom: 18px;
}

.m3-input {
  width: 100%;
  padding: 16px 14px 8px;
  background: var(--md-surface-container-highest);
  border: none;
  border-bottom: 2px solid var(--md-outline);
  border-radius: var(--md-shape-sm) var(--md-shape-sm) 0 0;
  color: var(--md-on-surface);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.m3-input:focus { border-bottom-color: var(--md-primary); }

.m3-float-label {
  position: absolute;
  left: 14px;
  top: 14px;
  font-size: 16px;
  color: var(--md-on-surface-variant);
  pointer-events: none;
  transition: all 0.2s;
}

.m3-input:focus + .m3-float-label,
.m3-input:not(:placeholder-shown) + .m3-float-label,
.m3-float-up {
  top: 4px;
  font-size: 11px;
  color: var(--md-primary);
}

.m3-input-sm {
  padding: 12px 14px 6px;
  font-size: 14px;
}

.m3-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.m3-field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Chip group */
.m3-chip-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.m3-filter-chip {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--md-outline);
  border-radius: 20px;
  color: var(--md-on-surface);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.m3-filter-chip::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.2s;
}

.m3-filter-chip:active::after { opacity: 0.12; }

.m3-filter-chip.selected {
  background: var(--md-primary-container);
  border-color: transparent;
  color: var(--md-on-primary-container);
}

/* Results */
.m3-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--md-surface-container-highest);
  border-radius: var(--md-shape-md);
  max-height: 180px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--md-elevation-2);
}

.m3-results.hidden { display: none; }

.result-item {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--md-outline-variant);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.result-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-on-surface);
  opacity: 0;
  transition: opacity 0.15s;
}

.result-item:active::after { opacity: 0.08; }
.result-item:last-child { border-bottom: none; }

.m3-selected {
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(87, 226, 141, 0.1);
  border-radius: var(--md-shape-sm);
  font-size: 13px;
  color: var(--md-green);
  border-left: 3px solid var(--md-green-bright);
}

.m3-selected.hidden { display: none; }

/* Buttons */
.m3-filled-btn {
  background: var(--md-primary);
  color: var(--md-on-primary);
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.m3-filled-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-on-primary);
  opacity: 0;
  transition: opacity 0.2s;
}

.m3-filled-btn:active::after { opacity: 0.12; }

.m3-text-btn {
  background: none;
  border: none;
  color: var(--md-primary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.m3-text-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-primary);
  opacity: 0;
  transition: opacity 0.2s;
}

.m3-text-btn:active::after { opacity: 0.08; }

/* Settings specific */
.m3-section-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--md-primary);
  margin: 20px 0 8px;
}

.m3-section-label:first-child { margin-top: 0; }

.m3-hint {
  font-size: 13px;
  color: var(--md-on-surface-variant);
  margin-bottom: 10px;
}

.m3-api-card {
  background: var(--md-surface-container-high);
  border-radius: var(--md-shape-md);
  padding: 14px;
  margin-bottom: 8px;
}

.api-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}

.api-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.api-link {
  margin-left: auto;
  font-size: 12px;
}

.m3-badge-on {
  margin-left: auto;
  background: rgba(87, 226, 141, 0.12);
  color: var(--md-green-bright);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.osrm-card {
  border: 1px dashed var(--md-outline-variant);
  background: transparent;
}

.osrm-note {
  font-size: 13px;
  color: var(--md-on-surface-variant);
}

/* Material Switch */
.m3-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--md-surface-container-high);
  border-radius: var(--md-shape-md);
  margin-bottom: 4px;
}

.switch-label { font-size: 15px; font-weight: 500; }
.switch-sub { font-size: 13px; color: var(--md-on-surface-variant); margin-top: 2px; }

.m3-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
}

.m3-switch input { opacity: 0; width: 0; height: 0; }

.track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--md-surface-variant);
  border: 2px solid var(--md-outline);
  border-radius: 16px;
  transition: 0.3s;
}

.thumb {
  position: absolute;
  height: 16px;
  width: 16px;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--md-outline);
  border-radius: 50%;
  transition: 0.3s;
}

.m3-switch input:checked + .track {
  background: var(--md-primary);
  border-color: var(--md-primary);
}

.m3-switch input:checked + .track .thumb {
  transform: translateY(-50%) translateX(20px);
  background: var(--md-on-primary);
  width: 24px;
  height: 24px;
  left: 2px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--md-surface-variant); border-radius: 2px; }

/* ---- Favourites ---- */
.fav-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.fav-bar:empty { display: none; }

.fav-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: var(--md-surface-container-highest);
  border: 1px solid var(--md-outline-variant);
  border-radius: 20px;
  font-size: 13px;
  color: var(--md-on-surface);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.fav-chip::after { content:''; position:absolute; inset:0; background:var(--md-primary); opacity:0; transition: opacity 0.2s; }
.fav-chip:active::after { opacity: 0.12; }
.fav-chip:active { border-color: var(--md-primary); }

.fav-chip .fav-emoji { font-size: 14px; }

.fav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--md-surface-container-high);
  border-radius: var(--md-shape-md);
  margin-bottom: 6px;
}

.fav-item .fav-emoji { font-size: 20px; flex-shrink: 0; }
.fav-item .fav-info { flex: 1; min-width: 0; }
.fav-item .fav-name { font-size: 14px; font-weight: 500; }
.fav-item .fav-addr { font-size: 12px; color: var(--md-on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fav-item .fav-del {
  background: none;
  border: none;
  color: var(--md-error);
  font-size: 16px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 20px;
}

.fav-item .fav-del:active { background: rgba(242,184,181,0.12); }

.fav-icon-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.fav-icon-opt {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: var(--md-shape-md);
  background: var(--md-surface-container-highest);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.fav-icon-opt.selected { border-color: var(--md-primary); background: rgba(168,199,250,0.12); }
.fav-icon-opt:active { transform: scale(0.9); }

/* ---- Day Header & Timeline ---- */
.day-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 0 6px;
}

.day-header:first-child { padding-top: 4px; }

.day-label {
  font-size: 20px;
  font-weight: 500;
}

.day-stats {
  font-size: 12px;
  color: var(--md-on-surface-variant);
}

.timeline-origin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 0 4px;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.home-dot { background: var(--md-green-bright); box-shadow: 0 0 6px rgba(87, 226, 141, 0.4); }

.timeline-origin-label {
  font-size: 13px;
  color: var(--md-on-surface-variant);
}

.timeline-connector {
  display: flex;
  justify-content: flex-start;
  padding-left: 8px;
}

.timeline-line {
  width: 2px;
  height: 12px;
  background: var(--md-outline-variant);
  border-radius: 1px;
}

.appt-route {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.m3-auto-hint {
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(168, 199, 250, 0.08);
  border-left: 3px solid var(--md-primary);
  border-radius: var(--md-shape-sm);
  font-size: 12px;
  color: var(--md-primary);
}

.m3-auto-hint.hidden { display: none; }

.hidden { display: none !important; }
