/* Shared layout pieces: the floating agent panel, and the phone configuration
   (the agent as a bottom sheet) that every layout uses. */

:root { --panel-w: min(430px, 34vw); --edge: clamp(12px, 2vh, 24px); }

/* ── floating agent panel ───────────────────────────────────────────────── */
.agent-float {
  position: fixed;
  top: var(--edge);
  right: var(--edge);
  bottom: var(--edge);
  z-index: 10;
  width: var(--panel-w);
  height: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: linear-gradient(170deg, rgba(169, 191, 217, 0.1), rgba(169, 191, 217, 0.02)), rgba(17, 27, 40, 0.72);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.5), inset 0 1px rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(30px) saturate(130%);
  animation: floatIn 900ms 300ms var(--ease) both;
  transition: translate 800ms var(--ease), opacity 500ms ease;
}
.agent-float .quiet-header { flex-wrap: wrap; row-gap: 8px; }
.quiet-header .header-tools { flex-wrap: wrap; }
.agent-float .message { backdrop-filter: none; }
.agent-hidden .agent-float { translate: calc(100% + 60px) 0; opacity: 0; pointer-events: none; }

.agent-pill {
  position: fixed;
  right: var(--edge);
  bottom: var(--edge);
  z-index: 11;
  display: none;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(17, 27, 40, 0.78);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4), inset 0 1px rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(24px);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  transition: border-color 200ms ease, transform 300ms var(--ease);
}
.agent-pill:hover { border-color: rgba(255, 255, 255, 0.6); transform: translateY(-2px); }
.agent-hidden .agent-pill { display: inline-flex; animation: rise 500ms 300ms var(--ease) both; }

.sheet-bar { display: none; }

/* ── the conversation ───────────────────────────────────────────────────── */
/* One rule for every bubble. The agent's sits against the left and may grow to
   80% of the column; the visitor's sits against the right and may grow to 80%
   the other way. The text inside both reads left to right. What the agent
   builds (its steps, its generated cards) gets the full width. */
.chat-pane .message-row.assistant,
.chat-pane .message-row.user { padding-inline: 0; }
.chat-pane .message-row.assistant { justify-content: flex-start; }
.chat-pane .message-row.user { justify-content: flex-end; }
.chat-pane .message,
.chat-pane .message.assistant,
.chat-pane .message.user { max-width: 80%; text-align: left; }
.chat-pane .agent-run,
.chat-pane .gen,
.chat-pane .trace { max-width: 100%; }


/* ── phone ──────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  :root { --edge: 8px; }

  /* the panel's header goes away: its controls ride on the sheet (see mountSheet) */
  .chat-pane { display: contents; }
  .chat-pane > .quiet-header:not(.stage-top) { display: none !important; }
  .chat-pane > .quiet-header,
  .quiet-header.stage-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 22;
    gap: 6px;
    min-height: 0;
    padding: 9px 10px 20px;
    background: linear-gradient(180deg, rgba(11, 18, 28, 0.94) 40%, rgba(11, 18, 28, 0));
    flex-wrap: nowrap;
    pointer-events: none;
  }
  .quiet-header > * { pointer-events: auto; }
  .quiet-header .brand,
  .sound-label,
  .panel-hide,
  .agent-pill { display: none !important; }
  .iter-nav { margin-left: 0; }
  .iter-nav a { padding: 5px 6px; }
  .header-tools { margin-left: auto; }
  .tool-btn, .sound-btn { height: 30px; padding: 0 8px; }

  /* the agent becomes a sheet at the bottom of the screen */
  .assistant-shell {
    position: fixed;
    left: var(--edge);
    right: var(--edge);
    bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    height: auto;
    max-height: calc(100svh - 70px);
    padding: 6px 8px 8px;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    background: linear-gradient(170deg, rgba(169, 191, 217, 0.1), rgba(169, 191, 217, 0.02)), rgba(15, 24, 36, 0.86);
    box-shadow: 0 -10px 60px rgba(0, 0, 0, 0.45), inset 0 1px rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(28px) saturate(130%);
    animation: none;
  }
  .sheet-bar { display: flex; align-items: center; gap: 6px; padding: 2px 0 0; }
  .sheet-handle {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    height: 30px;
    padding: 0 6px;
    border: 0;
    background: none;
    color: var(--soft-white);
    font-size: 0.72rem;
    text-align: left;
  }
  .sheet-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.03em; }
  .sheet-tools { flex: none; display: flex; align-items: center; gap: 6px; }
  .sheet-bar .tool-btn { flex: none; height: 30px; padding: 0 10px; backdrop-filter: none; }
  .sheet-bar .tool-btn.is-running { background: var(--white); border-color: var(--white); color: #172331; }
  .sheet-tools .sound-wave { position: static; flex: none; width: 30px; height: 30px; }
  .assistant-shell .message-stream { flex: 0 1 auto; padding: 4px 2px; transition: max-height 500ms var(--ease); }
  .assistant-shell[data-sheet="closed"] .message-stream { display: none; }
  /* peek: just the last line or the step in progress, so the page stays visible */
  .assistant-shell[data-sheet="peek"] .message-stream { max-height: 78px; overflow: hidden; mask-image: linear-gradient(180deg, transparent, #000 60%); }
  .assistant-shell[data-sheet="open"] .message-stream { max-height: min(62svh, 560px); mask-image: linear-gradient(180deg, transparent, #000 16px); }
  .assistant-shell .message { font-size: 0.88rem; padding: 12px 13px; backdrop-filter: none; }
  /* a phone column is narrow, so a bubble may take a little more of it */
  .chat-pane .assistant-shell .message,
  .chat-pane .assistant-shell .message.assistant,
  .chat-pane .assistant-shell .message.user { max-width: 90%; }
  /* the ribbon from a word to the thing it names has nowhere to run on a phone */
  #threads { display: none; }
  .assistant-shell .message-row.assistant,
  .assistant-shell .message-row.user { padding-inline: 0; }
  .assistant-shell .composer { border-radius: 12px; padding: 6px; box-shadow: none; }
  .assistant-shell .composer input { height: 38px; font-size: 1rem; }
  .assistant-shell .composer .mic-btn,
  .assistant-shell .composer .send-btn { width: 38px; height: 38px; border-radius: 9px; }
  .assistant-shell .context-chip { display: none; }
  .suggested-prompts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -2px; padding-inline: 2px; }
  .suggested-prompt { flex: none; }

  /* generated cards breathe a little less on a small screen */
  .gen { padding: 12px; gap: 10px; }
  .vs-side { height: 86px; }
  .car-card { flex-basis: 88%; }

  /* Split on a phone: the paper fills the screen, the agent is the sheet */
  .iter-aura .stage { padding: 0; }
  .iter-aura .portfolio-layout { display: block; height: auto; }
  .iter-aura .content-pane { position: fixed; inset: 0; height: auto; }
  .iter-aura .content-page { padding: 56px 8px 120px; border: 0; border-radius: 0; }
  .iter-aura .overview-section { grid-template-columns: minmax(0, 1fr); }
  .iter-aura .portrait-panel { min-height: 0; aspect-ratio: 4 / 3.4; order: -1; }
  .skill-layout,
  .project-grid { grid-template-columns: minmax(0, 1fr); }
  .project-card { min-height: 0; }
}
