:root {
  --primary: #00b1f0;
  --primary-strong: #008ac3;
  --primary-soft: #e6f7ff;
  --accent: #22c55e;
  --text: #0f172a;
  --muted: #65738f;
  --card: #ffffff;
  --card-border: rgba(0, 177, 240, 0.18);
  --shadow: 0 24px 70px -35px rgba(0, 0, 0, 0.55), 0 20px 50px -38px rgba(0, 177, 240, 0.45);
}

* { box-sizing: border-box; }

.d-none {
  display: none !important;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(0, 177, 240, 0.2), transparent 30%),
    radial-gradient(circle at 80% 8%, rgba(0, 177, 240, 0.16), transparent 28%),
    linear-gradient(140deg, var(--card) 0%, var(--bg-1) 48%, var(--bg-2) 100%);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Auth & login ---------- */
.login-wrapper {
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.65rem, 2.2vw, 1.4rem);
  position: relative;
  z-index: 1;
}

.login-card {
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.82));
  border-radius: clamp(18px, 3vw, 28px);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  padding: clamp(0.9rem, 2.8vw, 3rem);
  width: 100%;
  height: 100%;
  max-width: none;
  min-height: 0;
  position: relative;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.login-content {
  width: min(100%, clamp(19rem, 52vw, 38rem));
  min-height: 0;
  max-height: 100%;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.55rem, 1.6vmin, 1.15rem);
}

.login-logo-link {
  display: flex;
  justify-content: center;
  width: 100%;
}

.client-login-logo {
  width: clamp(220px, 42vmin, 440px);
  max-width: min(100%, 460px);
  height: auto;
}

.login-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(90% 80% at 85% 0%, rgba(0, 177, 240, 0.08), transparent);
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  background: rgba(0, 177, 240, 0.1);
  color: var(--primary-strong);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.eyebrow i { color: var(--accent); }

.event-title {
  font-size: clamp(1.55rem, 4.8vmin, 3rem);
  font-weight: 700;
  color: var(--primary-strong);
  line-height: 1.08;
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

#eventDescription {
  font-size: clamp(1.02rem, 2.7vmin, 1.45rem);
  color: var(--muted);
  font-weight: 500;
  line-height: 1.25;
  margin: 0;
  white-space: pre-wrap;
}

.session-info {
  font-size: clamp(0.88rem, 2.1vmin, 1.1rem);
  color: var(--primary-strong);
  font-weight: 600;
  margin-top: 0;
  display: grid;
  gap: 0.16rem;
}

.session-info .muted {
  color: var(--muted);
  font-weight: 500;
}

.session-info strong {
  font-size: clamp(1rem, 2.4vmin, 1.28rem);
  line-height: 1.15;
}

.session-kicker {
  color: var(--primary-strong);
  font-size: 0.78em;
  font-weight: 800;
  text-transform: uppercase;
}

.smart-chat-status {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(255, 251, 235, 0.95);
  color: #92400e;
  font-weight: 750;
}

.form-control, .form-select {
  border-radius: clamp(12px, 2.4vmin, 18px);
  border: 1px solid rgba(0, 177, 240, 0.18);
  background: #f7fbff;
  padding: clamp(0.9rem, 2.35vmin, 1.28rem) clamp(1rem, 2.8vmin, 1.35rem);
  font-size: clamp(1rem, 2.55vmin, 1.3rem);
  min-height: clamp(3rem, 7.4vmin, 4.25rem);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 8px 20px -14px rgba(0, 177, 240, 0.65);
  transform: translateY(-1px);
}

.login-form {
  width: 100%;
  display: grid;
  gap: clamp(0.75rem, 2vmin, 1.2rem);
  margin-top: clamp(0.25rem, 1.4vmin, 0.75rem);
}

.login-field {
  margin: 0;
}

#chatStatusAlert,
.login-content > .alert {
  width: 100%;
}

