:root {
  /* v0.110.0 "skyphusion" rebrand: cosmic sky-fusion palette. */
  --bg: #0a0e1a;
  --bg-elev: #111729;
  --bg-elev2: #1a2440;
  --bg-glass: rgba(20, 28, 51, 0.72);
  --fg: #e9edf6;
  --fg-dim: #8b94ab;
  --accent: #6d8cff;        /* electric periwinkle */
  --accent-hover: #88a2ff;
  --accent-2: #a06bff;      /* violet */
  --accent-cyan: #38e0ff;
  --border: #232c45;
  --border-soft: rgba(255, 255, 255, 0.07);
  --error: #ff6b8a;
  --warn: #f2c14e;
  --success: #50c878;
  --brand-grad: linear-gradient(120deg, #38e0ff 0%, #6d8cff 48%, #a06bff 100%);
  --radius: 16px;
  --radius-sm: 11px;
  --radius-pill: 999px;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.65);
  --shadow-glow: 0 10px 40px -12px rgba(109, 140, 255, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.sidebar-header h1,
.sidebar-header h2 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  margin: 0;
}

#new-chat {
  background: var(--accent);
  color: var(--bg);
  border: 0;
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
}

#new-chat:hover { background: var(--accent-hover); }

#user-badge {
  font-size: 0.75rem;
  color: var(--fg-dim);
  padding: 0.5rem 0.625rem;
  background: var(--bg);
  border-radius: 4px;
  margin-bottom: 1rem;
  word-break: break-all;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.history-list li {
  padding: 0.5rem 0.625rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
  cursor: pointer;
  font-size: 0.8125rem;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 0.5rem;
}

.history-list li:hover { background: var(--bg-elev2); }

.history-list .preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}

.history-list .meta {
  color: var(--fg-dim);
  font-size: 0.6875rem;
  white-space: nowrap;
}

.history-list .attach-icon {
  color: var(--fg-dim);
  font-size: 0.75rem;
}

.history-list .delete {
  background: none;
  border: 0;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0 0.25rem;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
}

.history-list li:hover .delete { opacity: 1; }
.history-list .delete:hover { color: var(--error); }

.workspace {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
  padding: 1.5rem;
  overflow: hidden;
  min-height: 0;
}

.controls {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 2fr;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
}

textarea {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.625rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  text-transform: none;
  letter-spacing: normal;
  resize: vertical;
  min-height: 60px;
}

textarea:focus {
  outline: 0;
  border-color: var(--accent);
}

/* ---------- Model picker (v0.14.x+, replaces native <select>) ----------
   Trigger button shows the current model label and a chevron. Clicking it
   opens a floating panel beneath, anchored to .model-picker (position:
   relative). The panel holds <details> accordion groups, one per catalog
   `group` field, each with a list of clickable model items. The first
   group is open on initial populate; the rest are collapsed.

   Capability badges (vision, streaming) sit at the right end of each item.
   The selected item is highlighted and gets a checkmark. */

.model-picker {
  position: relative;
}

.model-picker-trigger {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.625rem;
  font-family: inherit;
  font-size: 0.875rem;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
}

.model-picker-trigger:hover { border-color: var(--fg-dim); }
.model-picker-trigger:focus-visible { outline: 0; border-color: var(--accent); }

.model-picker-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-picker-chevron {
  color: var(--fg-dim);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
}

.model-picker-trigger[aria-expanded="true"] .model-picker-chevron {
  transform: rotate(180deg);
}

.model-picker-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  padding: 0.25rem;
}

.model-group { border-radius: 4px; }
.model-group + .model-group { margin-top: 0.125rem; }

