/* ============================================================
   TIPSY — DESIGN SYSTEM
   "Neon Nights" — dark-first, vibrant, breathable
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Inter:wght@400;500;600&display=swap');

/* ===========================
   DESIGN TOKENS
   =========================== */
:root {
  /* --- Surfaces --- */
  --bg: #0A0A10;
  --surface-1: #111119;
  --surface-2: #18181F;
  --surface-3: #1F1F2A;
  --border: #2A2A3C;
  --border-muted: #1A1A28;

  /* --- Brand --- */
  --primary: #7C6FF7;
  --primary-dim: rgba(124, 111, 247, 0.12);
  --primary-ring: rgba(124, 111, 247, 0.28);
  --primary-hover: #9187F9;

  /* --- Accent tones --- */
  --amber: #F5A623;
  --amber-dim: rgba(245, 166, 35, 0.12);
  --coral: #FF6B6B;
  --coral-dim: rgba(255, 107, 107, 0.12);
  --teal: #4ECDC4;
  --teal-dim: rgba(78, 205, 196, 0.12);

  /* --- Text --- */
  --text: #F0EEFF;
  --text-muted: #8884AA;
  --text-faint: #55527A;
  --white: #FFFFFF;
  --black: #000000;

  /* --- BAC state colors --- */
  --bac-sober: #4ECDC4;
  --bac-easy: #6EC96A;
  --bac-tipsy: #F5A623;
  --bac-drunk: #FF8C42;
  --bac-wasted: #FF6B6B;
  --bac-danger: #C45CF3;

  /* --- Typography --- */
  --ff-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --ff-body: 'Inter', system-ui, sans-serif;
  --ff-mono: ui-monospace, 'Courier New', monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-hero: clamp(3.5rem, 14vw, 5.5rem);

  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;

  /* --- Spacing (8pt grid) --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* --- Radius --- */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 9999px;

  /* --- Elevation --- */
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);

  /* --- Transitions --- */
  --t-fast: 120ms ease-out;
  --t-base: 200ms ease-out;
  --t-slow: 350ms ease-out;
}

/* Light mode — rethought, not inverted */
body.light {
  --bg: #F4F4FA;
  --surface-1: #FFFFFF;
  --surface-2: #EDEDF7;
  --surface-3: #E4E4F0;
  --border: #D5D3EE;
  --border-muted: #ECEAF8;
  --primary-dim: rgba(124, 111, 247, 0.09);
  --primary-ring: rgba(124, 111, 247, 0.2);
  --text: #0D0D14;
  --text-muted: #5B5780;
  --text-faint: #9895BB;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}


/* ===========================
   RESET & BASE
   =========================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--ff-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-normal);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

pre {
  font-family: var(--ff-mono);
}


/* ===========================
   APP SHELL
   =========================== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .app-shell {
    border-left: 1px solid var(--border-muted);
    border-right: 1px solid var(--border-muted);
  }
}

/* ===========================
   AUTH GATE
   =========================== */
.auth-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--sp-6);
  max-width: 440px;
  margin: 0 auto;
  gap: var(--sp-8);
}

.auth-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  text-align: center;
}

.auth-app-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(145deg, rgba(124, 111, 247, 0.14) 0%, rgba(245, 166, 35, 0.08) 100%);
  border: 1px solid rgba(124, 111, 247, 0.22);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-2);
  box-shadow: 0 0 40px rgba(124, 111, 247, 0.12), var(--shadow-sm);
}

.auth-title {
  font-family: var(--ff-display);
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: var(--fw-extrabold);
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--amber) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-top: var(--sp-1);
}

.auth-actions {
  width: 100%;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}

.btn-google:hover {
  background: var(--surface-3);
  border-color: rgba(124, 111, 247, 0.45);
  box-shadow: 0 0 0 3px rgba(124, 111, 247, 0.1);
}

.btn-google:active {
  background: var(--surface-3);
}

.google-icon {
  flex-shrink: 0;
}

.auth-lang-switcher {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.auth-lang-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: var(--fs-xs);
  font-family: var(--ff-body);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.1em;
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  transition: color var(--t-fast);
  line-height: 1;
}

