/* ============================================================
   Ready, Set, Go! — iOS Version
   Apple HIG Design Language
   SF Pro-inspired, frosted glass, native iOS feel
   ============================================================ */

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

:root {
  --bg: #000000;
  --bg-primary: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --bg-tertiary: #3a3a3c;
  --bg-grouped: #1c1c1e;
  --separator: rgba(84, 84, 88, 0.65);
  --label: #ffffff;
  --label2: #ebebf5cc;
  --label3: #ebebf54d;
  --label4: #ebebf52e;
  --blue: #0a84ff;
  --green: #30d158;
  --yellow: #ffd60a;
  --orange: #ff9f0a;
  --red: #ff453a;
  --teal: #64d2ff;
  --purple: #bf5af2;
  --pink: #ff375f;
  --grey: #8e8e93;
  --fill: rgba(120, 120, 128, 0.36);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

body {
  font-family: -apple-system, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--label);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(100px + var(--safe-bottom));
  overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }

/* ---- iOS Nav Bar ---- */
.ios-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  padding-top: var(--safe-top);
}

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

.nav-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-icon { font-size: 24px; }
.nav-icon-img { width: 28px; height: 28px; border-radius: 6px; }
.green { color: var(--green); }

.nav-btn {
  background: none;
  border: none;
  color: var(--blue);
  padding: 8px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:active { opacity: 0.5; }

/* ---- Status Pill ---- */
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  margin: 10px auto 0;
  width: fit-content;
  background: var(--bg-secondary);
  border-radius: 20px;
  font-size: 12px;
  color: var(--label2);
}

.status-pill.hidden { display: none; }

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  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: 12px;
  margin: 12px 16px;
  padding: 14px 16px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.home-card.set .card-title { color: var(--label); font-weight: 400; font-size: 13px; }
.home-card.set .card-subtitle { color: var(--green); font-weight: 600; }

.ios-card {
  background: var(--bg-primary);
  border-radius: 14px;
  overflow: hidden;
}

.card-icon { font-size: 28px; flex-shrink: 0; }
.card-text { flex: 1; min-width: 0; }
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--label3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ios-btn-pill {
  background: var(--blue);
  color: white;
  border: none;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.ios-btn-pill:active { opacity: 0.7; }

/* ---- 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; margin-bottom: 12px; }
.empty-title { font-size: 22px; font-weight: 700; }
.empty-sub { font-size: 15px; color: var(--label3); margin-top: 6px; }

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

/* ---- Appointment Card ---- */
.appt-card {
  background: var(--bg-primary);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.2s;
}

.appt-card:active { transform: scale(0.98); }

.appt-urgency-bar {
  height: 3px;
  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: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.appt-dest {
  font-size: 13px;
  color: var(--label3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.appt-actions {
  display: flex;
  gap: 2px;
}

.appt-actions button {
  background: none;
  border: none;
  color: var(--label3);
  font-size: 18px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.appt-actions button:active { background: var(--fill); }

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

.countdown-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--label3);
  margin-bottom: 8px;
}

.countdown-time {
  font-size: 52px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  line-height: 1;
  transition: color 0.5s;
}

.countdown-sub {
  font-size: 14px;
  color: var(--label3);
  margin-top: 8px;
}

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

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

.urgency-warning .appt-urgency-bar { background: var(--orange); }
.urgency-warning .countdown-time { color: var(--orange); }

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

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

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

@keyframes flash { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }

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

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

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

.provider-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.ptag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--label3);
}

/* ---- iOS FAB ---- */
.ios-fab {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(10, 132, 255, 0.4);
  cursor: pointer;
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s;
}

.ios-fab:active { transform: scale(0.9); }

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

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

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.sheet-panel {
  position: relative;
  background: var(--bg-secondary);
  border-radius: 14px 14px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--safe-bottom);
  animation: sheet-up 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet-panel-tall { max-height: 92vh; }

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

.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--fill);
  margin: 8px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 12px;
  border-bottom: 0.5px solid var(--separator);
}

.sheet-title {
  font-size: 17px;
  font-weight: 600;
}

