@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/Inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/Inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/Inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/Inter-700.woff2") format("woff2");
}

:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --fg: #1a1a1a;
  --fg-muted: #6b7280;
  --panel: #ffffff;
  --border: #e2e2e5;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --user-bubble: #2563eb;
  --user-fg: #fff;
  --assistant-bubble: #eef0f3;
  --assistant-fg: #1a1a1a;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 20px rgba(15, 23, 42, 0.1);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 120ms var(--ease);
  --transition: 180ms var(--ease);

  --font-sans: "Inter", -apple-system, "Segoe UI", "Nirmala UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113;
    --fg: #f0f0f0;
    --fg-muted: #9a9ea6;
    --panel: #1a1b1e;
    --border: #2c2d31;
    --assistant-bubble: #26272b;
    --assistant-fg: #f0f0f0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.55), 0 8px 20px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--fg);
}

button, input, select {
  font-family: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius-sm);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* mobile browsers' address-bar chrome makes 100vh taller than what's actually visible, pushing the input row off-screen; dvh accounts for it */
  max-width: 720px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 2;
}

.topbar h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  position: relative;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -2px;
  height: 1.5px;
  background: currentColor;
  transition: right var(--transition);
}
.nav-link:hover::after {
  right: 0;
}

#language-select {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
#language-select:hover {
  border-color: var(--accent);
}

.error-banner {
  background: color-mix(in srgb, var(--danger) 12%, var(--panel));
  color: var(--danger);
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}
.error-banner.hidden { display: none; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  line-height: 1.5;
  font-size: 0.94rem;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  animation: bubble-in var(--transition) both;
}

.bubble.user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: var(--user-fg);
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--assistant-bubble);
  color: var(--assistant-fg);
  border-bottom-left-radius: 4px;
}

.controls {
  border-top: 1px solid var(--border);
  padding: 12px 20px 20px;
  background: var(--panel);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.04);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-bottom: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa0aa;
  transition: background var(--transition);
}
.status-dot.processing { background: var(--warning); animation: pulse 1.2s infinite; }
.status-dot.speaking { background: var(--accent); animation: pulse 1.2s infinite; }
.status-dot.error { background: var(--danger); }

.input-row {
  display: flex;
  gap: 10px;
}

.text-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

#text-input {
  flex: 1;
  padding: 11px 42px 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.92rem;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
#text-input:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
#text-input:focus {
  border-color: var(--accent);
  background: var(--panel);
}

#text-input:disabled {
  opacity: 0.55;
}

.mic-inline-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.mic-inline-btn svg {
  width: 17px;
  height: 17px;
}
.mic-inline-btn:hover {
  background: var(--assistant-bubble);
  color: var(--fg);
}
.mic-inline-btn.listening {
  color: var(--danger);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#text-send {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
#text-send:hover { background: var(--accent-hover); }
#text-send:active { transform: scale(0.97); }
#text-send svg { width: 15px; height: 15px; }

.debug-panel {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--fg-muted);
}
.debug-panel summary {
  cursor: pointer;
}
.debug-panel pre {
  max-height: 160px;
  overflow: auto;
  background: var(--assistant-bubble);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}

@media (max-width: 480px) {
  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }
  .topbar h1 {
    font-size: 0.95rem;
  }
  .nav-link {
    font-size: 0.78rem;
  }
  #language-select {
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  .chat-log {
    padding: 14px;
  }
  .bubble {
    max-width: 88%;
    font-size: 0.9rem;
  }
  .controls {
    padding: 10px 14px 14px;
  }
}
