@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600&family=Sora:wght@400;600&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  color-scheme: dark;
  --font-body: "Space Grotesk", "Segoe UI", sans-serif;
  --font-ui: "Sora", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --bg: #0b1120;
  --bg-2: #0f1b2d;
  --panel: rgba(17, 24, 39, 0.9);
  --panel-border: rgba(148, 163, 184, 0.2);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-2: #1d4ed8;
  --accent-soft: rgba(34, 197, 94, 0.18);
  --accent-2-soft: rgba(29, 78, 216, 0.2);
  --shadow: 0 18px 30px rgba(8, 15, 35, 0.45);
  --bg-gradient: radial-gradient(circle at 20% 10%, #0f2740 0%, #0b1120 45%, #070b14 100%);
  --bg-texture: radial-gradient(circle at 15% 20%, rgba(34, 197, 94, 0.12), transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(37, 99, 235, 0.18), transparent 40%),
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.08), rgba(148, 163, 184, 0.08) 1px, transparent 1px, transparent 6px);
  --topbar-bg: rgba(11, 17, 32, 0.98);
  --input-bg: rgba(15, 23, 42, 0.9);
  --panel-strong: rgba(15, 23, 42, 0.85);
  --btn-secondary: rgba(51, 65, 85, 0.9);
  --btn-secondary-text: #ffffff;
  --preview-bg: rgba(15, 23, 42, 0.8);
  --log-bg: rgba(15, 23, 42, 0.6);
  --error-bg: rgba(127, 29, 29, 0.15);
  --error-border: rgba(248, 113, 113, 0.4);
  --error-text: #fecaca;
  --error-header: #fca5a5;
  --help-overlay: rgba(2, 6, 23, 0.7);
  --help-shell-bg: linear-gradient(160deg, rgba(8, 15, 35, 0.98), rgba(15, 23, 42, 0.96));
  --help-shell-border: rgba(148, 163, 184, 0.22);
  --help-card-bg: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(8, 15, 35, 0.84));
  --help-card-border: rgba(148, 163, 184, 0.18);
  --help-chip-bg: rgba(34, 197, 94, 0.16);
  --help-chip-text: #86efac;
  --help-support-bg: linear-gradient(135deg, rgba(29, 78, 216, 0.2), rgba(34, 197, 94, 0.16));
  --help-phone-bg: rgba(255, 255, 255, 0.06);
  --help-phone-border: rgba(148, 163, 184, 0.25);
  --help-shadow: 0 30px 70px rgba(2, 6, 23, 0.55);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-2: #e2e8f0;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(148, 163, 184, 0.35);
  --text: #0f172a;
  --muted: #475569;
  --accent: #16a34a;
  --accent-2: #2563eb;
  --accent-soft: rgba(22, 163, 74, 0.18);
  --accent-2-soft: rgba(37, 99, 235, 0.2);
  --shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
  --bg-gradient: radial-gradient(circle at 20% 10%, #f0f9ff 0%, #f8fafc 45%, #e2e8f0 100%);
  --bg-texture: radial-gradient(circle at 18% 12%, rgba(14, 165, 233, 0.15), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(34, 197, 94, 0.15), transparent 45%),
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.12), rgba(148, 163, 184, 0.12) 1px, transparent 1px, transparent 8px);
  --topbar-bg: rgba(248, 250, 252, 0.98);
  --input-bg: rgba(255, 255, 255, 0.95);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --btn-secondary: rgba(226, 232, 240, 0.95);
  --btn-secondary-text: #0f172a;
  --preview-bg: rgba(248, 250, 252, 0.9);
  --log-bg: rgba(248, 250, 252, 0.9);
  --error-bg: rgba(254, 202, 202, 0.35);
  --error-border: rgba(248, 113, 113, 0.6);
  --error-text: #b91c1c;
  --error-header: #b91c1c;
  --help-overlay: rgba(15, 23, 42, 0.28);
  --help-shell-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.96));
  --help-shell-border: rgba(148, 163, 184, 0.35);
  --help-card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.94));
  --help-card-border: rgba(148, 163, 184, 0.28);
  --help-chip-bg: rgba(22, 163, 74, 0.12);
  --help-chip-text: #15803d;
  --help-support-bg: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(22, 163, 74, 0.1));
  --help-phone-bg: rgba(255, 255, 255, 0.82);
  --help-phone-border: rgba(148, 163, 184, 0.28);
  --help-shadow: 0 28px 55px rgba(15, 23, 42, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background-image: var(--bg-gradient), var(--bg-texture);
  background-attachment: scroll;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

.startup-splash {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 16% 12%, rgba(34, 197, 94, 0.24), transparent 42%),
    radial-gradient(circle at 82% 8%, rgba(37, 99, 235, 0.24), transparent 38%),
    rgba(2, 6, 23, 0.86);
  backdrop-filter: blur(8px);
}

