/* COCKPIT-V2-MOBILE-REDUCED-001 — single-pane mobile cockpit styles.
   Layered on gentoo-tokens.css + cockpit-tokens.css. Owns its own .cv2m-
   prefix so it never collides with the desktop cockpit-shell.css. Visual
   chassis matches the canonical-style spec (navy/paper/grey, section
   pastels, mono badges) so mobile and desktop read as one product.

   Layout decisions (4-LLM consensus 2026-05-14):
     · Full-width chat at all viewports (no 3-pane on phone)
     · Stat strip is pull-down only — chrome stays minimal
     · Right-rail is a swipe-in drawer with an always-visible edge grip
     · Slash sheet is a bottom-anchored modal
     · Voice composer is long-press → ships transcript text */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--cockpit-paper, var(--gl-brand-paper));
  color: var(--cockpit-navy, var(--gl-brand-strong));
  font-family: var(--cockpit-font, var(--gl-font));
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

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

/* Root flex column — chrome top, chat fills, composer bottom. We pin the
   root to the viewport height so the chat log scrolls inside itself
   while the composer + header stay anchored. dvh handles mobile URL bars
   without jumping; vh fallback keeps older WebKit honest. */
.cv2m-root {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
}

/* ─── Header ────────────────────────────────────────────────────────── */
.cv2m-header {
  position: sticky;
  top: 0; z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid var(--section-slate-border);
}
.cv2m-header-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.cv2m-mono {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--gl-brand-soft);
  color: var(--gl-brand-strong);
  font-family: var(--cockpit-font-mono, var(--gl-font-mono));
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.cv2m-id {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  min-width: 0;
}
.cv2m-product {
  font-weight: 700;
  color: var(--cockpit-navy);
  letter-spacing: 0.2px;
}
.cv2m-divider { color: var(--section-slate-border); }
.cv2m-surface {
  color: var(--cockpit-grey);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
}

