/* ============================================================
   ROS / MAXIMUS design language — Live Translation screen
   Light + dark themes via [data-theme] on <html>.
   Token values mirror packages/ui globals.css from maximus-web.
   ============================================================ */

:root,
:root[data-theme="light"] {
  color-scheme: light;

  --background: #ffffff;
  --app-bg: #f4f4f3;
  --foreground: #1a1a18;
  --card: #ffffff;
  --card-foreground: #1a1a18;
  --muted: #f5f5f4;
  --muted-foreground: #6b7280;
  --surface: #f9fafb;

  --primary: #22c55e;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(34, 197, 94, 0.12);
  --secondary: #f1f1ef;
  --secondary-foreground: #1f2937;
  --accent-foreground: #3f6212;

  --border: #e5e7eb;
  --input: #e5e7eb;
  --ring: #22c55e;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #2563eb;
  --info-bg: #eff6ff;

  --sidebar: #f9fafb;
  --sidebar-foreground: #374151;
  --sidebar-border: #e5e7eb;
  --sidebar-active-bg: #ececeb;

  --avatar-fg: #0a6e4a;
  --avatar-bg: #e6f3ec;

  --shadow-xs: 0 1px 2px 0 rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(16, 24, 40, 0.08), 0 1px 2px -1px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 12px 28px -12px rgba(16, 24, 40, 0.18);

  --radius: 0.875rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.125rem;
  --radius-pill: 9999px;

  --font-sans: "Geist", "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --background: #000000;
  --app-bg: #000000;
  --foreground: #f8fafc;
  --card: #131313;
  --card-foreground: #ffffff;
  --muted: #1a1a1a;
  --muted-foreground: #9ca3af;
  --surface: #0c0c0c;

  --primary: #84cc16;
  --primary-foreground: #09090b;
  --primary-soft: rgba(132, 204, 22, 0.16);
  --secondary: #1f2937;
  --secondary-foreground: #f3f4f6;
  --accent-foreground: #bef264;

  --border: #2a2f37;
  --input: #2a2f37;
  --ring: #84cc16;

  --success: #4ade80;
  --success-bg: #14331f;
  --warning: #facc15;
  --warning-bg: #3a2a06;
  --danger: #f87171;
  --danger-bg: #3a1414;
  --info: #60a5fa;
  --info-bg: #13284d;

  --sidebar: #09090b;
  --sidebar-foreground: #d1d5db;
  --sidebar-border: #1f2937;
  --sidebar-active-bg: #18181b;

  --avatar-fg: #bef264;
  --avatar-bg: rgba(132, 204, 22, 0.16);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.55);
  --shadow-md: 0 16px 36px -16px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
select,
textarea,
input {
  font: inherit;
  color: inherit;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

/* ---------- App shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 20px 18px 14px;
}

.sidebar-logo .logo {
  height: 30px;
  width: auto;
  display: block;
}

:root[data-theme="light"] .logo-dark,
:root[data-theme="dark"] .logo-light {
  display: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  margin: 14px 8px 4px;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--sidebar-foreground);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-link .nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  opacity: 0.85;
}

.nav-link:hover {
  background: var(--muted);
  color: var(--foreground);
}

.nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--foreground);
  font-weight: 600;
}

.nav-link.active .nav-icon {
  color: var(--primary);
  opacity: 1;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--sidebar-border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.user-chip:hover {
  background: var(--muted);
}

.user-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-fg);
  font-weight: 700;
  font-size: 0.85rem;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
  flex: 1;
}

.user-meta strong {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--foreground);
}

.user-meta span {
  font-size: 0.72rem;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip .chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--muted-foreground);
}

/* ---------- Main column + topbar ---------- */

.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--background) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-heading .breadcrumb {
  margin: 0 0 2px;
  color: var(--muted-foreground);
  font-size: 0.74rem;
  font-weight: 600;
}

.topbar-heading h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-cluster {
  display: flex;
  gap: 8px;
}

