/* ─── Reset & Base ─────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #050c17;
  --surface: #0d1b2a;
  --surface2: #112236;
  --border: rgba(100, 180, 255, 0.10);
  --border-glow: rgba(100, 180, 255, 0.25);

  --cyan: #6ee7f7;
  --violet: #a78bfa;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --blue: #3b82f6;

  --text: #e2eaf6;
  --muted: #64748b;
  --dim: #334155;

  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Mono', monospace;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);

  --transition: 0.25s cubic-bezier(.4, 0, .2, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(110, 231, 247, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(167, 139, 250, 0.05) 0%, transparent 70%);
}

/* ─── Device Mockup ─────────────────────────────────── */
.device-scaffold {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.device-mockup {
  position: relative;
  width: 390px;
  height: 844px;
  max-width: 100%;
  max-height: 88vh;
  background: var(--bg);
  border: 10px solid #1e293b;
  border-radius: 48px;
  box-shadow:
    0 0 0 2px #334155,
    inset 0 0 0 2px #000,
    0 40px 80px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(110, 231, 247, 0.1);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Scrollbar adjustment for device */
.device-mockup::-webkit-scrollbar {
  width: 4px;
}

.device-mockup::-webkit-scrollbar-track {
  background: transparent;
}

.device-mockup::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}

.device-notch {
  position: sticky;
  top: 0;
  width: 140px;
  height: 28px;
  background: #1e293b;
  margin: 0 auto -28px;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  z-index: 1000;
  box-shadow: inset 0 -2px 5px rgba(0, 0, 0, 0.5);
}

/* ─── Scrollbars ────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--dim);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ─── Header ────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(5, 12, 23, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding-top: 28px;
  /* Room for notch */
}

.header-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-icon svg {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 0 10px rgba(110, 231, 247, 0.4));
}

.brand-name {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  border-radius: 99px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  transition: background var(--transition), box-shadow var(--transition);
}

.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* ─── Main Layout ───────────────────────────────────── */
.main {
  flex: 1;
  width: 100%;
  padding: 1rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  align-items: stretch;
}

/* ─── Card ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--border-glow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.card-icon {
  font-size: 1.05rem;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  flex: 1;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

/* ─── Mic Control ───────────────────────────────────── */
.mic-visual {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 140px;
  margin-bottom: 0.8rem;
}

.mic-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(110, 231, 247, 0.15);
  transition: transform var(--transition), opacity var(--transition);
}

.ring-outer {
  width: 120px;
  height: 120px;
}

.ring-inner {
  width: 86px;
  height: 86px;
}

.mic-ring.listening {
  animation: ring-pulse 1.8s ease-in-out infinite;
  border-color: rgba(110, 231, 247, 0.4);
}

.ring-inner.listening {
  animation-delay: 0.2s;
}

@keyframes ring-pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.6;
  }

  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

.mic-btn {
  position: relative;
  z-index: 2;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--surface2), #1c3a58);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 rgba(110, 231, 247, 0.3);
  transition: transform 0.2s, box-shadow 0.3s, background 0.3s;
}

.mic-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 0 22px rgba(110, 231, 247, 0.3);
}

.mic-btn.active {
  background: linear-gradient(135deg, rgba(110, 231, 247, 0.15), rgba(167, 139, 250, 0.15));
  box-shadow:
    0 0 0 3px rgba(110, 231, 247, 0.35),
    0 0 28px rgba(110, 231, 247, 0.25);
  color: #fff;
  animation: btn-pulse 2s ease-in-out infinite;
}

@keyframes btn-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(110, 231, 247, 0.35), 0 0 28px rgba(110, 231, 247, 0.25);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(110, 231, 247, 0.15), 0 0 40px rgba(110, 231, 247, 0.4);
  }
}

.mic-icon {
  width: 28px;
  height: 28px;
}

.mic-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

/* ─── Gauge ─────────────────────────────────────────── */
.gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.gauge-svg {
  width: 100%;
  max-width: 200px;
  overflow: visible;
}

#gauge-arc {
  transition: stroke-dashoffset 0.6s cubic-bezier(.4, 0, .2, 1);
}

