/*
 * AG-Remote phone UI, Material 3 Expressive.
 * Colour roles: an HCT scheme seeded with #2c5fcc (blue), near-neutral cool surfaces, and one
 * signature gradient used only for the "working" indicator and the empty-state headline.
 * Spec and contrast ratios: docs/design/PWA_REDESIGN_SPEC.md.
 */

/* "AG Remote Sans": Latin subset of Google Sans Flex (SIL OFL 1.1, see fonts/OFL.txt),
   weight axis 400-700, other axes pinned. Renamed because the original name is reserved
   for unmodified copies. */
@font-face {
  font-family: "AG Remote Sans";
  src: url("/fonts/ag-remote-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --md-primary: #2258c4;
  --md-on-primary: #ffffff;
  --md-primary-container: #dae2ff;
  --md-on-primary-container: #0040a2;
  --md-secondary: #585e71;
  --md-secondary-container: #dce2f9;
  --md-on-secondary-container: #404659;
  --md-tertiary: #6b5293;
  --md-tertiary-container: #ecdcff;
  --md-on-tertiary-container: #533a79;
  --md-surface: #ffffff;
  --md-surface-dim: #d9dadd;
  --md-surface-bright: #ffffff;
  --md-surface-container-lowest: #ffffff;
  --md-surface-container-low: #f6f6f9;
  --md-surface-container: #f0f0f3;
  --md-surface-container-high: #eaebee;
  --md-surface-container-highest: #e5e5e8;
  --md-on-surface: #191c1e;
  --md-on-surface-variant: #41484d;
  --md-outline: #71787e;
  --md-outline-variant: #c1c7ce;
  --md-inverse-surface: #2e3133;
  --md-inverse-on-surface: #f0f0f3;
  --md-inverse-primary: #b2c5ff;
  --md-error: #ba1a1a;
  --md-on-error: #ffffff;
  --md-error-container: #ffdad6;
  --md-on-error-container: #93000a;
  --md-warning-container: #ffddb8;
  --md-on-warning-container: #2b1700;
  --md-success: #376934;
  --md-scrim: rgba(0, 0, 0, 0.32);
  --md-gradient-1: #007491;
  --md-gradient-2: #2358c3;
  --md-gradient-3: #7148af;

  /* Legacy aliases kept for existing checks */
  --bg-primary: var(--md-surface);

  --brand-gradient: linear-gradient(90deg, var(--md-gradient-1), var(--md-gradient-2) 45%, var(--md-gradient-3));

  --font-sans: "AG Remote Sans", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* M3 Expressive corner scale */
  --shape-xs: 4px;
  --shape-sm: 8px;
  --shape-md: 12px;
  --shape-lg: 16px;
  --shape-lg-plus: 20px;
  --shape-xl: 28px;
  --shape-full: 999px;
  --elev-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);

  /* Motion: a spring for things that move, a standard curve for fades */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --motion-spring: cubic-bezier(0.34, 1.3, 0.64, 1);
  --dur-short: 150ms;
  --dur-medium: 300ms;
  --dur-spring: 500ms;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@supports (animation-timing-function: linear(0, 1)) {
  :root {
    --motion-spring: linear(0, 0.12 4%, 0.42 10%, 0.78 18%, 0.97 26%, 1.035 34%, 1.03 44%, 1.005 60%, 1);
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --md-primary: #b2c5ff;
    --md-on-primary: #002b74;
    --md-primary-container: #0040a2;
    --md-on-primary-container: #dae2ff;
    --md-secondary: #c0c6dd;
    --md-secondary-container: #404659;
    --md-on-secondary-container: #dce2f9;
    --md-tertiary: #d6baff;
    --md-tertiary-container: #533a79;
    --md-on-tertiary-container: #ecdcff;
    --md-surface: #111416;
    --md-surface-dim: #111416;
    --md-surface-bright: #37393c;
    --md-surface-container-lowest: #0c0e11;
    --md-surface-container-low: #191c1e;
    --md-surface-container: #1d2022;
    --md-surface-container-high: #282a2c;
    --md-surface-container-highest: #333537;
    --md-on-surface: #e2e2e5;
    --md-on-surface-variant: #c1c7ce;
    --md-outline: #8b9198;
    --md-outline-variant: #41484d;
    --md-inverse-surface: #e2e2e5;
    --md-inverse-on-surface: #2e3133;
    --md-inverse-primary: #2258c4;
    --md-error: #ffb4ab;
    --md-on-error: #690005;
    --md-error-container: #93000a;
    --md-on-error-container: #ffdad6;
    --md-warning-container: #653e00;
    --md-on-warning-container: #ffddb8;
    --md-success: #9cd593;
    --md-scrim: rgba(0, 0, 0, 0.6);
    --md-gradient-1: #5ed4fd;
    --md-gradient-2: #aabfff;
    --md-gradient-3: #cdacff;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --md-primary: #b2c5ff;
  --md-on-primary: #002b74;
  --md-primary-container: #0040a2;
  --md-on-primary-container: #dae2ff;
  --md-secondary: #c0c6dd;
  --md-secondary-container: #404659;
  --md-on-secondary-container: #dce2f9;
  --md-tertiary: #d6baff;
  --md-tertiary-container: #533a79;
  --md-on-tertiary-container: #ecdcff;
  --md-surface: #111416;
  --md-surface-dim: #111416;
  --md-surface-bright: #37393c;
  --md-surface-container-lowest: #0c0e11;
  --md-surface-container-low: #191c1e;
  --md-surface-container: #1d2022;
  --md-surface-container-high: #282a2c;
  --md-surface-container-highest: #333537;
  --md-on-surface: #e2e2e5;
  --md-on-surface-variant: #c1c7ce;
  --md-outline: #8b9198;
  --md-outline-variant: #41484d;
  --md-inverse-surface: #e2e2e5;
  --md-inverse-on-surface: #2e3133;
  --md-inverse-primary: #2258c4;
  --md-error: #ffb4ab;
  --md-on-error: #690005;
  --md-error-container: #93000a;
  --md-on-error-container: #ffdad6;
  --md-warning-container: #653e00;
  --md-on-warning-container: #ffddb8;
  --md-success: #9cd593;
  --md-scrim: rgba(0, 0, 0, 0.6);
  --md-gradient-1: #5ed4fd;
  --md-gradient-2: #aabfff;
  --md-gradient-3: #cdacff;
}




*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  font-family: var(--font-sans);
  background-color: var(--md-surface);
  color: var(--md-on-surface);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.1px;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* State layer shared by tappable things */
.btn-icon:active,
.btn-attach:active,
.tab:active,
.session-item:active,
.option-item:active,
.session-label-btn:active {
  background-color: color-mix(in srgb, var(--md-on-surface) 10%, transparent);
}

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  max-width: 760px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

/* Top app bar: flat, same surface as the page */
.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: calc(8px + var(--safe-top)) 6px 8px 8px;
  min-height: 64px;
  background: var(--md-surface);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.header-titles {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.brand-logo { display: none; }

.session-label {
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--md-on-surface);
  cursor: pointer;
  margin: 0;
  user-select: none;
  transition: opacity var(--dur-short) var(--ease);
}
.session-label:active { opacity: 0.7; }

.header-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Status: a dot and a short label */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px 0 10px;
  margin-right: 4px;
  border-radius: var(--shape-full);
  background: var(--md-surface-container);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  transition: background-color var(--dur-medium) var(--ease), color var(--dur-medium) var(--ease);
}
.status-text:empty { display: none; }
.status-badge:has(.status-text:empty) { padding: 0 8px; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-outline);
}