.status-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.status-tile > span {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.neutral {
  color: var(--muted-foreground);
  background: var(--muted);
  border-color: var(--border);
}

.status-pill.ok {
  color: var(--success);
  background: var(--success-bg);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

.status-pill.warn {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: color-mix(in srgb, var(--warning) 35%, transparent);
}

.status-pill.bad {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.status-pill.pulse::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1s ease-in-out infinite;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--foreground);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--muted);
}

.theme-toggle .theme-icon {
  width: 18px;
  height: 18px;
}

:root[data-theme="light"] .theme-toggle .icon-moon,
:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

/* ---------- Content & panels ---------- */

.content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--app-bg);
}

.panel,
.metrics-strip,
.caption-card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.panel {
  padding: 20px;
}

.panel-head {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-foreground);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--foreground);
}

.panel-sub {
  margin: 6px 0 0;
  color: var(--muted-foreground);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---------- Controls ---------- */

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.direction-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.direction-panel > label {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 600;
}

.direction-select {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.direction-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--muted);
  width: fit-content;
}

.direction-choice {
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: calc(var(--radius-md) - 4px);
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.direction-choice:hover {
  color: var(--foreground);
}

.direction-choice.active {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 45%, transparent);
}

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

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 88%, #000);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--secondary) 80%, var(--foreground) 8%);
}

.btn-outline {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--muted);
  color: var(--foreground);
}

.action-button {
  height: 48px;
  padding: 0 22px;
  font-size: 1rem;
}

.button-icon {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 22%, transparent);
}

.icon-button {
  width: 48px;
  height: 48px;
  padding: 0;
}

.icon-button span {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--danger);
}

.history-clear {
  height: 34px;
  padding: 0 14px;
  font-size: 0.85rem;
}

/* ---------- Stage ---------- */

.stage {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 14px;
  padding: 16px;
  background: var(--muted);
}

.participant,
.engine-core {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-xs);
}

.participant {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
}

.participant-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-fg);
  font-weight: 700;
  font-size: 1.05rem;
}

.participant p {
  margin: 0 0 2px;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 600;
}

.participant strong {
  color: var(--foreground);
  font-size: 1.15rem;
  font-weight: 600;
}

.engine-core {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 18px;
  overflow: hidden;
}

.engine-ring {
  position: relative;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
}

.engine-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--primary) 45%, transparent);
  animation: ring 2.6s ease-out infinite;
}

.engine-node {
  position: relative;
  z-index: 1;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--primary) 70%, transparent);
}

.pipeline-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(360px, 100%);
}

.pipeline-rail span {
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 0.76rem;
  font-weight: 600;
}

.message {
  margin: 0;
  min-height: 20px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ---------- Signal pills + wave bars ---------- */

.signal-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.1;
  overflow: hidden;
  transition: background-color 0.24s ease, border-color 0.24s ease, color 0.24s ease;
}

.signal-pill.active {
  color: var(--success);
  background: var(--success-bg);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

#mic-indicator-label,
#audio-indicator-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wave-bars {
  display: inline-flex;
  align-items: flex-end;
  flex: 0 0 auto;
  gap: 3px;
  height: 20px;
}

.wave-bars span {
  width: 3px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.72;
  transform-origin: center bottom;
  transition: transform 0.14s ease, opacity 0.14s ease;
}

#audio-indicator.active .wave-bars span {
  animation: wave 0.72s ease-in-out infinite alternate;
}

.wave-bars span:nth-child(2),
.wave-bars span:nth-child(5) {
  animation-delay: 0.1s;
}

.wave-bars span:nth-child(3),
.wave-bars span:nth-child(6) {
  animation-delay: 0.2s;
}

/* ---------- Latency strip ---------- */

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.latency-pill {
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--muted);
  color: var(--foreground);
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.latency-pill.total {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 32%, transparent);
  color: var(--accent-foreground);
}

/* ---------- Caption cards ---------- */

.caption-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.caption-card {
  min-height: 220px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.translated-card {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-topline > span:first-child {
  color: var(--foreground);
  font-size: 0.82rem;
  font-weight: 700;
}

#source-provider,
#provider-badge {
  color: var(--muted-foreground);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--muted);
}

