:root {
  /* Stanford identity palette — identity.stanford.edu/design-elements/color */
  --stanford-cardinal: #8c1515;        /* Cardinal Red */
  --stanford-cardinal-dark: #820000;   /* Cardinal Dark */
  --stanford-cardinal-bright: #b1040e; /* Cardinal Bright */
  --stanford-white: #ffffff;
  --stanford-black: #2e2d29;           /* Process Black */
  --stanford-cool-grey: #53565a;
  --stanford-fog: #f4f4f4;
  --stanford-light-sandstone: #f9f6ef;
  --stanford-sandstone: #d2c295;
  --stanford-stone: #7f7776;
  --stanford-palo-alto: #175e54;       /* accent: green */
  --stanford-poppy: #e98300;           /* accent: orange */
  --stanford-sky: #4298b5;             /* accent: blue */
  --stanford-illuminating: #fedd5c;    /* accent: yellow */

  --cardinal: var(--stanford-cardinal);
  --cardinal-dark: var(--stanford-cardinal-dark);
  --cardinal-soft: #f6eaea;
  --accent: var(--stanford-cardinal);
  --bg: var(--stanford-light-sandstone);
  --surface: var(--stanford-white);
  --surface-2: var(--stanford-fog);
  --text: var(--stanford-black);
  --muted: var(--stanford-cool-grey);
  --border: #e3ddd0;
  --success: var(--stanford-palo-alto);
  --success-soft: #e3efec;
  --gold: #a35c00;
  --gold-soft: #fdf0dc;
  --mine: var(--stanford-poppy);
  --shadow: 0 1px 2px rgba(46, 45, 41, 0.06), 0 6px 20px rgba(46, 45, 41, 0.06);
  --radius: 14px;
  --font: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --accent: #e86a6a;
    --cardinal-soft: #3a1f1f;
    --bg: #1c1b19;
    --surface: #2e2d29;
    --surface-2: #3a3935;
    --text: #f4f4f4;
    --muted: #b6b1a9;
    --border: #4a4843;
    --success: #6fbfae;
    --success-soft: #1d3330;
    --gold: #f5a93a;
    --gold-soft: #3d2c14;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.site-header {
  background: var(--stanford-cardinal);
  border-top: 6px solid var(--stanford-cardinal-dark);
  color: #fff;
  padding: 28px 16px 72px;
  position: relative;
  overflow: hidden;
}
.site-header::after {
  content: '';
  position: absolute;
  inset: auto -10% -60px -10%;
  height: 120px;
  background: var(--bg);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.header-inner { max-width: 1160px; margin: 0 auto; position: relative; z-index: 1; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.logo {
  width: 46px; height: 46px; border-radius: 12px; background: rgba(255, 255, 255, 0.14);
  display: grid; place-items: center; cursor: pointer; border: 0; padding: 0; color: #fff;
  transition: transform 0.15s;
}
.logo:active { transform: scale(0.92); }
.brand h1 { margin: 0; font-family: var(--font-serif); font-size: 1.7rem; font-weight: 700; letter-spacing: -0.01em; }
.brand small { display: block; font-size: 0.85rem; opacity: 0.8; font-weight: 400; letter-spacing: 0.04em; text-transform: uppercase; }
.tagline { margin: 18px 0 0; font-size: 1.15rem; max-width: 620px; opacity: 0.92; }
.header-actions { display: flex; gap: 8px; }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1160px; margin: -48px auto 0; padding: 0 16px 48px; position: relative; z-index: 2; }
.layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card h2 { margin: 0 0 14px; font-family: var(--font-serif); font-size: 1.35rem; }
.card h2 + .sub { margin-top: -10px; }
.card .sub { margin: 0 0 18px; color: var(--muted); font-size: 0.95rem; }
.sticky { position: sticky; top: 16px; }
@media (max-width: 900px) { .sticky { position: static; } }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.field .hint { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row-2 { grid-template-columns: 1fr; } }

input[type='text'], input[type='email'], input[type='tel'], input[type='time'], input[type='url'],
input[type='password'], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
input[aria-invalid='true'] { border-color: var(--accent); }

.date-wrap { position: relative; }
.date-wrap input[type='text'] { padding-right: 44px; }
.date-wrap .cal-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px;
  color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.date-wrap .cal-btn:hover { background: var(--border); color: var(--text); }
.date-wrap input[type='date'] { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented label { flex: 1 1 auto; position: relative; min-width: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.segmented span {
  display: flex; align-items: center; justify-content: center; text-align: center; gap: 6px;
  padding: 8px 8px; min-height: 38px; border-radius: 8px; font-weight: 600; font-size: 0.92rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--muted); transition: background 0.15s, color 0.15s; line-height: 1.2;
}
.segmented input:checked + span { background: var(--cardinal); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 44px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; cursor: pointer; text-decoration: none; transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--cardinal); color: #fff; }
.btn-primary:hover { background: var(--cardinal-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-light { background: rgba(255, 255, 255, 0.15); color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.btn-light:hover { background: rgba(255, 255, 255, 0.25); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 0.88rem; }
.btn-block { width: 100%; }
.btn-danger { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-danger:hover { background: var(--cardinal-soft); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; }

.form-error { color: var(--accent); font-size: 0.9rem; min-height: 1.2em; margin: 6px 0 0; }
.editing-banner {
  display: none; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--gold-soft); color: var(--gold); border-radius: 10px; padding: 8px 12px;
  font-weight: 600; font-size: 0.9rem; margin-bottom: 14px;
}
.editing .editing-banner { display: flex; }

.label-note { font-weight: 400; color: var(--muted); }
.check-options { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.check-option {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  font-weight: 600; font-size: 0.95rem; min-width: 0; transition: border-color 0.15s, background 0.15s;
}
.check-option input { width: 20px; height: 20px; margin: 0; flex-shrink: 0; accent-color: var(--cardinal); cursor: pointer; }
.check-option:has(input:checked) { border-color: var(--cardinal); background: var(--cardinal-soft); }
.check-option:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.check-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.trip { border: 1px solid var(--border); border-left: 4px solid var(--cardinal); border-radius: 10px; padding: 12px 14px 2px; margin: 0 0 14px; min-width: 0; }
.trip legend { font-weight: 700; font-size: 0.92rem; padding: 0 6px; margin-left: -6px; color: var(--accent); }
#trip-from { border-left-color: var(--stanford-palo-alto); }
#trip-from legend { color: var(--success); }
.segmented label:has(input:disabled) { opacity: 0.45; }

/* ---------- notify me ---------- */
.notify-box { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 12px; margin-bottom: 16px; }
.flex-box { margin-bottom: 14px; padding: 10px 12px; }
.flex-box .label { display: block; font-weight: 600; font-size: 0.9rem; }
.flex-pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.flex-pair { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; min-width: 0; }
.flex-pair select { flex: 1; min-width: 0; min-height: 38px; padding: 6px 8px; }
.ride-overlap { color: var(--success); font-weight: 600; font-size: 0.88rem; }
.notify-window { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-size: 0.92rem; flex-wrap: wrap; }
.notify-window select { width: auto; min-height: 38px; padding: 6px 10px; }
.notify-hint { margin: 8px 0 0; font-size: 0.82rem; color: var(--muted); }

/* ---------- your matches ---------- */
.matches-card { margin-bottom: 24px; border-top: 4px solid var(--cardinal); }
.matches-head h2 { margin-bottom: 4px; }
.matches-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.match-trip { margin-top: 18px; }
.match-trip-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px;
}
.match-trip-head strong { font-size: 1rem; }
.match-trip-head .count { font-size: 0.88rem; }
.match-none { color: var(--muted); font-size: 0.92rem; padding: 4px 4px 0; }

/* ---------- filters ---------- */
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin-bottom: 4px; }
.filters .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .filters { grid-template-columns: 1fr; } }
.filter-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.count { color: var(--muted); font-size: 0.92rem; }

.range { position: relative; height: 36px; }
.range input[type='range'] {
  position: absolute; left: 0; right: 0; top: 8px; width: 100%; margin: 0; background: none;
  pointer-events: none; -webkit-appearance: none; appearance: none; height: 20px;
}
.range input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--cardinal); cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.range input[type='range']::-moz-range-thumb {
  pointer-events: auto; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--cardinal); cursor: grab;
}
.range input[type='range']:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
.range-track { position: absolute; left: 0; right: 0; top: 16px; height: 4px; border-radius: 4px; background: var(--border); }
.range-fill { position: absolute; top: 16px; height: 4px; border-radius: 4px; background: var(--cardinal); }
.range-label { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.range-ticks { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }

/* ---------- ride list ---------- */
.day-group { margin-top: 22px; }
.day-group h3 {
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  margin: 0 0 10px; display: flex; align-items: center; gap: 10px;
}
.day-group h3::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.rides { display: grid; gap: 10px; }
.ride {
  display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ride:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.ride.mine { border-color: var(--mine); box-shadow: inset 4px 0 0 var(--mine); }
.ride.shuttle { background: var(--cardinal-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.ride.highlight { animation: pulse 1.6s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.ride-time { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.ride-time small { display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.ride-main { min-width: 0; }
.ride-name { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ride-meta { color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.ride-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) {
  .ride { grid-template-columns: 70px minmax(0, 1fr); }
  .ride-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.badge-shuttle { background: var(--cardinal); color: #fff; border-color: var(--cardinal); }
.badge-mine { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.badge-match { background: var(--success-soft); color: var(--success); border-color: transparent; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { color: var(--border); margin-bottom: 8px; }
.demo-note {
  background: var(--gold-soft); color: var(--gold); border-radius: 10px; padding: 10px 14px;
  font-size: 0.9rem; margin-bottom: 16px;
}
.loading { text-align: center; padding: 32px; color: var(--muted); }

/* ---------- modal / share ---------- */
dialog {
  border: 0; border-radius: var(--radius); padding: 0; max-width: 420px; width: calc(100% - 32px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(20, 10, 10, 0.5); }
.dialog-body { padding: 22px; }
.dialog-body h2 { margin: 0 0 4px; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.share-grid .btn { flex-direction: column; gap: 4px; min-height: 76px; }
.share-link { display: flex; gap: 8px; }
.share-link input { flex: 1; font-size: 0.88rem; }
.dialog-close { position: absolute; top: 10px; right: 10px; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: max-content; max-width: calc(100% - 32px); }
.toast {
  background: #2e2d29; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-weight: 600; animation: toast-in 0.25s ease-out;
}
.toast.error { background: var(--cardinal); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 24px 16px; text-align: center; color: var(--muted); font-size: 0.92rem; }
.site-footer a { font-weight: 600; }
.site-footer .dot { margin: 0 8px; opacity: 0.5; }

/* ---------- admin ---------- */
.admin-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: minmax(0, 1fr); } }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.85rem; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle:last-child { border-bottom: 0; }
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background 0.2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(20px); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
tr.past td { opacity: 0.5; }
.login-card { max-width: 400px; margin: 0 auto; }
.section-gap { margin-top: 24px; }

/* ---------- easter eggs ---------- */
.falling { position: fixed; top: -40px; z-index: 200; pointer-events: none; font-size: 28px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
.drive-by { position: fixed; bottom: 40px; left: -120px; z-index: 200; font-size: 64px; pointer-events: none; animation: drive 2.4s ease-in forwards; }
@keyframes drive { to { transform: translateX(calc(100vw + 240px)); } }
.shake { animation: shake 0.5s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
.flip { transition: transform 1s; transform: rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