.status-badge[data-status="idle"] .status-dot { background: var(--md-success); }
.status-badge[data-status="generating"] .status-dot { background: var(--md-primary); animation: pulse 1.2s ease-in-out infinite; }
.status-badge[data-status="awaiting_approval"] {
  background: var(--md-warning-container);
  color: var(--md-on-warning-container);
}
.status-badge[data-status="awaiting_approval"] .status-dot { background: currentColor; }
.status-badge[data-status="disconnected"] .status-dot { background: var(--md-error); }
.status-badge[data-status="disconnected"] {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.status-badge[data-status="disconnected"]:hover {
  background: var(--md-surface-container-high);
}
.status-badge[data-status="disconnected"]:active {
  background: var(--md-surface-container-highest);
  transform: scale(0.96);
}

@keyframes pulse {
  50% { opacity: 0.3; }
}

/* Icon button (48px touch target) */
.btn-icon {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--shape-full);
  background: none;
  color: var(--md-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--dur-short) var(--ease);
}
.btn-icon svg { width: 24px; height: 24px; }

/* Working indicator: the signature gradient sweeping under the header */
.progress {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 3px;
  border-radius: 3px;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--dur-medium) var(--ease);
}
body[data-status="generating"] .progress { opacity: 1; }
.progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg,
    transparent, var(--md-gradient-1) 20%, var(--md-gradient-2) 40%, var(--md-gradient-3) 60%, transparent 80%);
  background-size: 200% 100%;
}
body[data-status="generating"] .progress-bar { animation: sweep 1.6s linear infinite; }
@keyframes sweep {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* Window tabs: hidden from chat screen per user preference; switched via side drawer */
.tab-bar {
  display: none !important;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 200px;
  height: 40px;
  margin: 4px 0;
  padding: 0 16px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-full);
  background: none;
  color: var(--md-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--dur-short) var(--ease), border-color var(--dur-short) var(--ease);
}
/* 48px touch target around the 40px chip */
.tab::before {
  content: "";
  position: absolute;
  inset: -4px 0;
}
.tab[aria-selected="true"] {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  border-color: transparent;
}
.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status badge: dot while working, "!" when the window needs you */
.tab-badge { display: none; }
.tab[data-status="generating"] .tab-badge {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-primary);
  animation: pulse 1.2s ease-in-out infinite;
}
.tab[data-status="awaiting_approval"] .tab-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--md-error);
  color: var(--md-on-error);
  font-size: 11px;
  font-weight: 700;
}
.tab[data-status="awaiting_approval"] .tab-badge::before { content: "!"; }