#gauge-needle {
  transition: transform 0.6s cubic-bezier(.4, 0, .2, 1);
}

.gauge-label {
  text-align: center;
  margin-top: -0.3rem;
}

.gauge-value {
  display: block;
  font-size: 2.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.gauge-emotion {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ─── Emotion Pills ─────────────────────────────────── */
.emotion-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.pill {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface2);
  transition: all var(--transition);
  letter-spacing: 0.03em;
}

.pill.active[data-emotion="calm"] {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.2);
}

.pill.active[data-emotion="stress"] {
  background: rgba(234, 179, 8, 0.12);
  border-color: var(--yellow);
  color: var(--yellow);
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.2);
}

.pill.active[data-emotion="fear"] {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.pill.active[data-emotion="anger"] {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

/* ─── Transcript ────────────────────────────────────── */
.transcript-card {
  flex: none;
}

.transcript-box {
  min-height: 180px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  position: relative;
}

.transcript-placeholder {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
}

.transcript-lines {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transcript-line {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  animation: fadeSlideIn 0.35s ease-out;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.t-seq {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  min-width: 50px;
  padding-top: 2px;
}

.t-text {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.55;
  flex: 1;
}

.t-badge {
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  border: 1px solid;
  white-space: nowrap;
  align-self: center;
}

.t-badge.calm {
  color: var(--green);
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.08);
}

.t-badge.stress {
  color: var(--yellow);
  border-color: var(--yellow);
  background: rgba(234, 179, 8, 0.08);
}

.t-badge.fear {
  color: var(--blue);
  border-color: var(--blue);
  background: rgba(59, 130, 246, 0.08);
}

.t-badge.anger {
  color: var(--red);
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.08);
}

.t-score {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  padding-top: 2px;
  min-width: 36px;
  text-align: right;
}

/* ─── Seq badge & buttons ───────────────────────────── */
.seq-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--cyan);
  background: rgba(110, 231, 247, 0.08);
  border: 1px solid rgba(110, 231, 247, 0.2);
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  letter-spacing: 0.05em;
  margin-left: auto;
}

.clear-btn,
.copy-btn {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}

.clear-btn:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(239, 68, 68, 0.08);
}

.copy-btn {
  margin-left: 0.4rem;
}

.copy-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(110, 231, 247, 0.08);
}

/* ─── JSON Stream ───────────────────────────────────── */
.json-card {
  flex: 1;
}

.json-box {
  min-height: 200px;
  max-height: 340px;
  overflow-y: auto;
  background: #030a12;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.json-placeholder {
  color: var(--dim);
  font-style: italic;
}

.json-entry {
  animation: fadeSlideIn 0.3s ease-out;
}

.json-entry pre {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Syntax highlight tokens */
.jk {
  color: #a78bfa;
}

/* key */
.js {
  color: #6ee7f7;
}

/* string value */
.jn {
  color: #fb923c;
}

/* number */
.jp {
  color: #64748b;
}

/* punctuation */
.jc {
  color: #22c55e;
}

/* calm */
.jst {
  color: #eab308;
}

/* stress */
.jf {
  color: #3b82f6;
}

/* fear */
.ja {
  color: #ef4444;
}

/* anger */

.json-entry-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
  font-size: 0.67rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.json-tone-bar {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  margin-bottom: 0.35rem;
  position: relative;
  overflow: visible;
}

.json-tone-bar::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
  left: var(--tone-pct, 0%);
  transition: left 0.5s ease;
}

/* ─── Footer ────────────────────────────────────────── */
.footer {
  background: rgba(5, 12, 23, 0.9);
  border-top: 1px solid var(--border);
  padding: 0.7rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ─── Alert Banner ──────────────────────────────────── */
.alert-banner {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  padding: 0.7rem 1.4rem;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  text-align: center;
  width: 90%;
}

.alert-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 500px) {
  .device-mockup {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border: none;
    border-radius: 0;
  }

  .device-notch {
    display: none;
  }

  .header {
    padding-top: 0;
  }

  body {
    padding: 0;
  }
}