/* ============================================================
   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: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'PingFang SC',
               'Microsoft YaHei', sans-serif;
  --font-serif: ui-serif, 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);
  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-sidebar-toggle {
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-elev);
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.app-sidebar-toggle:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: white;
}

.app-sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.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;
}

/* Serving model versions: a muted debug-only line under the connection status. */
.app-model-info {
  padding: 0 12px 10px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.app-model-info[hidden],
.app-model-list[hidden] {
  display: none;
}

.app-model-summary {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  opacity: 0.7;
}

.app-model-summary:hover,
.app-model-summary:focus-visible,
.app-model-summary[aria-expanded='true'] {
  opacity: 1;
}

.app-model-list {
  margin: 6px 0 0;
  font-variant-numeric: tabular-nums;
}

.app-model-list dt {
  margin-top: 4px;
}

.app-model-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink-mute);
}

.app-model-list .app-model-checked {
  margin-top: 6px;
  opacity: 0.7;
}

@media (min-width: 769px) {
  .app-sidebar {
    transition:
      width 0.2s ease,
      flex-basis 0.2s ease,
      padding 0.2s ease;
  }

  .app-sidebar[data-collapsed='true'] {
    width: 72px;
    flex-basis: 72px;
    padding-inline: 10px;
  }

  .app-sidebar[data-collapsed='true'] .app-brand {
    justify-content: center;
    padding-inline: 0;
  }

  .app-sidebar[data-collapsed='true'] .app-brand-logo,
  .app-sidebar[data-collapsed='true'] .app-brand-text,
  .app-sidebar[data-collapsed='true'] .app-nav-label,
  .app-sidebar[data-collapsed='true'] .app-lang-toggle,
  .app-sidebar[data-collapsed='true'] .app-conn-label,
  .app-sidebar[data-collapsed='true'] .app-model-info {
    display: none;
  }

  .app-sidebar[data-collapsed='true'] .app-nav-item {
    justify-content: center;
    padding: 10px 0;
  }

  .app-sidebar[data-collapsed='true'] .app-nav-item.is-active::before {
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    height: auto;
    border-radius: 0 2px 2px 0;
  }

  .app-sidebar[data-collapsed='true'] .app-sidebar-foot {
    justify-content: center;
    padding-inline: 0;
  }
}

/* -------------------- 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;
  flex-wrap: wrap;
}

.public-api-credentials {
  width: 280px;
  max-width: 100%;
  min-width: 0;
  display: grid;
  gap: 4px;
}

.public-api-credentials label {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.public-api-credentials input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.public-api-credentials [role="status"] {
  min-height: 16px;
  overflow-wrap: anywhere;
  color: var(--danger);
}

.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;
  }
}

.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);
}

/* -------------------- Streaming text crossfade --------------------
   Each update of a streaming bubble inserts a new ``.text-frame`` layer
   that fades in while the previous layer fades out on top of it. Both
   layers live in the same CSS Grid cell so the paragraph's height /
   width is determined by the union of the two during the swap, then
   relaxes to the new layer once the leaving frame is removed.

   This is intentionally simpler than per-character diffing — see the
   companion comment in frontend/streaming-text.js for the rationale.
   The trade-off is that unchanged glyphs also briefly re-fade on every
   partial, but the visual result is a calm crossfade rather than a
   busy left-to-right wave that draws the eye away from the content. */
