/* ============================================================
   XRZ — Design tokens
   ============================================================ */
:root {
  --primary: #2563EB;
  --secondary: #1D4ED8;
  --bg: #0B1220;
  --card: #111827;
  --border: #1E293B;
  --text: #FFFFFF;
  --text-2: #94A3B8;
  --success: #22C55E;
  --danger: #EF4444;

  --radius: 18px;
  --radius-sm: 12px;
  --border-w: 2.5px;
  --shadow-block: 6px 6px 0 rgba(37, 99, 235, 0.35);
  --shadow-block-hover: 9px 9px 0 rgba(37, 99, 235, 0.45);
  --glow: 0 0 0 1px rgba(37,99,235,.25), 0 0 32px rgba(37,99,235,.25);
  --ease: cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(37,99,235,.16), transparent 60%),
    radial-gradient(900px 500px at 100% 10%, rgba(29,78,216,.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--primary); color: white; }

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11,18,32,.75);
  backdrop-filter: blur(10px);
  border-bottom: var(--border-w) solid var(--border);
}
.topbar-inner {
  max-width: 1040px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .5px; font-size: 18px; }
.topbar-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-off { background: var(--text-2); }
.dot-on { background: var(--success); box-shadow: 0 0 0 4px rgba(34,197,94,.18); }

/* ============================================================
   Layout / Screens
   ============================================================ */
#app { max-width: 1040px; margin: 0 auto; padding: 48px 20px 80px; }

.screen { display: none; animation: fadeSlide .45s var(--ease); }
.screen.active { display: block; }

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

/* ============================================================
   Cards (NeoBrutalist blocks)
   ============================================================ */
.hero-card, .panel-card, .chat-shell {
  background: var(--card);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-block);
}

.hero-card {
  padding: 56px 44px;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(37,99,235,.10), transparent 45%);
  pointer-events: none;
}

.eyebrow {
  display: inline-block;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--primary);
  background: rgba(37,99,235,.12);
  border: 1.5px solid rgba(37,99,235,.35);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 22px;
}

.hero-card h1 {
  font-size: clamp(36px, 6vw, 58px);
  line-height: 1.05;
  margin: 0 0 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.lead { color: var(--text-2); font-size: 18px; max-width: 46ch; margin: 0 0 32px; }

.hero-actions { margin-bottom: 20px; }

.hero-links { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; }
.sep { opacity: .4; }

.hero-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
.meta-card {
  background: var(--card);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.meta-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-block); }
.meta-card strong { font-size: 22px; }
.meta-card span { font-size: 13px; color: var(--text-2); }

/* Panel (consent / queue) */
.panel-card { padding: 44px; max-width: 560px; margin: 0 auto; }
.panel-card.center { text-align: center; }
.panel-card h2 { font-size: 26px; margin: 0 0 6px; font-weight: 800; }
.muted { color: var(--text-2); font-size: 14px; margin: 0 0 20px; }

.check-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
.check-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.02);
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.check-row:hover { border-color: var(--primary); }
.consent-box {
  appearance: none; width: 20px; height: 20px; flex: 0 0 20px;
  border: var(--border-w) solid var(--text-2);
  border-radius: 6px; margin-top: 1px;
  display: grid; place-items: center;
  transition: all .15s var(--ease);
}
.consent-box:checked {
  background: var(--primary); border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.2);
}
.consent-box:checked::after {
  content: "✓"; color: white; font-size: 13px; font-weight: 800;
}
.inline-link { background: none; border: none; color: var(--primary); font: inherit; text-decoration: underline; padding: 0; cursor: pointer; }

.panel-actions { display: flex; justify-content: flex-end; gap: 12px; }

