:root {
  --brand-primary: #3154d8;
  --brand-primary-dark: #203ca9;
  --brand-primary-light: #edf1ff;
  --brand-secondary: #7657e8;

  --page-background: #f4f6fb;
  --card-background: #ffffff;
  --panel-background: #f8f9fd;

  --text-primary: #182033;
  --text-secondary: #65708a;
  --text-light: #929bb0;

  --border: #e3e7f0;
  --success: #24a866;
  --danger: #db4655;
  --danger-light: #fff0f1;

  --shadow:
    0 18px 50px rgba(29, 43, 84, 0.1);

  font-family:
    Inter,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;

  color: var(--text-primary);
  background: var(--page-background);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(
      circle at 10% 0%,
      rgba(49, 84, 216, 0.1),
      transparent 28%
    ),
    radial-gradient(
      circle at 95% 18%,
      rgba(118, 87, 232, 0.08),
      transparent 25%
    ),
    var(--page-background);
}

/* Header */

.site-header {
  min-height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background:
    linear-gradient(
      135deg,
      var(--brand-primary),
      var(--brand-secondary)
    );
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  box-shadow:
    0 8px 18px rgba(49, 84, 216, 0.25);
}

.brand-name {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.5px;
}

.brand-name span {
  color: var(--brand-primary);
}

.header-label {
  padding: 7px 12px;
  border: 1px solid #dce2fa;
  border-radius: 999px;
  background: var(--brand-primary-light);
  color: var(--brand-primary-dark);
  font-size: 13px;
  font-weight: 650;
}

/* Page */

.page {
  width: 100%;
  flex: 1;
  padding: 44px 24px;
}

.assistant-card {
  width: min(100%, 820px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--card-background);
  box-shadow: var(--shadow);
}

/* Emma profile */

.assistant-header {
  padding: 28px 30px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}

.avatar-wrapper {
  position: relative;
  flex: 0 0 auto;
}

.avatar {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background:
    linear-gradient(
      145deg,
      var(--brand-primary),
      var(--brand-secondary)
    );
  color: #ffffff;
  font-size: 27px;
  font-weight: 800;
  box-shadow:
    0 0 0 1px var(--border),
    0 9px 22px rgba(49, 84, 216, 0.2);
}

.avatar.speaking {
  animation: assistant-pulse 1.25s infinite;
}

.status-dot {
  position: absolute;
  right: 1px;
  bottom: 3px;
  width: 15px;
  height: 15px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #a1a9b8;
}

.status-dot.connected {
  background: var(--success);
}

.status-dot.error {
  background: var(--danger);
}

.assistant-identity {
  min-width: 0;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.assistant-identity h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.7px;
}

.assistant-identity p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 15px;
}

.ai-badge {
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
}

/* Controls */

.control-panel {
  padding: 24px 30px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-background);
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 50px;
  padding: 0 44px 0 15px;
  border: 1px solid #d5daE7;
  border-radius: 11px;
  outline: none;
  background: #ffffff;
  color: var(--text-primary);
  font: inherit;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

select:focus {
  border-color: var(--brand-primary);
  box-shadow:
    0 0 0 4px rgba(49, 84, 216, 0.12);
}

select:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.button {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    opacity 150ms ease;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  background:
    linear-gradient(
      135deg,
      var(--brand-primary),
      var(--brand-primary-dark)
    );
  color: #ffffff;
  box-shadow:
    0 8px 18px rgba(49, 84, 216, 0.22);
}

.button-danger {
  border: 1px solid #ffd3d7;
  background: var(--danger-light);
  color: var(--danger);
}

.button-icon {
  margin-right: 7px;
  color: #80ffbc;
}

.connection-status {
  margin-top: 15px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

#statusText {
  color: var(--text-primary);
  font-weight: 650;
}

.privacy-message {
  text-align: right;
}

/* Shared section headings */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.section-header h2 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: -0.35px;
}

