:root {
  --bg: #f4f7fb;
  --bg-soft: #eef2f8;

  --card: #ffffff;
  --card-hover: #fafbff;

  --accent: #635bdb;
  --accent-hover: #554dcc;
  --accent-light: #eeecff;

  --accent-2: #00a884;
  --accent-2-light: #e7faf5;

  --text: #1c2333;
  --text-soft: #3f4758;
  --muted: #737c90;

  --border: #e2e6ef;
  --border-strong: #d3d9e6;

  --danger: #e5485d;
  --danger-light: #fff0f2;

  --input-bg: #f8f9fc;
  --transcript-user: #f0efff;
  --transcript-assistant: #e9f8f4;

  --shadow-sm: 0 2px 8px rgba(35, 43, 65, 0.06);
  --shadow-md: 0 10px 30px rgba(35, 43, 65, 0.08);
  --shadow-lg: 0 20px 50px rgba(35, 43, 65, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;

  background:
    radial-gradient(
      circle at 50% -10%,
      rgba(99, 91, 219, 0.10),
      transparent 40%
    ),
    linear-gradient(180deg, #f8faff 0%, var(--bg) 100%);

  color: var(--text);

  font-family:
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  display: flex;
  justify-content: center;

  padding: 40px 20px;
}

/* =========================
   APP CONTAINER
========================= */

.app {
  width: 100%;
  max-width: 920px;
}

/* =========================
   HEADER
========================= */

header {
  text-align: center;
  margin-bottom: 28px;
}

header h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text);
}

header h1 span {
  color: var(--accent-2);
  font-weight: 500;
}

.subtitle {
  color: var(--muted);
  margin: 7px 0 0;
  font-size: 14px;
}

/* =========================
   CARDS
========================= */

.card {
  background: rgba(255, 255, 255, 0.94);

  border-radius: 22px;
  padding: 36px;

  margin-bottom: 24px;

  min-height: 520px;

  border: 1px solid rgba(226, 230, 239, 0.9);

  box-shadow:
    var(--shadow-lg),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;

  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.card:hover {
  box-shadow:
    0 24px 60px rgba(35, 43, 65, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.call-card {
  text-align: center;
}

/* =========================
   STATUS
========================= */

.status-dot {
  width: 14px;
  height: 14px;

  border-radius: 50%;

  margin: 0 auto 9px;

  background: #aeb5c4;

  box-shadow: 0 0 0 4px #f0f2f6;

  transition:
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.status-dot.connected {
  background: var(--accent-2);

  box-shadow:
    0 0 0 4px var(--accent-2-light),
    0 0 14px rgba(0, 168, 132, 0.35);
}

.status-dot.listening {
  background: var(--accent);

  box-shadow:
    0 0 0 4px var(--accent-light),
    0 0 14px rgba(99, 91, 219, 0.35);

  animation: pulse 1.2s infinite;
}

.status-dot.error {
  background: var(--danger);

  box-shadow:
    0 0 0 4px var(--danger-light),
    0 0 14px rgba(229, 72, 93, 0.25);
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.35);
  }

  100% {
    transform: scale(1);
  }
}

.status-text {
  color: var(--muted);
  margin-bottom: 18px;
  font-size: 14px;
}

/* =========================
   CALL BUTTON
========================= */

.call-btn {
  appearance: none;

  background:
    linear-gradient(
      135deg,
      var(--accent),
      #8179e8
    );

  border: none;

  color: #ffffff;

  padding: 14px 30px;

  min-width: 150px;

  border-radius: 999px;

  font-size: 15px;
  font-weight: 600;

  cursor: pointer;

  box-shadow:
    0 8px 18px rgba(99, 91, 219, 0.25);

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.call-btn:hover {
  transform: translateY(-2px);

  box-shadow:
    0 12px 24px rgba(99, 91, 219, 0.30);
}

.call-btn:active {
  transform: translateY(0);
}

.call-btn:focus-visible {
  outline: 3px solid rgba(99, 91, 219, 0.22);
  outline-offset: 3px;
}

.call-btn.active {
  background:
    linear-gradient(
      135deg,
      var(--danger),
      #f16f80
    );

  box-shadow:
    0 8px 18px rgba(229, 72, 93, 0.22);
}

.call-btn.active:hover {
  box-shadow:
    0 12px 24px rgba(229, 72, 93, 0.28);
}

/* =========================
   MICROPHONE LEVEL
========================= */

.mic-level {
  width: 100%;
  height: 7px;

  background: #e9edf4;

  border-radius: 999px;

  margin: 20px 0 7px;

  overflow: hidden;

  border: 1px solid #e1e5ed;
}

#micLevelBar {
  height: 100%;
  width: 0%;

  background:
    linear-gradient(
      90deg,
      var(--accent-2),
      #28c9a6
    );

  border-radius: inherit;

  transition: width 0.08s linear;
}

/* =========================
   TRANSCRIPT
========================= */

.transcript {
  text-align: left;

  margin-top: 20px;

  max-height: 280px;

  overflow-y: auto;

  padding-right: 6px;

  font-size: 14px;
  line-height: 1.55;
}

/* Custom scrollbar */

.transcript::-webkit-scrollbar {
  width: 6px;
}

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

.transcript::-webkit-scrollbar-thumb {
  background: #ccd2df;
  border-radius: 999px;
}

.transcript::-webkit-scrollbar-thumb:hover {
  background: #b8bfce;
}

.transcript .line {
  margin-bottom: 10px;

  padding: 10px 13px;

  border-radius: 12px;

  border: 1px solid transparent;

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.transcript .line:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.transcript .line.USER {
  background: var(--transcript-user);
  border-color: #e2dfff;
}

.transcript .line.ASSISTANT {
  background: var(--transcript-assistant);
  border-color: #d6f1ea;
}

.transcript .role {
  color: var(--muted);

  font-size: 10px;
  font-weight: 700;

  text-transform: uppercase;

  letter-spacing: 0.6px;

  margin-right: 7px;
}

/* =========================
   KNOWLEDGE BASE
========================= */

.kb-card h2 {
  margin-top: 0;
  margin-bottom: 8px;

  font-size: 19px;
  letter-spacing: -0.2px;
}

.hint {
  color: var(--muted);

  font-size: 13px;

  line-height: 1.5;
}

/* =========================
   KB ACTIONS
========================= */

.kb-actions {
  display: flex;

  flex-wrap: wrap;

  gap: 10px;

  margin: 16px 0;
}

.kb-actions button,
#kbFile {
  appearance: none;

  background: var(--input-bg);

  color: var(--text-soft);

  border: 1px solid var(--border-strong);

  padding: 10px 14px;

  border-radius: 9px;

  cursor: pointer;

  font: inherit;
  font-size: 13px;
  font-weight: 500;

  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.kb-actions button:hover,
#kbFile:hover {
  background: #ffffff;

  border-color: #bfc6d6;

  transform: translateY(-1px);

  box-shadow: var(--shadow-sm);
}

.kb-actions button:focus-visible,
#kbFile:focus-visible {
  outline: 3px solid rgba(99, 91, 219, 0.16);
  outline-offset: 2px;
}

/* File input */

#kbFile {
  max-width: 100%;
}

