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

:root {
  --bg: #1a1a2e;
  --card: #16213e;
  --card-hover: #1b2a4a;
  --border: #0f3460;
  --accent: #e94560;
  --accent-2: #ff5570;
  --yellow: #ffd166;
  --green: #a7e8c0;
  --danger: #dc2626;
  --muted: #999;
  --text: #eee;
  --text-dim: #aab;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
}

.app {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-narrow {
  max-width: 460px;
}

/* ---------- Header ---------- */
.header {
  position: relative;
  text-align: center;
  padding: 8px 0 4px;
}

.header.has-back { padding-top: 8px; }

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title { font-size: 1.6rem; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 0.95rem; margin-top: 2px; }

.back-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.1s ease;
}
.back-btn:hover { background: var(--border); }
.back-btn:active { transform: scale(0.96); }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

a.link-btn { text-decoration: underline; }

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--yellow);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--text-dim); }

.input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input::placeholder { color: #667; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #e94560 0%, #ff5570 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.btn:hover { box-shadow: 0 4px 14px rgba(233, 69, 96, 0.4); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-block { width: 100%; }

.btn-ghost {
  background: var(--card);
  border-color: var(--border);
  color: #fff;
}
.btn-ghost:hover { box-shadow: none; background: var(--border); }

.btn-danger {
  background: var(--danger);
  border-color: #b91c1c;
}
.btn-danger:hover { box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35); }

.form-error {
  color: var(--accent-2);
  font-size: 0.85rem;
  min-height: 18px;
  margin-bottom: 8px;
}

/* ---------- Toggle tabs ---------- */
.toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.tab {
  padding: 14px 12px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ccc;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease, color 0.2s ease;
}
.tab:hover { background: var(--border); color: #fff; }
.tab:active { transform: scale(0.97); }
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, #e94560 0%, #ff5570 100%);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.35);
}

/* ---------- Chips (holidayers) ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.chip-remove {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.chip-remove:hover { background: var(--accent-2); }

/* ---------- Beer Tally actions ---------- */
.beer-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.beer-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 4px;
  color: #fff;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.12s ease;
}
.beer-action:hover { background: var(--border); border-color: var(--accent); }
.beer-action:active { transform: scale(0.96); }
.beer-action-icon { font-size: 1.6rem; line-height: 1; }
.beer-action-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; color: var(--text-dim); }

/* ---------- Venue cards ---------- */
.venue-list { display: grid; grid-template-columns: 1fr; gap: 10px; }

.venue-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.venue-card:hover { border-color: var(--accent); background: var(--card-hover); transform: translateY(-1px); }

