:root {
  --navy: #1b3a6b;
  --navy-dark: #112850;
  --green: #1e9b5a;
  --green-dark: #167a46;
  --green-light: #e6f5ee;
  --white: #fff;
  --gray: #f4f5f7;
  --text: #1a1a1a;
  --text-secondary: #555;
  --border: #e0e0e0;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray);
  color: var(--text);
  min-height: 100vh;
}

.header {
  background: var(--navy);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo-img {
  height: 36px;
  width: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.header-title {
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.live-badge {
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 5px 12px;
  border-radius: 100px;
}

.live-badge.visible {
  display: flex;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #ff4444;
  border-radius: 50%;
  animation: blink 1.2s ease-in-out infinite;
}

.live-text {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  height: calc(100vh - 61px);
}

.main {
  overflow-y: auto;
  padding: 20px;
}

.sidebar {
  background: #fff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.state {
  display: none;
}

.state.active {
  display: block;
}

.waiting-card,
.ended-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.waiting-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 12px;
}

.waiting-title,
.ended-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--navy);
  margin-bottom: 8px;
}

.waiting-subtitle,
.ended-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
}

.promo-code {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 10px;
  border-radius: 8px;
  background: #eef6ff;
  color: var(--navy);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.promo-urgency {
  font-size: 15px;
  font-weight: 600;
  color: #c2410c;
  margin-bottom: 12px;
  line-height: 1.5;
}

.promo-timer {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
}

.waiting-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

.viewers-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 24px;
}

.timer-section {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  margin-bottom: 20px;
}

.timer-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.timer-digits {
  display: flex;
  justify-content: center;
  gap: 12px;
}

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

.timer-num {
  font-size: 48px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  min-width: 64px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  display: block;
}

.timer-unit {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.timer-sep {
  font-size: 40px;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
  padding-top: 8px;
}

.agenda-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

.agenda-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
}

.agenda-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.agenda-item:last-child {
  border-bottom: none;
}

.agenda-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.agenda-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.video-wrapper {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
  margin-bottom: 16px;
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-overlay-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: 5px 12px;
  border-radius: 100px;
  pointer-events: none;
  z-index: 2;
}

.video-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  gap: 8px;
}

.video-btn {
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.progress-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  z-index: 2;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  width: 0%;
  transition: width 0.5s linear;
}

.video-info {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.video-info-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.viewers-live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.viewers-num {
  font-weight: 700;
  color: var(--text);
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}

.chat-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9f9f9;
  min-height: 0;
}

.chat-msg {
  display: flex;
  gap: 8px;
  padding: 2px 4px;
  margin: 0 -4px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.chat-msg-highlight {
  background: rgba(27, 58, 107, 0.1);
}

.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-avatar.has-photo {
  padding: 0;
  overflow: hidden;
  background: transparent;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-bubble {
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  max-width: calc(100% - 40px);
  border: 1px solid var(--border);
}

.chat-bubble.moderator {
  border-color: var(--green);
  background: var(--green-light);
}

.chat-bubble.self {
  border-color: #ccc;
  background: #f0f0f0;
}

.chat-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 2px;
}

.chat-name.moderator {
  color: var(--green-dark);
}

.chat-reply-quote {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid var(--green-dark);
  background: rgba(255, 255, 255, 0.65);
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 6px;
  cursor: pointer;
  font: inherit;
}

.chat-reply-quote:hover {
  background: rgba(255, 255, 255, 0.9);
}

.chat-reply-quote-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 2px;
}

.chat-reply-quote-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chat-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

.chat-time {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.chat-typing {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 16px 8px;
  background: #f9f9f9;
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-typing.visible {
  display: flex;
}

.chat-typing-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-typing-dots {
  display: flex;
  gap: 3px;
}

.chat-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: chatTypingDot 1.2s infinite ease-in-out;
}

.chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chatTypingDot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.chat-gate {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  background: var(--gray);
}

.chat-input:focus {
  border-color: var(--green);
}

.chat-input:disabled {
  opacity: 0.6;
}

.chat-send {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.chat-send:hover:not(:disabled) {
  background: var(--green-dark);
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.chat-gate.hidden {
  display: none;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 16px;
  margin-bottom: 12px;
}

.modal-btn {
  width: 100%;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.modal-error {
  color: #c0392b;
  font-size: 13px;
  margin-bottom: 8px;
  min-height: 18px;
}

.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 14px 18px;
  border-radius: 10px;
  max-width: min(92vw, 480px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  z-index: 300;
  cursor: pointer;
  display: none;
}

.toast.visible {
  display: block;
  animation: toast-in 0.25s ease;
}

.toast-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 4px;
}

.toast-question {
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 6px;
  border-left: 2px solid var(--green);
  padding-left: 8px;
}

.toast-body {
  font-size: 14px;
  line-height: 1.4;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.cta-btn {
  display: inline-block;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  margin-top: 8px;
}

.dev-switch {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 999;
}

.dev-switch.visible {
  display: flex;
}

.dev-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

@media (max-width: 768px) {
  .header {
    padding: 10px 12px;
    gap: 8px;
  }

  .header-logo {
    gap: 8px;
    min-width: 0;
    flex: 1;
  }

  .header-logo-img {
    height: 30px;
    width: 30px;
  }

  .header-title {
    font-size: 12px;
    line-height: 1.2;
  }

  .header .live-badge {
    flex-shrink: 0;
    padding: 3px 7px;
    gap: 4px;
  }

  .header .live-dot {
    width: 6px;
    height: 6px;
  }

  .header .live-text {
    font-size: 9px;
    letter-spacing: 0.2px;
    white-space: nowrap;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 61px);
  }

  .main {
    padding: 12px;
  }

  .sidebar {
    height: min(55vh, 520px);
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .timer-num {
    font-size: 36px;
    min-width: 50px;
  }

  .waiting-title,
  .ended-title {
    font-size: 22px;
  }

  .timer-digits {
    gap: 8px;
  }

  .toast {
    top: auto;
    bottom: 16px;
  }
}