.startup-splash-card {
  width: min(420px, calc(100vw - 36px));
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(170deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.9));
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: 0 24px 40px rgba(2, 6, 23, 0.6);
}

.startup-splash-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  align-items: center;
  justify-items: center;
  background: linear-gradient(135deg, #22c55e, #06b6d4);
  border-radius: 12px;
  padding: 9px;
}

.startup-splash-logo .dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
}

.startup-splash-logo .dot.on {
  background: #ffffff;
}

.startup-splash-card h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 33px);
}

.startup-splash-card p {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
}

.startup-splash-loader {
  margin: 18px auto 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.35);
  border-top-color: #22c55e;
  animation: startup-spin 860ms linear infinite;
}

.auth-user-badge {
  max-width: 250px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--topbar-bg);
  backdrop-filter: none;
  position: sticky;
  top: 0;
  z-index: 10;
  align-items: center;
  flex-wrap: nowrap;
}

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

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  align-items: center;
  justify-items: center;
  background: linear-gradient(135deg, #22c55e, #06b6d4);
  color: white;
  padding: 8px;
  border-radius: 10px;
}

.logo .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.logo .dot.on {
  background: white;
  box-shadow: none;
}

.title h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.01em;
}

.title p {
  margin: 0;
  font-size: 12px;
  font-family: var(--font-ui);
  color: var(--muted);
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
  font-family: var(--font-ui);
  justify-content: flex-end;
}

.action-pair {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-ui);
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-body);
}

.field textarea {
  width: 100%;
  resize: vertical;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 600;
}

.app {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  padding: 22px 28px 28px;
  align-items: start;
}

.chat {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  min-height: 70vh;
  height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.messages {
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  height: 100%;
}

.chat-empty {
  margin: auto;
  width: min(440px, 100%);
  padding: 18px 16px;
  border-radius: 14px;
  border: 1px dashed var(--panel-border);
  background: var(--panel-strong);
  text-align: center;
}

.chat-empty h3 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 18px;
}

.chat-empty p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.message-day-separator {
  align-self: center;
  margin: 2px 0;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--panel-border) 88%, var(--accent) 12%);
  background: color-mix(in srgb, var(--panel-strong) 92%, transparent);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.message {
  max-width: 76%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 15px;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.18);
  position: relative;
  z-index: 1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message.is-download-open {
  z-index: 124;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: white;
  border: 1px solid rgba(37, 99, 235, 0.4);
  font-weight: 600;
}

.message.assistant {
  align-self: flex-start;
  background: linear-gradient(160deg, var(--panel-strong), var(--panel));
  color: var(--text);
  border: 1px solid var(--panel-border);
  font-weight: 500;
}

.message.assistant.is-pending {
  border-style: dashed;
  opacity: 0.88;
}

.message.assistant.is-pending::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  pointer-events: none;
  animation: pending-ring 1.2s ease-in-out infinite;
}

.message .meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-ui);
}

.message .actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.message .actions .action-btn {
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 12px;
  letter-spacing: 0.01em;
  font-weight: 500;
  font-family: var(--font-ui);
}

.message .actions .copy-btn {
  background: rgba(15, 23, 42, 0.85);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.18);
}

.message .actions .copy-btn.is-copied {
  color: var(--accent);
  border-color: var(--accent-soft);
}

.message .actions .action-btn:hover {
  transform: none;
  box-shadow: none;
  color: var(--text);
  background: var(--panel-strong);
}

.message .actions .copy-btn:hover {
  color: #ffffff;
  background: rgba(15, 23, 42, 1);
}

.message .actions .action-btn:focus-visible,
.download-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.download-menu {
  position: relative;
  display: inline-flex;
  z-index: 2;
  overflow: visible;
}

.message .actions .download-launcher {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  justify-content: center;
  background: var(--btn-secondary);
  color: var(--btn-secondary-text);
  border: 1px solid var(--panel-border);
  box-shadow: none;
}

.message .actions .download-launcher .icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message .actions .download-launcher:hover {
  color: var(--text);
  background: var(--panel-strong);
}

.download-popover {
  position: absolute;
  top: auto;
  bottom: calc(100% + 8px);
  right: auto;
  left: 4px;
  z-index: 125;
  min-width: 148px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.34);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.download-popover.is-below {
  top: calc(100% + 8px);
  bottom: auto;
}