.app-meta {
  color: rgba(101, 115, 143, 0.82);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.client-app-meta {
  margin-top: 0.15rem;
}

.btn-primary {
  border-radius: clamp(12px, 2.4vmin, 18px);
  border: none;
  background: linear-gradient(120deg, var(--primary) 0%, #3cd5ff 55%, #22c55e 100%);
  box-shadow: 0 15px 35px -20px rgba(0, 177, 240, 0.7);
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: clamp(0.9rem, 2.35vmin, 1.25rem) clamp(1rem, 2.8vmin, 1.45rem);
  min-height: clamp(3rem, 7.4vmin, 4.25rem);
  font-size: clamp(1rem, 2.55vmin, 1.3rem);
}
.btn-primary:focus, .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 38px -20px rgba(0, 177, 240, 0.8);
}

#eventName { color: var(--primary-strong); }

/* ---------- Chat layout ---------- */
.page-shell {
  height: calc(100dvh - 24px);
  min-height: calc(100dvh - 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  max-width: 1320px;
  margin: auto;
  box-sizing: border-box;
  overflow: hidden;
  border-radius: 20px;
  box-shadow: 0 20px 60px -42px rgba(0, 0, 0, 0.35);
}

.chat-frame {
  width: 100%;
  max-width: 1220px;
  height: calc(100% - 12px);
  max-height: calc(100% - 12px);
  min-height: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88));
  border-radius: 26px;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.chat-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1.4rem 1.6rem 1.2rem;
  background: linear-gradient(125deg, rgba(0, 177, 240, 0.12), rgba(255, 255, 255, 0.08));
  border-bottom: 1px solid rgba(0, 177, 240, 0.15);
  position: relative;
  z-index: 5;
}

.hero-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.hero-content {
  text-align: center;
  min-width: 0;
  width: 100%;
}

.brand-mark {
  width: clamp(140px, 22vw, 260px);
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 12px 25px rgba(0, 0, 0, 0.1));
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  width: 100%;
}

.hero-title {
  display: block;
  width: 100%;
  margin: 0;
  font-size: clamp(2rem, 8.2vw, 2.75rem);
  color: var(--primary-strong);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.05;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
  text-wrap: nowrap;
  white-space: nowrap;
}

.hero-description {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: clamp(0.88rem, 2.3vw, 1.04rem);
  font-weight: 600;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.hero-actions {
  margin-top: 0.25rem;
  display: flex;
  justify-content: center;
}

.welcome {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.9rem;
  background: rgba(0, 177, 240, 0.12);
  color: var(--primary-strong);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
}
.welcome strong { color: var(--primary-strong); }

.session-badge {
  display: none;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
  font-weight: 700;
  font-size: 0.85rem;
}
.session-badge.is-visible {
  display: inline-flex;
}
.session-badge.upcoming {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}
.hero-actions { display: flex; gap: 0.6rem; align-items: center; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 12px;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(0, 177, 240, 0.16);
  background: #fff;
  color: var(--primary-strong);
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 12px 30px -20px rgba(0, 0, 0, 0.28);
}
.ghost-btn:hover { transform: translateY(-1px); }

.ghost-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.95rem;
}

.status-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid rgba(0, 177, 240, 0.2);
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}
.status-closed {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.25);
}
.status-open { background: rgba(34, 197, 94, 0.12); }

.chat-thread {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1.2rem 1.4rem;
  background: linear-gradient(180deg, #f7fbff 0%, #edf6ff 100%);
}

.load-older {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  margin-bottom: 0.8rem;
}
.load-older.hidden { display: none; }
.load-older .btn {
  border-radius: 999px;
}

.typing-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem 0.5rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}
.typing-indicator.show { display: flex; }
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: typingPulse 1s infinite ease-in-out;
}
@keyframes typingPulse {
  0%, 100% { transform: scale(0.8); opacity: 0.45; }
  50% { transform: scale(1.2); opacity: 1; }
}

.message-row {
  display: flex;
  align-items: flex-end;
  margin: 0.45rem 0;
  animation: messageIn 0.18s ease-out;
}