/* Stat-toggle: minimal chevron, rotates 180° when strip is open. */
.cv2m-stat-toggle {
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  background: var(--gl-brand-soft);
  color: var(--cockpit-navy);
  border: 1px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.cv2m-stat-toggle:active { transform: scale(0.96); }
.cv2m-stat-toggle-chevron {
  font-size: 14px;
  line-height: 1;
  transition: transform 180ms ease;
}
.cv2m-root[data-stat-strip="open"] .cv2m-stat-toggle-chevron {
  transform: rotate(180deg);
}

/* ─── Stat strip (pull-down) ────────────────────────────────────────── */
.cv2m-stat-strip {
  background: #fff;
  border-bottom: 1px solid var(--section-slate-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cv2m-stat-strip::-webkit-scrollbar { display: none; }
.cv2m-stat-strip-list {
  display: flex;
  gap: var(--sp-2);
  list-style: none;
  margin: 0;
  padding: 10px 14px;
  min-width: 100%;
  width: max-content;
}
.cv2m-stat {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 116px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: #fff;
  border: 1px solid var(--section-slate-border);
  box-shadow: var(--gl-shadow-sm);
  flex-shrink: 0;
}
.cv2m-stat-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--strip-dot-defer);
  flex-shrink: 0;
}
.cv2m-stat[data-tone="wins"]    .cv2m-stat-dot { background: var(--strip-dot-wins); }
.cv2m-stat[data-tone="urgent"]  .cv2m-stat-dot { background: var(--strip-dot-urgent); }
.cv2m-stat[data-tone="ready"]   .cv2m-stat-dot { background: var(--strip-dot-ready); }
.cv2m-stat[data-tone="routine"] .cv2m-stat-dot { background: var(--strip-dot-routine); }
.cv2m-stat[data-tone="defer"]   .cv2m-stat-dot { background: var(--strip-dot-defer); }
.cv2m-stat-body {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.cv2m-stat-count {
  font-family: var(--cockpit-font-mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--cockpit-navy);
}
.cv2m-stat-label {
  font-size: 10.5px;
  color: var(--cockpit-grey);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ─── Stream chips ──────────────────────────────────────────────────── */
.cv2m-streams {
  position: sticky;
  top: 50px; /* below header */
  top: calc(env(safe-area-inset-top) + 50px);
  z-index: 20;
  background: var(--cockpit-paper, var(--gl-brand-paper));
  border-bottom: 1px solid var(--section-slate-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cv2m-streams::-webkit-scrollbar { display: none; }
.cv2m-streams-list {
  display: flex;
  gap: var(--sp-2);
  list-style: none;
  margin: 0;
  padding: 8px 14px;
  width: max-content;
}
.cv2m-stream-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: #fff;
  border: 1px solid var(--section-slate-border);
  color: var(--cockpit-navy);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
  flex-shrink: 0;
}
.cv2m-stream-chip[aria-selected="true"],
.cv2m-stream-chip[data-active="true"] {
  background: var(--gl-brand-strong);
  border-color: var(--gl-brand-strong);
  color: #fff;
}
.cv2m-stream-chip:active { transform: scale(0.97); }
.cv2m-stream-chip-name {
  font-weight: 600;
}
.cv2m-stream-chip-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--gl-p1, #c2410c);
  color: #fff;
  font-family: var(--cockpit-font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}
.cv2m-stream-chip-badge[data-zero="true"] { display: none; }
.cv2m-stream-chip[aria-selected="true"] .cv2m-stream-chip-badge {
  background: #fff;
  color: var(--gl-brand-strong);
}

/* ─── Chat ───────────────────────────────────────────────────────────── */
.cv2m-chat {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--cockpit-paper, var(--gl-brand-paper));
}
.cv2m-chat-log {
  list-style: none;
  margin: 0;
  padding: 14px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}
.cv2m-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 86%;
}
.cv2m-msg[data-role="me"]    { align-self: flex-end; }
.cv2m-msg[data-role="agent"] { align-self: flex-start; }
.cv2m-msg[data-role="system"] {
  align-self: center;
  max-width: 92%;
  align-items: center;
}
.cv2m-msg-bubble {
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.45;
  background: #fff;
  border: 1px solid var(--section-slate-border);
  color: var(--cockpit-navy);
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--gl-shadow-sm);
}
.cv2m-msg[data-role="me"] .cv2m-msg-bubble {
  background: var(--gl-brand-strong);
  border-color: var(--gl-brand-strong);
  color: #fff;
}
.cv2m-msg[data-role="agent"] .cv2m-msg-bubble {
  background: #fff;
  border-color: var(--gl-brand-soft);
}
.cv2m-msg[data-role="system"] .cv2m-msg-bubble {
  background: var(--section-slate-card);
  border: 1px dashed var(--section-slate-border);
  color: var(--cockpit-grey);
  font-size: 12px;
  font-family: var(--cockpit-font-mono);
}
.cv2m-msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--cockpit-font-mono);
  font-size: 10px;
  color: var(--cockpit-grey);
  letter-spacing: 0.3px;
}
.cv2m-msg[data-role="me"] .cv2m-msg-meta { align-self: flex-end; }
.cv2m-msg-who { font-weight: 700; text-transform: uppercase; }
.cv2m-msg-slash {
  font-family: var(--cockpit-font-mono);
  font-size: 12px;
  color: var(--gl-brand-strong);
  background: var(--gl-brand-soft);
  border-radius: var(--r-chip);
  padding: 1px 6px;
  margin-right: 4px;
}

/* ─── Composer ──────────────────────────────────────────────────────── */
.cv2m-composer {
  position: sticky;
  bottom: 0; z-index: 25;
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--section-slate-border);
}
.cv2m-composer-plus,
.cv2m-composer-send {
  width: 40px; height: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid transparent;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.cv2m-composer-plus {
  background: var(--gl-brand-soft);
  color: var(--cockpit-navy);
  font-weight: 600;
}
.cv2m-composer-plus:active { transform: scale(0.94); }
.cv2m-composer-send {
  background: var(--gl-brand);
  color: #fff;
  font-weight: 700;
}
.cv2m-composer-send:disabled {
  background: var(--section-slate-card);
  color: var(--cockpit-grey);
  cursor: not-allowed;
}
.cv2m-composer-send:not(:disabled):active { transform: scale(0.94); }
.cv2m-composer-field {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}
.cv2m-composer-field input {
  flex: 1;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--section-slate-border);
  border-radius: var(--r-pill);
  background: var(--cockpit-paper, var(--gl-brand-paper));
  color: var(--cockpit-navy);
  font: inherit;
  font-size: 15px; /* iOS: 16px+ avoids zoom; 15 is close enough w/ viewport */
}
.cv2m-composer-field input:focus {
  outline: 2px solid var(--gl-brand);
  outline-offset: 1px;
  background: #fff;
}
.cv2m-root[data-recording="true"] .cv2m-composer-field input {
  background: var(--section-rose-card);
  border-color: var(--section-rose-bar);
}