.bubble-text {
  display: inline-grid;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-text > .text-frame {
  /* Stack every layer in the same cell so they overlap pixel-perfectly
     during the crossfade window. */
  grid-column: 1;
  grid-row: 1;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: inherit;
}

.bubble-text > .text-frame.is-current {
  animation: text-frame-in 0.32s ease-out;
}

.bubble-text > .text-frame.is-leaving {
  /* ``forwards`` keeps opacity at 0 between the animation finishing and
     the JS cleanup yanking the node, so we never see a single-frame
     flash of the leaving text after its fade completes. */
  pointer-events: none;
  animation: text-frame-out 0.28s ease-in forwards;
}

/* Hotword highlight applied to runs inside the final ``is-current``
   layer. ``applyHotwordHighlights`` rewrites the layer's innerHTML to
   wrap matching substrings in ``<mark class="is-hotword">``; we strip
   the browser's default yellow ``mark`` styling and reapply the brand
   accent palette. Each match is one continuous element so we don't
   need the per-char ``:has``-based boundary rules the diff version
   relied on. */
.bubble-text .is-hotword,
.bubble-text mark.is-hotword {
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-weight: 500;
  /* tiny vertical breathing room via box-shadow inset rather than
     padding so the glyph baseline doesn't shift */
  box-shadow: inset 0 -1px 0 rgba(181, 96, 74, 0.35);
  border-radius: 4px;
  padding: 0 2px;
}

.model-compare-result {
  display: grid;
  gap: 2px;
  margin-top: 8px;
  padding: 7px 9px;
  border-left: 3px solid var(--info);
  border-radius: 6px;
  background: var(--info-soft);
}

.model-compare-label {
  color: var(--info);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.35;
}

.model-compare-text {
  color: var(--ink-mute);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.model-compare-result[data-state='loading'] .model-compare-text {
  color: var(--ink-faint);
}

.model-compare-result[data-state='error'] {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.model-compare-result[data-state='error'] .model-compare-label,
.model-compare-result[data-state='error'] .model-compare-text {
  color: var(--danger);
}

.model-compare-session {
  margin: 8px 0;
  max-height: 260px;
  overflow-y: auto;
  flex-shrink: 0;
}

@keyframes text-frame-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes text-frame-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  /* Honour the OS-level "reduce motion" preference: snap text in / out
     instantly so users sensitive to motion still see updated bubbles
     without any visible transition. */
  .bubble-text > .text-frame.is-current,
  .bubble-text > .text-frame.is-leaving {
    animation-duration: 0.001s;
  }
}

/* -------------------- 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;
}

.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;
}

@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 --------------------
   ``.bubble-replay-slot`` is the placeholder rendered into the bubble
   skeleton from page load. It MUST occupy the exact box the eventual
   ``.replay-btn`` will take so the moment the final response arrives
   and ``applyReplayButton`` swaps the placeholder for a real button,
   no width is added to the flex row and the wrapped text doesn't
   reflow. The button itself layers ``.replay-btn`` on top of the same
   ``.bubble-replay-slot`` class, so its own width/margin rule wins for
   the visual chrome (border, background, hover) while the slot rule
   keeps the reserved geometry consistent across both states. */
.bubble-replay-slot {
  display: inline-flex;
  width: 22px;
  height: 22px;
  margin-left: 4px;
  flex-shrink: 0;
  vertical-align: middle;
}

.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 {
  flex-shrink: 0;
  white-space: nowrap;
  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);
}

.amphion-logo,
.doubao-logo {
  display: inline-block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  object-fit: contain;
  vertical-align: middle;
}
.doubao-heading { display: inline-flex; align-items: center; gap: 6px; }
.doubao-pill { display: flex; align-items: center; }

/* --- Two independent live transcripts on a shared audio interval --- */
.comparison-unit {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper-elev);
}
.comparison-range {
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 7px;
}
.comparison-source {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  font-size: 14px;
  line-height: 1.65;
}
.comparison-source-label { font-size: 12px; }
.comparison-source-status { color: var(--ink-faint); font-size: 10px; white-space: nowrap; }
.comparison-doubao { border-top: 1px dashed var(--line-strong); margin-top: 9px; padding-top: 9px; }
.comparison-doubao-items { color: var(--ink-mute); overflow-wrap: anywhere; }
.comparison-doubao-items > span + span::before { content: ' '; }
.comparison-doubao-items .is-partial { opacity: 0.72; }
.comparison-primary-items { min-width: 0; overflow-wrap: anywhere; }
.comparison-primary .chat-row-ai { display: inline; margin: 0; }
.comparison-primary .chat-bubble-float:not(.chat-bubble-discard) { animation: none; opacity: 1; transform: none; }
.comparison-primary .chat-row-ai > div { display: contents; }
.comparison-primary .chat-avatar { display: none; }
.comparison-primary .ai-content { display: inline; padding: 0; border: 0; background: transparent; }
.comparison-primary .bubble-content:not([hidden]),
.comparison-primary .bubble-content > div:first-child { display: inline; }
.comparison-primary .bubble-text { display: inline-grid; vertical-align: middle; }
.comparison-primary .text-frame.is-current { animation: none; }
.comparison-primary .text-frame.is-leaving { display: none; }
.comparison-primary .bubble-actions { display: inline-flex; vertical-align: middle; margin: 0 6px; }
.comparison-primary .bubble-meta-slot { display: inline-flex; gap: 4px; vertical-align: middle; }
.comparison-primary-items > .chat-row + .chat-row::before { content: ' '; }
@media (max-width: 480px) {
  .comparison-unit { padding: 9px 8px; }
  .comparison-source { grid-template-columns: 58px minmax(0, 1fr) auto; gap: 6px; }
}