.message-row-client {
  flex-direction: row-reverse;
}

.message-content {
  width: max-content;
  max-width: min(58ch, 88vw);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.message-row-client .message-content {
  align-items: flex-end;
}

.message-meta {
  font-size: 0.78rem;
  margin-bottom: 3px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}
.message-meta strong {
  color: var(--text) !important;
  font-weight: 800;
}

.client-status-chip {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 0.14rem 0.42rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 800;
  white-space: nowrap;
}

.client-status-chip.status-pending {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.25);
  color: #92400e;
}

.client-status-chip.status-valid {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.24);
  color: #15803d;
}

.client-status-chip.music-status-received {
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(14, 165, 233, 0.24);
  color: #075985;
}

.client-status-chip.music-status-validated {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.24);
  color: #15803d;
}

.client-status-chip.music-status-played {
  background: rgba(129, 140, 248, 0.16);
  border-color: rgba(129, 140, 248, 0.28);
  color: #3730a3;
}

.client-status-chip.music-status-refused {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.28);
  color: #991b1b;
}

.message-bubble {
  display: inline-block;
  width: fit-content;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  align-self: flex-start;
  padding: 0.62rem 0.78rem;
  margin: 1px 0 4px 0;
  border-radius: 14px;
  font-size: 0.95em;
  line-height: 1.38;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 10px 24px -22px rgba(0, 0, 0, 0.32);
}
.admin-msg {
  background: #f4fbff;
  color: #0b2c44;
  border-color: rgba(0, 177, 240, 0.2);
  border-bottom-left-radius: 6px;
}
.client-msg {
  background: #eaf8ef;
  color: #12331e;
  border-color: rgba(34, 197, 94, 0.2);
  border-bottom-right-radius: 6px;
  align-self: flex-end;
}

.reaction-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.24rem;
  margin-top: 0.18rem;
  padding-left: 0.2rem;
}

.reaction-btn {
  min-width: 2.1rem;
  height: 1.55rem;
  border: 1px solid rgba(0, 177, 240, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #0f3b57;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  padding: 0 0.38rem;
  font-size: 0.76rem;
  line-height: 1;
}

.reaction-btn.active {
  color: #075985;
  border-color: rgba(14, 165, 233, 0.35);
  background: rgba(14, 165, 233, 0.14);
}

.reaction-btn:disabled {
  opacity: 0.65;
}

.reaction-count {
  min-width: 0.5rem;
  font-weight: 800;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}


.reply-bubble {
  width: fit-content;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  align-self: flex-start;
  background: rgba(14, 165, 233, 0.07);
  border-left: 2px solid var(--primary);
  padding: 0.45rem 0.6rem;
  margin-bottom: 6px;
  font-size: 0.86rem;
  line-height: 1.32;
  white-space: pre-wrap;
  border-radius: 12px;
}

.composer {
  padding: 1rem 1.4rem 0.72rem;
  border-top: 1px solid rgba(0, 177, 240, 0.12);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  z-index: 2;
}

.composer-form {
  display: flex;
  gap: 0.8rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 220px;
}

.field-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--muted);
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.message-counter {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill-field {
  background: #f7fbff;
  border-radius: 14px;
  border: 1px solid rgba(0, 177, 240, 0.16);
  padding: 0.85rem 0.95rem;
}

.category-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.category-choice {
  border: 1px solid rgba(0, 177, 240, 0.18);
  background: #f7fbff;
  color: var(--text);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 48px;
  font-weight: 700;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.category-choice.active {
  border-color: rgba(0, 177, 240, 0.75);
  background: rgba(0, 177, 240, 0.12);
  color: var(--primary-strong);
  box-shadow: 0 8px 20px -18px rgba(0, 177, 240, 0.7);
}

.category-choice:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.message-textarea {
  min-height: 84px;
  max-height: 160px;
  resize: vertical;
  line-height: 1.35;
}

.input-with-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
}

/* Modal composer */
.composer-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 2000;
}

