/* ============================================================
   Amphion Demo · Claude-style "paper" light theme
   ============================================================ */

/* -------------------- Design tokens -------------------- */
:root {
  --paper: #FAF9F5;
  --paper-sunk: #F5F3EC;
  --paper-elev: #FFFFFF;

  --ink: #2A2A27;
  --ink-mute: #6B6B66;
  --ink-faint: #9A9A93;
  --ink-ghost: rgba(42, 42, 39, 0.08);

  --line: #E8E4DC;
  --line-soft: #F1EDE5;
  --line-strong: #D7D2C7;

  --accent: #CC785C;
  --accent-deep: #B5604A;
  --accent-soft: #F3E3DB;
  --accent-ghost: rgba(204, 120, 92, 0.12);

  --ok: #6F8F6B;
  --ok-soft: #E4EEDF;
  --warn: #B58A3B;
  --warn-soft: #F2E6C8;
  --danger: #B4504A;
  --danger-soft: #F3DAD7;
  --info: #4F7C9A;
  --info-soft: #DCE7EF;

  --shadow-xs: 0 1px 0 rgba(52, 44, 30, 0.04);
  --shadow-sm: 0 1px 2px rgba(52, 44, 30, 0.05);
  --shadow-md: 0 6px 18px -10px rgba(52, 44, 30, 0.18),
               0 1px 0 rgba(52, 44, 30, 0.04);
  --shadow-lg: 0 14px 36px -18px rgba(52, 44, 30, 0.22),
               0 1px 0 rgba(52, 44, 30, 0.04);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI',
               sans-serif;
  --font-serif: ui-serif, 'Source Serif 4', 'Source Serif Pro', Georgia, Cambria,
                'Times New Roman', Times, serif;

  --sidebar-w: 240px;
}

/* -------------------- Base -------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.55;
  overflow: hidden;
}

::selection {
  background: var(--accent-ghost);
  color: var(--ink);
}

h1,
h2,
h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

/* -------------------- App shell -------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  width: 100%;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* -------------------- Sidebar -------------------- */
.app-sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  background: var(--paper-sunk);
  border-right: 1px solid var(--line);
  view-transition-name: sidebar;
  z-index: 10;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.app-brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--paper-elev);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}

.app-brand-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.app-brand-sub {
  font-size: 10.5px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 0;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-mute);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  position: relative;
  transition:
    color 0.18s ease,
    background-color 0.18s ease;
}

.app-nav-item:hover {
  color: var(--ink);
  background: rgba(42, 42, 39, 0.04);
}

.app-nav-item.is-active {
  color: var(--ink);
  background: var(--paper-elev);
  box-shadow: var(--shadow-xs);
}

.app-nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}

.app-nav-item .app-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.85;
}

.app-sidebar-foot {
  margin-top: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.app-conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 3px rgba(154, 154, 147, 0.12);
  transition:
    background-color 0.24s ease,
    box-shadow 0.24s ease;
  flex-shrink: 0;
}

.app-conn-dot[data-state='ready'],
.app-conn-dot[data-state='connected'] {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(111, 143, 107, 0.18);
}

.app-conn-dot[data-state='pending'],
.app-conn-dot[data-state='listening'],
.app-conn-dot[data-state='analyzing'],
.app-conn-dot[data-state='busy'] {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.18);
}

.app-conn-dot[data-state='error'] {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 80, 74, 0.18);
}

.app-conn-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------------------- Language toggle -------------------- */
.app-lang-toggle {
  margin-top: 10px;
  padding: 4px;
  display: inline-flex;
  align-self: stretch;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--paper-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
}

.app-lang-btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-mute);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  min-width: 36px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    color 0.18s ease,
    background-color 0.18s ease;
}

.app-lang-btn:hover {
  color: var(--ink);
}

.app-lang-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  box-shadow: var(--shadow-xs);
}

.app-lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* -------------------- Page header -------------------- */
.page-header {
  padding: 22px 28px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.page-sub {
  font-size: 12.5px;
  color: var(--ink-mute);
  margin-top: 4px;
}

.page-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 28px 22px;
  overflow: hidden;
}