.model-group-header {
  list-style: none;
  cursor: pointer;
  padding: 0.5rem 0.625rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  background: var(--bg-elev2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.model-group-header::-webkit-details-marker { display: none; }
.model-group-header::marker { content: ""; }

.model-group-header::before {
  content: "\25B8";
  font-size: 0.625rem;
  color: var(--fg-dim);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.model-group[open] > .model-group-header::before {
  transform: rotate(90deg);
}

.model-group-count {
  margin-left: auto;
  color: var(--fg-dim);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.model-group-list {
  list-style: none;
  margin: 0;
  padding: 0.125rem 0;
}

.model-item {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--fg);
  padding: 0.5rem 0.625rem 0.5rem 1.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 4px;
}

.model-item:hover { background: var(--bg-elev2); }

.model-item.selected {
  background: var(--bg-elev2);
  color: var(--accent);
}

.model-item.selected::after {
  content: "\2713";
  margin-left: auto;
  color: var(--accent);
  font-size: 0.75rem;
}

.model-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-item-badges {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.model-badge {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.0625rem 0.375rem;
  border-radius: 3px;
  background: var(--bg);
  color: var(--fg-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.model-badge.badge-vision {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.model-badge.badge-stream {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}

/* Mobile: the panel can use more vertical room since the layout collapses */
@media (max-width: 768px) {
  .model-picker-panel { max-height: 70vh; }
}

.input-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.bottom-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.attach-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

#attach-btn {
  background: transparent;
  color: var(--fg-dim);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

#attach-btn:hover:not(:disabled) {
  color: var(--fg);
  border-color: var(--fg-dim);
}

#attach-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint {
  flex: 1;
  font-size: 0.75rem;
  color: var(--fg-dim);
}

.hint.warn { color: var(--warn); }

/* Scope the legacy flat-send styling away from the round composer button.
   #run (id) was out-specifying the .composer-send class rules, so the send
   button collapsed into a padded rounded square with the arrow off-center. */
#run:not(.composer-send) {
  margin-left: auto;
  background: var(--accent);
  color: var(--bg);
  border: 0;
  padding: 0.5rem 1.25rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
}

#run:not(.composer-send):hover:not(:disabled) { background: var(--accent-hover); }
#run:not(.composer-send):disabled { opacity: 0.5; cursor: wait; }

.attachments, .loaded-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.attachment {
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--fg-dim);
  max-width: 320px;
}

.attachment img.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--bg);
}

.attachment .video-strip {
  display: flex;
  gap: 2px;
  height: 48px;
}

.attachment .video-strip img {
  height: 48px;
  width: 32px;
  object-fit: cover;
  border-radius: 2px;
}

.attachment .name {
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.attachment .size {
  color: var(--fg-dim);
  font-size: 0.6875rem;
}

.attachment .remove {
  background: none;
  border: 0;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0 0.25rem;
  font-size: 0.875rem;
  line-height: 1;
}

.attachment .remove:hover { color: var(--error); }

.attachment .audio-icon, .attachment .video-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 3px;
  font-size: 1.25rem;
}

.output-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  overflow: hidden;
}

.output-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
}

/* ---------- Transcript (multi-turn conversation view) ---------- */

.transcript {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  padding-right: 0.25rem;
  min-height: 0;
}

.transcript.empty::before {
  content: "no messages yet \2014 type a prompt below to start";
  display: block;
  text-align: center;
  color: var(--fg-dim);
  font-size: 0.875rem;
  margin-top: 2rem;
}

.turn {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}

.turn-user {
  background: var(--bg-elev);
}

.turn-assistant {
  background: var(--bg-elev2);
}