/* -------------------- 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 --------------------
   The SPA router (frontend/router.js) replaces ``<main class="app-main">``
   in place inside ``document.startViewTransition``. The sidebar lives
   outside that subtree and is therefore not part of the cross-fade —
   it just stays put. Only the contents that actually changed (the
   page header text and ``.page-content``) participate in the root
   cross-fade.

   We deliberately do NOT register a ``@view-transition`` rule here;
   that rule only matters for cross-document navigations, which the
   SPA short-circuits.
*/

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 140ms;
  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(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------------------- 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-sidebar-toggle {
    display: none;
  }

  .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;
  }
}

/* -------------------- Upload audio file -------------------- */
.upload-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper-elev);
  color: var(--ink-mute);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.12s ease;
}

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

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

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

.btn-upload .upload-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  display: inline-block;
}

.btn-upload .btn-upload-label {
  display: inline-block;
}

.enroll-upload-row {
  margin-top: 8px;
  justify-content: flex-start;
}

.upload-status {
  font-size: 11.5px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
  max-width: 260px;
  text-align: center;
}

.upload-status[data-state="info"] {
  color: var(--ink-mute);
}

.upload-status[data-state="warn"] {
  color: var(--accent-deep, #b07d2a);
}

.upload-status[data-state="success"] {
  color: var(--info, #4a7c59);
}

.upload-status[data-state="error"] {
  color: var(--danger, #b4504a);
}

/* -------------------- Hotword control panel -------------------- */
body[data-page="meeting"] #hotword-panel {
  overflow: hidden;
}

body[data-page="meeting"] .hotword-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
}

body[data-page="meeting"] .hotword-panel-heading {
  min-width: 0;
}

body[data-page="meeting"] .hotword-context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

body[data-page="meeting"] .hotword-field {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

body[data-page="meeting"] .hotword-field > label {
  color: var(--ink-faint);
  font-size: 10.5px;
  line-height: 1.2;
}

body[data-page="meeting"] .hotword-field > p {
  margin: 0;
  color: var(--ink-faint);
  font-size: 9.5px;
  line-height: 1.35;
}

body[data-page="meeting"] .hotword-field > .hotword-input,
body[data-page="meeting"] .hotword-field > .asr-lang-select {
  width: 100%;
  min-width: 0;
  padding-block: 7px;
  font-size: 13px;
}

body[data-page="meeting"] .settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

body[data-page="meeting"] .settings-row.is-featured {
  margin: 10px -6px 0;
  padding: 10px 8px;
  border: 1px solid rgba(204, 120, 92, 0.18);
  border-radius: var(--radius-md);
  background: var(--accent-ghost);
}

body[data-page="meeting"] .settings-section {
  padding: 11px 0 12px;
  border-bottom: 1px solid var(--line);
}

body[data-page="meeting"] .recognition-mode-section {
  padding: 11px 0 12px;
  border-bottom: 1px solid var(--line);
}

body[data-page="meeting"] .recognition-mode-heading {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

body[data-page="meeting"] .recognition-mode-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 76px;
  gap: 3px;
  padding: 3px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-sunk);
}

body[data-page="meeting"] .meeting-roster-heading,
body[data-page="meeting"] .meeting-roster-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

body[data-page="meeting"] .meeting-roster-heading {
  margin-bottom: 10px;
}

body[data-page="meeting"] .meeting-roster-list {
  display: grid;
  gap: 8px;
}

body[data-page="meeting"] .meeting-roster-row {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-sunk);
}