/* "Last active 3 h ago": the shown conversation is idle and has been quiet for a while */
.last-active {
  align-self: center;
  margin: 0 16px 4px;
  padding: 4px 12px;
  border-radius: var(--shape-full);
  background: var(--md-surface-container);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--md-on-surface-variant);
  flex-shrink: 0;
}

/* Approval card: the most prominent thing on screen. It sits just above the composer,
   within thumb reach, and springs up from there. */
.approval-card {
  order: 1;
  margin: 8px 12px 4px;
  padding: 20px;
  background: var(--md-surface-container-highest);
  border-radius: var(--shape-xl);
  animation: card-in var(--dur-spring) var(--motion-spring);
  flex-shrink: 0;
  max-height: 62vh;
  max-height: 62dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.approval-card.busy { opacity: 0.6; pointer-events: none; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(32px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.approval-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.approval-header svg {
  box-sizing: content-box;
  width: 20px;
  height: 20px;
  padding: 8px;
  border-radius: 50%;
  background: var(--md-warning-container);
  color: var(--md-on-warning-container);
  flex-shrink: 0;
}

.approval-badge {
  flex: 1;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
}

/* Kind of request as a small chip */
.approval-kind {
  height: 24px;
  padding: 0 10px;
  border-radius: var(--shape-sm);
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  font-size: 12px;
  line-height: 24px;
  font-weight: 500;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.approval-desc {
  font-size: 18px;
  line-height: 26px;
  font-weight: 500;
  letter-spacing: 0;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

/* The exact command or file. It wraps rather than scrolls sideways, so nothing a
   person is approving can sit off screen. */
.approval-detail {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  border-radius: var(--shape-lg);
  padding: 12px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 180px;
  overflow-y: auto;
}

.approval-cwd {
  margin-top: 8px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.2px;
  color: var(--md-on-surface-variant);
  word-break: break-all;
}

.approval-ide-only {
  margin-top: 12px;
  font-size: 14px;
  color: var(--md-error);
}

/* Filled text field */
.text-field,
.option-writein input {
  width: 100%;
  height: 56px;
  margin-top: 12px;
  padding: 0 16px;
  border: none;
  border-bottom: 1px solid var(--md-on-surface-variant);
  border-radius: var(--shape-xs) var(--shape-xs) 0 0;
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  font: inherit;
  font-size: 16px;
  transition: border-color var(--dur-short) var(--ease);
}
.text-field:focus,
.option-writein input:focus {
  outline: none;
  border-bottom: 2px solid var(--md-primary);
  padding-top: 1px;
}
.text-field::placeholder,
.option-writein input::placeholder { color: var(--md-on-surface-variant); font-size: 14px; }

.approval-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 24px;
  border-radius: var(--shape-full);
  border: none;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  transition: border-radius var(--dur-short) var(--ease), filter var(--dur-short) var(--ease);
}
/* Expressive press: the pill squares off a little */
.btn:active { border-radius: var(--shape-lg); filter: brightness(0.94); }
.btn:disabled { opacity: 0.38; cursor: default; }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.btn-approve,
.btn-primary {
  background: var(--md-primary);
  color: var(--md-on-primary);
}

.btn-always {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}

.btn-deny {
  background: transparent;
  color: var(--md-error);
  border: 1px solid var(--md-outline);
}

.btn-text {
  background: transparent;
  color: var(--md-primary);
  padding: 0 16px;
  min-height: 48px;
}

/* Question options: large selectable list items */
.approval-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: var(--shape-lg);
  border: none;
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease), border-radius var(--dur-short) var(--ease);
}
.option-item.selected {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  border-radius: var(--shape-xl);
}

.option-radio-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--md-on-surface-variant);
  flex-shrink: 0;
  position: relative;
}
.option-item.selected .option-radio-dot { border-color: var(--md-primary); }
.option-item.selected .option-radio-dot::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--md-primary);
}