.turn-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.turn-text {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

.turn-text.pending { color: var(--fg-dim); font-style: italic; }
.turn-text.error   { color: var(--error); }

.turn-meta {
  font-size: 0.7rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}

.turn-meta:empty { display: none; }

.turn-artifact {
  border-radius: 4px;
  background: var(--bg);
  padding: 0.5rem;
}

.output-image {
  max-width: 100%;
  max-height: 60vh;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
}

.output-audio {
  width: 100%;
  display: block;
}

.output-video {
  width: 100%;
  max-height: 60vh;
  display: block;
  background: #000;
  border-radius: 4px;
}

.output-actions {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.history-list .status-failed { color: var(--warn); }

.output-actions {
  margin-top: 0.5rem;
  text-align: right;
}

.output-actions a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.output-actions a:hover { color: var(--accent-hover); }

.loaded-attachments:empty { display: none; }
.loaded-attachments .attachment .remove { display: none; }

/* ---------- Mobile / responsive ---------- */

/* Mobile drawer affordances (hidden on desktop, only visible at <=768px) */
.sidebar-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* iOS prevents auto-zoom on focus only if the input font-size is >= 16px.
   Apply to all interactive form elements regardless of viewport, since users
   on small laptops can still trigger the zoom-equivalent on touchscreens. */
@media (max-width: 768px) {
  select, textarea, button, input {
    font-size: 16px;
  }

  /* Collapse the two-column layout to single column. */
  .layout {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes an off-canvas drawer, hidden by default, slides in
     from the left when .layout has .sidebar-open. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(85vw, 320px);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    padding-top: calc(1rem + env(safe-area-inset-top));
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    padding-left: calc(1rem + env(safe-area-inset-left));
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.4);
  }

  .layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Backdrop covers the workspace when drawer is open; tap to close. */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease-out;
  }

  .layout.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Hamburger button: fixed at top-left, always tappable. */
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: calc(0.5rem + env(safe-area-inset-top));
    left: calc(0.5rem + env(safe-area-inset-left));
    width: 44px;
    height: 44px;
    z-index: 30;
    background: var(--bg-elev2);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
  }

  /* History items: bigger tap targets, always-visible delete (no hover on touch). */
  .history-list li {
    padding: 0.75rem 0.625rem;
    font-size: 0.9375rem;
    grid-template-columns: 1fr auto auto;
  }

  .history-list .delete {
    opacity: 1;
    padding: 0 0.5rem;
    font-size: 1.25rem;
  }

  .history-list .meta {
    font-size: 0.75rem;
  }

  /* Workspace: pull padding in, leave headroom for the hamburger button. */
  .workspace {
    padding: 1rem;
    padding-top: calc(3.5rem + env(safe-area-inset-top));
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    gap: 0.75rem;
    grid-template-rows: auto auto auto 1fr;
    overflow-y: auto;
  }

  /* Stack the model / system-prompt controls vertically. */
  .controls {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Buttons in the input area get bigger touch targets. */
  #attach-btn {
    padding: 0.625rem 0.875rem;
    min-height: 44px;
  }

  #run:not(.composer-send) {
    padding: 0.625rem 1.25rem;
    min-height: 44px;
    font-size: 0.9375rem;
  }

  #new-chat {
    padding: 0.5rem 0.875rem;
    min-height: 36px;
  }

  /* Image / video frame previews in attachments: a bit smaller on mobile. */
  .attachment {
    max-width: 100%;
    flex: 1 1 auto;
  }

  /* Generated image output: cap height tighter on mobile so it doesn't push
     other content off-screen. */
  .output-image {
    max-height: 50vh;
  }

  /* Bottom row may need to wrap if model labels are long. */
  .bottom-row {
    flex-wrap: wrap;
  }

  /* On mobile, the attach hint is often too long; let it shrink to nothing. */
  .hint {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Output text: bump readability. */
  .output {
    font-size: 0.875rem;
  }
}

/* Narrower phones: pull more padding. */
@media (max-width: 420px) {
  .workspace {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
  }

  .attachment .name {
    max-width: 120px;
  }
}

/* ---------- Documents section (RAG Pass 1) ---------- */

.documents-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.documents-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem 0;
}

.documents-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.125rem 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
}

.documents-list li:hover { background: var(--bg-elev2); }

