@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap");

:root {
  --bg: #f8f8f6;
  --white: #ffffff;
  --border: #e4e4e0;
  --border2: #d0d0ca;
  --text: #1a1a18;
  --muted: #6b6b65;
  --light: #f0f0ec;
  --accent: #1a6b3c;
  --accent-light: #e8f5ee;
  --accent-hover: #155730;
  --warn: #b45309;
  --warn-light: #fef3c7;
  --danger: #991b1b;
  --danger-light: #fef2f2;
  --success: #166534;
  --success-light: #dcfce7;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  padding: 24px 16px 48px;
}

/* ── Tab Warning ─────────────────────────────────── */
#tabWarning {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#tabWarning.show {
  display: flex;
}

.tw-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  max-width: 360px;
  box-shadow: var(--shadow-md);
}
.tw-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.tw-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.tw-msg {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ── Widget Wrapper ───────────────────────────────── */
.widget-wrap {
  max-width: 860px;
  margin: 0 auto;
}

/* ── Header ──────────────────────────────────────── */
.widget-header {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.header-left {
  flex: 1;
}
.header-badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.header-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
}
.header-sub {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}
.header-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.trust-item {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Permission Screen — compact banner ──────────────── */
.perm-screen {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 0;
  flex-wrap: wrap;
}
.perm-left {
  flex: 1;
}
.perm-badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 6px;
}
.perm-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}
.perm-sub {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}
.perm-right {
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius);
  font-family: "DM Sans", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s;
  letter-spacing: 0.01em;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ── Main Widget ─────────────────────────────────── */
.main-widget {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* ── Status Row ──────────────────────────────────── */
.status-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--light);
  flex-wrap: wrap;
}
.s-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  color: var(--muted);
  padding: 4px 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: all 0.3s;
}
.s-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d1d1cb;
  transition: all 0.3s;
  display: inline-block;
}
.s-chip.active .s-dot {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.s-chip.active {
  border-color: #b0d9be;
  color: var(--accent);
}
.s-chip.warn .s-dot {
  background: var(--warn);
}
.s-chip.warn {
  border-color: #fcd34d;
  color: var(--warn);
}
.s-chip.fail .s-dot {
  background: var(--danger);
}
.s-chip.fail {
  border-color: #fca5a5;
  color: var(--danger);
}

/* ── Fail Banner ─────────────────────────────────── */
.fail-banner {
  background: var(--danger-light);
  border-bottom: 1px solid #fca5a5;
  padding: 12px 20px;
  font-size: 0.85rem;
  color: var(--danger);
  font-weight: 500;
}

/* ── Completion Screen ────────────────────────────── */
.completion-screen {
  padding: 40px 32px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--success-light);
}
.completion-check {
  font-size: 3rem;
  margin-bottom: 12px;
}
.completion-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 8px;
}
.completion-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 28px;
}

.coupon-box {
  background: var(--white);
  border: 2px dashed #86efac;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 420px;
  margin: 0 auto 24px;
}
.coupon-label {
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.coupon-code {
  font-family: "DM Mono", monospace;
  font-size: 2rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 5px;
  background: var(--accent-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.coupon-instructions {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
}
.coupon-copy-btn {
  width: 100%;
  justify-content: center;
}

.completion-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}
.cs-item {
  text-align: center;
}
.cs-val {
  font-family: "DM Mono", monospace;
  font-size: 1.5rem;
  color: var(--accent);
  font-weight: 500;
}
.cs-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ── Content Grid ─────────────────────────────────── */
.video-panel {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
@media (max-width: 680px) {
  .widget-header {
    flex-direction: column;
    gap: 16px;
  }
  .header-right {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* ── Video Panel ─────────────────────────────────── */
.video-panel {
  border-right: 1px solid var(--border);
}
.video-wrap {
  position: relative;
  background: #000;
}
.video-wrap video {
  width: 100%;
  display: block;
}

.attention-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 11px;
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
  backdrop-filter: blur(4px);
}
.attention-badge.visible {
  opacity: 1;
}
.ab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d1d1cb;
  display: inline-block;
  transition: all 0.3s;
}
.attention-badge.valid .ab-dot {
  background: var(--accent);
  animation: abPulse 1.5s infinite;
}
.attention-badge.valid {
  color: var(--accent);
  border-color: #b0d9be;
}
.attention-badge.invalid .ab-dot {
  background: var(--danger);
}
.attention-badge.invalid {
  color: var(--danger);
  border-color: #fca5a5;
}

@keyframes abPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(26, 107, 60, 0.3);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(26, 107, 60, 0);
  }
}

.video-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity 0.3s;
}
.video-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.overlay-msg {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  max-width: 260px;
  line-height: 1.5;
}
.overlay-hint {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.45);
}

