/* CampusCar Web App — Phase 1 styling
   Brand-Variablen sind aus ../styles.css übernommen damit App und Marketing-Site
   konsistent wirken. */

:root {
  --bg: #f6f8fb;
  --ink: #141414;
  --muted: #5f666f;
  --line: #d9dfe7;
  --surface: #ffffff;
  --chrome: rgba(255, 255, 255, 0.92);
  --primary: #0f8f63;
  --primary-ink: #0a6649;
  --primary-soft: #d9efe4;
  --accent: #e84d35;
  --yellow: #f2c94c;
  --danger: #c0392b;
  --radius-sm: 0.45rem;
  --radius-md: 0.55rem;
  --radius-lg: 0.5rem;
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.06);
  --shadow-md: 0 12px 32px -16px rgba(20, 20, 20, 0.18);
  --header-h: 56px;
  --bottom-h: calc(64px + env(safe-area-inset-bottom));
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101412;
  --ink: #eef4f0;
  --muted: #a5b2aa;
  --line: #26332d;
  --surface: #171d1a;
  --chrome: rgba(16, 20, 18, 0.92);
  --primary: #49bd88;
  --primary-ink: #94e5bd;
  --primary-soft: rgba(73, 189, 136, 0.18);
  --accent: #ff806d;
  --yellow: #d6a93d;
  --danger: #ef6253;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 18px 42px -18px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body { min-height: 100svh; }

img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }

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

h1, h2, h3 { margin: 0; font-family: "Fraunces", serif; line-height: 1.1; letter-spacing: -0.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; font-family: "Space Grotesk", sans-serif; font-weight: 600; }
p { margin: 0; line-height: 1.55; }

/* ---------- Boot screen ---------- */
.boot-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center; gap: 0.6rem;
  background: var(--bg); z-index: 100;
  font-family: "Fraunces", serif; font-size: 1.4rem; color: var(--primary-ink);
  transition: opacity 200ms ease;
}
.boot-screen[hidden] { display: none; }
.boot-screen.fade-out { opacity: 0; pointer-events: none; }

/* ---------- App bar ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; height: var(--header-h);
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  padding-top: env(safe-area-inset-top);
}
.app-bar__brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--ink); text-decoration: none; font-weight: 700;
}
.app-bar__brand:hover { text-decoration: none; }
.app-bar__actions { display: inline-flex; gap: 0.4rem; }
.app-bar__actions button {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 0.4rem 0.6rem; border-radius: var(--radius-sm);
}
.app-bar__actions button:hover { background: var(--bg); color: var(--ink); }

.app-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.app-controls--compact {
  justify-content: flex-end;
}
.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 0.15rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.segmented__button {
  min-width: 2.25rem;
  min-height: 1.85rem;
  padding: 0;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
}
.segmented__button.is-active {
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.icon-btn {
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover,
.segmented__button:hover {
  color: var(--ink);
}
.cc-icon {
  display: block;
  flex: 0 0 auto;
}

/* ---------- Outlet ---------- */
.app-outlet {
  width: calc(100% - 2rem);
  max-width: 540px;
  margin: 1.25rem auto;
  padding-bottom: calc(var(--bottom-h) + 1.5rem);
}
body.no-bottom-nav .app-outlet { padding-bottom: 1.5rem; }
body.full-bleed .app-outlet { width: 100%; margin: 0; padding: 0; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--chrome);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(12px);
}
.bottom-nav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.2rem; padding: 0.55rem 0; min-height: 64px;
  color: var(--muted); text-decoration: none; font-size: 0.7rem; font-weight: 600;
}
.bottom-nav__item:hover { text-decoration: none; }
.bottom-nav__item[aria-current="true"] { color: var(--primary-ink); }
.bottom-nav__icon {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.35rem;
}