.auth-lang-btn:hover {
  color: var(--text-muted);
}

.auth-lang-btn.active {
  color: var(--primary);
}

.auth-lang-sep {
  color: var(--text-faint);
  font-size: var(--fs-xs);
  opacity: 0.4;
  user-select: none;
}

.auth-disclaimer {
  color: var(--text-faint);
  font-size: var(--fs-xs);
  text-align: center;
  margin-top: calc(-1 * var(--sp-4));
}


/* ===========================
   HEADER
   =========================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border-muted);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-logo {
  font-family: var(--ff-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-extrabold);
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--primary) 0%, var(--amber) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-user {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ===========================
   TAB BAR
   =========================== */
.tab-bar {
  display: flex;
  background: var(--surface-1);
  border-top: 1px solid var(--border-muted);
  padding: 0 var(--sp-2);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  bottom: 0;
  z-index: 99;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1;
  min-width: fit-content;
  padding: var(--sp-3) var(--sp-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-faint);
  font-family: var(--ff-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  letter-spacing: 0.01em;
  min-height: 44px;
}

.tab-btn:hover {
  color: var(--text-muted);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}


/* ===========================
   MAIN CONTENT
   =========================== */
.app-content {
  flex: 1;
  padding: var(--sp-5) var(--sp-5) var(--sp-16);
}

/* ===========================
   TAB PANELS
   =========================== */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeUp 200ms ease-out;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ===========================
   SECTIONS
   =========================== */
.section {
  margin-bottom: var(--sp-8);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.section-title {
  font-family: var(--ff-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
  color: var(--text);
}

.section-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--sp-3);
}


/* ===========================
   BAC HERO
   =========================== */
.bac-hero {
  text-align: center;
  padding: var(--sp-8) var(--sp-4) var(--sp-5);
}

.bac-eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--sp-2);
}

.bac-number {
  font-family: var(--ff-display);
  font-size: var(--fs-hero);
  font-weight: var(--fw-extrabold);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--bac-sober);
  transition: color var(--t-slow), text-shadow var(--t-slow);
  margin-bottom: var(--sp-3);
  text-shadow: 0 0 48px currentColor;
}

.bac-number.state-easy {
  color: var(--bac-easy);
}

.bac-number.state-tipsy {
  color: var(--bac-tipsy);
}

.bac-number.state-drunk {
  color: var(--bac-drunk);
}

.bac-number.state-wasted {
  color: var(--bac-wasted);
}

.bac-number.state-danger {
  color: var(--bac-danger);
}

.bac-status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.bac-status-text {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
}

.bac-disclaimer {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin-top: var(--sp-3);
  font-style: italic;
}

.state-image {
  width: 200px;
  height: 200px;
  border-radius: var(--r-xl);
  object-fit: cover;
  margin: 0 auto var(--sp-5);
  border: 2px solid var(--border);
  background: var(--surface-2);
  transition: border-color var(--t-slow), transform var(--t-slow);
  box-shadow: 0 0 40px rgba(124, 111, 247, 0.15);
}

.state-image:not([src=""]) {
  transform: scale(1.02);
}

/* ===========================
   HISTORY TOGGLE
   =========================== */
.history-toggle {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 4px;
  margin: var(--sp-5) 0 var(--sp-6);
  gap: 4px;
}

.history-toggle-btn {
  flex: 1;
  padding: var(--sp-2) var(--sp-4);
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--ff-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  min-height: 36px;
}

.history-toggle-btn.active {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 10px var(--primary-ring);
}