#customControls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #1a1a18;
  border-top: 1px solid #2a2a28;
}
#customControls button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0e0da;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.72rem;
  font-family: "DM Sans", sans-serif;
  transition: background 0.2s;
}
#customControls button:hover {
  background: rgba(255, 255, 255, 0.18);
}
#customControls button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
#customTimeDisplay {
  flex: 1;
  text-align: right;
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
}

.progress-wrap {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.progress-pct {
  font-family: "DM Mono", monospace;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 500;
}
.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #22c55e);
  border-radius: 3px;
  width: 0%;
  transition: width 0.5s ease;
}
.progress-note {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ── Utility ─────────────────────────────────────── */
.hidden {
  display: none !important;
}

* {
  user-select: none;
  -webkit-user-select: none;
}
input,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

/* ── Countdown ───────────────────────────────────── */
.countdown-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
}

.countdown-number {
  font-family: "DM Mono", monospace;
  font-size: 10rem;
  font-weight: 300;
  color: #ffffff;
  line-height: 1;
  text-align: center;
  will-change: transform, opacity, filter;
}

.countdown-sub {
  font-family: "DM Sans", sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  min-height: 1.4em;
}

@keyframes cdSlowPop {
  0% {
    transform: scale(1.8);
    opacity: 0;
    filter: blur(12px);
  }
  25% {
    transform: scale(1.02);
    opacity: 1;
    filter: blur(0px);
  }
  70% {
    transform: scale(1);
    opacity: 1;
    filter: blur(0px);
  }
  100% {
    transform: scale(0.75);
    opacity: 0;
    filter: blur(6px);
  }
}

@keyframes cdFadeUp {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  30% {
    opacity: 1;
    transform: translateY(0);
  }
  70% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ── Face Distance Message ───────────────────────── */
.face-distance-msg {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  border-bottom: 1px solid transparent;
  transition: all 0.3s ease;
}

.face-distance-msg.warn {
  background: linear-gradient(90deg, #fffbeb, var(--warn-light));
  color: #92400e;
  border-color: #fde68a;
  border-left: 3px solid var(--warn);
}

.face-distance-msg.danger {
  background: linear-gradient(90deg, #fff5f5, var(--danger-light));
  color: #7f1d1d;
  border-color: #fecaca;
  border-left: 3px solid var(--danger);
}

.fd-icon {
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ── Countdown ───────────────────────────────────── */
.cd-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.cd-number {
  font-family: "DM Mono", monospace;
  font-size: 9rem;
  font-weight: 300;
  color: #ffffff;
  line-height: 1;
  text-align: center;
  will-change: transform, opacity;
}

@keyframes cdPop {
  0% {
    transform: scale(2);
    opacity: 0;
  }
  30% {
    transform: scale(1);
    opacity: 1;
  }
  75% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.7);
    opacity: 0;
  }
}

.cd-sub {
  font-family: "DM Sans", sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  min-height: 1.4em;
}

/* ── Countdown face status message ──────────────── */
.cd-face-msg {
  font-family: "DM Sans", sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: 20px;
  text-align: center;
  margin-top: 4px;
  transition: all 0.3s ease;
}

.cd-face-msg.ok {
  background: rgba(26, 107, 60, 0.85);
  color: #ffffff;
}

.cd-face-msg.warn {
  background: rgba(180, 83, 9, 0.85);
  color: #ffffff;
}

.cd-face-msg.danger {
  background: rgba(153, 27, 27, 0.85);
  color: #ffffff;
}

/* ── Popup Modal ─────────────────────────────────── */
#avPopup {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
#avPopup.show { display: flex; }

.popup-inner {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 95vh;
  max-height: 95vh;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.popup-status-row {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: #1a1a18;
  border-bottom: 1px solid #2a2a28;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.popup-video-wrap {
  position: relative;
  background: #000;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.popup-video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.popup-progress {
  padding: 10px 16px;
  background: #1a1a18;
  border-top: 1px solid #2a2a28;
  flex-shrink: 0;
}

.popup-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #1a1a18;
  border-top: 1px solid #2a2a28;
  flex-shrink: 0;
}