/* -------------------- Cards -------------------- */
.glass-card,
.paper-card {
  background: var(--paper-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* -------------------- Chat bubbles (Claude-style) -------------------- */
#chat-area {
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

#chat-area::-webkit-scrollbar {
  width: 8px;
}

#chat-area::-webkit-scrollbar-track {
  background: transparent;
}

#chat-area::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

#chat-area::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint);
}

.chat-row {
  display: flex;
  margin-bottom: 14px;
}

.chat-row-user {
  justify-content: flex-end;
}

.chat-row-ai {
  justify-content: flex-start;
}

.chat-bubble {
  border-radius: var(--radius-lg);
  max-width: min(86%, 680px);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
}

.chat-bubble-user {
  max-width: 78%;
  background: var(--paper-sunk);
  border: 1px solid var(--line);
  border-top-right-radius: 6px;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.chat-bubble-ai {
  background: transparent;
  border: none;
  padding: 4px 2px 6px;
  color: var(--ink);
  position: relative;
  overflow: hidden;
}

.chat-bubble-ai.ai-processing::after {
  content: '';
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: -2px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent) 40%,
    var(--accent) 60%,
    transparent 100%
  );
  background-size: 220% 100%;
  animation: ai-processing-flow 1.6s linear infinite;
  opacity: 0.7;
}

@keyframes ai-processing-flow {
  0% {
    background-position: 180% 0;
  }
  100% {
    background-position: -80% 0;
  }
}

.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-elev);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
}

.chat-avatar svg {
  color: var(--accent);
}

.chat-bubble-user .user-voice-label {
  color: var(--ink);
  font-weight: 500;
}

.chat-bubble-user svg {
  color: var(--ink-mute);
}

.waveform-bar {
  background: var(--accent);
  opacity: 0.7;
  width: 3px;
  border-radius: 999px;
}

.chat-bubble-float {
  animation: bubble-float-in 0.32s cubic-bezier(0.2, 0.72, 0.2, 1);
}