.sheet-cancel, .sheet-done {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 17px;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 4px;
  -webkit-tap-highlight-color: transparent;
}

.sheet-cancel:active, .sheet-done:active { opacity: 0.5; }
.sheet-done { font-weight: 600; }

.sheet-body { padding: 16px; }

/* ---- iOS Form Elements ---- */
.ios-field-group { margin-bottom: 18px; position: relative; }

.ios-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--label2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ios-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 10px;
  color: var(--label);
  font-size: 17px;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: box-shadow 0.2s;
}

.ios-input:focus {
  box-shadow: 0 0 0 2px var(--blue);
}

.ios-input-sm {
  font-size: 14px;
  padding: 10px 12px;
}

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

/* Segment control */
.ios-segment {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--label2);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn.active {
  background: var(--bg-primary);
  color: var(--label);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Search Results */
.ios-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-tertiary);
  border-radius: 10px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

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

.result-item {
  padding: 12px 14px;
  font-size: 14px;
  border-bottom: 0.5px solid var(--separator);
  cursor: pointer;
  color: var(--label2);
  -webkit-tap-highlight-color: transparent;
}

.result-item:active { background: var(--fill); }
.result-item:last-child { border-bottom: none; }

.ios-selected {
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(48, 209, 88, 0.12);
  border-radius: 10px;
  font-size: 13px;
  color: var(--green);
}

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

.ios-btn-text {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 0;
  margin-top: 6px;
  -webkit-tap-highlight-color: transparent;
}

.ios-btn-text:active { opacity: 0.5; }

/* Settings specific */
.ios-section-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--label3);
  margin: 20px 0 8px;
}

.ios-section-header:first-child { margin-top: 0; }

.ios-hint {
  font-size: 13px;
  color: var(--label3);
  margin-bottom: 10px;
}

.ios-api-row {
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}

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

.api-info a { font-size: 12px; }
.api-info strong { font-size: 15px; }

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

.green-dot { background: var(--green); }
.blue-dot { background: var(--blue); }
.red-dot { background: var(--red); }
.grey-dot { background: var(--grey); }

.ios-badge-active {
  background: rgba(48, 209, 88, 0.15);
  color: var(--green);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.osrm-row {
  border: 1px dashed var(--separator);
  background: transparent;
}

.osrm-row .api-info { margin-bottom: 0; }

/* iOS Toggle */
.ios-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  margin-bottom: 4px;
  font-size: 15px;
}

.ios-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--fill);
  border-radius: 31px;
  transition: 0.3s;
}

.slider::before {
  content: '';
  position: absolute;
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.ios-switch input:checked + .slider { background: var(--green); }
.ios-switch input:checked + .slider::before { transform: translateX(20px); }

/* Scrollbar — thin & subtle */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fill); 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 12px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 13px;
  color: var(--label2);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.fav-chip:active { background: var(--blue); color: white; border-color: var(--blue); }

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

/* Fav list in settings */
.fav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  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: 600; }
.fav-item .fav-addr { font-size: 11px; color: var(--label3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fav-item .fav-del {
  background: none;
  border: none;
  color: var(--red);
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.fav-item .fav-del:active { background: rgba(255,69,58,0.15); }

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

.fav-icon-opt {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.fav-icon-opt.selected { border-color: var(--blue); background: rgba(10,132,255,0.15); }
.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: 700;
  letter-spacing: -0.3px;
}

.day-stats {
  font-size: 12px;
  color: var(--label3);
}

.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(--green); box-shadow: 0 0 6px rgba(48, 209, 88, 0.5); }

.timeline-origin-label {
  font-size: 13px;
  color: var(--label2);
}

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

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

/* Route label on card */
.appt-route {
  font-size: 12px;
  color: var(--label3);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Auto-hint in form */
.ios-auto-hint {
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(10, 132, 255, 0.1);
  border-radius: 8px;
  font-size: 12px;
  color: var(--blue);
}

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

/* search wrapper for origin */
.search-wrapper { position: relative; }

.hidden { display: none !important; }

/* ---- Desktop centering ---- */
@media (min-width: 600px) {
  .home-card { margin-left: auto; margin-right: auto; }
}