/* =========================
   KB STATUS
========================= */

.kb-status {
  font-size: 13px;

  color: var(--muted);

  min-height: 20px;

  padding-top: 4px;
}

/* =========================
   FOOTER
========================= */

footer {
  display: grid;

  grid-template-columns: 1fr 1fr;

  gap: 16px 18px;

  font-size: 12px;

  color: var(--muted);

  padding: 0 4px 10px;
}

footer label {
  grid-column: span 1;

  display: flex;
  flex-direction: column;

  gap: 5px;

  font-weight: 500;
}

footer input {
  margin-top: 4px;

  padding: 10px 11px;

  border-radius: 8px;

  border: 1px solid var(--border-strong);

  background: #ffffff;

  color: var(--text);

  width: 100%;

  font: inherit;

  outline: none;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

footer input::placeholder {
  color: #a4aaba;
}

footer input:hover {
  border-color: #bdc4d2;
}

footer input:focus {
  border-color: var(--accent);

  box-shadow:
    0 0 0 3px rgba(99, 91, 219, 0.12);

  background: #ffffff;
}

/* =========================
   SELECTION
========================= */

::selection {
  background: rgba(99, 91, 219, 0.18);
  color: var(--text);
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 700px) {
  body {
    padding: 24px 14px;
  }

  .card {
    padding: 24px 20px;

    border-radius: 18px;

    min-height: auto;
  }

  header {
    margin-bottom: 22px;
  }

  header h1 {
    font-size: 26px;
  }

  .call-btn {
    width: 100%;
    max-width: 260px;
  }

  footer {
    grid-template-columns: 1fr;

    gap: 12px;
  }

  footer label {
    grid-column: span 1;
  }

  .transcript {
    max-height: 240px;
  }
}

@media (max-width: 420px) {
  body {
    padding: 18px 10px;
  }

  .card {
    padding: 20px 16px;
    margin-bottom: 16px;
  }

  header h1 {
    font-size: 23px;
  }

  .subtitle {
    font-size: 13px;
  }

  .kb-actions {
    flex-direction: column;
  }

  .kb-actions button,
  #kbFile {
    width: 100%;
  }
}

/* =========================
   REDUCED MOTION
========================= */

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