.section-eyebrow {
  color: var(--brand-primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Realtime conversation */

.conversation-section {
  padding: 26px 30px 30px;
}

.clear-transcript {
  width: auto;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #ffffff;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.clear-transcript:hover {
  border-color: #c8cee0;
  color: var(--brand-primary);
}

.transcript {
  height: 390px;
  margin-top: 18px;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    linear-gradient(
      180deg,
      #fbfcff,
      #f6f8fc
    );
  scroll-behavior: smooth;
}

.empty-transcript {
  margin: auto;
  padding: 30px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-transcript .empty-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 13px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-size: 20px;
  font-weight: 800;
}

.empty-transcript strong {
  display: block;
  color: var(--text-primary);
  font-size: 15px;
}

.empty-transcript p {
  margin: 7px 0 0;
  font-size: 13px;
}

.transcript-message {
  max-width: min(84%, 610px);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.transcript-message.student {
  align-self: flex-end;
  align-items: flex-end;
}

.transcript-message.emma {
  align-self: flex-start;
  align-items: flex-start;
}

.transcript-speaker {
  padding: 0 5px;
  color: var(--text-light);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.transcript-text {
  margin: 0;
  padding: 12px 15px;
  border-radius: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  box-shadow:
    0 3px 10px rgba(29, 43, 84, 0.05);
}

.transcript-message.student .transcript-text {
  border-bottom-right-radius: 4px;
  background:
    linear-gradient(
      135deg,
      var(--brand-primary),
      var(--brand-primary-dark)
    );
  color: #ffffff;
}

.transcript-message.emma .transcript-text {
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  background: #ffffff;
  color: var(--text-primary);
}

.transcript-message.interim .transcript-text {
  opacity: 0.72;
}

.transcript-message.interim .transcript-text::after {
  content: " ●";
  color: #9d88ee;
  animation: transcript-blink 0.8s infinite;
}

.transcript-message.final .transcript-text {
  opacity: 1;
}

/* Summary at end */

.usage {
  padding: 27px 30px 30px;
  border-top: 1px solid var(--border);
  background: var(--panel-background);
}

.summary-header {
  margin-bottom: 17px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 12px;
}

.summary-item {
  min-width: 0;
  min-height: 86px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #ffffff;
}

.summary-label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.summary-item strong {
  color: var(--text-primary);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.summary-model strong {
  color: var(--brand-primary-dark);
}

.summary-note {
  margin: 14px 2px 0;
  color: var(--text-light);
  font-size: 12px;
}

/* Footer */

.site-footer {
  padding: 18px 32px 26px;
  display: flex;
  justify-content: center;
  gap: 10px;
  color: var(--text-light);
  font-size: 12px;
}

.site-footer span + span::before {
  content: "•";
  margin-right: 10px;
}

/* Animations */

@keyframes assistant-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 1px var(--border),
      0 0 0 0 rgba(49, 84, 216, 0.28);
  }

  50% {
    box-shadow:
      0 0 0 1px var(--border),
      0 0 0 12px rgba(49, 84, 216, 0);
  }
}

@keyframes transcript-blink {
  0%,
  100% {
    opacity: 0.25;
  }

  50% {
    opacity: 1;
  }
}

/* Responsive layout */

@media (max-width: 720px) {
  .site-header {
    min-height: 64px;
    padding: 0 18px;
  }

  .header-label {
    display: none;
  }

  .page {
    padding: 20px 12px;
  }

  .assistant-card {
    border-radius: 18px;
  }

  .assistant-header,
  .control-panel,
  .conversation-section,
  .usage {
    padding-left: 19px;
    padding-right: 19px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .connection-status {
    flex-direction: column;
    gap: 5px;
  }

  .privacy-message {
    text-align: left;
  }

  .transcript {
    height: 360px;
    padding: 14px;
  }

  .transcript-message {
    max-width: 92%;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .summary-model {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  .brand-name {
    font-size: 19px;
  }

  .assistant-header {
    padding-top: 22px;
  }

  .avatar {
    width: 58px;
    height: 58px;
    font-size: 23px;
  }

  .assistant-identity h1 {
    font-size: 23px;
  }

  .assistant-identity p {
    font-size: 13px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-model {
    grid-column: auto;
  }

  .site-footer {
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }

  .site-footer span + span::before {
    display: none;
  }

  .login-card {
    max-width: 400px;
  }

  .login-form {
    flex-direction: column;
  }
}

/* Login Styles */

.login-card {
  width: 100%;
  max-width: 450px;
  margin: 60px auto;
  padding: 48px 40px;
  border-radius: 16px;
  background: var(--card-background);
  box-shadow: var(--shadow);
}

.login-header {
  margin-bottom: 32px;
  text-align: center;
}

.login-header h2 {
  margin: 0 0 8px 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
}

.login-header p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-primary);
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: var(--card-background);
  color: var(--text-primary);
  transition: border-color 150ms ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.form-group input::placeholder {
  color: var(--text-light);
}

.button-full {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-message {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--danger-light);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
  animation: slideIn 200ms ease;
}

.status-message {
  padding: 12px 16px;
  border-radius: 8px;
  background: #d4edda;
  color: var(--success);
  font-size: 13px;
  line-height: 1.4;
  animation: slideIn 200ms ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.demo-credentials {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.demo-credentials p {
  margin: 0 0 8px 0;
}

.demo-credentials code {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--panel-background);
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  word-break: break-all;
}

.logout-button {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
}

.logout-button:hover {
  background: var(--panel-background);
  color: var(--text-primary);
}

.logout-button:active {
  transform: scale(0.98);
}