/* ScaleForge — shared design system */
:root {
  --accent: #6d5cff;
  --accent-2: #00d4ff;
  --bg: #07070c;
  --bg-2: #0c0c15;
  --panel: rgba(13, 13, 21, 0.72);
  --panel-strong: rgba(24, 24, 36, 0.85);
  --line: rgba(255, 255, 255, 0.09);
  --line-bright: rgba(255, 255, 255, 0.16);
  --text: #f2f3f8;
  --muted: #8b8da3;
  --dim: #5a5c73;
  --ok: #34d399;
  --warn: #fbbf24;
  --hot: #fb7185;
  --radius: 18px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* animated mesh background */
.mesh { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.mesh i {
  position: absolute; display: block; border-radius: 50%;
  filter: blur(120px); opacity: 0.28; mix-blend-mode: screen;
  animation: drift 26s ease-in-out infinite;
}
.mesh i:nth-child(1) { width: 46vw; height: 46vw; left: -8vw; top: -12vw; background: var(--accent); }
.mesh i:nth-child(2) { width: 38vw; height: 38vw; right: -6vw; top: 8vh; background: var(--accent-2); animation-delay: -9s; }
.mesh i:nth-child(3) { width: 42vw; height: 42vw; left: 30vw; bottom: -18vw; background: #ff5c9d; animation-delay: -17s; opacity: 0.16; }
.mesh::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 0%, rgba(7,7,12,0.35), rgba(7,7,12,0.82) 70%);
}
@keyframes drift {
  0%, 100% { transform: translate3d(0,0,0) scale(1); }
  33% { transform: translate3d(6vw, 4vh, 0) scale(1.12); }
  66% { transform: translate3d(-5vw, -3vh, 0) scale(0.94); }
}
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.035;
  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='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell { position: relative; z-index: 2; min-height: 100%; display: flex; flex-direction: column; }

/* topbar */
.topbar {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 18px;
  padding: 20px 28px; border-bottom: 1px solid var(--line);
  background: rgba(7,7,12,0.72); backdrop-filter: blur(20px);
  animation: headerin 1s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes headerin { from { opacity: 0; transform: translateY(-14px); } }

/* one prismatic pass as the page settles */
.topbar::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 36%, rgba(120,180,255,0.09) 46%,
              rgba(255,255,255,0.13) 50%, rgba(255,140,200,0.09) 54%, transparent 64%);
  transform: translateX(-130%);
  animation: prism 1.8s cubic-bezier(0.22, 1, 0.36, 1) 0.5s both;
}

/* a live edge along the bottom while a call is running */
.topbar::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 1px; width: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  background-size: 45% 100%; background-repeat: no-repeat;
  opacity: 0; transition: opacity 0.5s;
}
body[data-callphase]:not([data-callphase="idle"]) .topbar::after {
  opacity: 1; animation: edgerun 2.8s linear infinite;
}
@keyframes edgerun {
  from { background-position: -50% 0; }
  to   { background-position: 150% 0; }
}

.brand span { animation: brandin 0.8s cubic-bezier(0.16,1,0.3,1) 0.15s both; }
@keyframes brandin { from { opacity: 0; transform: translateX(-8px); } }

@media (prefers-reduced-motion: reduce) {
  .topbar, .topbar::before, .brand span, .brand .mark i { animation: none; }
  .topbar::after { opacity: 0; }
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 650; letter-spacing: -0.02em; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 22px -4px var(--accent);
}
/* the mark is a voice meter, and it behaves like one */
.brand .mark i {
  display: block; width: 2px; border-radius: 2px; background: #fff;
  height: 5px; opacity: 0.92;
  animation: meter 1.5s ease-in-out infinite;
  animation-play-state: paused;
}
.brand .mark { gap: 2px; }
.brand .mark i { flex: 0 0 2px; }
.brand .mark i:nth-child(1) { animation-delay: 0.00s; --peak: 7px; }
.brand .mark i:nth-child(2) { animation-delay: 0.16s; --peak: 13px; }
.brand .mark i:nth-child(3) { animation-delay: 0.32s; --peak: 17px; }
.brand .mark i:nth-child(4) { animation-delay: 0.10s; --peak: 11px; }
.brand .mark i:nth-child(5) { animation-delay: 0.26s; --peak: 6px; }
@keyframes meter {
  0%, 100% { height: 4px; }
  50%      { height: var(--peak, 12px); }
}

/* idle: a slow breath. during a call: alive, and quicker while speaking */
body[data-callphase] .brand .mark i { animation-play-state: running; }
body[data-callphase="idle"] .brand .mark i { animation-duration: 3.4s; opacity: 0.6; }
body[data-callphase="listening"] .brand .mark i { animation-duration: 1.5s; }
body[data-callphase="thinking"] .brand .mark i { animation-duration: 0.75s; }
body[data-callphase="speaking"] .brand .mark i { animation-duration: 0.5s; }

.brand .mark svg { width: 16px; height: 16px; }
.brand .mark.img { background: none; box-shadow: none; width: auto; height: 32px; max-width: 150px; border-radius: 0; object-fit: contain; }
.brand small { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.navlink {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 550;
  padding: 8px 14px; border-radius: 10px; border: 1px solid transparent; transition: 0.18s;
}
.navlink:hover { color: var(--text); background: var(--panel); border-color: var(--line); }
.navlink.active { color: var(--text); background: var(--panel-strong); border-color: var(--line-bright); }

/* generic bits */
.pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.05); color: var(--muted); letter-spacing: 0.01em;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.live { color: var(--ok); border-color: rgba(52,211,153,0.3); background: rgba(52,211,153,0.08); }
.pill.live .dot { background: var(--ok); animation: blip 1.6s ease-in-out infinite; }
.pill.hot { color: var(--hot); border-color: rgba(251,113,133,0.3); background: rgba(251,113,133,0.09); }
.pill.warm { color: var(--warn); border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.09); }
@keyframes blip { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }

.btn {
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 12px 22px; border-radius: 12px; border: 1px solid var(--line-bright);
  background: var(--panel-strong); color: var(--text); transition: 0.18s;
}
.btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 32px -12px var(--accent);
}
.btn.primary:hover { box-shadow: 0 14px 40px -10px var(--accent); }
.btn.danger { background: rgba(251,113,133,0.13); border-color: rgba(251,113,133,0.35); color: #ffa8b6; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.sm { padding: 8px 14px; font-size: 12.5px; border-radius: 10px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 24px 60px -30px rgba(0,0,0,0.9);
}
.panel-head {
  display: flex; align-items: center; gap: 10px; padding: 15px 18px;
  border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted);
}
.panel-head .count {
  margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-strong); border: 1px solid var(--line); color: var(--dim); letter-spacing: 0;
}

input, textarea, select {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: rgba(0,0,0,0.28); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; width: 100%; transition: 0.16s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,92,255,0.16);
}
label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.03em; }
textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