.documents-list .doc-name {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.documents-list .doc-meta {
  grid-column: 1;
  grid-row: 2;
  font-size: 0.7rem;
  color: var(--fg-dim);
}

.documents-list .delete {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  background: none;
  border: none;
  color: var(--fg-dim);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

.documents-list .delete:hover { color: var(--warn); }

.doc-status {
  font-size: 0.75rem;
  color: var(--fg-dim);
  padding: 0.25rem 0;
  min-height: 1.25rem;
}

.doc-status.error { color: var(--warn); }

/* ---------- RAG (Pass 2): use-docs toggle + retrieved chunks ---------- */

.use-docs-row {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--fg-dim);
  padding: 0 0.5rem;
  user-select: none;
  cursor: pointer;
}

.use-docs-row input[type="checkbox"] {
  accent-color: var(--accent, #4a9eff);
  cursor: pointer;
}

.use-docs-row[hidden] { display: none; }

.retrieved-chunks {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
}

.retrieved-chunks .rc-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  margin-bottom: 0.5rem;
}

.retrieved-chunk {
  margin-bottom: 0.25rem;
  padding: 0.375rem 0.5rem;
  background: var(--bg-elev2);
  border-radius: 4px;
}

.retrieved-chunk summary {
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.8rem;
}

.retrieved-chunk summary::-webkit-details-marker { display: none; }
.retrieved-chunk summary::marker { content: ""; }

.retrieved-chunk .rc-num {
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  min-width: 1.5em;
}

.retrieved-chunk .rc-file {
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retrieved-chunk .rc-meta {
  color: var(--fg-dim);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.retrieved-chunk[open] summary { margin-bottom: 0.375rem; }

.retrieved-chunk .rc-text {
  margin: 0;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 3px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  max-height: 12rem;
  overflow-y: auto;
}

/* ---------- Per-turn action buttons (v0.12.0+) ---------- */
/* Copy and retry buttons that appear under each assistant response.
   Subtle by default; brighten on hover. Square footprint with a small SVG
   inside. Inherit color via stroke="currentColor" on the SVG. */

.turn-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.turn-action {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.turn-action svg {
  width: 12px;
  height: 12px;
  display: block;
}

.turn-action:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.turn-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.turn-action-success {
  color: var(--accent);
  border-color: var(--accent);
}

.turn-action:disabled {
  cursor: default;
}

/* ---------- Drag-and-drop visual feedback (v0.19.5) ---------- */

.input-area.drop-active {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: var(--bg-elev);
}

.input-area.drop-active::after {
  content: "drop to attach";
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 0.75rem;
  color: var(--accent);
  pointer-events: none;
  letter-spacing: 0.02em;
  background: var(--bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--accent);
}

/* ---------- Projects section (v0.20.1) ---------- */

.projects-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--bg-elev);
}

.projects-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.projects-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s ease;
  position: relative;
}

.projects-list li:hover {
  background: var(--bg-elev2);
}

.projects-list li.active {
  background: var(--bg-elev2);
  box-shadow: inset 2px 0 0 var(--accent);
}

.projects-list .proj-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.projects-list .proj-meta {
  font-size: 0.75rem;
  color: #888;
  flex-shrink: 0;
}

.projects-list .proj-actions {
  display: none;
  gap: 0.25rem;
}

.projects-list li:hover .proj-actions,
.projects-list li.active .proj-actions {
  display: inline-flex;
}

.projects-list .proj-action {
  background: transparent;
  border: 1px solid transparent;
  color: #aaa;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: color 0.1s ease, border-color 0.1s ease;
}

.projects-list .proj-action:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.projects-list .proj-empty {
  padding: 0.5rem;
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
}

#proj-new-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

#proj-new-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

/* ---------- Active-project chip (v0.20.1) ---------- */

/* v0.20.1.1: same `[hidden]` override fix as `.modal[hidden]` below. The
 * `display: inline-flex` rule otherwise renders the chip always-on, ignoring
 * the JS-driven `activeProjectChip.hidden = true` flag. */
.active-project-chip[hidden] { display: none; }

.active-project-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-elev2);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 0.85rem;
  width: fit-content;
}

.active-project-chip .apc-label {
  color: #888;
}

.active-project-chip .apc-name {
  color: var(--accent);
  font-weight: 500;
}

.active-project-chip .apc-clear {
  background: transparent;
  border: 0;
  color: #888;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  margin-left: 0.2rem;
}

.active-project-chip .apc-clear:hover {
  color: var(--accent);
}

/* ---------- Modal (v0.20.1) ---------- */

/* v0.20.1.1: `.modal { display: flex }` below overrides the user-agent's
 * `[hidden] { display: none }` rule, which meant modals were rendered always
 * regardless of `el.hidden = true` in the JS. This attribute selector restores
 * the hidden contract; same pattern repeated for `.active-project-chip`. */
.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-panel {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--bg-elev2);
  border-radius: 8px;
  width: min(560px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--bg-elev2);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
}

.modal-close {
  background: transparent;
  border: 0;
  color: #888;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.modal-field span {
  font-size: 0.85rem;
  color: #bbb;
}

.modal-field input,
.modal-field textarea {
  background: var(--bg);
  border: 1px solid var(--bg-elev2);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  color: inherit;
  font-family: inherit;
  font-size: 0.9rem;
}

.modal-field input:focus,
.modal-field textarea:focus {
  outline: 0;
  border-color: var(--accent);
}

.modal-error {
  background: rgba(255, 100, 100, 0.1);
  border: 1px solid rgba(255, 100, 100, 0.3);
  color: #ff8080;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.modal-hint {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  color: #aaa;
}

.modal-empty {
  text-align: center;
  padding: 1.5rem;
  color: #888;
  font-style: italic;
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--bg-elev2);
}

.modal-actions button {
  background: var(--bg-elev2);
  border: 1px solid var(--bg-elev2);
  color: inherit;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

.modal-actions button:hover {
  border-color: var(--accent);
}

.modal-actions .modal-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.modal-actions .modal-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.modal-actions .modal-danger {
  background: transparent;
  border-color: rgba(255, 100, 100, 0.3);
  color: #ff8080;
  margin-right: auto;
}

.modal-actions .modal-danger:hover {
  background: rgba(255, 100, 100, 0.1);
  border-color: #ff8080;
}

/* ---------- Project documents picker modal (v0.20.1) ---------- */

.project-docs-modal-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.project-docs-modal-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
}

