:root {
  --ink: #07060d;
  --ink-2: #100e18;
  --card: rgba(22, 18, 32, 0.72);
  --line: rgba(255, 236, 210, 0.1);
  --text: #f6efe4;
  --mute: #b7ab9c;
  --lime: #d6f36b;
  --peach: #ffb48a;
  --lilac: #d7b4ff;
  --mint: #7ee0c6;
  --danger: #ff8b8b;
  --ok: #9dffb0;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: "Manrope", system-ui, sans-serif;
}

body {
  padding: 18px 16px 40px;
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(214, 243, 107, 0.22), transparent 42%),
    radial-gradient(ellipse at 90% 10%, rgba(215, 180, 255, 0.2), transparent 40%),
    radial-gradient(ellipse at 50% 100%, rgba(255, 180, 138, 0.16), transparent 45%);
  animation: drift 16s ease-in-out infinite alternate;
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

header, .stats, .tabs, main, .gate, .sheet { position: relative; z-index: 2; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  animation: rise 0.7s ease both;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 {
  font-family: "Unbounded", sans-serif;
  font-size: 22px;
  letter-spacing: 0.08em;
}
.brand p { color: var(--mute); font-size: 12px; margin-top: 2px; }

.bolt {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--lime), var(--peach));
  font-size: 22px;
  box-shadow: 0 8px 24px rgba(214, 243, 107, 0.25);
  animation: pop 2.8s ease-in-out infinite;
}

.live-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.live-pill i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 0 rgba(214, 243, 107, 0.7);
  animation: ping 1.6s infinite;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat {
  padding: 12px 10px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  animation: rise 0.8s ease both;
}
.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }
.stat b {
  display: block;
  font-family: "Unbounded", sans-serif;
  font-size: 18px;
  margin-bottom: 4px;
}
.stat span { color: var(--mute); font-size: 11px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  overflow-x: auto;
}
.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--mute);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 8px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tabs button.on {
  color: #1a1408;
  background: linear-gradient(135deg, var(--lime), #f5ffb8);
}

.page { display: none; }
.page.on { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  margin-bottom: 10px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}
.card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.kicker {
  font-size: 12px;
  color: var(--mute);
  font-weight: 700;
}
.time { font-size: 11px; color: var(--mute); }
.card p { font-size: 14px; line-height: 1.45; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(214, 243, 107, 0.12);
  color: var(--lime);
}
.chip.wait { background: rgba(255, 180, 138, 0.14); color: var(--peach); }
.chip.human { background: rgba(255, 139, 139, 0.14); color: var(--danger); }
.chip.ok { background: rgba(157, 255, 176, 0.14); color: var(--ok); }

.acc {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.avatar {
  width: 44px; height: 44px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-family: "Unbounded", sans-serif;
  background: linear-gradient(160deg, var(--lilac), var(--mint));
  color: #160e22;
  font-size: 16px;
  flex-shrink: 0;
}
.meta { color: var(--mute); font-size: 12px; margin-top: 3px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
button.ghost, .row-btns button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--mute);
}
.empty b {
  display: block;
  font-family: "Unbounded", sans-serif;
  color: var(--text);
  margin-bottom: 8px;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(5, 4, 10, 0.55);
  display: grid;
  align-items: end;
}
.sheet[hidden],
.gate[hidden] {
  display: none !important;
}
.sheet-card {
  background: #14111c;
  border-top: 1px solid var(--line);
  border-radius: 28px 28px 0 0;
  padding: 18px 16px 28px;
  animation: up 0.28s ease;
}
.sheet-card h3 {
  font-family: "Unbounded", sans-serif;
  font-size: 16px;
  margin-bottom: 12px;
}
textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0d0b14;
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 10px;
}
textarea { min-height: 140px; resize: vertical; }
.sheet-actions { display: flex; gap: 8px; }
.sheet-actions button, #gateBtn {
  flex: 1;
  border: 0;
  border-radius: 14px;
  padding: 12px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}
.primary { background: linear-gradient(135deg, var(--lime), #f5ffb8); color: #1a1408; }
.dim { background: rgba(255,255,255,0.06); color: var(--text); }

.gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(7,6,13,0.88);
}
.gate-card {
  width: min(360px, 92vw);
  padding: 24px;
  border-radius: 28px;
  background: #14111c;
  border: 1px solid var(--line);
  text-align: center;
}
.gate-card h2 { font-family: "Unbounded", sans-serif; margin: 12px 0 8px; }
.gate-card p { color: var(--mute); margin-bottom: 14px; }
.gate-err { color: var(--danger) !important; font-size: 13px; }

.chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
  margin-bottom: 12px;
}
.bubble {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
}
.bubble.client { background: rgba(215,180,255,0.16); align-self: flex-start; }
.bubble.ai { background: rgba(214,243,107,0.16); align-self: flex-end; }

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(3%, 2%, 0) scale(1.05); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes up {
  from { transform: translateY(24px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
@keyframes ping {
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes pop {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.06); }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
