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

:root {
  --primary: #6C63FF;
  --primary-light: #8B85FF;
  --primary-dark: #5248CC;
  --accent: #FF6584;
  --success: #43D9A2;
  --warning: #FFB84C;
  --bg: #F7F7FC;
  --surface: #FFFFFF;
  --border: #E4E4F0;
  --text: #1A1A2E;
  --text-muted: #6B6B8A;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(108,99,255,0.10);
  --shadow-lg: 0 8px 40px rgba(108,99,255,0.18);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app { min-height: 100vh; }

/* ── NAV ── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.nav-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
}
.nav-logo span { font-size: 1.5rem; }

.nav-identity {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.nav-email {
  font-size: .8rem;
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 400px) {
  .nav-email { max-width: 90px; }
}
.btn-logout {
  font-size: .75rem;
  padding: .25rem .6rem;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
}
.btn-logout:hover { background: var(--surface-alt); }

/* ── HERO ── */
.hero {
  text-align: center;
  padding: 5rem 1.5rem 3rem;
  max-width: 640px;
  margin: 0 auto;
}
.hero-emoji { font-size: 4rem; line-height: 1; margin-bottom: 1.25rem; }
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: .75rem;
}
.hero h1 em { color: var(--primary); font-style: normal; }
.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
  line-height: 1.6;
}
.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}
@media(min-width: 480px) {
  .hero-actions { flex-direction: row; justify-content: center; }
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1.75rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(108,99,255,0.35);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .5rem 1rem; font-size: .875rem; border-radius: 8px; }
.btn-danger { background: #ff4d6d; color: #fff; }
.btn-danger:hover { background: #c9184a; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #2eb88a; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-full { width: 100%; }

/* ── CARD ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 2rem;
}
@media(max-width: 480px) { .card { padding: 1.25rem; } }

/* ── CONTAINER ── */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.container-sm {
  max-width: 520px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ── FORM ── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
  margin-bottom: .5rem;
}
.form-group label .hint {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: .25rem;
}
.form-control {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color .2s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); background: #fff; }
.form-control::placeholder { color: var(--text-muted); }

/* ── DATE PICKER GRID ── */
.date-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.date-picker-header h3 {
  font-size: 1rem;
  font-weight: 700;
  text-transform: capitalize;
}
.month-nav {
  display: flex;
  gap: .5rem;
}
.month-nav button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.month-nav button:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-day-name {
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: .25rem 0;
}
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: .875rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .15s;
  user-select: none;
}
.calendar-day:hover:not(.empty):not(.past) { border-color: var(--primary); color: var(--primary); }
.calendar-day.selected {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(108,99,255,0.4);
}
.calendar-day.empty { cursor: default; }
.calendar-day.past { opacity: .3; cursor: not-allowed; }
.calendar-day.today { border-color: var(--primary-light); color: var(--primary); font-weight: 600; }
.calendar-day.today.selected { border-color: transparent; color: #fff; }

/* ── SELECTED DATES TAGS ── */
.tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: rgba(108,99,255,.1);
  color: var(--primary);
  border-radius: 8px;
  padding: .3rem .75rem;
  font-size: .8rem;
  font-weight: 600;
}
.tag-remove {
  cursor: pointer;
  opacity: .6;
  font-size: 1rem;
  line-height: 1;
  transition: opacity .2s;
}
.tag-remove:hover { opacity: 1; }

/* ── JOIN CODE INPUT ── */
.code-input-wrapper {
  display: flex;
  gap: .75rem;
  align-items: stretch;
}
.code-input {
  flex: 1;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  text-align: center;
}

/* ── SESSION VIEW ── */
.session-header {
  background: linear-gradient(135deg, var(--primary) 0%, #9B8FFF 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
}
.session-header h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: .25rem; }
.session-header p { opacity: .85; font-size: .95rem; }
.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}
.session-meta-item {
  background: rgba(255,255,255,.18);
  border-radius: 8px;
  padding: .4rem .85rem;
  font-size: .8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .35rem;
}

/* ── SHARE BAR ── */
.share-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}
.share-bar-code {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.code-badge {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: .15em;
  color: var(--primary);
  background: rgba(108,99,255,.08);
  border-radius: 10px;
  padding: .4rem .9rem;
}
.share-bar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── RESULTS ── */
.results-grid {
  display: grid;
  gap: .75rem;
}
.result-row {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all .2s;
  cursor: default;
}
.result-row.best {
  border-color: var(--success);
  background: rgba(67,217,162,.05);
}
.result-row.good { border-color: var(--warning); background: rgba(255,184,76,.05); }

.result-date {
  font-weight: 700;
  font-size: 1rem;
}
.result-names {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .15rem;
}
.result-bar-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  min-width: 60px;
}
.result-bar {
  height: 100%;
  border-radius: 99px;
  transition: width .5s ease;
  background: var(--border);
}
.result-row.best .result-bar { background: var(--success); }
.result-row.good .result-bar { background: var(--warning); }
.result-row.low .result-bar { background: var(--accent); }

.result-count {
  font-size: .875rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-muted);
}
.result-row.best .result-count { color: var(--success); }
.badge-best {
  font-size: .7rem;
  font-weight: 700;
  background: var(--success);
  color: #fff;
  border-radius: 6px;
  padding: .2rem .5rem;
  white-space: nowrap;
}

/* ── PARTICIPANTS ── */
.participants-list { display: grid; gap: .5rem; margin-top: .75rem; }
.participant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-radius: 10px;
  padding: .65rem 1rem;
  gap: .75rem;
}
.participant-name { font-weight: 600; font-size: .95rem; }
.participant-dates {
  font-size: .78rem;
  color: var(--text-muted);
}
.participant-actions { display: flex; gap: .5rem; }

/* ── VOTE GRID ── */
.vote-grid {
  display: grid;
  gap: .5rem;
}
.vote-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.vote-row:hover { border-color: var(--primary-light); }
.vote-row.voted {
  border-color: var(--primary);
  background: rgba(108,99,255,.07);
}
.vote-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
  font-size: .85rem;
}
.vote-row.voted .vote-checkbox {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.vote-date { font-weight: 600; font-size: .95rem; }
.vote-count { margin-left: auto; font-size: .8rem; color: var(--text-muted); }

/* ── SECTION TITLE ── */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text);
}

/* ── ALERT / TOAST ── */
.alert {
  border-radius: 10px;
  padding: .85rem 1.1rem;
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.alert-error { background: #fff0f3; color: #c9184a; border: 1px solid #ffb3c1; }
.alert-success { background: #f0fff8; color: #1a7a55; border: 1px solid #a8f0d4; }
.alert-info { background: #f0efff; color: var(--primary-dark); border: 1px solid #c8c4ff; }

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: .85rem 1.25rem;
  border-radius: 12px;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn .3s ease;
  max-width: 300px;
}
.toast.toast-success { background: #1a7a55; }
.toast.toast-error { background: #c9184a; }
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── LOADING ── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 3rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TABS ── */
.tabs { display: flex; gap: .25rem; background: var(--bg); padding: .25rem; border-radius: 12px; margin-bottom: 1.5rem; }
.tab {
  flex: 1;
  padding: .6rem 1rem;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: all .2s;
  text-align: center;
}
.tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: .95rem; line-height: 1.6; }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── UTILITY ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .875rem; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
/* ── RESPONSIVE ── */
@media(max-width: 600px) {
  .session-header { padding: 1.25rem; }
  .share-bar { flex-direction: column; align-items: stretch; }
  .share-bar-actions { justify-content: stretch; }
  .share-bar-actions .btn { flex: 1; }
  .result-row { flex-wrap: wrap; }
}