.download-option {
  width: 100%;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.download-option:hover {
  background: var(--panel);
  border-color: var(--panel-border);
}

.composer {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
}

.tab {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.tab.active {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border-color: transparent;
  box-shadow: 0 12px 20px var(--accent-soft);
  transform: translateY(-1px);
}

.mode-panel {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel-strong);
}

.hidden {
  display: none;
}

.braille-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.braille-grid {
  display: grid;
  grid-template-columns: repeat(2, 50px);
  grid-template-rows: repeat(4, 50px);
  gap: 10px;
  justify-content: start;
  margin-bottom: 12px;
}

.braille-dot {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid #334155;
  background: #0f172a;
  cursor: pointer;
  transition: all 0.15s ease;
}

.braille-dot.active {
  background: #22c55e;
  border-color: #22c55e;
}

.braille-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.preview {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  background: var(--preview-bg);
  font-family: var(--font-ui);
}

.preview img {
  max-width: 100%;
  border-radius: 8px;
}

.camera-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

video {
  width: 100%;
  border-radius: 10px;
  background: black;
  border: 1px solid var(--panel-border);
}

.send-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.send-actions {
  display: flex;
  gap: 8px;
}

.mobile-chat-composer {
  display: none;
}

.mobile-attach-menu {
  position: absolute;
  left: 12px;
  bottom: calc(100% + 8px);
  width: min(220px, calc(100vw - 24px));
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel-strong);
  box-shadow: 0 16px 28px rgba(2, 6, 23, 0.3);
  padding: 6px;
  display: grid;
  gap: 4px;
}

.mobile-attach-menu button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 7px 10px;
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
}

.mobile-attach-menu button:hover {
  border-color: var(--panel-border);
  background: var(--panel);
}

.mobile-compose-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.mobile-compose-row textarea {
  flex: 1;
  min-height: 44px;
  max-height: 148px;
  border-radius: 22px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  overflow-y: hidden;
  touch-action: manipulation;
}

.mobile-compose-row textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mobile-circle-btn,
.mobile-send-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-circle-btn {
  background: var(--btn-secondary);
  color: var(--btn-secondary-text);
  font-family: var(--font-ui);
  font-size: 24px;
  line-height: 1;
}

.mobile-send-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #05220f;
}

.mobile-send-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-circle-btn:disabled,
.mobile-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mobile-attachment-chip {
  margin-bottom: 8px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  border-radius: 14px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: 12px;
}

.mobile-attachment-chip button {
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  min-height: 28px;
  padding: 3px 10px;
  cursor: pointer;
}

.mobile-status {
  margin: 6px 4px 0;
  min-height: 16px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--muted);
}

.btn {
  padding: 8px 12px;
  min-height: 40px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--accent-2);
  color: white;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 14px rgba(13, 24, 53, 0.4);
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn.secondary {
  background: var(--btn-secondary);
  color: var(--btn-secondary-text);
  border: 1px solid var(--panel-border);
}

.btn.primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #072012;
  font-weight: 600;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  box-shadow: none;
}

.btn .icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn .icon.fill {
  fill: currentColor;
  stroke: none;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 16px rgba(13, 24, 53, 0.5);
}

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

.help-trigger {
  min-height: 38px;
  border-radius: 8px;
  justify-content: center;
  flex: 0 0 auto;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(37, 99, 235, 0.22));
  border-color: rgba(96, 165, 250, 0.25);
}

.help-trigger .icon {
  width: 14px;
  height: 14px;
}

.help-trigger:hover {
  box-shadow: 0 14px 24px rgba(14, 116, 144, 0.28);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-ui);
}

.status {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-ui);
}

.error-panel {
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  border-radius: 10px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.error-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: var(--error-header);
}

.error-panel pre {
  margin: 0;
  white-space: pre-wrap;
  color: var(--error-text);
}

.log-drawer {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--log-bg);
}

.log-drawer summary {
  cursor: pointer;
  color: var(--muted);
}

.log-drawer pre {
  margin: 8px 0 0 0;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--text);
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: var(--help-overlay);
  backdrop-filter: blur(16px);
  animation: fade-in 180ms ease;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 131;
  padding: 34px 24px;
  overflow-y: auto;
}

.help-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  border-radius: 28px;
  border: 1px solid var(--help-shell-border);
  background: var(--help-shell-bg);
  box-shadow: var(--help-shadow);
  position: relative;
  overflow: hidden;
  animation: help-in 220ms ease;
}

