/* Room OS — one input, one surface.
 * Near-black canvas, one accent, type does the hierarchy work. */

:root {
  --bg: #07090d;
  --panel: #10151f;
  --panel-2: #161d2c;
  --editor: #05070a;
  --line: #1c2333;
  --text: #eef2f8;
  --muted: #8b98b0;
  --faint: #5f6f8c;
  --accent: #4da3ff;
  --ok: #7ee2a8;
  --danger: #ff7a7a;
  --radius: 14px;
  --topbar-h: 68px;
  --cmdbar-h: 88px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100svh;
}

.muted { color: var(--muted); font-size: 13px; }

button {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:active { transform: none; }

.ghost-btn {
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  min-height: 40px;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.ghost-btn:hover { color: var(--text); border-color: #2c3852; }
.ghost-btn.danger { color: var(--danger); }
.ghost-btn.danger:hover { border-color: var(--danger); }

.link-btn {
  color: var(--accent);
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============ top bar ============ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  height: var(--topbar-h);
  background: rgba(7, 9, 13, 0.86);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 0;
  border-radius: 10px;
  flex: none;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #232d44, #121826);
  border: 1px solid #2c3852;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

/* Quiet manual escape hatch. The command bar is the real interface. */
.stage-tabs {
  display: flex;
  gap: 2px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.stage-tabs button {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  min-height: 36px;
  transition: color 0.15s ease, background 0.15s ease;
}
.stage-tabs button:hover { color: var(--text); }
.stage-tabs button.active { color: var(--text); background: var(--panel-2); }

.agent-presence {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 6px 10px 6px 6px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
  min-width: 0;
  position: relative;
}
.agent-presence:hover { background: var(--panel); border-color: var(--line); }
.agent-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: none;
  background: linear-gradient(135deg, #3b4a6b, #1c2536);
  border: 1px solid #2c3852;
  display: flex;
  align-items: center;
  justify-content: center;
}
.agent-avatar.sm { width: 34px; height: 34px; }
.avatar-initial { font-size: 15px; font-weight: 800; color: var(--text); }
.presence-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ok);
  border: 2.5px solid var(--bg);
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(126, 226, 168, 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(126, 226, 168, 0); }
}
.agent-avatar.pulse { animation: avatar-pulse 0.9s ease-in-out 2; }
@keyframes avatar-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(77, 163, 255, 0); }
  50% { box-shadow: 0 0 0 9px rgba(77, 163, 255, 0.35); }
}
.agent-meta { min-width: 0; }
.agent-name { font-weight: 700; font-size: 13.5px; line-height: 1.25; }
.agent-activity {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.unread {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #06121f;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.unread[hidden] { display: none; }

/* ============ the command bar: the product ============ */

.stage { min-width: 0; }

.command-zone { position: relative; z-index: 30; }

/* Idle: the hero. Big, centered, glowing on focus. */
body[data-stage="home"] .command-zone {
  max-width: 720px;
  margin: 0 auto;
  padding: 13vh 20px 0;
}
.command-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid #2a3550;
  border-radius: 20px;
  padding: 10px 10px 10px 20px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.command-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(77, 163, 255, 0.18), 0 0 44px rgba(77, 163, 255, 0.12);
}
body[data-stage="home"] .command-bar input { font-size: 20px; padding: 16px 10px; }
/* Composer buttons: + | dictate | voice. 44px targets, always. */
.bar-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.bar-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.bar-btn:active { transform: scale(0.94); }
.bar-btn svg { width: 22px; height: 22px; }
.voice-btn { background: #2f7cf6; color: #fff; box-shadow: 0 4px 20px rgba(47, 124, 246, 0.45); }
.voice-btn:hover { background: #4188f7; color: #fff; }
.mic-btn.live { color: #ff5d5d; animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 50% { opacity: 0.45; } }

/* Attachment tray: what you're handing the agent, before you send. */
.attach-tray {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 720px;
  margin: 0 auto 10px;
  padding: 0 20px;
}
.attach-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 30px 6px 6px;
  max-width: 220px;
}
.attach-chip img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.attach-chip .attach-doc {
  flex: none;
  width: 44px; height: 44px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: var(--accent);
}
.attach-chip .attach-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-chip .attach-x {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* The + sheet: give the agent context, not just files. */
.plus-sheet {
  position: absolute;
  left: 20px;
  bottom: calc(100% + 10px);
  z-index: 60;
  min-width: 230px;
  max-width: 300px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}
.plus-sheet button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  min-height: 48px;
}
.plus-sheet button:hover { background: rgba(255, 255, 255, 0.06); }
.plus-sheet .sheet-head {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 8px 14px 4px;
}
.plus-sheet .sheet-file-sub {
  display: block; font-size: 12px; font-weight: 400; color: var(--muted);
}

/* Voice mode: a room you talk in. */
.voice-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4, 6, 11, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}
.voice-orb {
  width: 128px; height: 128px; border-radius: 50%;
  background: #2f7cf6;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  box-shadow: 0 0 90px rgba(47, 124, 246, 0.55);
  animation: orbpulse 2.2s ease-in-out infinite;
}
.voice-orb span {
  width: 5px; border-radius: 3px; background: #fff;
  animation: orbbar 1.1s ease-in-out infinite;
}
.voice-orb span:nth-child(1) { height: 22px; animation-delay: 0s; }
.voice-orb span:nth-child(2) { height: 38px; animation-delay: 0.15s; }
.voice-orb span:nth-child(3) { height: 52px; animation-delay: 0.3s; }
.voice-orb span:nth-child(4) { height: 38px; animation-delay: 0.45s; }
.voice-orb span:nth-child(5) { height: 22px; animation-delay: 0.6s; }
@keyframes orbpulse { 50% { transform: scale(1.06); box-shadow: 0 0 120px rgba(47, 124, 246, 0.7); } }
@keyframes orbbar { 50% { transform: scaleY(0.45); } }
.voice-status { font-size: 17px; font-weight: 700; color: var(--text); margin: 0; }
.voice-transcript {
  font-size: 15px; color: var(--muted);
  max-width: 560px; min-height: 24px; margin: 0;
}
.voice-stop {
  background: #fff; color: #0a0c12;
  font-size: 16px; font-weight: 700;
  border-radius: 999px; padding: 15px 34px; min-height: 54px;
}

/* Workbench action cards: plain words for everything the OS did. */
.msg.action {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 10px;
  padding: 9px 12px;
  margin: 6px 0;
  max-width: 100%;
}
.action-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.action-detail {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.action-time, .msg-time {
  font-size: 11px;
  font-weight: 400;
  color: var(--faint);
  white-space: nowrap;
}
.action-time { margin-top: 4px; }

/* @ pills: point the bar at room context without leaving the keyboard. */
.at-picker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 60;
  max-height: 300px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}
.at-picker[hidden] { display: none; }
.at-picker .sheet-head {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 8px 14px 4px;
}
.at-picker button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-height: 46px;
}
.at-picker button:hover { background: rgba(255, 255, 255, 0.06); }
.at-picker .sheet-file-sub {
  display: block; font-size: 12px; font-weight: 400; color: var(--muted);
}

.voice-overlay[hidden],
.plus-sheet[hidden],
.attach-tray[hidden],
.bar-toast[hidden] { display: none; }
.bar-toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  z-index: 300;
  background: #1a2233;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 13px 20px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.command-bar input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 17px;
  padding: 13px 8px;
  outline: none;
}
.command-bar input::placeholder { color: var(--faint); }

/* Working: a slim rail pinned under the top bar. */
body:not([data-stage="home"]) .command-zone {
  position: sticky;
  top: var(--topbar-h);
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 20px;
  background: linear-gradient(to bottom, var(--bg) 72%, transparent);
}
body:not([data-stage="home"]) .command-bar { border-radius: 14px; padding: 4px 4px 4px 10px; }
body:not([data-stage="home"]) .command-bar input { font-size: 15px; padding: 10px 8px; }
body:not([data-stage="home"]) .bar-btn { width: 40px; height: 40px; }

/* The agent's hand, visible on the stage. */
.stage-banner {
  margin: 10px auto 0;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
  animation: banner-in 0.24s ease;
}
.stage-banner[hidden] { display: none; }
.stage-banner { cursor: pointer; }
.stage-banner.fail { border-color: rgba(255, 93, 93, 0.5); }
.stage-banner.fail .banner-dot { background: #ff5d5d; }
.stage-banner .banner-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex: none;
  animation: banner-blink 1.1s ease-in-out infinite;
}
@keyframes banner-blink { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.stage-banner b { color: var(--text); font-weight: 600; }

/* ============ stages ============ */

.stage-pane {
  padding: 26px 22px 80px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  animation: pane-in 0.24s ease;
}
.stage-pane[hidden] { display: none; }
@keyframes pane-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-pane { text-align: center; padding-top: 5vh; }
.home-pane h1 {
  font-size: clamp(30px, 6vw, 46px);
  margin: 0 0 26px;
  letter-spacing: -0.025em;
  font-weight: 750;
}
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 600;
  min-height: 48px;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip:active { transform: none; }
.home-continue { max-width: 860px; margin: 34px auto 0; text-align: left; }
.home-continue h2 {
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0 0 14px; text-align: center;
}
.home-cards { margin-bottom: 18px; }
.home-cards .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.home-label {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 8px;
}
.home-file {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; color: var(--text);
  transition: border-color 0.15s ease;
}
.home-file:hover { border-color: var(--accent); }
.home-file-name { font-size: 14px; font-weight: 650; }
.home-file-path { font-size: 12px; color: var(--muted); }

/* Watch */
.watch-search { display: flex; gap: 8px; margin-bottom: 20px; }
.watch-search input {
  flex: 1; min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease;
}
.watch-search input:focus { border-color: var(--accent); }
.watch-search button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 22px;
  font-weight: 700;
  font-size: 14px;
  min-height: 48px;
}
.player-section { margin: 0 0 8px; }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.now-playing { font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-wrap { position: relative; padding-top: 56.25%; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
.player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.results-section { margin-top: 30px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.empty {
  color: var(--muted);
  grid-column: 1 / -1;
  text-align: center;
  padding: 34px 12px;
  border: 1px dashed #2a3550;
  border-radius: var(--radius);
  font-size: 13.5px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
  position: relative;
}
.card:hover { transform: translateY(-2px); border-color: #2c3852; }
.card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: #0b0f18; }
.card-body { padding: 12px 14px 14px; }
.card-title {
  font-weight: 600; font-size: 14px; line-height: 1.4; margin: 0 0 7px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; align-items: center; }
.badge-demo {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: #3a2b00; color: #ffcf5c; border: 1px solid #7a5c14;
}
.card-dock {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(7, 9, 13, 0.82);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  min-height: 32px;
}
.card:hover .card-dock, .card:focus-within .card-dock { opacity: 1; }
.card-dock:hover { color: var(--text); border-color: var(--accent); }

/* Build */
.stage-pane.build-pane {
  max-width: 1060px;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - var(--topbar-h) - 90px);
}
.build-pane[hidden] { display: none; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 2px 12px;
  flex: none;
}
.editor-path-wrap { display: flex; align-items: center; min-width: 0; flex: 1; }
.editor-path {
  font-size: 13px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dirty-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ffcf5c;
  box-shadow: 0 0 8px rgba(255, 207, 92, 0.7);
  margin-right: 9px;
  flex: none;
}
.dirty-dot[hidden] { display: none; }
.editor-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.editor-actions button[hidden] { display: none; }
.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  border: 1px dashed #2a3550;
  border-radius: var(--radius);
  min-height: 220px;
}
.editor-empty[hidden] { display: none; }
.editor-empty-title { font-size: 16px; font-weight: 650; margin: 0; }
.editor-empty p { margin: 0; font-size: 13.5px; line-height: 1.6; max-width: 340px; }
.editor {
  flex: 1;
  min-height: 320px;
  padding: 22px 24px;
  background: var(--editor);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #dbe4f3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.15s ease;
}
.editor:focus { border-color: #2b3a5c; }
.editor[hidden] { display: none; }
.preview {
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.preview[hidden] { display: none; }
.save-status { padding: 10px 4px 0; min-height: 34px; font-size: 12.5px; flex: none; }

/* Files */
.files-pane .filter-input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 16px;
  outline: none;
  margin-bottom: 18px;
  transition: border-color 0.15s ease;
}
.files-pane .filter-input:focus { border-color: var(--accent); }
.files-group { margin-bottom: 24px; }
.files-group-head {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.files-count {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
  min-height: 56px;
}
.file-row:hover { border-color: #2c3852; transform: translateY(-1px); }
.file-row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.file-row-name { font-size: 14px; font-weight: 600; }
.file-row-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-row-date { font-size: 12px; color: var(--muted); flex: none; }

/* ============ agent drawer: the thread is a log ============ */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 8, 0.6);
  z-index: 55;
  animation: fade-in 0.2s ease;
}
.scrim[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.agent-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 94vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 60;
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.5);
}
.agent-drawer[hidden] { display: none; }
@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 12px;
  flex: none;
}
.drawer-head-meta { flex: 1; min-width: 0; }
.drawer-sub { font-size: 12px; }
.drawer-stages {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 12px;
  flex: none;
}
.drawer-stages button {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 600;
  min-height: 40px;
}
.drawer-stages button:hover { color: var(--text); border-color: #2c3852; }
.drawer-hint { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); flex: none; font-size: 12px; }

/* Messages: the agent talks like a person. No blue bubbles. */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 6px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 120px;
}
.msg { max-width: 100%; }
.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.msg-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #3b4a6b, #1c2536);
  border: 1px solid #2c3852;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; flex: none;
}
.msg .who { font-size: 12px; font-weight: 700; color: var(--text); }
.msg-text {
  font-size: 15px;
  line-height: 1.55;
  color: #d7deec;
  overflow-wrap: anywhere;
  padding-left: 30px;
}
.msg.mine { align-self: flex-end; max-width: 88%; }
.msg.mine .msg-head { justify-content: flex-end; }
.msg.mine .msg-text {
  background: #182a45;
  border: 1px solid #24405f;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 15px;
  font-size: 14.5px;
}
.msg.sys {
  align-self: center;
  font-size: 12px;
  color: var(--faint);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  max-width: 92%;
  text-align: center;
}
.msg.result .result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
  padding-left: 30px;
}
.result-cards .card img { aspect-ratio: 16 / 10; }