.project-docs-modal-list li:hover {
  background: var(--bg-elev2);
}

.project-docs-modal-list input[type=checkbox] {
  cursor: pointer;
}

.project-docs-modal-list .pd-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-docs-modal-list .pd-meta {
  font-size: 0.75rem;
  color: #888;
}

/* ---------- Conversation row project chip + move menu (v0.20.2) ---------- */

.conv-proj-chip {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  background: rgba(122, 162, 247, 0.08);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  line-height: 1.2;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.conv-proj-chip-stale {
  color: #888;
  border-color: #555;
  background: transparent;
}

.history-list .conv-move {
  display: none;
  background: transparent;
  border: 0;
  color: #888;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  font-size: 0.85rem;
  line-height: 1;
  border-radius: 3px;
}

.history-list .conv-move:hover {
  color: var(--accent);
  background: var(--bg-elev2);
}

.history-list li:hover .conv-move {
  display: inline-block;
}

.move-menu {
  z-index: 200;
  background: var(--bg-elev);
  border: 1px solid var(--bg-elev2);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  min-width: 200px;
  max-width: 280px;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.25rem;
}

.move-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.move-menu-item:hover {
  background: var(--bg-elev2);
}

.move-menu-item.current {
  color: var(--accent);
  font-weight: 500;
}

.move-menu-item.current::after {
  content: " \2713";
  color: var(--accent);
}

/* ---------- Discord import (v0.20.4) ---------- */

.discord-import {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-elev2);
}

.discord-import-title {
  margin: 0 0 0.3rem 0;
  font-size: 0.95rem;
  font-weight: 500;
}

.discord-import-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

#discord-import-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

#discord-import-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

#discord-import-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.discord-import-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #aaa;
  cursor: pointer;
}

.discord-import-status {
  margin-top: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 4px;
  font-size: 0.82rem;
  background: var(--bg-elev2);
  color: #ccc;
}

.discord-import-status.ok {
  background: rgba(122, 200, 122, 0.12);
  border: 1px solid rgba(122, 200, 122, 0.35);
  color: #9bd89b;
}

.discord-import-status.error {
  background: rgba(255, 100, 100, 0.1);
  border: 1px solid rgba(255, 100, 100, 0.3);
  color: #ff8080;
}

/* ---------- standalone page body (stt.html) ---------- */

.stt-body {
  display: block;
  overflow: auto;
}

/* ============================================================
   v0.110.0 - "skyphusion" modern focus-mode redesign.
   Overrides the legacy two-pane layout: sidebar becomes a
   slide-in overlay, the conversation is a centered column, and
   the composer floats. Bold cosmic brand on a deep-space base.
   ============================================================ */

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

html, body { background: var(--bg); font-size: 15px; }
body::before {
  /* subtle aurora glow behind everything */
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 80% -10%, rgba(160, 107, 255, 0.16), transparent 70%),
    radial-gradient(50% 45% at 0% 0%, rgba(56, 224, 255, 0.10), transparent 70%);
}

/* Focus mode: single full-width column; sidebar overlays it. */
.layout { display: block; height: 100vh; height: 100dvh; position: relative; z-index: 1; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  width: min(310px, 86vw);
  transform: translateX(-104%);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.1rem 0.9rem;
  gap: 0.4rem;
}
.layout.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 55; display: none;
  background: rgba(5, 8, 16, 0.55); backdrop-filter: blur(2px);
}
.layout.sidebar-open .sidebar-backdrop { display: block; }

/* main column */
.main { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 0.6rem;
  padding: max(0.6rem, env(safe-area-inset-top)) 0.9rem 0.6rem;
  background: var(--bg-glass);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--border-soft);
}

.icon-btn {
  flex: 0 0 auto;
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: var(--radius-pill); border: 1px solid transparent;
  background: transparent; color: var(--fg-dim); font-size: 1.15rem;
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--bg-elev2); color: var(--fg); border-color: var(--border); }