.venue-info { min-width: 0; flex: 1; }
.venue-name { font-size: 1.05rem; font-weight: 700; color: #fff; word-break: break-word; }
.venue-note { margin-top: 3px; font-size: 0.85rem; color: var(--text-dim); }
.venue-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.venue-rating, .venue-price {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.venue-rating {
  color: var(--yellow);
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid rgba(255, 209, 102, 0.25);
}
.venue-price {
  color: var(--green);
  background: rgba(110, 231, 183, 0.10);
  border: 1px solid rgba(110, 231, 183, 0.25);
}

.venue-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 13px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #e94560 0%, #ff5570 100%);
  border-radius: 10px;
  text-decoration: none;
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.venue-link:hover { box-shadow: 0 4px 14px rgba(233, 69, 96, 0.4); }
.venue-link:active { transform: scale(0.95); }

.venue-delete {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #fff;
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid rgba(220, 38, 38, 0.4);
  border-radius: 50%;
  cursor: pointer;
}
.venue-delete:hover { background: var(--danger); }

.empty {
  padding: 20px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

/* ---------- Autocomplete dropdown ---------- */
.autocomplete-wrap { position: relative; }

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  display: none;
  max-height: 280px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.autocomplete-dropdown.open { display: block; }

.autocomplete-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--card-hover); }
.ac-main { font-weight: 600; }
.ac-sub { font-size: 0.8rem; color: var(--text-dim); }

/* ---------- Take Me Home ---------- */
.take-me-home-btn {
  width: 100%;
  padding: 16px 12px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--danger);
  border: 1px solid #b91c1c;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
  transition: transform 0.1s ease, background 0.1s ease, box-shadow 0.1s ease;
}
.take-me-home-btn:hover { background: #ef4444; }
.take-me-home-btn:active { transform: scale(0.98); background: #b91c1c; }
.take-me-home-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Switch ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.switch-row .label { font-size: 0.95rem; font-weight: 600; }

.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch .slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 4px;
  top: 4px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Trip grid ---------- */
.trip-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }

.trip-card {
  display: block;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.trip-card:hover { border-color: var(--accent); background: var(--card-hover); transform: translateY(-1px); }

.trip-card-name { font-size: 1.15rem; font-weight: 700; }
.trip-card-meta { margin-top: 6px; font-size: 0.85rem; color: var(--text-dim); }

.visibility-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
}
.visibility-badge.public { color: var(--green); background: rgba(110, 231, 183, 0.12); border: 1px solid rgba(110, 231, 183, 0.3); }
.visibility-badge.private { color: var(--text-dim); background: rgba(170, 170, 187, 0.1); border: 1px solid rgba(170, 170, 187, 0.3); }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
}

.toast {
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--danger); }

/* ---------- Camera modal ---------- */
.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.8);
}
.camera-modal.open { display: flex; }
.camera-modal-viewport { position: relative; width: 100%; max-width: 480px; }
.camera-modal video {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: cover;
  border-radius: 12px;
  background: #111;
}
.camera-saving {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
}
.camera-saving.show { display: flex; }
.camera-saving-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: camera-spin 0.8s linear infinite;
}
@keyframes camera-spin { to { transform: rotate(360deg); } }

/* ---------- Gallery modal ---------- */
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
}
.gallery-modal.open { display: flex; }
.gallery-modal-content {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.gallery-modal-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 16px; padding-right: 36px; }
.gallery-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.gallery-modal-close:hover { background: var(--accent-2); }
.gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.gallery-item { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.gallery-item-thumb { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--border); }
.gallery-item-timestamp { display: block; padding: 6px 4px; font-size: 0.7rem; color: var(--muted); text-align: center; }
.gallery-empty { padding: 24px 8px; color: var(--muted); font-size: 0.95rem; }

/* ---------- Photo modal ---------- */
.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.9);
}
.photo-modal.open { display: flex; }
.photo-modal-content {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-modal-img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 8px; background: #111; }
.photo-modal-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 8px; }
.photo-modal-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
}
.photo-modal-btn:hover { background: rgba(0, 0, 0, 0.75); }
.photo-modal-copied {
  position: absolute;
  top: 52px;
  right: 8px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: #2e7d32;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.photo-modal-copied.show { opacity: 1; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--yellow); }
.stat-label { margin-top: 4px; font-size: 0.8rem; color: var(--text-dim); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
td { color: var(--text); }

/* ---------- Bar chart ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%;
  max-width: 34px;
  background: linear-gradient(180deg, #e94560 0%, #ff5570 100%);
  border-radius: 6px 6px 0 0;
  min-height: 2px;
}
.bar-label { font-size: 0.65rem; color: var(--text-dim); text-align: center; }

/* ---------- Responsive ---------- */
@media (min-width: 620px) {
  .venue-list { grid-template-columns: repeat(2, 1fr); }
  .trip-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .title { font-size: 1.8rem; }
}

@media (max-width: 480px) {
  .tab { font-size: 0.85rem; padding: 12px 6px; }
  .venue-card { flex-direction: column; align-items: flex-start; }
  .venue-link { align-self: stretch; justify-content: center; }
  .beer-actions { grid-template-columns: repeat(3, 1fr); }
}