/* ─── Voice overlay (long-press) ────────────────────────────────────── */
.cv2m-voice {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center; justify-content: center;
  background: rgba(13, 42, 74, 0.55);
  padding: var(--sp-4);
}
.cv2m-voice[hidden] { display: none; }
.cv2m-loading[hidden] { display: none; }
.cv2m-voice-card {
  width: min(360px, 100%);
  background: #fff;
  border-radius: var(--r-card);
  border: 1px solid var(--section-rose-border);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  box-shadow: 0 14px 40px rgba(13, 42, 74, 0.28);
}
.cv2m-voice-pulse {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--section-rose-card);
  border: 2px solid var(--section-rose-bar);
  animation: cv2m-pulse 1.05s ease-in-out infinite;
}
@keyframes cv2m-pulse {
  0%, 100% { transform: scale(1);   box-shadow: 0 0 0 0 rgba(253, 164, 175, 0.55); }
  50%      { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(253, 164, 175, 0); }
}
.cv2m-voice-label {
  font-family: var(--cockpit-font-mono);
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--cockpit-navy);
  font-weight: 700;
}
.cv2m-voice-transcript {
  font-size: 15px;
  line-height: 1.45;
  color: var(--cockpit-navy);
  min-height: 1.4em;
  text-align: center;
}
.cv2m-voice-transcript:empty::before {
  content: "Speak…";
  color: var(--cockpit-grey);
  font-style: italic;
}
.cv2m-voice-hint {
  font-size: 11px;
  color: var(--cockpit-grey);
  text-align: center;
}

/* ─── Right-rail drawer ─────────────────────────────────────────────── */
.cv2m-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  pointer-events: none;
}
.cv2m-drawer-handle {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 18px;
  height: 72px;
  border-top-left-radius: var(--r-chip);
  border-bottom-left-radius: var(--r-chip);
  background: var(--gl-brand-soft);
  border: 1px solid var(--section-slate-border);
  border-right: none;
  display: flex;
  align-items: center; justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: -2px 0 6px rgba(13, 42, 74, 0.08);
}
.cv2m-drawer-handle-grip {
  width: 2px;
  height: 28px;
  background: var(--cockpit-navy);
  border-radius: 2px;
  box-shadow: 4px 0 0 var(--cockpit-navy);
}
.cv2m-drawer-panel {
  width: min(86vw, 320px);
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--section-slate-border);
  box-shadow: -8px 0 20px rgba(13, 42, 74, 0.16);
  transform: translateX(100%);
  transition: transform 220ms ease;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.cv2m-root[data-drawer="open"] .cv2m-drawer-panel {
  transform: translateX(0);
}
.cv2m-root[data-drawer="open"] .cv2m-drawer-handle {
  opacity: 0.3;
}
.cv2m-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--section-slate-border);
}
.cv2m-drawer-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--cockpit-navy);
}
.cv2m-drawer-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--cockpit-grey);
  font-size: 22px; line-height: 1;
  cursor: pointer;
}
.cv2m-drawer-close:active { background: var(--section-slate-card); }
.cv2m-drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.cv2m-drawer-block {
  background: var(--section-slate-bg);
  border: 1px solid var(--section-slate-border);
  border-radius: var(--r-card);
  padding: var(--sp-3);
}
.cv2m-drawer-block-label {
  font-family: var(--cockpit-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--cockpit-grey);
  margin-bottom: 6px;
}
.cv2m-drawer-block-body {
  font-size: 13px;
  color: var(--cockpit-navy);
  line-height: 1.5;
}
.cv2m-drawer-block-body ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.cv2m-drawer-empty {
  font-size: 13px;
  font-style: italic;
  color: var(--cockpit-grey);
  text-align: center;
  padding: var(--sp-4) 0;
}