/* ---------- Cards / Panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1rem; }
.card__title { margin-bottom: 0.4rem; }
.card__lead { color: var(--muted); margin-bottom: 1.2rem; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field > label {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--muted);
}
.field > input,
.field > textarea,
.field > select {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field > input:focus,
.field > textarea:focus,
.field > select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field--error > input,
.field--error > textarea { border-color: var(--danger); }
.field__hint { font-size: 0.78rem; color: var(--muted); }
.field__error { font-size: 0.8rem; color: var(--danger); }

.form-actions { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.4rem; }
.form-row { display: flex; gap: 0.6rem; align-items: center; justify-content: space-between; }
.form-link { font-size: 0.9rem; color: var(--muted); text-align: center; }
.form-link a { color: var(--primary-ink); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; -webkit-appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
  font-size: 1rem; font-weight: 600;
  cursor: pointer; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  transition: transform 80ms ease, background 120ms ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: white; }
.btn--primary:hover:not([disabled]) { background: var(--primary-ink); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover:not([disabled]) { background: var(--surface); }
.btn--danger { background: var(--danger); color: white; }
.btn--block { width: 100%; }

/* ---------- Auth-Layout ---------- */
.auth-screen {
  min-height: calc(100svh - var(--header-h));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.2rem 0;
  width: 100%;
}
.auth-card {
  width: calc(100% - 5rem);
  max-width: 100%;
  margin-inline: auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.8rem 1.5rem 1.5rem;
  box-shadow: var(--shadow-md);
}
.auth-card__title { margin-bottom: 0.3rem; font-size: 1.85rem; }
.auth-card__lead { color: var(--muted); margin-bottom: 1.4rem; }
.auth-card__brand-row {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 1.2rem; color: var(--primary-ink); font-weight: 700;
}
.auth-card__tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.center { text-align: center; }
.stack-sm { display: flex; flex-direction: column; gap: 0.4rem; }
.stack-md { display: flex; flex-direction: column; gap: 0.8rem; }
.eyebrow-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.32rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-chip--success {
  border-color: transparent;
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.post-icon {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.post-icon--small {
  width: 1.65rem;
  height: 1.65rem;
}
.meta-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-weight: 700;
}
.avatar--sm {
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.85rem;
}
.avatar--md {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1rem;
}
.avatar--fallback {
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
}
.list-row,
.thread-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}
button.list-row,
.thread-card {
  cursor: pointer;
}
button.list-row:hover,
.thread-card:hover {
  background: var(--bg);
  text-decoration: none;
}
.list-row__body,
.thread-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.list-row__body > *,
.thread-card__body > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-card__meta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.contact-list {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}
.person-button {
  min-width: 5rem;
  max-width: 6.5rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.person-button:hover {
  background: var(--bg);
}
.person-button span:last-child {
  width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
}
.route-map {
  position: relative;
  overflow: hidden;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.route-map__canvas {
  width: 100%;
  height: 180px;
}
.route-map__status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  text-align: center;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}
.route-map__status[hidden] {
  display: none;
}
.route-map--empty {
  min-height: 0;
  padding: 0.85rem;
}
.route-map--empty .route-map__canvas {
  display: none;
}
.route-map--empty .route-map__status {
  position: static;
  background: transparent;
  padding: 0;
}
.geo-permission {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.geo-permission__icon {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.geo-permission__body {
  flex: 1;
  min-width: 0;
}
.geo-permission__body p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.86rem;
}
.geo-permission__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}
.geo-permission__actions .btn {
  min-height: 2.35rem;
  padding: 0.48rem 0.72rem;
  font-size: 0.86rem;
}
.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100svh - var(--header-h) - var(--bottom-h));
  background: var(--bg);
  margin: -1.25rem 0 0;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  padding: 1rem;
}
.chat-empty {
  margin: auto;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}
.chat-inputbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  background: var(--bg);
}
.chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.message-bubble {
  align-self: flex-start;
  max-width: min(78%, 28rem);
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.4;
}
.message-bubble--own {
  align-self: flex-end;
  border-color: transparent;
  border-radius: 16px 16px 4px 16px;
  background: var(--primary);
  color: white;
}
.message-bubble__time {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.7rem;
  opacity: 0.75;
}
.message-bubble--own .message-bubble__time {
  color: rgba(255, 255, 255, 0.86);
}

.spinner {
  display: inline-block; width: 1.1em; height: 1.1em;
  border: 2px solid currentColor; border-bottom-color: transparent;
  border-radius: 50%; animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--bottom-h) + 12px); z-index: 50;
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: rgba(20, 20, 20, 0.92); color: white;
  padding: 0.7rem 1rem; border-radius: 999px;
  font-size: 0.9rem; box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.is-shown { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--danger); }
.toast--success { background: var(--primary); }

@media (max-width: 430px) {
  .auth-card {
    padding: 1.5rem 1rem 1.2rem;
  }
  .auth-card__title {
    font-size: 1.85rem;
  }
  .form-row {
    align-items: stretch;
  }
  .route-map,
  .route-map__canvas {
    min-height: 150px;
    height: 150px;
  }
  .route-map--empty {
    height: auto;
    min-height: 0;
  }
  .thread-card__meta {
    font-size: 0;
  }
  .thread-card__meta .cc-icon {
    width: 18px;
    height: 18px;
  }
}