body[data-page="meeting"] .meeting-roster-fields {
  min-width: 0;
  flex: 1;
}

body[data-page="meeting"] .meeting-speaker-id {
  width: 100%;
  box-sizing: border-box;
}

body[data-page="meeting"] .meeting-roster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

@media (max-width: 1180px) {
  body[data-page="meeting"] .recognition-mode-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
  }
}

body[data-page="meeting"] .recognition-mode-option {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

body[data-page="meeting"] .recognition-mode-option > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

body[data-page="meeting"] .recognition-mode-option > span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 7px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--ink-mute);
  font-size: 11.5px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

body[data-page="meeting"] .recognition-mode-option > input:checked + span {
  border-color: var(--line-strong);
  background: var(--paper-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

body[data-page="meeting"] .recognition-mode-option > input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

body[data-page="meeting"] .recognition-mode-options.is-locked {
  opacity: 0.55;
}

body[data-page="meeting"] .recognition-mode-options.is-locked .recognition-mode-option {
  cursor: not-allowed;
}

body[data-page="meeting"] .recognition-mode-hint {
  height: 16px;
  margin: 5px 2px 0;
  overflow: hidden;
  font-size: 10px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-page="meeting"] .hotword-manager {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding-top: 12px;
}

body[data-page="meeting"] .hotword-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 26px;
  margin-bottom: 7px;
}

body[data-page="meeting"] .hotword-manager-tools {
  display: flex;
  align-items: center;
  gap: 2px;
}

body[data-page="meeting"] .btn-quiet {
  padding: 4px 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-mute);
  font-size: 11.5px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease;
}

body[data-page="meeting"] .btn-quiet:hover {
  color: var(--ink);
  background: var(--paper-sunk);
}

body[data-page="meeting"] .btn-quiet.is-danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

body[data-page="meeting"] .hotword-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-bottom: 9px;
}

body[data-page="meeting"] .hotword-add-row > .hotword-input {
  width: 100%;
  min-width: 0;
}

body[data-page="meeting"] .hotword-add-row > .btn-secondary {
  min-width: 64px;
  padding-inline: 12px;
  white-space: nowrap;
}

body[data-page="meeting"] .hotword-list-surface {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 64px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(247, 244, 237, 0.72);
  scrollbar-gutter: stable;
}

body[data-page="meeting"] .hotword-extractor {
  flex: 0 0 auto;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

body[data-page="meeting"] .hotword-extractor > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-mute);
  font-size: 11.5px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

body[data-page="meeting"] .hotword-extractor > summary::-webkit-details-marker {
  display: none;
}

body[data-page="meeting"] .hotword-extractor > summary::before {
  content: '+';
  display: inline-grid;
  width: 16px;
  height: 16px;
  margin-right: -2px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-faint);
  transition: transform 0.18s ease;
}

body[data-page="meeting"] .hotword-extractor[open] > summary::before {
  transform: rotate(45deg);
}

body[data-page="meeting"] .hotword-extractor > summary > :first-child {
  margin-right: auto;
}