.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px; background: var(--brand-grad);
  box-shadow: var(--shadow-glow); transform: rotate(45deg);
}
.brand-name {
  font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
@media (max-width: 560px) { .brand-name { display: none; } }

.topbar-model { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; }
.topbar-model .model-picker { max-width: 340px; width: 100%; }

/* compact model-picker trigger for the topbar */
.model-picker-trigger {
  width: 100%; border-radius: var(--radius-pill) !important;
  background: var(--bg-elev) !important; border: 1px solid var(--border) !important;
  padding: 0.45rem 0.9rem !important;
}
.model-picker-trigger:hover { border-color: var(--accent) !important; }

/* settings popover */
.settings-panel {
  position: absolute; top: 58px; right: 0.9rem; z-index: 40;
  width: min(380px, calc(100vw - 1.8rem));
  display: flex; flex-direction: column; gap: 0.75rem;
  padding: 1rem; border-radius: var(--radius);
  background: var(--bg-elev); /* solid so page content doesn't bleed through */
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.settings-panel[hidden] { display: none; }
.settings-field { display: flex; flex-direction: column; gap: 0.4rem; }
.settings-field > span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-dim); }
.settings-panel textarea {
  width: 100%; resize: vertical; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem; font-family: inherit; font-size: 0.9rem;
}
.settings-panel textarea:focus { outline: none; border-color: var(--accent); }

/* conversation: centered reading column */
.conversation { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.conv-head {
  max-width: 820px; margin: 0 auto; padding: 1rem 1.25rem 0;
  display: flex; align-items: baseline; gap: 0.75rem; color: var(--fg-dim);
}
#conv-title { font-size: 0.9rem; font-weight: 600; color: var(--fg); }
#output-meta { font-size: 0.75rem; }
.transcript { max-width: 820px; margin: 0 auto; padding: 0.75rem 1.25rem 1.5rem; }

/* floating composer */
.input-area {
  position: sticky; bottom: 0; z-index: 20;
  max-width: 820px; width: 100%; margin: 0 auto;
  padding: 0.5rem 1.25rem calc(0.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
.composer {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.4rem 0.4rem 0.5rem;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 26px; box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.2s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow-glow); }
/* override the legacy .attach-row drag border/padding now that it only holds
   the paperclip button inside the composer */
.composer .attach-row {
  display: flex; align-items: center; flex: 0 0 auto;
  border: 0; padding: 0; margin: 0; background: none;
}
.composer-attach {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: var(--radius-pill);
  border: 0; background: transparent; color: var(--fg-dim); font-size: 1.4rem;
  line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.composer-attach:hover { background: var(--bg-elev2); color: var(--fg); }
.composer-field { flex: 1 1 auto; display: flex; min-width: 0; }
.composer-field textarea {
  width: 100%; border: 0; background: transparent; color: var(--fg);
  font-family: inherit; font-size: 16px; line-height: 1.5; /* 16px: no iOS zoom-on-focus */
  padding: 0.45rem 0.35rem; resize: none; outline: none;
  /* min/max clamp the JS auto-grow in app.js (autoGrowUserInput); past
     max-height the textarea scrolls. */
  min-height: 2.75rem; max-height: 40vh; overflow-y: auto;
}
/* id-level selector so it beats the legacy `#run` rules (which set padding +
   border-radius:4px + min-height:44px, making a de-centered rounded square). */
.composer-send {
  width: 40px; height: 40px; min-height: 0; flex: 0 0 auto; padding: 0;
  border: 0; border-radius: 50%; margin-left: 0;
  background: var(--brand-grad); color: #0a0e1a;
  cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow-glow);
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.15s ease;
}
.composer-send svg { display: block; } /* no inline-baseline gap: arrow dead-center */
.composer-send:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.composer-send:active:not(:disabled) { transform: translateY(0) scale(0.96); }
.composer-send:disabled { opacity: 0.45; cursor: default; box-shadow: none; }

/* v0.118.0: voice-chat mic button (talk to the model, hear the reply) */
.composer-mic {
  width: 38px; height: 38px; flex: 0 0 auto; padding: 0; border: 0;
  border-radius: var(--radius-pill); background: transparent; color: var(--fg-dim);
  cursor: pointer; display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
.composer-mic[hidden] { display: none; }
.composer-mic svg { display: block; }
.composer-mic:hover { background: var(--bg-elev2); color: var(--fg); }
.composer-mic.is-live { background: var(--error); color: #fff; animation: vc-pulse 1.5s ease-in-out infinite; }
@keyframes vc-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 138, 0.55); }
  50% { box-shadow: 0 0 0 7px rgba(255, 107, 138, 0); }
}
.voice-chat-status { font-size: 0.78rem; color: var(--accent); font-weight: 600; }
.composer-foot {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.4rem 0.6rem 0; min-height: 1rem;
}
.composer-foot .hint { font-size: 0.72rem; color: var(--fg-dim); }

/* voice (conversational STT) composer panel - restored + modernized */
#voice-panel {
  display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.5rem;
  padding: 0.7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev);
}
#voice-panel[hidden] { display: none; }
.voice-controls { display: flex; align-items: center; gap: 0.75rem; }
#voice-start {
  font-size: 0.95rem; padding: 0.5rem 1.2rem; border-radius: var(--radius-pill);
  border: 0; background: var(--brand-grad); color: #0a0e1a; font-weight: 700; cursor: pointer;
}
#voice-start.is-live { background: var(--error); color: #fff; }
.voice-status { font-size: 0.85rem; color: var(--fg-dim); }
.voice-hint { color: var(--fg-dim); }
#voice-live {
  min-height: 3.25rem; font-size: 1.15rem; line-height: 1.5; padding: 0.7rem 0.9rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
}
#voice-turns { display: flex; flex-direction: column; gap: 0.4rem; max-height: 16rem; overflow-y: auto; }

