:root {
  --bg: #F2F7FF;
  --card: #FFFFFF;
  --ink: #2D3A4A;
  --muted: #7A8AA0;
  --primary: #FF7A59;
  --primary-dark: #F0603C;
  --sky: #3BAFDA;
  --green: #27AE60;
  --red: #E74C3C;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(45, 58, 74, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #E4F1FF 0%, var(--bg) 220px, var(--bg) 100%);
  color: var(--ink);
  font-family: 'Varela Round', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Intro */
.intro {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(160deg, #E4F1FF, #FFF4E8);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; animation: introOut 0.5s ease 1.5s forwards;
}
@keyframes introOut { to { opacity: 0; visibility: hidden; } }
.car-bob { animation: bob 1.2s ease-in-out infinite; transform-origin: center; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.cal-float { animation: bob 1.2s ease-in-out 0.25s infinite; transform-origin: center; }
.intro-car { animation: driveIn 0.7s cubic-bezier(.2,.9,.3,1.2); }
@keyframes driveIn { from { transform: translateX(120px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.wordmark { font-size: 44px; font-weight: 700; letter-spacing: 0.5px; }
.wordmark.small { font-size: 34px; margin: 0 0 4px; }
.wordmark.tiny-mark { font-size: 22px; }
.w1 { color: var(--ink); }
.w2 { color: var(--primary); }

/* Gate */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.gate-card { width: 100%; max-width: 400px; padding: 28px 24px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.who-title { margin: 4px 0 10px; font-size: 26px; }

.muted { color: var(--muted); margin: 0; }
.tiny { font-size: 13px; }

.field-label { font-size: 14px; color: var(--muted); text-align: right; margin-top: 6px; }
.input {
  width: 100%; padding: 13px 14px; font-size: 17px; font-family: inherit;
  border: 2px solid #E1E9F5; border-radius: 13px; background: #FAFCFF; color: var(--ink);
  outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: var(--sky); }

.btn {
  border: none; border-radius: 14px; padding: 13px 18px; font-size: 17px; font-family: inherit;
  cursor: pointer; transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(255, 122, 89, 0.4); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.big { width: 100%; margin-top: 8px; font-size: 19px; padding: 15px; }
.btn.ghost { background: transparent; color: var(--sky); border: 2px dashed #BBDDF0; }
.btn.ghost:hover { background: #F0F9FF; }

.error { color: var(--red); font-size: 14px; margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 8px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 2px solid #E1E9F5; background: #fff; border-radius: 999px;
  padding: 10px 18px; font-size: 17px; font-family: inherit; cursor: pointer;
  transition: all 0.15s;
}
.chip .dot { width: 14px; height: 14px; border-radius: 50%; }
.chip.selected { border-color: var(--ink); background: #F4F9FF; font-weight: 700; }
.add-member { display: flex; gap: 8px; }
.add-member .input { flex: 1; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(255,255,255,0.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid #E8F0FA;
}
.brand { display: flex; align-items: center; gap: 8px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  border: none; background: #EEF5FD; color: var(--ink); border-radius: 12px;
  width: 40px; height: 40px; font-size: 20px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.icon-btn:hover { background: #E0EEFB; }
.me-chip {
  border: none; border-radius: 999px; padding: 8px 14px; font-family: inherit; font-size: 15px;
  color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}

/* Hero */
.hero { padding: 18px 20px 4px; }
.greeting { font-size: 24px; font-weight: 700; }
.car-status { margin-top: 6px; font-size: 15px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.car-status .pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 12px; font-size: 14px;
}
.pill.free { background: #E4F8EC; color: #1B7A43; }
.pill.busy { background: #FDECEA; color: #B03A2E; }

/* Week nav */
.week-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.week-title { font-size: 17px; font-weight: 700; }

/* Days */
.days { display: flex; flex-direction: column; gap: 12px; padding: 4px 16px 120px; }
.day {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; border: 2px solid transparent;
}
.day.today { border-color: var(--sky); }
.day.past { opacity: 0.72; }
.day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.day-name { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.today-pill { background: var(--sky); color: #fff; font-size: 12px; border-radius: 999px; padding: 3px 10px; }
.day-date { color: var(--muted); font-size: 14px; }
.empty-day { color: #1B7A43; font-size: 14px; background: #F0FBF4; border-radius: 10px; padding: 8px 12px; }

.booking {
  display: flex; align-items: center; gap: 10px; border-radius: 13px; padding: 10px 12px; margin-top: 8px;
  animation: popIn 0.25s ease;
}
@keyframes popIn { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.booking .time { font-weight: 700; font-size: 15px; white-space: nowrap; }
.booking .who { font-size: 15px; font-weight: 700; }
.booking .note { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.booking .cancel {
  border: none; background: rgba(255,255,255,0.7); color: var(--red); border-radius: 9px;
  font-size: 12px; padding: 5px 9px; cursor: pointer; font-family: inherit; white-space: nowrap;
}

/* FAB */
.fab {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--primary); color: #fff; border: none; border-radius: 999px;
  padding: 16px 34px; font-size: 19px; font-family: inherit; cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 122, 89, 0.5);
  transition: transform 0.12s, background 0.15s;
}
.fab:hover { background: var(--primary-dark); }
.fab:active { transform: translateX(-50%) scale(0.95); }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 90px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(45,58,74,0.35);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; border-radius: 22px 22px 0 0; width: 100%; max-width: 480px;
  padding: 20px 22px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px;
  animation: slideUp 0.28s cubic-bezier(.2,.9,.3,1.1);
  max-height: 92vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { margin: 0; font-size: 22px; }
.time-row { display: flex; gap: 10px; }
.time-row > div { flex: 1; }

/* Toast */
.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 12px 22px; font-size: 15px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25); animation: popIn 0.25s ease; max-width: 88vw; text-align: center;
}

.confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; }

@media (min-width: 760px) {
  .days { display: grid; grid-template-columns: repeat(2, 1fr); align-items: start; }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 22px; }
}

.gate { flex-direction: column; gap: 14px; }
.gate-footer { padding: 0; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 4px 0; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: #E3D9CC; }
.new-fam, .fam-done { display: flex; flex-direction: column; gap: 10px; }
.fam-code { font-size: 38px; font-weight: 800; letter-spacing: 6px; color: var(--primary-dark); background: #FFF4E8; border-radius: 16px; padding: 10px; direction: ltr; }
.footer { direction: ltr; unicode-bidi: isolate; }