/* ===========================
   CALENDAR GRID
   =========================== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: var(--sp-5);
}

.cal-day {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  cursor: default;
  position: relative;
  border: 1px solid var(--border-muted);
  transition: transform var(--t-fast);
  overflow: hidden;
}

.cal-day:hover {
  transform: scale(1.1);
  z-index: 1;
}

.cal-day-num {
  line-height: 1;
}

.cal-day-bac {
  font-size: 9px;
  opacity: 0.8;
  margin-top: 2px;
}

.cal-day.bucket-0 {
  background: var(--surface-2);
  color: var(--text-faint);
}

.cal-day.bucket-1 {
  background: rgba(78, 205, 196, 0.20);
  color: var(--teal);
  border-color: rgba(78, 205, 196, 0.35);
}

.cal-day.bucket-2 {
  background: rgba(245, 166, 35, 0.22);
  color: var(--amber);
  border-color: rgba(245, 166, 35, 0.40);
}

.cal-day.bucket-3 {
  background: rgba(255, 107, 107, 0.22);
  color: var(--coral);
  border-color: rgba(255, 107, 107, 0.40);
}

.cal-day.empty {
  background: transparent;
  border: none;
}

.cal-legend {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.cal-dot-0 {
  background: var(--surface-3);
}

.cal-dot-1 {
  background: var(--teal);
}

.cal-dot-2 {
  background: var(--amber);
}

.cal-dot-3 {
  background: var(--coral);
}

/* ===========================
   TODAY SESSION CARDS
   =========================== */
.today-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.today-stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  text-align: center;
}

.today-stat-value {
  font-family: var(--ff-display);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-extrabold);
  color: var(--primary);
  display: block;
}

.today-stat-label {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin-top: var(--sp-1);
}

.bac-refresh-row {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-4);
}


/* ===========================
   SOCIAL SESSION
   =========================== */
.social-hero-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(124, 111, 247, 0.18), transparent 40%),
    radial-gradient(circle at bottom left, rgba(245, 166, 35, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 32%),
    var(--surface-1);
}

.social-hero-card::after {
  content: '';
  position: absolute;
  inset: auto -40px -60px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 111, 247, 0.2), transparent 68%);
  pointer-events: none;
}

.social-hero-header,
.social-hero-intro,
.social-hero-actions {
  position: relative;
  z-index: 1;
}

.social-hero-intro {
  margin-bottom: var(--sp-4);
  max-width: 40ch;
}

.social-hero-actions {
  display: grid;
  gap: var(--sp-3);
}

.social-join-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  box-shadow: var(--shadow-sm);
}

.social-join-card .invite-row {
  align-items: stretch;
}

.social-join-card .btn {
  min-width: 92px;
}

.social-session-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.social-session-preview {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  width: 100%;
  text-align: left;
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}

.social-session-preview:hover {
  transform: translateX(2px);
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
  box-shadow: var(--shadow-sm);
}

.social-session-preview:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.social-session-preview-active {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  box-shadow: 0 0 0 1px var(--primary-ring);
}

.social-session-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.social-session-preview-title {
  font-family: var(--ff-display);
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.social-session-preview-meta,
.social-session-preview-status {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

.social-session-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.session-summary {
  line-height: 1.6;
}

.social-preview-hint {
  margin-bottom: var(--sp-3);
}

.invite-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.invite-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.invite-link-input {
  flex: 1;
  min-width: 0;
  font-family: var(--ff-mono);
  color: var(--primary);
  letter-spacing: 0.01em;
}

.invite-link-input[readonly] {
  cursor: text;
}

.session-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
}

.session-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-width: 0;
}

.session-meta-label {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.session-meta-value {
  font-family: var(--ff-display);
  font-weight: var(--fw-bold);
  color: var(--text);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-member-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.session-member-hint {
  margin-bottom: var(--sp-1);
}

.session-member-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: center;
  width: 100%;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}

.session-member-item:hover {
  transform: translateX(2px);
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

.session-member-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.session-member-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary-dim), var(--amber-dim));
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
  font-size: 1.2rem;
  flex-shrink: 0;
}