.help-shell::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 220px;
  background:
    radial-gradient(circle at top left, rgba(34, 197, 94, 0.24), transparent 48%),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.22), transparent 42%);
  pointer-events: none;
}

.help-hero {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 28px 28px 18px;
}

.help-hero-copy {
  max-width: 720px;
}

.help-eyebrow {
  margin: 0 0 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--help-chip-text);
}

.help-hero h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.05;
}

.help-intro {
  margin: 12px 0 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: 15px;
}

.help-close {
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
  border-radius: 999px;
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
  color: #ffffff;
  border-color: rgba(254, 202, 202, 0.58);
  background: #dc2626;
  box-shadow: 0 10px 22px rgba(127, 29, 29, 0.32);
  animation: help-close-glow 2.2s ease-in-out infinite;
}

.help-close:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.75);
  background: #b91c1c;
  box-shadow: 0 14px 28px rgba(127, 29, 29, 0.45);
}

.help-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0 28px 28px;
}

.help-card {
  position: relative;
  padding: 20px;
  border-radius: 22px;
  border: 1px solid var(--help-card-border);
  background: var(--help-card-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.help-card::after {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.12), transparent 70%);
  pointer-events: none;
}

.help-card-wide {
  grid-column: span 2;
}

.help-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--help-chip-bg);
  color: var(--help-chip-text);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.help-card h3 {
  margin: 14px 0 10px;
  font-size: 20px;
}

.help-steps,
.help-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.help-steps li,
.help-list li {
  margin-bottom: 10px;
}

.help-steps li:last-child,
.help-list li:last-child {
  margin-bottom: 0;
}

.help-list strong {
  color: var(--text);
}

.help-support {
  background: var(--help-support-bg);
}

.help-support-copy,
.help-support-note {
  margin: 0;
  color: var(--muted);
}

.help-phone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0 14px;
  padding: 12px 18px;
  border-radius: 16px;
  border: 1px solid var(--help-phone-border);
  background: var(--help-phone-bg);
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.12);
}

.footer {
  padding: 12px 24px 24px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-ui);
}

.message.is-new {
  animation: message-in 200ms ease;
}

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

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

@keyframes help-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes help-close-glow {
  0% {
    box-shadow: 0 10px 22px rgba(127, 29, 29, 0.28);
  }
  50% {
    box-shadow: 0 14px 30px rgba(220, 38, 38, 0.42);
  }
  100% {
    box-shadow: 0 10px 22px rgba(127, 29, 29, 0.28);
  }
}

@keyframes startup-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pending-ring {
  0% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    opacity: 0.35;
  }
}