.display-text {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--foreground);
}

.display-text.compact {
  font-size: 1.5rem;
  line-height: 1.3;
}

.display-text.dense {
  font-size: 1.2rem;
  line-height: 1.4;
}

.display-text.placeholder {
  color: var(--muted-foreground);
  font-weight: 500;
}

.display-text.interim {
  color: var(--muted-foreground);
  font-style: italic;
}

.result-meta {
  margin: 16px 0 0;
  color: var(--muted-foreground);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
}

.translated-card.flash {
  animation: flash-card 0.9s ease;
}

/* ---------- Preview console ---------- */

.console-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.console-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--foreground);
}

.scenario-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.scenario-chip {
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.scenario-chip:hover {
  color: var(--foreground);
  background: var(--muted);
}

.scenario-chip.active {
  color: var(--accent-foreground);
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
}

.text-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--foreground);
  font-size: 0.95rem;
  line-height: 1.5;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.text-helper {
  margin: 10px 0 0;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ---------- History (ROS transcript bubbles) ---------- */

.history-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.history-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--foreground);
}

.conversation-history {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
  scroll-behavior: smooth;
}

.history-empty {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.history-entry {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--muted);
}

.history-entry-header,
.history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-entry-header {
  justify-content: space-between;
  flex-wrap: wrap;
}

.history-direction {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 600;
}

.history-latency,
.history-time {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
}

.history-latency {
  color: var(--accent-foreground);
  background: var(--primary-soft);
}

.history-time {
  color: var(--muted-foreground);
  background: var(--card);
  border: 1px solid var(--border);
}

.history-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.history-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 11px 13px;
}

.history-block:first-child {
  background: var(--secondary);
  border-radius: var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg);
}

.history-block:last-child {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-sm) var(--radius-lg) var(--radius-lg);
}

.history-block-label {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 600;
}

.history-block p {
  margin: 0;
  color: var(--foreground);
  font-size: 0.92rem;
  line-height: 1.45;
}

/* ---------- Footer ---------- */

.footer {
  margin-top: 4px;
  padding: 8px 4px 0;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

/* ---------- Animations ---------- */

@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

@keyframes wave {
  from {
    transform: scaleY(0.45);
  }
  to {
    transform: scaleY(1.55);
  }
}

@keyframes ring {
  0% {
    transform: scale(0.7);
    opacity: 0.85;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

@keyframes flash-card {
  0% {
    box-shadow: var(--shadow-xs);
  }
  35% {
    box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-md);
  }
  100% {
    box-shadow: var(--shadow-xs);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .stage,
  .metrics-strip,
  .caption-grid,
  .history-pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    height: auto;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-border);
  }
  .sidebar-logo {
    padding: 6px 8px;
  }
  .sidebar-nav {
    display: none;
  }
  .sidebar-footer {
    margin-left: auto;
    border-top: 0;
    padding: 0;
  }
  .user-meta {
    display: none;
  }
  .main-col {
    height: auto;
    overflow: visible;
  }
  .content {
    overflow: visible;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }
  .status-cluster {
    flex: 1;
  }
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .action-row {
    flex-direction: column;
  }
  .direction-toggle,
  .action-button {
    width: 100%;
  }
  .direction-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .display-text {
    font-size: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .engine-pulse,
  .status-pill.pulse::after,
  .translated-card.flash,
  #audio-indicator.active .wave-bars span {
    animation: none !important;
  }
}

/* ---------- Embedded in the ROS portal (iframe) ----------
   Drop our own ROS sidebar and theme toggle so only the Live Translation
   surface shows. ROS owns the theme when embedded (it passes the theme in via
   ?theme= / postMessage and has its own control in settings), so a standalone
   toggle in the frame would just be a confusing duplicate. data-embed is set
   pre-paint in index.html (auto-detects the iframe; ?embed=1 forces it).
   Standalone rendering is unchanged. */
:root[data-embed="1"] .app-shell {
  grid-template-columns: 1fr;
}

:root[data-embed="1"] .sidebar,
:root[data-embed="1"] .theme-toggle {
  display: none;
}