.session-member-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.session-member-toprow {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.session-member-name {
  font-family: var(--ff-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-base);
  color: var(--text);
}

.session-member-meta,
.session-member-submeta {
  color: var(--text-faint);
  font-size: var(--fs-xs);
}

.session-member-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.session-member-bac {
  font-family: var(--ff-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-extrabold);
  color: var(--primary);
  line-height: 1;
}

.session-member-bac-label,
.session-member-sober {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

.session-drink-history {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.session-drink-log {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.session-drink-log-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-drink-log-name {
  color: var(--text);
  font-weight: var(--fw-semibold);
}

.session-drink-log-meta {
  color: var(--text-faint);
  font-size: var(--fs-xs);
}


/* ===========================
   CARDS
   =========================== */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: border-color var(--t-fast);
}

.card+.card {
  margin-top: var(--sp-3);
}

.card-elevated {
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
}

.card-flush {
  padding: 0;
  overflow: hidden;
}


/* ===========================
   BUTTONS
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--ff-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* Primary */
.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 16px var(--primary-ring);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 24px var(--primary-ring);
}

/* Secondary */
.btn-secondary {
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--text-faint);
}

/* Danger */
.btn-danger {
  background: var(--coral-dim);
  color: var(--coral);
  border: 1px solid color-mix(in srgb, var(--coral) 28%, transparent);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--coral) 20%, transparent);
}

/* Accent */
.btn-accent {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 28%, transparent);
}

.btn-accent:hover {
  background: color-mix(in srgb, var(--amber) 20%, transparent);
}

/* Sizes */
.btn-sm {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  min-height: 44px;
  border-radius: var(--r-sm);
}

.btn-lg {
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--fs-lg);
  min-height: 52px;
  border-radius: var(--r-lg);
}

.btn-full {
  width: 100%;
}

.btn-pill {
  border-radius: var(--r-pill);
}

/* Emoji sentiment */
.btn-sentiment {
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 1.4rem;
  padding: var(--sp-2) var(--sp-4);
  min-height: 44px;
  border-radius: var(--r-md);
  flex: 1;
  transition: background var(--t-fast), transform var(--t-fast);
}

.btn-sentiment:hover {
  background: var(--surface-3);
  transform: scale(1.06);
}


/* ===========================
   BUTTON GROUP
   =========================== */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.btn-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.btn-row>.btn {
  flex: 1;
}


/* ===========================
   INPUTS
   =========================== */
.input,
.select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--ff-body);
  font-size: var(--fs-base);
  color: var(--text);
  min-height: 44px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--text-faint);
}

.input:hover,
.select:hover {
  border-color: var(--text-faint);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--surface-3);
}

textarea.input {
  min-height: 80px;
  resize: vertical;
  line-height: 1.6;
}

.select {
  cursor: pointer;
}

/* Form layout */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.form-row {
  display: flex;
  gap: var(--sp-2);
}

.form-row>* {
  flex: 1;
  min-width: 0;
}


/* ===========================
   DRINK LIST
   =========================== */
.drink-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.drink-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  cursor: pointer;
  min-height: 44px;
}

.drink-item:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  transform: translateX(2px);
}

.drink-item:active {
  transform: scale(0.99);
}

.drink-icon {
  font-size: 1.6rem;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.drink-info {
  flex: 1;
  min-width: 0;
}

.drink-name {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drink-meta {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin-top: 2px;
}

.drink-log-btn {
  flex-shrink: 0;
  padding: var(--sp-2) var(--sp-3);
  background: var(--primary-dim);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  border-radius: var(--r-sm);
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
  min-height: 44px;
}

.drink-log-btn:hover {
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  transform: scale(1.04);
}

.drink-log-btn:active {
  transform: scale(0.96);
}

.drink-log-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.drink-star-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-faint);
  cursor: pointer;
  padding: var(--sp-2);
  transition: color var(--t-fast), transform var(--t-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.drink-star-btn:hover {
  color: var(--amber);
  transform: scale(1.2);
}

.drink-star-on {
  color: var(--amber);
}

.drink-del-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-faint);
  font-size: 1.2rem;
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  transition: all var(--t-fast);
  opacity: 0.6;
}

.drink-del-btn:hover {
  background: var(--coral-dim);
  border-color: var(--coral);
  color: var(--coral);
  opacity: 1;
  transform: scale(1.05);
}


/* ===========================
   EMPTY STATE
   =========================== */
.empty-state {
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  color: var(--text-faint);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: var(--sp-3);
  opacity: 0.6;
}