.option-text { font-size: 16px; line-height: 24px; }

.option-submit-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.option-writein {
  display: flex;
  gap: 8px;
  align-items: center;
}
.option-writein input { margin-top: 0; flex: 1; }

/* Chat feed */
.chat-feed {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Empty state: a big gradient headline and lots of space */
.empty-state {
  margin: auto 0;
  padding: 0 8px 12vh;
  max-width: 400px;
  color: var(--md-on-surface-variant);
}
.empty-icon { display: none; }
/* It says "Connected", so it waits until the phone is */
body[data-status="disconnected"] .empty-state { visibility: hidden; }
.empty-state h2 {
  font-size: 32px;
  line-height: 40px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--md-primary);
  margin-bottom: 12px;
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .empty-state h2 {
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}
.empty-state p {
  font-size: 16px;
  line-height: 24px;
}

.chat-message {
  animation: message-in var(--dur-spring) var(--motion-spring);
  min-width: 0;
}
@keyframes message-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* User prompts: a soft container on the right */
.chat-message.user {
  align-self: flex-end;
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--shape-lg-plus) var(--shape-sm) var(--shape-lg-plus) var(--shape-lg-plus);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}
/* "You" is for screen readers; the position already says it */
.chat-message.user .chat-author {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Agent replies: plain full-width text under a small avatar with the app's mark */
.chat-message.agent {
  align-self: stretch;
  display: grid;
  grid-template-columns: 28px 1fr;
  column-gap: 10px;
  row-gap: 8px;
  align-items: center;
}
.chat-message.agent::before {
  content: "";
  grid-column: 1;
  grid-row: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--md-primary-container);
}
.chat-message.agent::after {
  content: "";
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  background: var(--md-on-primary-container);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 19l6-10 6 10'/%3E%3Cpath d='M9.5 6.5a3.5 3.5 0 0 1 5 0'/%3E%3Cpath d='M7.05 4.05a7 7 0 0 1 9.9 0'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 19l6-10 6 10'/%3E%3Cpath d='M9.5 6.5a3.5 3.5 0 0 1 5 0'/%3E%3Cpath d='M7.05 4.05a7 7 0 0 1 9.9 0'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chat-message.agent .chat-author {
  grid-column: 2;
  grid-row: 1;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
}
.chat-message.agent .chat-text,
.chat-message.agent .chat-images {
  grid-column: 1 / -1;
}

.chat-text {
  font-size: 16px;
  line-height: 24px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-link {
  color: var(--md-primary);
  text-underline-offset: 3px;
}

/* File cited by the agent, shown by name only, as an assist chip */
.chat-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 26px;
  padding: 0 8px 0 6px;
  margin: 1px 0;
  vertical-align: bottom;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-sm);
  color: var(--md-on-surface);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-file::before {
  content: "";
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: var(--md-primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M360-240h240q17 0 28.5-11.5T640-280q0-17-11.5-28.5T600-320H360q-17 0-28.5 11.5T320-280q0 17 11.5 28.5T360-240Zm0-160h240q17 0 28.5-11.5T640-440q0-17-11.5-28.5T600-480H360q-17 0-28.5 11.5T320-440q0 17 11.5 28.5T360-400ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h287q16 0 30.5 6t25.5 17l194 194q11 11 17 25.5t6 30.5v447q0 33-23.5 56.5T720-80H240Zm280-560v-160H240v640h480v-440H560q-17 0-28.5-11.5T520-640ZM240-800v200-200 640-640Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M360-240h240q17 0 28.5-11.5T640-280q0-17-11.5-28.5T600-320H360q-17 0-28.5 11.5T320-280q0 17 11.5 28.5T360-240Zm0-160h240q17 0 28.5-11.5T640-440q0-17-11.5-28.5T600-480H360q-17 0-28.5 11.5T320-440q0 17 11.5 28.5T360-400ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h287q16 0 30.5 6t25.5 17l194 194q11 11 17 25.5t6 30.5v447q0 33-23.5 56.5T720-80H240Zm280-560v-160H240v640h480v-440H560q-17 0-28.5-11.5T520-640ZM240-800v200-200 640-640Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Bottom bar: a floating pill composer */
.app-footer {
  order: 2;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px calc(14px + var(--safe-bottom));
  background: var(--md-surface);
  flex-shrink: 0;
  z-index: 10;
}

.prompt-form {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 48px;
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline-variant);
  border-radius: 26px;
  transition: background-color var(--dur-short) var(--ease), border-color var(--dur-short) var(--ease), box-shadow var(--dur-short) var(--ease);
}
.prompt-form:focus-within {
  background: var(--md-surface-container-high);
  border-color: var(--md-primary);
  box-shadow: 0 0 0 1px var(--md-primary);
}

#promptInput {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--md-on-surface);
  font: inherit;
  font-size: 15px;
  line-height: 20px;
  padding: 8px 6px;
  margin: 0;
  resize: none;
  height: 36px;
  min-height: 36px;
  max-height: 120px;
  outline: none;
  box-sizing: border-box;
  overflow-y: hidden;
  align-self: center;
}
#promptInput::placeholder {
  color: var(--md-on-surface-variant);
  opacity: 0.8;
}