/* Backdrop that the user can tap to dismiss the drawer. */
.cv2m-drawer::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(13, 42, 74, 0);
  pointer-events: none;
  transition: background 180ms ease;
}
.cv2m-root[data-drawer="open"] .cv2m-drawer::before {
  background: rgba(13, 42, 74, 0.32);
  pointer-events: auto;
}

/* ─── Bottom sheet (slash commands) ─────────────────────────────────── */
.cv2m-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.cv2m-sheet[hidden] { display: none; }
.cv2m-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 42, 74, 0.42);
  cursor: pointer;
}
.cv2m-sheet-panel {
  position: relative;
  background: #fff;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 28px rgba(13, 42, 74, 0.22);
  padding-bottom: env(safe-area-inset-bottom);
  animation: cv2m-sheet-in 220ms ease;
}
@keyframes cv2m-sheet-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.cv2m-sheet-panel::before {
  content: "";
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  width: 44px; height: 4px;
  border-radius: var(--r-pill);
  background: var(--section-slate-bar);
}
.cv2m-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 24px var(--sp-4) var(--sp-2);
}
.cv2m-sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--cockpit-navy);
}
.cv2m-sheet-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--cockpit-grey);
  font-size: 22px; line-height: 1;
  cursor: pointer;
}
.cv2m-sheet-search {
  padding: 0 var(--sp-4);
  display: flex;
}
.cv2m-sheet-search input {
  flex: 1;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--section-slate-border);
  border-radius: var(--r-pill);
  background: var(--cockpit-paper, var(--gl-brand-paper));
  font: inherit;
  font-size: 15px;
  color: var(--cockpit-navy);
}
.cv2m-sheet-search input:focus {
  outline: 2px solid var(--gl-brand);
  outline-offset: 1px;
  background: #fff;
}
.cv2m-sheet-list {
  list-style: none;
  margin: var(--sp-3) 0 0;
  padding: 0 var(--sp-2) var(--sp-2);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}
.cv2m-sheet-group-label {
  font-family: var(--cockpit-font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cockpit-grey);
  padding: var(--sp-3) var(--sp-3) var(--sp-1);
}
.cv2m-sheet-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 10px 12px;
  border-radius: var(--r-card);
  cursor: pointer;
}
.cv2m-sheet-item[aria-selected="true"],
.cv2m-sheet-item:active {
  background: var(--gl-brand-soft);
}
.cv2m-sheet-item-slash {
  font-family: var(--cockpit-font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--gl-brand-strong);
  min-width: 86px;
}
.cv2m-sheet-item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cv2m-sheet-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--cockpit-navy);
}
.cv2m-sheet-item-hint {
  font-size: 12px;
  color: var(--cockpit-grey);
  line-height: 1.4;
}
.cv2m-sheet-hint {
  margin: 0;
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
  font-size: 11px;
  color: var(--cockpit-grey);
  font-family: var(--cockpit-font-mono);
  text-align: center;
}
.cv2m-sheet-empty {
  padding: var(--sp-5);
  text-align: center;
  color: var(--cockpit-grey);
  font-style: italic;
  font-size: 13px;
}

.cv2m-loading {
  padding: var(--sp-6);
  text-align: center;
  color: var(--cockpit-grey);
  font-size: 13px;
}

/* ─── Wider phones / tablets ────────────────────────────────────────── */
@media (min-width: 768px) {
  /* This shell is mobile-only by intent — the desktop cockpit lives in
     cockpit-shell.html. We cap the chat column on tablets so the
     single-pane experience reads cleanly without stretching edge to
     edge. Right-rail drawer and stat-strip remain unchanged. */
  .cv2m-chat-log,
  .cv2m-composer,
  .cv2m-streams-list,
  .cv2m-stat-strip-list {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
}