/* keep the sidebar toggle (legacy mobile-only button) visible at all sizes;
   the .icon-btn rules above style it now that it lives in the topbar. */
.sidebar-toggle { position: static; }

/* ---- account accordion (top-right): email + Voice ---- */
.account { position: relative; flex: 0 0 auto; }
.account-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 45;
  width: min(290px, calc(100vw - 1.2rem));
  display: flex; flex-direction: column; padding: 0.4rem;
  background: var(--bg-elev); /* solid so page content doesn't bleed through */
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.account-menu[hidden] { display: none; }
.account-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.7rem; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--fg); background: transparent;
  border: 0; cursor: pointer; text-align: left; width: 100%; font: inherit;
}
.account-row:hover { background: var(--bg-elev2); }
.account-link { flex-direction: column; align-items: flex-start; gap: 0.12rem; }
.account-user {
  gap: 0.6rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 1px solid var(--border-soft); margin-bottom: 0.25rem;
}
.account-ico { color: var(--accent); display: grid; place-items: center; flex: 0 0 auto; }
.account-email { font-size: 0.85rem; color: var(--fg); word-break: break-all; }
.account-name { font-weight: 600; font-size: 0.92rem; }
.account-sub { font-size: 0.72rem; color: var(--fg-dim); }

/* ---- gateway banner (public demo: nudge users to set credentials) ---- */
.gateway-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin: 0 1rem 0.5rem; padding: 0.55rem 0.85rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--fg);
}
.gateway-banner[hidden] { display: none; }
.gateway-banner button {
  flex: 0 0 auto; padding: 0.35rem 0.75rem; font: inherit; font-size: 0.82rem;
  background: var(--accent); color: var(--bg); border: 0; border-radius: var(--radius-sm);
  cursor: pointer;
}
.gateway-banner button:hover { filter: brightness(1.08); }

/* ---- history search ---- */
.history-search {
  width: 100%; margin: 0 0 0.6rem; padding: 0.5rem 0.75rem;
  background: var(--bg); color: var(--fg); font: inherit; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: var(--radius-pill); outline: none;
}
.history-search:focus { border-color: var(--accent); }
.history-search::placeholder { color: var(--fg-dim); }

/* ---- searchable model picker ---- */
.model-picker-panel {
  display: flex; flex-direction: column; padding: 0.5rem;
  max-height: 66vh; overflow: hidden;
  /* roomier so full model labels aren't squished onto one cramped line */
  min-width: 340px; width: max-content; max-width: min(460px, calc(100vw - 1.4rem));
}
/* CRITICAL: the picker is toggled via the `hidden` attribute (app.js sets
   panel.hidden); without this guard the display:flex above keeps it always
   open (an author display rule beats the UA [hidden]{display:none}). */
.model-picker-panel[hidden] { display: none; }
.model-picker-search {
  flex: 0 0 auto; width: 100%; margin-bottom: 0.45rem; padding: 0.5rem 0.75rem;
  background: var(--bg); color: var(--fg); font: inherit; font-size: 0.88rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none;
}
.model-picker-search:focus { border-color: var(--accent); }
.model-picker-search::placeholder { color: var(--fg-dim); }
.model-picker-results { flex: 1 1 auto; overflow-y: auto; }
/* let labels wrap to their full text instead of truncating/squishing */
.model-picker-results .model-item { align-items: flex-start; }
.model-picker-results .model-item-label {
  white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.35;
}