body[data-page="meeting"] .hotword-extractor-body {
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

body[data-page="meeting"] .hotword-extractor-body > .hotword-textarea {
  width: 100%;
  min-height: 76px;
}

body[data-page="meeting"] .hotword-extractor-body > .btn-primary {
  justify-self: start;
}

@media (max-width: 420px) {
  body[data-page="meeting"] .hotword-context-grid {
    grid-template-columns: 1fr;
  }
}

body[data-page="meeting"] #hotword-panel { overflow-y: auto; }
body[data-page="asr"] #hotword-panel { overflow-y: auto; }

/* Offline recognition: settings beside reusable audio and results. */
body[data-page="emotion"] .offline-content { overflow-y: auto; padding: 28px; }
.offline-workspace { display: grid; grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); gap: 24px; width: 100%; max-width: 1240px; margin: 0 auto; align-items: start; }
.offline-settings-card, .offline-input-card, .offline-results-card { padding: 24px; box-shadow: none; }
.offline-main-column { display: grid; gap: 20px; min-width: 0; }
.offline-section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.offline-section-heading h2 { font-size: 14px; font-weight: 600; margin: 0; }
.offline-section-heading .status-pill { margin-left: auto; }
.offline-step { font-size: 11px; font-weight: 600; color: var(--accent-deep); background: var(--accent-soft); border-radius: 6px; padding: 4px 6px; }
.offline-field { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 20px; }
.offline-field > label, #offline-hotwords-panel > label { font-size: 12px; font-weight: 500; color: var(--ink-mute); }
.offline-field select { width: 100%; min-height: 40px; }
.offline-target-toggle { display: flex; align-items: center; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.offline-target-toggle input { accent-color: var(--accent-deep); width: 16px; height: 16px; }
#offline-hotwords-panel { display: grid; gap: 8px; margin-top: 8px; }
#offline-hotwords { min-height: 96px; resize: vertical; font-size: 13px; line-height: 1.6; padding: 10px 12px; }
#offline-hotwords:disabled { background: var(--paper-sunk); color: var(--ink-mute); opacity: .6; }
#offline-target-note { font-size: 12px; line-height: 1.7; margin-top: 10px; }
body[data-page="emotion"] #enrollment-card { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 20px; }
body[data-page="emotion"] #enrollment-card > div:first-child { flex-wrap: wrap; }
body[data-page="emotion"] #enrollment-card p { line-height: 1.7; }
.offline-instructions { font-size: 12px; line-height: 1.8; color: var(--ink-mute); margin: -4px 0 20px; }
.offline-capture-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding: 18px; background: var(--paper-sunk); border: 1px dashed var(--line-strong); border-radius: 12px; }
.offline-capture-controls .mic-btn { width: 44px; height: 44px; box-shadow: none; }
.offline-capture-controls .pulse-ring { display: none; }
.offline-capture-controls .mic-status-label { margin: 0; font-size: 12px; letter-spacing: 0; }
.offline-capture-controls .upload-row { margin: 0 0 0 auto; flex-wrap: wrap; }
#offline-audio-panel { margin: 20px 0 0; border-top: 1px solid var(--line); padding-top: 18px; }
#offline-audio { height: 40px; }
#offline-run { background: var(--accent-deep); border-color: var(--accent-deep); color: white; padding: 9px 16px; margin-top: 12px; }
#offline-run:disabled { opacity: .5; }
body[data-page="emotion"] #emotion-result { min-height: 160px; padding: 20px; line-height: 1.8; overflow-wrap: anywhere; }
body[data-page="emotion"] #emotion-history { max-height: 260px; }
.offline-footnote { font-size: 11px; line-height: 1.7; color: var(--ink-mute); margin-top: 20px; }
@media (max-width: 1000px) { .offline-workspace { grid-template-columns: 270px minmax(0, 1fr); gap: 16px; } .offline-settings-card, .offline-input-card, .offline-results-card { padding: 18px; } }
@media (max-width: 760px) { body[data-page="emotion"] .offline-content { padding: 16px; } .offline-workspace { grid-template-columns: minmax(0, 1fr); } .offline-capture-controls .upload-row { margin-left: 0; } }
/* Speaker revisions can attribute different intervals of one ASR sentence. */
.speaker-timeline { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }
.speaker-timeline .status-pill { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

.bubble-actions,
.bubble-feedback-slot {
  display: inline-flex;
  align-items: flex-start;
  gap: 4px;
  flex-shrink: 0;
}

.bubble-feedback-slot {
  min-width: 22px;
  min-height: 22px;
}

.model-feedback {
  display: inline-flex;
  margin-top: 8px;
}

.bubble-feedback-slot .model-feedback {
  margin-top: 0;
}

.model-feedback-download {
  margin-left: 0;
  text-decoration: none;
}

.model-feedback-download:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.enrollment-profiles .hotword-input {
  flex: 1 1 120px;
  min-width: 0;
  max-width: 100%;
}

/* Confucius streaming playground */
.confucius-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; }
.confucius-workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.confucius-transcript-heading { display: flex; align-items: center; gap: 10px; padding: 2px 0 20px; font-size: 12px; font-weight: 500; color: var(--ink-mute); }
.confucius-transcript-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 24px 0; }
.confucius-greeting { display: flex; align-items: flex-start; gap: 12px; max-width: 660px; }
.confucius-greeting .chat-avatar { flex-shrink: 0; }
.confucius-greeting .chat-bubble { font-size: 13px; line-height: 1.8; }
.confucius-greeting-tip { margin-top: 14px; color: var(--ink-mute); }
.confucius-greeting[hidden] { display: none; }
#confucius-results { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.9; }
#confucius-results p { background: var(--paper-elev); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 16px 20px; margin: 0 0 14px; max-width: 660px; box-shadow: var(--shadow-sm); }
#confucius-results .confucius-partial { color: var(--ink-mute); border-style: dashed; }
.confucius-capture { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; padding: 28px 0 12px; }
.confucius-settings { display: flex; flex-direction: column; gap: 18px; min-height: 0; overflow-y: auto; padding-bottom: 4px; }
.confucius-settings-card { padding: 20px; }
.confucius-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.confucius-card-heading h2 { font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.confucius-model-tag { font-size: 10px; letter-spacing: .06em; color: var(--accent-deep); background: var(--accent-soft); border: 1px solid var(--line); border-radius: 5px; padding: 3px 7px; }
.confucius-field + .confucius-field { margin-top: 18px; }
.confucius-field > label { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--ink-mute); font-size: 11px; }
.confucius-field-unit { color: var(--ink-faint); }
.confucius-field .asr-lang-select, .confucius-field .hotword-input { width: 100%; height: 40px; }
.confucius-help { margin-top: 9px; font-size: 11px; line-height: 1.75; color: var(--ink-faint); }
.confucius-hotword-intro { margin: -10px 0 14px; color: var(--ink-mute); }
#confucius-hotwords { width: 100%; min-height: 140px; max-height: 240px; resize: vertical; font-size: 12px; line-height: 1.8; }
.confucius-hotword-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
#confucius-hotword-status { font-size: 11px; line-height: 1.5; color: var(--ink-mute); }
#confucius-apply { flex-shrink: 0; font-size: 12px; padding: 8px 14px; }
@media (max-width: 1100px) { .confucius-layout { grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; } }
@media (max-width: 800px) {
  .confucius-layout { display: flex; overflow-y: auto; }
  .confucius-workspace { min-height: 430px; flex-shrink: 0; }
  .confucius-settings { overflow: visible; flex-shrink: 0; }
}

/* Keep transcript controls available while hiding them for demonstrations. */
html[data-debug-controls='false'] .bubble-actions,
html[data-debug-controls='false'] .model-feedback {
  display: none;
}

.app-debug-toggle {
  position: relative;
  display: inline-flex;
  align-self: flex-start;
  flex-shrink: 0;
  margin: 8px 10px 14px;
  color: var(--ink-mute);
  cursor: pointer;
}
.app-debug-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.app-debug-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  opacity: 0.55;
}
.app-debug-icon svg { width: 18px; height: 18px; }
.app-debug-toggle input:checked + .app-debug-icon { opacity: 0.85; }
.app-debug-toggle:hover .app-debug-icon,
.app-debug-toggle input:focus-visible + .app-debug-icon {
  opacity: 1;
  background: rgba(128, 128, 128, 0.1);
}
.app-debug-toggle input:focus-visible + .app-debug-icon {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (min-width: 769px) {
  .app-sidebar[data-collapsed='true'] .app-debug-toggle { margin-inline: auto; }
}
@media (max-width: 768px) {
  .app-debug-toggle { margin: 0; align-self: center; }
}

/* The compact mobile header has no room for the model line. */
@media (max-width: 768px) {
  .app-model-info {
    display: none;
  }
}