@keyframes bubble-float-in {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-bubble-discard {
  animation: bubble-discard 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
  overflow: hidden;
}

@keyframes bubble-discard {
  0% {
    opacity: 1;
    max-height: 120px;
  }
  100% {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}

/* -------------------- Streaming text reveal -------------------- */
.stream-char {
  opacity: 0;
  display: inline;
  animation: stream-char-in 0.18s ease-out forwards;
}

@keyframes stream-char-in {
  from {
    opacity: 0;
    filter: blur(3px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

.stream-meta {
  animation: stream-meta-in 0.3s ease-out 0.4s both;
}

@keyframes stream-meta-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hotword-hit {
  display: inline;
  padding: 0 4px;
  margin: 0 1px;
  border-radius: 5px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid rgba(204, 120, 92, 0.24);
}

/* -------------------- Shimmer -------------------- */
.shimmer-line {
  background: linear-gradient(
    90deg,
    var(--line-soft) 0%,
    rgba(232, 228, 220, 0.4) 50%,
    var(--line-soft) 100%
  );
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* -------------------- Mic button -------------------- */
.mic-btn-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-ring {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.pulse-ring.active {
  opacity: 0.5;
  animation: pulse-expand 2.2s ease-out infinite;
}

.pulse-ring.active:nth-child(2),
.pulse-ring.active:nth-child(3) {
  display: none;
}

@keyframes pulse-expand {
  0% {
    transform: scale(1);
    opacity: 0.45;
  }
  100% {
    transform: scale(1.85);
    opacity: 0;
  }
}

.mic-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  cursor: pointer;
  background: var(--paper-elev);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    background-color 0.22s ease,
    color 0.22s ease;
  position: relative;
  z-index: 1;
  /* Keep the mic pinned across page transitions. Because the button sits at
     the same spot on every page and shares this name, the VT engine treats
     it as a single element that simply stays put instead of fading out. */
  view-transition-name: mic-btn;
}

.mic-btn:hover:not([disabled]) {
  transform: scale(1.05);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.mic-btn:active:not([disabled]) {
  transform: scale(0.97);
}

.mic-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.mic-btn.recording {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: var(--paper-elev);
  box-shadow:
    0 10px 28px -12px rgba(204, 120, 92, 0.55),
    0 1px 0 rgba(52, 44, 30, 0.04);
  animation: mic-breathe 1.8s ease-in-out infinite;
}

::view-transition-old(mic-btn),
::view-transition-new(mic-btn) {
  /* Static mic = same snapshot both sides; no animation needed. */
  animation: none;
}

@keyframes mic-breathe {
  0%, 100% {
    box-shadow:
      0 10px 24px -14px rgba(204, 120, 92, 0.5),
      0 0 0 0 rgba(204, 120, 92, 0.18);
  }
  50% {
    box-shadow:
      0 14px 28px -14px rgba(204, 120, 92, 0.6),
      0 0 0 10px rgba(204, 120, 92, 0.06);
  }
}

#mic-status,
.mic-status-label {
  font-size: 12.5px;
  color: var(--ink-mute);
  margin-top: 12px;
}

/* -------------------- Replay button -------------------- */
.replay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper-elev);
  color: var(--ink-mute);
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
  flex-shrink: 0;
  margin-left: 4px;
}

.replay-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: var(--accent);
  transform: scale(1.08);
}

.replay-btn.is-playing {
  color: var(--accent-deep);
  border-color: var(--accent);
  background: var(--accent-soft);
  animation: replay-pulse 1s ease-in-out infinite;
}

@keyframes replay-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* -------------------- Status pills -------------------- */
.status-pill {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-sunk);
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-pill[data-state='ready'],
.status-pill[data-state='synced'] {
  border-color: rgba(111, 143, 107, 0.4);
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill[data-state='listening'],
.status-pill[data-state='recording'],
.status-pill[data-state='analyzing'],
.status-pill[data-state='busy'],
.status-pill[data-state='pending'] {
  border-color: rgba(204, 120, 92, 0.4);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.status-pill[data-state='done'] {
  border-color: rgba(111, 143, 107, 0.4);
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill[data-state='error'] {
  border-color: rgba(180, 80, 74, 0.4);
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill[data-state='offline'],
.status-pill[data-state='waiting'] {
  border-color: rgba(181, 138, 59, 0.38);
  background: var(--warn-soft);
  color: var(--warn);
}

/* -------------------- Inputs -------------------- */
.hotword-input,
.hotword-textarea {
  background: var(--paper-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  caret-color: var(--accent);
  padding: 8px 12px;
  outline: none;
  font-size: 14px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.hotword-textarea {
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
  min-height: 84px;
}

.hotword-input:focus,
.hotword-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ghost);
}

.hotword-input::placeholder,
.hotword-textarea::placeholder {
  color: var(--ink-faint);
}

.asr-lang-select {
  background: var(--paper-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 7px 32px 7px 12px;
  outline: none;
  font-size: 13px;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.asr-lang-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ghost);
}

.asr-lang-select option {
  background: var(--paper-elev);
  color: var(--ink);
}

/* -------------------- Generic buttons -------------------- */
.btn-primary {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--paper-elev);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--paper-elev);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--paper-sunk);
  border-color: var(--ink-faint);
}

.btn-ghost {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-mute);
  font-size: 13px;
  cursor: pointer;
  transition:
    color 0.18s ease,
    background-color 0.18s ease;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(42, 42, 39, 0.05);
}

.btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* -------------------- Hotword pill -------------------- */
.hotword-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  background: var(--paper-sunk);
  color: var(--ink);
  border: 1px solid var(--line);
}

.hotword-pill button {
  all: unset;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 14px;
  line-height: 1;
  transition: color 0.18s ease;
}

.hotword-pill button:hover {
  color: var(--danger);
}

/* -------------------- Hotword extract status -------------------- */
.hotword-extract-status {
  font-size: 11px;
  border-radius: 999px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  background: var(--paper-sunk);
  color: var(--ink-mute);
}

.hotword-extract-status.is-loading {
  color: var(--info);
  border-color: rgba(79, 124, 154, 0.4);
  background: var(--info-soft);
}

.hotword-extract-status.is-success {
  color: var(--ok);
  border-color: rgba(111, 143, 107, 0.4);
  background: var(--ok-soft);
}

.hotword-extract-status.is-error {
  color: var(--danger);
  border-color: rgba(180, 80, 74, 0.4);
  background: var(--danger-soft);
}

#hotword-extract-btn.is-attention {
  animation: extract-btn-pulse 2.4s ease-in-out infinite;
}

@keyframes extract-btn-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(204, 120, 92, 0.0);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(204, 120, 92, 0.09);
  }
}