/* Send: an icon until there is something to send, then a filled circle */
.btn-send,
.btn-stop {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border: none;
  border-radius: var(--shape-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
  align-self: center;
  transition: background-color var(--dur-short) var(--ease), color var(--dur-short) var(--ease), transform var(--dur-spring) var(--motion-spring);
}
.btn-send {
  background: var(--md-primary);
  color: var(--md-on-primary);
}
.btn-send:disabled {
  background: transparent;
  color: color-mix(in srgb, var(--md-on-surface-variant) 40%, transparent);
  cursor: default;
}
.btn-send svg {
  width: 19px;
  height: 19px;
  transform: translateX(1px);
}
.btn-stop svg {
  width: 16px;
  height: 16px;
}

/* Stop takes the send button's place while the agent works (send comes back beside it
   once there is text to send) */
.btn-stop {
  background: var(--md-on-surface);
  color: var(--md-surface);
  animation: pop-in var(--dur-spring) var(--motion-spring);
}
.btn-stop svg { width: 16px; height: 16px; }
.prompt-form:has(.btn-stop:not(.hidden)) .btn-send:disabled { display: none; }
@keyframes pop-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.btn-attach,
.btn-mic {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border: none;
  border-radius: var(--shape-full);
  background: none;
  color: var(--md-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
  align-self: center;
  transition: background-color var(--dur-short) var(--ease), color var(--dur-short) var(--ease);
}
.btn-attach svg,
.btn-mic svg { width: 20px; height: 20px; }
.btn-attach:disabled,
.btn-mic:disabled { opacity: 0.38; }

.btn-mic.listening {
  color: var(--md-error);
  background: var(--md-error-container);
  box-shadow: 0 0 0 2px var(--md-error);
  animation: pulse-listening 1.5s ease-in-out infinite;
}

@keyframes pulse-listening {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-error) 40%, transparent); }
  50% { opacity: 0.85; box-shadow: 0 0 0 6px color-mix(in srgb, var(--md-error) 0%, transparent); }
}

/* Picked images waiting to be sent */
.attach-tray {
  display: flex;
  gap: 8px;
  padding: 8px 4px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.attach-item {
  position: relative;
  flex-shrink: 0;
  animation: pop-in var(--dur-spring) var(--motion-spring);
}
.attach-item img {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--shape-lg);
}
.attach-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
  font-size: 16px;
  line-height: 24px;
  cursor: pointer;
}
/* 48px touch target around the 24px button */
.attach-remove::before {
  content: "";
  position: absolute;
  inset: -12px;
}
.attach-item.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 36px 8px 12px;
  background: var(--md-surface-container-high);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-lg);
  min-height: 48px;
  max-width: 220px;
}
.attach-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-primary);
  flex-shrink: 0;
}
.attach-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.attach-file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--md-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-file-size {
  font-size: 11px;
  color: var(--md-outline);
}
.attach-item.file-item .attach-remove {
  top: 50%;
  transform: translateY(-50%);
  right: 6px;
}