.composer-modal.show {
  display: flex;
}

.composer-dialog {
  width: min(520px, 90vw);
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(0, 177, 240, 0.12);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.3);
  padding: 1.1rem 1.2rem 1.25rem;
}

.reset-card {
  max-width: 90%;
}

.composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-weight: 700;
  color: var(--primary-strong);
}

.composer-header .btn-close {
  box-shadow: none;
}

.send-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.send-btn:disabled {
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

@media (max-width: 768px) {
  .login-wrapper {
    padding: clamp(0.5rem, 2.4vw, 0.9rem);
  }
  .login-content {
    width: min(100%, 34rem);
  }
  .page-shell { padding: 0.5rem; }
  .chat-frame {
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
    min-height: calc(100dvh - 24px);
    border-radius: 18px;
  }
  .chat-hero {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .hero-title {
    font-size: clamp(2rem, 8.6vw, 2.55rem);
  }
  .chat-thread {
    padding: 0.75rem 0.8rem;
  }
  .brand-mark { width: clamp(120px, 40vw, 180px); }
  .message-row { margin: 0.28rem 0; }
  .message-content { max-width: min(42ch, 76vw); }
  .message-meta {
    font-size: 0.7rem;
    margin-bottom: 2px;
    gap: 0.3rem;
  }
  .client-status-chip {
    padding: 0.11rem 0.34rem;
    font-size: 0.6rem;
  }
  .message-bubble {
    padding: 0.48rem 0.62rem;
    margin-bottom: 3px;
    border-radius: 11px;
    font-size: 0.88rem;
    line-height: 1.28;
    box-shadow: 0 8px 18px -18px rgba(0, 0, 0, 0.28);
  }
  .admin-msg { border-bottom-left-radius: 5px; }
  .client-msg { border-bottom-right-radius: 5px; }
  .reply-bubble {
    padding: 0.35rem 0.5rem;
    margin-bottom: 5px;
    border-radius: 10px;
    font-size: 0.78rem;
    line-height: 1.25;
  }
  .composer-form { flex-direction: column; align-items: stretch; }
  .field-row { min-width: 100%; }
  .input-with-actions { flex-direction: column; align-items: stretch; }
  .send-btn { width: 100%; justify-content: center; }
  .app-meta { font-size: 0.68rem; }
}

@media (max-width: 520px) {
  .login-card {
    justify-content: center;
    padding: clamp(0.8rem, 4vw, 1.2rem);
  }
  .login-content {
    gap: clamp(0.5rem, 1.8vh, 0.85rem);
  }
  .client-login-logo {
    width: clamp(240px, 58vmin, 360px);
  }
  .chat-thread {
    padding: 0.65rem;
  }
  .message-row { margin: 0.22rem 0; }
  .message-content { max-width: 74vw; }
  .message-meta { font-size: 0.68rem; }
  .client-status-chip { font-size: 0.58rem; }
  .message-bubble {
    padding: 0.42rem 0.55rem;
    border-radius: 10px;
    font-size: 0.84rem;
    line-height: 1.24;
  }
  .client-app-meta {
    margin-top: 0.08rem;
  }
}

@media (max-height: 640px) {
  .login-card {
    justify-content: flex-start;
  }
  .login-content {
    justify-content: flex-start;
    padding: 0.25rem 0;
  }
  .client-login-logo {
    width: clamp(155px, 34vmin, 240px);
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert {
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 24px -20px rgba(0, 0, 0, 0.45);
}

/* Welcome modal */
.welcome-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 2100;
}
.welcome-modal.show { display: flex; }
.welcome-dialog {
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(0, 177, 240, 0.15);
  box-shadow: 0 24px 60px -30px rgba(0,0,0,0.35);
  padding: 1rem 1.1rem 1.1rem;
}
.welcome-header { border-bottom: 1px solid rgba(0, 0, 0, 0.06); padding-bottom: 0.35rem; margin-bottom: 0.35rem; }
.welcome-message { font-size: 1rem; color: var(--text); }