.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 4px 20px 10px 50px;
  flex: none;
}
.typing[hidden] { display: none; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-bounce {
  0%, 100% { transform: translateY(0); opacity: 0.45; }
  50% { transform: translateY(-5px); opacity: 1; }
}

.chat-setup {
  background: #2a2113;
  border: 1px solid #7a5c14;
  color: #ffcf5c;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13.5px;
  margin: 0 18px 12px;
  line-height: 1.5;
  flex: none;
}

/* Toast: a new agent message while the drawer is closed */
.agent-toast {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 58;
  max-width: min(380px, calc(100vw - 40px));
  background: var(--panel-2);
  border: 1px solid #2c3852;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 13.5px;
  text-align: left;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
  animation: banner-in 0.22s ease;
  min-height: 48px;
}
.agent-toast[hidden] { display: none; }
.agent-toast b { color: var(--text); }

/* ============ dock: the mini player ============ */

.dock {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 322px;
  z-index: 45;
  background: #0d1220;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.6);
  animation: banner-in 0.24s ease;
}
.dock[hidden] { display: none; }
.dock-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 14px;
}
.dock-thumb {
  width: 64px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  flex: none;
  background: #000;
}
.dock-thumb[hidden] { display: none; }
.dock-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #c3cede;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.dock-x {
  color: var(--muted);
  padding: 10px 12px;
  font-size: 12px;
  border-radius: 8px;
  flex: none;
  min-height: 40px;
}
.dock-x:hover { background: #1a2338; color: var(--text); }
.dock-video { position: relative; padding-top: 56.25%; background: #000; }
.dock-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ============ name overlay ============ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 5, 8, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.overlay-card h2 { margin: 0 0 8px; font-size: 22px; }
.overlay-card p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.overlay-card form { display: flex; flex-direction: column; gap: 12px; }
.overlay-card input {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
}
.overlay-card input:focus { border-color: var(--accent); }
.overlay-card button {
  background: var(--accent);
  color: #06121f;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  min-height: 52px;
}

/* ============ phone: talk-first ============ */

@media (max-width: 900px) {
  :root { --topbar-h: 60px; }
  .topbar { padding: 0 12px; gap: 8px; height: var(--topbar-h); }
  .stage-tabs { display: none; } /* the command bar is the navigation */
  .brand-title { font-size: 15px; }
  .agent-activity { max-width: 34vw; }

  .stage { display: flex; flex-direction: column; }

  /* The command bar never leaves the thumb zone. */
  .command-zone {
    order: 98;
    position: sticky;
    bottom: 0;
    z-index: 44;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 78%, transparent);
    max-width: none;
    margin: 0;
  }
  body[data-stage="home"] .command-zone { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  body:not([data-stage="home"]) .command-zone { top: auto; }
  .command-bar { border-radius: 16px; padding: 6px 6px 6px 10px; }
  .command-bar input,
  body[data-stage="home"] .command-bar input { font-size: 16px; padding: 12px 8px; }
  .stage-banner { margin-top: 8px; }

  .stage-pane { padding: 18px 14px 40px; }
  .home-pane { padding-top: 8vh; order: 1; }
  .stage-pane.build-pane { min-height: 0; }
  .editor { min-height: 38vh; font-size: 14px; }

  /* The dock becomes a slim strip pinned above the command bar. No fixed
     positioning on the phone, so the keyboard can't make it jump. */
  .dock {
    position: sticky;
    order: 97;
    bottom: calc(var(--cmdbar-h) + env(safe-area-inset-bottom));
    right: auto;
    width: auto;
    margin: 0 12px;
    border-radius: 14px;
    cursor: pointer;
  }
  .dock .dock-video { display: none; }
  .dock-thumb:not([hidden]) { display: block; }

  /* The thread becomes a bottom sheet. */
  .agent-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: 80vh;
    max-height: 80dvh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    animation: sheet-in 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes sheet-in {
    from { transform: translateY(60px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .agent-toast {
    left: 12px;
    right: 12px;
    bottom: calc(var(--cmdbar-h) + 12px + env(safe-area-inset-bottom));
    max-width: none;
  }

  .cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .card-dock { opacity: 1; } /* no hover on touch */
  .chip { min-height: 48px; }
  .ghost-btn { min-height: 44px; }
  .file-row { min-height: 60px; }
  .drawer-stages button { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Brodie OS boot: it should feel like waking someone up, not loading a page. */
.boot {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #04060b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  transition: opacity 0.45s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot[hidden] { display: none; }
.boot-word {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--text);
  animation: boot-in 0.7s ease both;
}
.boot-word::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 14px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: boot-in 0.7s ease both;
}
.boot-lines {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  min-height: 88px;
  text-align: left;
}
.boot-lines div { animation: boot-in 0.25s ease both; }
.boot-lines .ok { color: var(--accent); }
@keyframes boot-in { from { opacity: 0; transform: translateY(6px); } }

/* Home activity: proof the OS does things, live. */
.home-activity { margin-top: 26px; }
.home-activity h2 {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin: 0 0 10px;
}
.home-activity[hidden] { display: none; }
#activity-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.activity-line {
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-line b { color: var(--text); font-weight: 600; }

/* ---------------- Taste Room — the training harness ---------------- */
.taste-pane { max-width: 1100px; }
.taste-head h1 { margin: 0 0 6px; font-size: 22px; }
.taste-head p { margin: 0 0 18px; max-width: 640px; }
.taste-head b { color: var(--text); }
.taste-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.taste-presence {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; color: var(--muted); background: var(--card); white-space: nowrap;
}
.presence-dot { width: 9px; height: 9px; border-radius: 50%; background: #666; transition: background .3s, box-shadow .3s; }
.presence-dot.on { background: #34d399; box-shadow: 0 0 8px #34d399; }
@media (max-width: 640px) { .taste-head { flex-direction: column; } }

/* ---- Agent face: the room's second face, built for the agent ---- */
.taste-agent-login {
  flex-shrink: 0; align-self: center;
  background: transparent; border: 1px dashed var(--border); border-radius: 999px;
  color: var(--muted); font-size: 12px; padding: 7px 12px; cursor: pointer;
}
.taste-agent-login:hover { color: var(--text); border-color: var(--text); }
.taste-agent { margin-top: 4px; }
.agent-bar {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 16px; border: 1px solid var(--border); border-radius: 12px;
  background: #0d1117; margin-bottom: 14px;
}
.agent-bar h2 { margin: 0 0 6px; font-size: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.agent-bar p { margin: 0; max-width: 560px; }
.agent-badge {
  display: inline-block; font-size: 10px; letter-spacing: 1px; vertical-align: middle;
  background: #34d399; color: #04120c; border-radius: 4px; padding: 2px 6px; margin-right: 8px;
}
.agent-session {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  font-size: 13px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.agent-session button {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 12px; padding: 6px 10px; cursor: pointer;
}
.agent-session button:hover { border-color: var(--text); }
.agent-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .agent-grid { grid-template-columns: 1fr; } }
.agent-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  background: #0d1117;
}
.agent-card h3 { margin: 0 0 10px; font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.agent-orders { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.65; color: var(--text); }
.agent-orders code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
  background: #161b22; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
  word-break: break-all;
}
.agent-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.agent-job {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  background: #11161d; font-size: 13px;
}
.agent-job-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.agent-job-top code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); }
.agent-job-prompt { margin-bottom: 6px; }
.agent-job-tags .taste-tag { font-size: 11px; }
.agent-status { font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .5px; }
.st-pending { color: #fbbf24; }
.st-working { color: #60a5fa; }
.st-done { color: #34d399; }
.st-failed { color: #f87171; }

.taste-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

.taste-form { display: flex; gap: 10px; margin-bottom: 10px; }
.taste-form input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  min-height: 48px;
}
.taste-form input:focus { outline: none; border-color: var(--accent); }
.taste-form button {
  background: var(--accent);
  color: #04101f;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 18px;
  min-height: 48px;
  white-space: nowrap;
}
.taste-form button:active { transform: scale(0.98); }

.taste-status { min-height: 22px; margin-bottom: 10px; }

.taste-arena {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  gap: 12px;
  align-items: stretch;
}
.taste-arena[hidden] { display: none; }

.taste-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.taste-card.winner { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.taste-img-wrap {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.taste-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.taste-card.loading .taste-img-wrap {
  background: linear-gradient(100deg, var(--panel-2) 40%, #1d2740 50%, var(--panel-2) 60%);
  background-size: 200% 100%;
  animation: taste-shimmer 1.2s infinite;
}
@keyframes taste-shimmer { to { background-position: -200% 0; } }
.taste-card-meta { display: flex; justify-content: center; }
.taste-style {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.taste-card.winner .taste-style { color: var(--ok); }
.taste-pick {
  background: rgba(77, 163, 255, 0.12);
  border: 1px solid var(--accent);
  color: var(--text);
  font-weight: 700;
  border-radius: 10px;
  padding: 12px;
  min-height: 48px;
}
.taste-pick:active { transform: scale(0.98); }
.taste-card.winner .taste-pick { background: rgba(126, 226, 168, 0.12); border-color: var(--ok); }

.taste-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.taste-why { margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.taste-why[hidden] { display: none; }
.taste-why p { margin: 0 0 10px; }
.taste-why form { display: flex; gap: 10px; }
.taste-why input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  min-height: 44px;
}
.taste-why input:focus { outline: none; border-color: var(--accent); }
.taste-why button {
  background: var(--accent);
  color: #04101f;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 44px;
  white-space: nowrap;
}

.taste-profile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: calc(var(--topbar-h) + 12px);
}
.taste-profile-head { display: flex; align-items: baseline; justify-content: space-between; }
.taste-profile h2 { margin: 0; font-size: 15px; }
.taste-profile h3 { margin: 14px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.taste-rounds { font-size: 12px; color: var(--muted); font-weight: 700; }
.taste-profile-sub { margin: 6px 0 0; font-size: 12.5px; }
.taste-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.taste-tag {
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  padding: 5px 11px;
  border: 1px solid var(--line);
}
.taste-tag.like { color: var(--ok); border-color: rgba(126, 226, 168, 0.4); background: rgba(126, 226, 168, 0.07); }
.taste-tag.dislike { color: var(--danger); border-color: rgba(255, 122, 122, 0.35); background: rgba(255, 122, 122, 0.06); }
.taste-tag.flash { animation: taste-flash 0.9s ease; }
@keyframes taste-flash { 0% { box-shadow: 0 0 0 3px rgba(126, 226, 168, 0.5); } 100% { box-shadow: none; } }
.taste-notes { display: flex; flex-direction: column; gap: 6px; }
.taste-note { font-size: 12.5px; color: var(--muted); border-left: 2px solid var(--accent); padding-left: 10px; }
.taste-profile .ghost-btn { margin-top: 14px; width: 100%; }

@media (max-width: 860px) {
  .taste-layout { grid-template-columns: 1fr; }
  .taste-profile { position: static; }
  .taste-arena { grid-template-columns: 1fr; }
  .taste-vs { padding: 2px 0; }
  .taste-form { flex-direction: column; }
  .taste-why form { flex-direction: column; }
}