@media (max-width: 980px) {
  .topbar {
    flex-wrap: wrap;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .chat {
    height: auto;
  }

  .messages {
    max-height: none;
  }

  .composer {
    position: static;
    max-height: none;
  }

  .field input,
  .field select {
    width: 100%;
  }

  .send-row {
    flex-direction: column;
    align-items: stretch;
  }

  .send-actions {
    justify-content: space-between;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .help-card-wide {
    grid-column: span 1;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 14px 16px;
  }

  .app {
    padding: 18px 16px 24px;
  }

  .help-modal {
    padding: 18px 12px;
  }

  .help-hero {
    padding: 22px 20px 16px;
    flex-direction: column;
  }

  .help-grid {
    padding: 0 20px 20px;
  }

  .help-card {
    padding: 18px;
  }

  .action-pair {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .messages {
    padding: 16px 14px;
    gap: 12px;
  }

  .message-day-separator {
    font-size: 11px;
    padding: 4px 10px;
  }

  .message {
    max-width: 92%;
    padding: 10px 11px;
    font-size: 14px;
  }

  .composer {
    padding: 14px;
  }

  .mode-tabs {
    grid-template-columns: 1fr;
  }

  .tab {
    min-height: 42px;
  }

  .camera-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .send-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .send-actions .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
}

@media (max-width: 1024px) {
  html,
  body {
    height: 100svh;
    min-height: 100svh;
  }

  body {
    height: 100svh;
    min-height: 100svh;
    display: block;
    position: relative;
    overflow: hidden;
    overscroll-behavior-y: none;
  }

  .topbar {
    position: fixed;
    top: var(--mobile-topbar-offset, 0px);
    left: 0;
    right: 0;
    z-index: 66;
    padding: 10px 12px 8px;
    gap: 8px;
  }

  .app {
    position: relative;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    gap: 0;
    padding: calc(var(--mobile-topbar-height, 68px) + 8px) 8px calc(116px + env(safe-area-inset-bottom));
    height: var(--mobile-app-height, 100svh);
    max-height: var(--mobile-app-height, 100svh);
    min-height: 0;
    overflow: hidden;
  }

  .chat {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-anchor: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    justify-content: flex-start;
    scroll-padding-bottom: 18px;
    padding: 10px 6px 20px;
    gap: 12px;
    background: transparent;
    border-radius: 0;
  }

  body.mobile-keyboard-open .messages.has-items::before {
    content: "";
    margin-top: auto;
  }

  .message {
    max-width: 88%;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
    border-width: 1px;
    padding: 11px 12px;
  }

  .message.user {
    border-bottom-right-radius: 6px;
    background: linear-gradient(145deg, #22c55e, #16a34a 62%, #15803d);
    color: #03250f;
    border-color: rgba(34, 197, 94, 0.45);
  }

  .message.assistant {
    border-bottom-left-radius: 6px;
    background: color-mix(in srgb, var(--panel-strong) 92%, transparent);
    color: var(--text);
    border-color: rgba(148, 163, 184, 0.4);
  }

  .message .meta {
    opacity: 0.9;
    font-size: 12px;
  }

  :root[data-theme="dark"] .message.user {
    background: linear-gradient(160deg, #22c55e, #15803d);
    color: #031f0d;
    border-color: rgba(74, 222, 128, 0.4);
  }

  :root[data-theme="dark"] .message.assistant {
    background: rgba(15, 23, 42, 0.94);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.4);
  }

  .message .actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    overflow: visible;
    padding-bottom: 2px;
    gap: 8px;
    margin-top: 10px;
    scrollbar-width: thin;
  }

  .message.is-download-open .actions {
    overflow: visible;
  }

  .message.is-download-open .download-menu {
    z-index: 126;
  }

  .message.is-download-open .download-popover {
    z-index: 127;
  }

  .message .actions .action-btn {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--panel-strong) 94%, transparent);
    color: var(--text);
  }

  .chat-empty {
    margin-top: 14vh;
    text-align: left;
    border-style: solid;
  }

  .composer {
    display: none;
  }

  .mobile-chat-composer {
    display: block;
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 34;
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--panel-border) 85%, var(--accent) 15%);
    border-radius: 18px;
    background: color-mix(in srgb, var(--panel-strong) 96%, transparent);
    backdrop-filter: none;
    box-shadow: 0 14px 34px rgba(2, 6, 23, 0.3);
  }

  body.mobile-nav-open .mobile-chat-composer {
    opacity: 0;
    transform: translateY(18px);
    pointer-events: none;
  }

  body.mobile-nav-open .messages {
    pointer-events: none;
  }

  .mobile-attach-menu {
    left: 0;
    bottom: calc(100% + 10px);
    width: min(260px, calc(100vw - 24px));
    border-radius: 16px;
    padding: 7px;
  }

  .mobile-compose-row {
    gap: 7px;
    align-items: center;
  }

  .mobile-compose-row textarea {
    min-height: 46px;
    max-height: 140px;
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 16px;
    line-height: 1.35;
  }

  .mobile-circle-btn,
  .mobile-send-btn {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 14px;
  }

  .mobile-circle-btn {
    font-size: 22px;
  }

  .mobile-send-btn {
    box-shadow: 0 10px 20px rgba(22, 163, 74, 0.32);
  }

  .mobile-attachment-chip {
    margin-bottom: 6px;
    border-radius: 12px;
    padding: 7px 9px;
  }

  .mobile-status {
    margin: 6px 2px 0;
    font-size: 12px;
  }

  :root[data-theme="light"] .mobile-chat-composer {
    background: rgba(255, 255, 255, 0.98);
  }

  .footer {
    display: none;
  }
}

/* ── Passkey nudge banner ─────────────────────────────────────────────── */
.passkey-nudge-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-2) 92%, var(--accent) 8%);
  border: 1px solid color-mix(in srgb, var(--panel-border) 60%, var(--accent) 40%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  color: var(--text);
  max-width: min(560px, calc(100vw - 32px));
  animation: nudge-slide-in 0.25s ease;
}

@keyframes nudge-slide-in {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.passkey-nudge-banner-text {
  flex: 1;
  min-width: 0;
}

.passkey-nudge-dismiss {
  flex-shrink: 0;
  font-size: 14px;
  padding: 2px 6px;
  opacity: 0.7;
}

.passkey-nudge-dismiss:hover {
  opacity: 1;
}