/* Images inside a sent message */
.chat-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chat-message.user .chat-images { margin: -4px -8px 8px; }
.chat-message.user .chat-images:last-child { margin-bottom: -4px; }
.chat-images img {
  max-width: 160px;
  max-height: 160px;
  border-radius: var(--shape-md);
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.chat-images img:active {
  transform: scale(0.97);
  opacity: 0.85;
}

/* Snackbar: sits above every layer, including dialogs */
.snackbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(84px + var(--safe-bottom));
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 4px 4px 4px 16px;
  border-radius: var(--shape-sm);
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
  box-shadow: var(--elev-2);
  z-index: 300;
  animation: snack-in var(--dur-spring) var(--motion-spring);
}
/* An open approval card sits where the snackbar would; show the snackbar at the top instead */
body:has(.approval-card:not(.hidden)) .snackbar {
  top: calc(68px + var(--safe-top));
  bottom: auto;
}
@keyframes snack-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
.snackbar-message { flex: 1; font-size: 14px; line-height: 20px; padding: 10px 0; }
.snackbar-action {
  min-height: 48px;
  padding: 0 12px;
  border: none;
  border-radius: var(--shape-full);
  background: none;
  color: var(--md-inverse-primary);
  font-weight: 500;
  cursor: pointer;
}
.snackbar-close {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--shape-full);
  background: none;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Dialogs: centred on wide screens, bottom sheets on phones */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--md-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
  animation: fade-in var(--dur-medium) var(--ease);
}
@keyframes fade-in {
  from { opacity: 0; }
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 24px;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-xl);
  animation: dialog-in var(--dur-spring) var(--motion-spring);
}
@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 599px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    max-width: none;
    padding: 28px 24px calc(24px + var(--safe-bottom));
    border-radius: var(--shape-xl) var(--shape-xl) 0 0;
    background: var(--md-surface-container-low);
    animation-name: sheet-in;
  }
  /* Drag-handle look, decorative */
  .modal-card::before {
    content: "";
    position: absolute;
    top: 12px;
    left: 50%;
    width: 32px;
    height: 4px;
    margin-left: -16px;
    border-radius: 2px;
    background: var(--md-outline-variant);
  }
}
@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.modal-card h2 {
  font-size: 24px;
  line-height: 32px;
  font-weight: 500;
  letter-spacing: 0;
  margin-bottom: 12px;
}

.modal-card p {
  color: var(--md-on-surface-variant);
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 20px;
}

.dialog-icon {
  width: 56px;
  height: 56px;
  margin: 8px auto 16px;
  border-radius: 50%;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
}
#pairingModal h2,
#pairingModal #pairHint { text-align: center; }

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -8px -12px 4px 0;
}
.dialog-header h2 { margin: 0; font-size: 22px; line-height: 28px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--md-on-surface-variant);
  margin-bottom: 6px;
}

/* Code entry: big, tabular, one field (a pasted QR link must fit too) */
.token-input {
  width: 100%;
  height: 64px;
  padding: 0 16px;
  border: 2px solid transparent;
  border-radius: var(--shape-lg);
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
  font-family: var(--font-sans);
  font-size: 28px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 6px;
  text-align: center;
  text-transform: none;
  transition: border-color var(--dur-short) var(--ease);
}
.token-input:placeholder-shown {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.2px;
}
.token-input::placeholder { color: var(--md-on-surface-variant); }
.token-input:focus {
  outline: none;
  border-color: var(--md-primary);
}

/* The 4-digit code to compare with the PC */
.modal-card .pair-check-code {
  margin: 4px 0 20px;
  font-size: 56px;
  line-height: 64px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 12px;
  text-indent: 12px;
  text-align: center;
  color: var(--md-on-surface);
}

.modal-card .pair-error {
  color: var(--md-error);
  font-size: 14px;
  margin: 10px 0 0;
  text-align: center;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
#pairingModal .modal-actions { flex-direction: column-reverse; align-items: stretch; }

.modal-card .dialog-footnote {
  margin: 20px 0 0;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.4px;
  text-align: center;
  color: var(--md-on-surface-variant);
}

/* Windows & conversations list */
.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 60vh;
  max-height: 60dvh;
  overflow-y: auto;
  margin: 0 -12px;
}

.list-subheader {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--md-primary);
  padding: 16px 16px 8px;
}

.list-divider {
  height: 1px;
  background: var(--md-outline-variant);
  margin: 8px 16px;
}

.list-empty {
  color: var(--md-on-surface-variant);
  padding: 8px 16px;
}
.list-empty.error { color: var(--md-error); }