/* ---- mobile optimization ---- */
@media (max-width: 720px) {
  .conv-head, .transcript, .input-area { padding-left: 0.9rem; padding-right: 0.9rem; }
  /* roomier touch targets */
  .icon-btn { width: 42px; height: 42px; }
  .composer-attach, .composer-send { width: 40px; height: 40px; }
  .topbar { gap: 0.35rem; }
  .topbar-model .model-picker { max-width: none; }
  /* settings popover as a near-full-width sheet under the topbar */
  .settings-panel {
    top: 56px; left: 0.6rem; right: 0.6rem; width: auto;
    max-height: calc(100dvh - 70px); overflow-y: auto;
  }
  .settings-panel textarea { font-size: 16px; } /* no iOS zoom-on-focus */
  /* the slide-in sidebar covers most of a phone screen */
  .sidebar { width: min(340px, 92vw); }
  /* phones: the placeholder wraps to ~2 lines, so size the box to fit it (and
     the centered text fills it instead of sitting above the paperclip) */
  .composer-field textarea { min-height: 4.25rem; }
  .composer { padding: 0.45rem 0.45rem 0.45rem 0.5rem; }
  /* keep the (now wider) model dropdown inside the viewport: pin it as a
     contained sheet under the topbar instead of an absolute dropdown anchored
     to the centered trigger (which overflowed the right edge and shifted the
     whole screen off-center). The .topbar's backdrop-filter makes it the
     containing block for this fixed panel, so top:100% = the topbar's bottom
     edge (robust to the safe-area-inset height on notched phones); left/right
     0.6rem are relative to the topbar's full-width box. */
  .model-picker-panel {
    position: fixed; top: calc(100% + 4px); left: 0.6rem; right: 0.6rem;
    min-width: 0; width: auto; max-width: none;
    max-height: 72vh;
  }
}

/* coarse-pointer (touch) devices: never rely on hover-only affordances */
@media (hover: none) {
  .composer-send:hover:not(:disabled) { transform: none; }
}

/* ---- #80 public-mode first-party auth screen ---- */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(1100px 560px at 50% -12%, rgba(109, 140, 255, 0.16), transparent 60%),
    var(--bg);
}
.auth-screen[hidden] { display: none; }
/* When the auth gate is up the app shell stays out of the layout entirely
   (no empty shell bleeding behind the card, no stray tab targets). */
body.auth-active .layout { display: none; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--shadow-glow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  padding: 2rem 1.75rem;
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.auth-sub {
  text-align: center;
  color: var(--fg-dim);
  font-size: 0.85rem;
  margin: 0 0 1.4rem;
}
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 1.25rem;
}
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--fg-dim);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}
.auth-tab[aria-selected="true"] {
  background: var(--accent);
  color: var(--bg);
}
.auth-error { margin-bottom: 0.9rem; }
.auth-error[hidden] { display: none; }
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
}
.auth-field[hidden] { display: none; }
.auth-field label {
  /* Override the global uppercase <label> style so the card matches the
     lowercase aesthetic of the gateway modal the user visits next. */
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--fg-dim);
  font-weight: 600;
}
.auth-field input {
  background: var(--bg);
  border: 1px solid var(--bg-elev2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  color: inherit;
  font-family: inherit;
  font-size: 0.9rem;
}
.auth-field input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 140, 255, 0.18);
}
.auth-field.invalid input { border-color: var(--error); }
.auth-note {
  font-size: 0.72rem;
  color: var(--fg-dim);
}
.auth-note[hidden] { display: none; }
.auth-field-err {
  font-size: 0.75rem;
  color: var(--error);
}
.auth-field-err[hidden] { display: none; }
.auth-submit {
  width: 100%;
  border: 0;
  background: var(--accent);
  color: var(--bg);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 0.25rem;
}
.auth-submit:hover { background: var(--accent-hover); }
.auth-submit:disabled { opacity: 0.55; cursor: not-allowed; }
.auth-foot {
  color: var(--fg-dim);
  font-size: 0.72rem;
  line-height: 1.6;
  margin: 1.1rem 0 0;
  text-align: center;
}
.account-logout .account-name { color: var(--error); }
.account-logout[hidden] { display: none; }

/* ---- #80 in-app account deletion ---- */
.account-delete .account-name { color: var(--error); }
.account-delete[hidden] { display: none; }
.account-delete-warning {
  color: var(--error);
  background: rgba(255, 107, 138, 0.08);
  border: 1px solid rgba(255, 107, 138, 0.28);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}
.modal-actions .modal-danger-primary {
  background: var(--error);
  border-color: var(--error);
  color: var(--bg);
  font-weight: 700;
}
.modal-actions .modal-danger-primary:hover {
  background: #ff8aa2;
  border-color: #ff8aa2;
}