.empty-state-title {
  font-family: var(--ff-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.empty-state-body {
  font-size: var(--fs-sm);
  color: var(--text-faint);
  line-height: 1.6;
}


/* ===========================
   BADGE / PILL
   =========================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
}

.badge-primary {
  background: var(--primary-dim);
  color: var(--primary);
}

.badge-teal {
  background: var(--teal-dim);
  color: var(--teal);
}

.badge-amber {
  background: var(--amber-dim);
  color: var(--amber);
}

.badge-coral {
  background: var(--coral-dim);
  color: var(--coral);
}


/* ===========================
   TOGGLE / CHECKBOX
   =========================== */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
}

.toggle-item:hover {
  background: var(--surface-2);
}

.toggle-input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: unset;
  border-radius: 5px;
  background: var(--surface-3);
  border: 1.5px solid var(--border);
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.toggle-label {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text);
}


/* ===========================
   DATA / PRE DISPLAY
   =========================== */
.data-pre {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin-top: var(--sp-3);
  line-height: 1.8;
  max-height: 320px;
  overflow-y: auto;
}


/* ===========================
   SENTIMENT ROW
   =========================== */
.sentiment-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-3);
}

.sentiment-row .select {
  flex: 1.2;
}


/* ===========================
   DIVIDER
   =========================== */
.divider {
  height: 1px;
  background: var(--border-muted);
  margin: var(--sp-6) 0;
}


/* ===========================
   TOAST SYSTEM
   =========================== */
.toast-container {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
  width: calc(100% - var(--sp-8));
  max-width: 400px;
}

.toast {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  text-align: center;
  animation: toastIn 250ms ease-out forwards;
}

.toast-success {
  border-color: color-mix(in srgb, var(--teal) 55%, transparent);
  color: var(--teal);
}

.toast-error {
  border-color: color-mix(in srgb, var(--coral) 55%, transparent);
  color: var(--coral);
}

.toast-warning {
  border-color: color-mix(in srgb, var(--amber) 55%, transparent);
  color: var(--amber);
}

.toast-exit {
  animation: toastOut 220ms ease-in forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.94);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
}


/* ===========================
   TYPOGRAPHY UTILITIES
   =========================== */
.text-primary {
  color: var(--text);
}

.text-muted {
  color: var(--text-muted);
}

.text-faint {
  color: var(--text-faint);
}

.text-sm {
  font-size: var(--fs-sm);
}

.text-xs {
  font-size: var(--fs-xs);
}

.text-center {
  text-align: center;
}

.label-tag {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}


/* ===========================
   LAYOUT UTILITIES
   =========================== */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* ===========================
   MODAL SYSTEM
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.84);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-slow), visibility var(--t-slow);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay-fullscreen {
  padding: var(--sp-2);
}

.modal-surface {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(20px);
  transition: transform var(--t-slow);
}

.modal-overlay.active .modal-surface {
  transform: scale(1) translateY(0);
}

.modal-surface-fullscreen {
  max-width: min(96vw, 1100px);
  max-height: 94vh;
}

.modal-surface-fullscreen .modal-body {
  padding-top: var(--sp-3);
}

.modal-header {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--ff-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 1.75rem;
  cursor: pointer;
  line-height: 1;
  padding: var(--sp-1);
  transition: color var(--t-fast);
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: var(--sp-4);
  overflow-y: auto;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.modal-body pre {
  background: var(--surface-2);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  font-family: var(--ff-mono);
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border);
  color: var(--text);
}

.modal-stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.modal-section-title {
  font-family: var(--ff-display);
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--text);
}

.modal-paragraph {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.7;
}

.modal-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  list-style: none;
}

.modal-list-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  color: var(--text-muted);
}

.modal-link {
  color: var(--primary);
  font-weight: var(--fw-semibold);
  word-break: break-word;
}

.modal-meta {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

.bac-chart-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(94vh - 180px);
  object-fit: contain;
  background: var(--surface-1);
}

@media (max-width: 420px) {
  .session-meta-grid {
    grid-template-columns: 1fr;
  }

  .session-member-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .session-member-stats {
    grid-column: 2 / -1;
    align-items: flex-start;
    text-align: left;
  }
}

/* ===========================
   REDUCED MOTION
   =========================== */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