.session-item {
  padding: 12px 16px;
  min-height: 64px;
  border-radius: var(--shape-lg);
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease);
}
.session-item.current {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.session-item.busy { opacity: 0.5; }

.session-item-title {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item-sub {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 18px;
  color: var(--md-on-surface-variant);
}
.session-item.current .session-item-sub { color: inherit; }
.session-item-sub span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focused-tag {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: var(--shape-xs);
  background: color-mix(in srgb, var(--md-success) 18%, transparent);
  color: var(--md-on-surface);
  font-size: 11px;
  line-height: 18px;
  font-weight: 500;
  vertical-align: 2px;
}

/* Notification bell: slashed when off, filled when on */
#btnNotify .bell-on { display: none; }
#btnNotify[aria-pressed="true"] .bell-on { display: inline; }
#btnNotify[aria-pressed="true"] .bell-off { display: none; }
#btnNotify[aria-pressed="true"] { color: var(--md-primary); }

/* Reduced motion: no movement, only short fades */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  body[data-status="generating"] .progress-bar {
    animation: none !important;
    background: var(--brand-gradient);
    background-size: 100% 100%;
  }
  .status-dot { animation: none !important; }
}



/* Auto-Pilot Chip */
.autopilot-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  margin-right: 2px;
  border: 1px solid var(--md-warning-container);
  border-radius: var(--shape-full);
  background: var(--md-warning-container);
  color: var(--md-on-warning-container);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: opacity var(--dur-short) var(--ease);
}
.autopilot-chip:active { opacity: 0.8; }
.autopilot-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: auto-pilot-glow 1.5s ease-in-out infinite alternate;
}
@keyframes auto-pilot-glow {
  from { opacity: 0.4; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

@media (max-width: 380px) {
  .autopilot-chip {
    padding: 0 8px;
    gap: 4px;
  }
  .autopilot-label {
    display: none;
  }
  .autopilot-chip::after {
    content: 'Auto';
    font-size: 11px;
    font-weight: 600;
  }
}

/* Navigation Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--md-scrim);
  z-index: 300;
  animation: fade-in var(--dur-medium) var(--ease);
}
.drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background: var(--md-surface-container-low);
  display: flex;
  flex-direction: column;
  animation: drawer-in var(--dur-spring) var(--motion-spring);
  box-shadow: var(--elev-2);
}
@keyframes drawer-in {
  from { transform: translateX(-100%); }
  to { transform: none; }
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--md-outline-variant);
}
.drawer-branding {
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--shape-sm);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
}
.drawer-branding h2 {
  font-size: 17px;
  line-height: 24px;
  font-weight: 500;
  color: var(--md-on-surface);
  margin: 0;
}
.drawer-status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--md-surface-container);
  border-bottom: 1px solid var(--md-outline-variant);
  gap: 8px;
}
.drawer-status-strip .status-badge {
  margin-right: 0;
}
.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.drawer-header-actions .btn-icon {
  width: 38px;
  height: 38px;
}
.drawer-autopilot-card {
  margin: 12px 16px 4px;
  padding: 12px 14px;
  border-radius: var(--shape-lg);
  background: var(--md-surface-container);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.autopilot-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.autopilot-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
}
.autopilot-desc {
  font-size: 11px;
  color: var(--md-on-surface-variant);
}
/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--md-surface-container-highest);
  border-radius: var(--shape-full);
  border: 2px solid var(--md-outline);
  transition: .2s;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--md-outline);
  border-radius: 50%;
  transition: .2s;
}
.switch input:checked + .switch-slider {
  background-color: var(--md-primary);
  border-color: var(--md-primary);
}
.switch input:checked + .switch-slider:before {
  transform: translateX(18px);
  background-color: var(--md-on-primary);
}
.drawer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.drawer-section-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--md-primary);
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 0 4px;
}
.drawer-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--shape-md);
  border: none;
  background: transparent;
  color: var(--md-on-surface);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease);
}
.drawer-item:hover,
.drawer-item:active {
  background-color: var(--md-surface-container-high);
}
.drawer-item.active {
  background-color: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-weight: 500;
}
.drawer-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-item-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--shape-full);
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface-variant);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.drawer-item.active .drawer-item-badge {
  background: color-mix(in srgb, var(--md-on-secondary-container) 14%, transparent);
  color: var(--md-on-secondary-container);
}
.drawer-item-badge:empty {
  display: none;
}
.drawer-footer {
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container-low);
}
.theme-switcher {
  display: flex;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-full);
  padding: 3px;
  gap: 2px;
}
.theme-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border: none;
  border-radius: var(--shape-full);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease), color var(--dur-short) var(--ease);
}
.theme-btn.active {
  background: var(--md-surface);
  color: var(--md-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.drawer-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  margin-top: 10px;
  border-radius: var(--shape-full);
  background: var(--md-surface-container-high);
  border: 1px solid var(--md-outline-variant);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-short) var(--ease), color var(--dur-short) var(--ease), border-color var(--dur-short) var(--ease);
}
.drawer-action-btn:hover {
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
}
.drawer-action-btn:active {
  background: var(--md-surface-container-highest);
  transform: scale(0.98);
}

/* Markdown styling in chat */
.md-p {
  margin: 0 0 10px;
}
.md-p:last-child {
  margin-bottom: 0;
}
.md-hr {
  border: none;
  border-top: 1px solid var(--md-outline-variant);
  margin: 14px 0;
}
.chat-text strong {
  font-weight: 600;
  color: var(--md-on-surface);
}
.chat-text em {
  font-style: italic;
}
.chat-text code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 2px 5px;
  border-radius: var(--shape-xs);
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
}
.md-h {
  margin: 14px 0 6px;
  font-weight: 600;
  color: var(--md-on-surface);
  line-height: 1.3;
}
.md-h3 { font-size: 17px; }
.md-h4 { font-size: 15px; }
.md-h5 { font-size: 14px; }
.md-quote {
  margin: 10px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--md-primary);
  background: var(--md-surface-container-low);
  border-radius: 0 var(--shape-sm) var(--shape-sm) 0;
  color: var(--md-on-surface-variant);
  font-size: 14px;
}
.md-list {
  margin: 6px 0 10px 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.md-list.md-list-ordered {
  list-style-type: decimal;
}
.md-list li {
  line-height: 22px;
  display: list-item;
}
.md-list .md-list {
  margin: 4px 0 4px 18px;
}
.md-list-cont {
  margin: 4px 0 4px 0;
}

/* Code block container */
.code-block {
  margin: 10px 0;
  border-radius: var(--shape-md);
  background: var(--md-surface-container-highest);
  overflow: hidden;
  border: 1px solid var(--md-outline-variant);
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: color-mix(in srgb, var(--md-surface-container-highest) 80%, black 20%);
  font-size: 11px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
}
.code-lang {
  text-transform: lowercase;
  font-family: var(--font-mono);
}
.btn-copy-code {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: var(--shape-xs);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease), color var(--dur-short) var(--ease);
}
.btn-copy-code:hover,
.btn-copy-code:active {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}
.btn-copy-code.copied {
  color: var(--md-success);
}
.code-block pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  color: var(--md-on-surface);
}
.code-block pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

