@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', var(--font-family-sans);
  font-size: 15px;
  line-height: 1.45;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

/* App Shell Layout */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-app);
  border-left: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

/* Top App Header with Notch & Safe Area Support */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  box-sizing: border-box;
  min-height: var(--header-height);
  background-color: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--safe-top);
  padding-bottom: 8px;
  padding-left: max(var(--space-md), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-md), env(safe-area-inset-right, 0px));
}

.brand-section {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-brand), #f5cc66);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #0e0f12;
  box-shadow: 0 2px 8px var(--accent-brand-glow);
  overflow: hidden;
  flex-shrink: 0;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-title {
  font-family: 'Playfair Display', var(--font-family-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-ochre);
  font-weight: 600;
}

/* Event Selector pill in header */
.header-event-selector {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  cursor: pointer;
  max-width: 50%;
  transition: border-color var(--trans-fast);
}

.header-event-selector:hover {
  border-color: var(--accent-brand);
}

.event-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-profit);
  box-shadow: 0 0 8px var(--status-profit);
  animation: pulse-live 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-live {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px var(--status-profit); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.event-name-display {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content Area */
.app-content {
  flex: 1;
  padding: var(--space-md);
  padding-bottom: calc(var(--bottom-nav-height) + 24px);
}

/* Mobile-First Bottom Navigation with Safe Area Support */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 900px;
  box-sizing: border-box;
  height: var(--bottom-nav-height);
  background-color: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  z-index: 1000;
  padding-top: 4px;
  padding-bottom: max(6px, var(--safe-bottom));
  padding-left: max(var(--space-xs), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-xs), env(safe-area-inset-right, 0px));
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  transition: all var(--trans-fast);
  position: relative;
}

.nav-item.active {
  color: var(--accent-brand);
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
  transition: transform var(--trans-bounce);
}

.nav-item.active .nav-icon {
  transform: translateY(-2px) scale(1.1);
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.nav-badge-live {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  width: 7px;
  height: 7px;
  background-color: var(--accent-brand);
  border-radius: 50%;
}

/* Toast Container */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 480px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-undo {
  background: linear-gradient(135deg, #1e222d, #272d3b);
  border-color: var(--accent-brand);
  box-shadow: 0 4px 20px var(--accent-brand-glow);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.toast-text-group {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  line-height: 1.25;
}

.toast-text-group strong {
  font-size: 14px;
  color: var(--accent-brand);
}

.btn-undo {
  background: var(--accent-brand);
  color: #0e0f12;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--trans-fast);
}

.btn-undo:hover {
  background: var(--accent-brand-hover);
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-out {
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s ease;
}

/* Mobile Responsive Notch Adjustments */
@media (max-width: 768px) {
  :root {
    /* Ensure a clean, comfortable clearance on mobile below notches, Dynamic Islands, and camera holes */
    --safe-top: max(calc(env(safe-area-inset-top, 0px) + 16px), 32px);
  }

  .app-header {
    padding-top: var(--safe-top);
    padding-bottom: 12px;
  }
}