/* Queue pulse */
.pulse-ring {
  width: 88px; height: 88px; margin: 4px auto 24px;
  border-radius: 50%;
  border: var(--border-w) solid var(--primary);
  display: grid; place-items: center;
  animation: ring 1.8s ease-out infinite;
}
.pulse-core { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); box-shadow: var(--glow); }
@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(37,99,235,.35); }
  70% { box-shadow: 0 0 0 22px rgba(37,99,235,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  border: var(--border-w) solid transparent;
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  font-weight: 700;
  font-size: 15px;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background .12s var(--ease), border-color .12s var(--ease);
}
.btn:active { transform: translateY(2px); }
.btn-lg { padding: 17px 30px; font-size: 16.5px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-primary {
  background: var(--primary); color: white; border-color: #0B1220;
  box-shadow: 4px 4px 0 rgba(0,0,0,.35);
}
.btn-primary:hover { background: var(--secondary); box-shadow: 6px 6px 0 rgba(0,0,0,.4); transform: translateY(-2px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: transparent; color: var(--text); border-color: var(--primary);
}
.btn-secondary:hover { background: rgba(37,99,235,.12); }

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

.btn-danger { background: var(--danger); color: white; border-color: #0B1220; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-danger:disabled { opacity: .4; cursor: not-allowed; }

.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-outline:hover { background: rgba(239,68,68,.1); }

.link-btn { background: none; border: none; color: var(--text-2); font-size: 14px; text-decoration: underline; padding: 0; }
.link-btn:hover { color: var(--text); }

/* ============================================================
   Chat
   ============================================================ */
.chat-shell { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; height: 640px; overflow: hidden; position: relative; }
.chat-body-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-body-wrap::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
  background: linear-gradient(to bottom, rgba(17,24,39,0), var(--card) 92%);
  pointer-events: none;
}

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: var(--border-w) solid var(--border);
}
.chat-partner { display: flex; align-items: center; gap: 12px; }
.chat-sub { font-size: 12.5px; color: var(--text-2); }
.chat-header-actions { display: flex; gap: 8px; }

.chat-body { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }

.system-msg {
  align-self: center; color: var(--text-2); font-size: 12.5px;
  background: rgba(255,255,255,.03); border: 1.5px solid var(--border);
  padding: 6px 14px; border-radius: 999px;
}

.msg-bubble {
  max-width: 72%; padding: 11px 16px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.4;
  border: var(--border-w) solid var(--border);
  animation: pop .18s var(--ease);
  word-wrap: break-word;
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }

.msg-me { align-self: flex-end; background: var(--primary); border-color: #0B1220; color: white; }
.msg-them { align-self: flex-start; background: #0F1729; }
.msg-time { display: block; font-size: 10.5px; opacity: .6; margin-top: 4px; }

.typing-row { padding: 6px 22px; font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.typing-row[hidden] { display: none; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-2); animation: bounce 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-input-row { display: flex; gap: 10px; padding: 16px 22px; border-top: var(--border-w) solid var(--border); }
.chat-input-row input {
  flex: 1; background: #0F1729; border: var(--border-w) solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; color: var(--text); font-size: 14.5px; outline: none;
  transition: border-color .15s var(--ease);
}
.chat-input-row input:focus { border-color: var(--primary); box-shadow: var(--glow); }

.chat-footer-actions { padding: 0 22px 18px; display: flex; justify-content: center; }
.chat-footer-actions .btn { width: 100%; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,8,16,.7); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 50; padding: 20px;
  animation: fadeIn .2s var(--ease);
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--card); border: var(--border-w) solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-block-hover);
  padding: 32px; max-width: 440px; width: 100%;
  animation: fadeSlide .25s var(--ease);
}
.modal-card h3 { margin: 0 0 6px; font-size: 20px; }

.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.reason-chip {
  border: var(--border-w) solid var(--border); background: transparent; color: var(--text);
  padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 600;
  transition: all .12s var(--ease);
}
.reason-chip:hover { border-color: var(--danger); }
.reason-chip.selected { background: var(--danger); border-color: var(--danger); color: white; }

.modal-card textarea {
  width: 100%; min-height: 70px; resize: vertical;
  background: #0F1729; border: var(--border-w) solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; color: var(--text); font-size: 13.5px; margin-bottom: 18px; outline: none;
}
.modal-card textarea:focus { border-color: var(--primary); }

/* ============================================================
   Toasts
   ============================================================ */
.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast {
  background: var(--card); border: var(--border-w) solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 10px; padding: 12px 16px; font-size: 13.5px; box-shadow: var(--shadow-block);
  animation: slideIn .25s var(--ease);
  min-width: 220px;
}
.toast.danger { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slideIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }

/* ============================================================
   Skeleton
   ============================================================ */
.skeleton { background: linear-gradient(90deg, #111827 25%, #1a2436 37%, #111827 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .hero-card { padding: 36px 24px; }
  .hero-meta { grid-template-columns: 1fr; }
  .chat-shell { height: calc(100vh - 160px); border-radius: 14px; }
  .panel-card { padding: 30px 22px; }
  .reason-grid { grid-template-columns: 1fr; }
}