/* Table container */
.table-container {
  margin: 12px 0;
  border-radius: var(--shape-md);
  border: 1px solid var(--md-outline-variant);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--md-surface-container-low);
  max-width: 100%;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--md-surface-container);
  border-bottom: 1px solid var(--md-outline-variant);
}
.table-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
}
.table-container table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 20px;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}
.table-container th,
.table-container td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--md-outline-variant);
  border-right: 1px solid color-mix(in srgb, var(--md-outline-variant) 50%, transparent);
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  min-width: 80px;
}
.table-container th:last-child,
.table-container td:last-child {
  border-right: none;
}
.table-container th {
  font-weight: 600;
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.table-container tbody tr:last-child td {
  border-bottom: none;
}
.table-container tbody tr:hover {
  background-color: color-mix(in srgb, var(--md-surface-container-high) 40%, transparent);
}

/* Message action bar */
.chat-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.btn-msg-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: var(--shape-full);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease), color var(--dur-short) var(--ease);
}
.btn-msg-action:hover,
.btn-msg-action:active {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}
.btn-msg-action.copied {
  color: var(--md-success);
}

/* Antigravity Thinking & Steps Component (Matches IDE 1:1) */
.chat-thinking-block {
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  user-select: none;
  font-family: inherit;
  font-size: 13px;
  color: #9e9e9e;
}
.chat-thinking-header {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
  padding: 3px 0;
  color: #9e9e9e;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.chat-thinking-header:hover,
.chat-thinking-header:active {
  color: var(--md-on-surface, #e0e0e0);
}
.chat-thinking-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.chat-thinking-title code {
  color: inherit;
  font-family: monospace;
  font-size: 12px;
}
.chat-thinking-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.chat-thinking-block.expanded .chat-thinking-chevron {
  transform: rotate(90deg);
}
.chat-thinking-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding-left: 12px;
}
.chat-thinking-details.hidden {
  display: none;
}
.chat-thinking-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-thinking-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #9e9e9e;
  line-height: 1.4;
  word-break: break-word;
}
.chat-thinking-item code {
  color: inherit;
  font-family: monospace;
  font-size: 12px;
}
.chat-thinking-duration {
  font-size: 13px;
  color: #757575;
  margin-top: 2px;
}
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--md-primary);
  padding: 6px 12px;
  margin: 4px 0;
  font-weight: 500;
}
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-primary);
  animation: pulse-dot 1.2s infinite ease-in-out;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Hide status text when generating so only glowing dot is visible */
.status-badge[data-status="generating"] .status-text:empty {
  display: none;
}
.status-badge[data-status="generating"] {
  padding: 0 8px;
}

/* Chat Files & Audio */
.chat-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.chat-file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-sm);
  font-size: 12px;
  color: var(--md-on-surface);
}
.chat-audio-chip {
  flex-direction: column;
  align-items: flex-start;
}
.chat-audio-chip audio {
  height: 32px;
}
.btn-mic.listening {
  color: #ef4444 !important;
  animation: pulse-mic 1s infinite alternate ease-in-out;
}
@keyframes pulse-mic {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.15); opacity: 1; }
}