/* -------------------- Toggle switch -------------------- */
.hotword-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.hotword-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.hotword-switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper-sunk);
  transition: background-color 0.22s ease, border-color 0.22s ease;
}

.hotword-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--paper-elev);
  box-shadow: 0 1px 3px rgba(52, 44, 30, 0.22);
  transition: transform 0.22s ease;
}

.hotword-switch input:checked + .hotword-switch-track {
  background: var(--accent);
  border-color: var(--accent-deep);
}

.hotword-switch input:checked + .hotword-switch-track::after {
  transform: translateX(16px);
  background: var(--paper-elev);
}

.hotword-switch-label {
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  font-size: 11.5px;
}

/* -------------------- Helper text -------------------- */
.text-muted {
  color: var(--ink-mute);
}

.text-faint {
  color: var(--ink-faint);
}

/* -------------------- Toggle arrow (legacy) -------------------- */
.toggle-arrow {
  transition: transform 0.3s ease;
  display: inline-block;
}

/* -------------------- Emotion "listening" dot -------------------- */
.emotion-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.emotion-live-dot.is-active {
  opacity: 1;
  animation: emotion-live-breathe 2s ease-in-out infinite;
}

@keyframes emotion-live-breathe {
  0%, 100% {
    opacity: 0.45;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* -------------------- View transitions -------------------- */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 260ms;
  animation-timing-function: cubic-bezier(0.2, 0.72, 0.2, 1);
}

::view-transition-old(root) {
  animation-name: page-fade-out;
}

::view-transition-new(root) {
  animation-name: page-fade-in;
}

@keyframes page-fade-out {
  to {
    opacity: 0;
  }
}

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

::view-transition-old(sidebar),
::view-transition-new(sidebar) {
  animation: none;
  mix-blend-mode: normal;
}

/* Fallback when VT is unsupported */
.app-main.is-page-leaving {
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

/* -------------------- Responsive -------------------- */
@media (max-width: 768px) {
  body {
    overflow: auto;
  }

  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .app-sidebar {
    width: 100%;
    flex-basis: auto;
    height: auto;
    position: sticky;
    top: 0;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    align-items: center;
    gap: 10px;
    background: var(--paper-sunk);
    backdrop-filter: saturate(180%) blur(8px);
  }

  .app-brand {
    padding: 0 8px 0 4px;
    border: none;
    margin: 0;
    flex-shrink: 0;
  }

  .app-brand-text {
    display: none;
  }

  .app-nav {
    flex-direction: row;
    gap: 4px;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1 1 auto;
  }

  .app-nav-item {
    padding: 6px 10px;
    white-space: nowrap;
    font-size: 12.5px;
  }

  .app-nav-item.is-active::before {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 2px;
    width: auto;
    height: 2px;
    border-radius: 2px 2px 0 0;
  }

  .app-nav-item .app-nav-label {
    display: inline;
  }

  .app-sidebar-foot {
    margin: 0;
    padding: 0 6px;
    border: none;
    flex-shrink: 0;
  }

  .app-conn-label {
    display: none;
  }

  .app-lang-toggle {
    margin: 0;
    padding: 2px;
    align-self: center;
    flex-shrink: 0;
  }

  .app-lang-btn {
    padding: 3px 8px;
    min-width: 28px;
    font-size: 11px;
  }

  .page-header {
    padding: 16px 16px 10px;
  }

  .page-content {
    padding: 14px 16px 18px;
  }

  .mic-btn {
    width: 60px;
    height: 60px;
  }

  .pulse-ring {
    width: 60px;
    height: 60px;
  }
}
