/* ============================================================================
 * Octio Agent — wizard + chat + voice overlay
 *
 * Sits on top of the Claude Design HTML. All styles are scoped to .octio-agent
 * so they don't leak into the rest of the page.
 *
 * Palette inherits from the design HTML's :root variables. Adds one accent
 * (--octio-orange) for the agent's active state.
 * ========================================================================= */

.octio-agent {
  --octio-ink: #111111;
  --octio-ink-soft: #2a2a2a;
  --octio-muted: #6b6b6b;
  --octio-slab: #ffffff;
  --octio-cream: #e5d6c2;
  --octio-cream-soft: #efe2d1;
  --octio-orange: #b85a2e;
  --octio-orange-glow: #e07a35;
  --octio-rule: #ececec;
  --octio-radius: 6px;
  --octio-font-display: "Cabinet Grotesk", "General Sans", system-ui, sans-serif;
  --octio-font-body: "General Sans", "Inter", system-ui, sans-serif;
  --octio-font-mono: "SFMono-Regular", ui-monospace, Menlo, monospace;
}

/* ─── FAB ─────────────────────────────────────────────────────────────── */
.octio-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 12px 12px;
  background: rgba(13, 13, 14, 0.92);
  color: #f4efe7;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.45);
  transition: transform .2s ease, background .2s ease;
  backdrop-filter: blur(12px) saturate(1.1);
}
.octio-fab:hover { transform: translateY(-2px); background: rgba(13, 13, 14, 1); }
.octio-fab-orb {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffb877 0%, #f0902e 28%, #b85a2e 60%, #6a3a0f 100%);
  box-shadow: inset -2px -3px 8px rgba(0, 0, 0, 0.4), inset 2px 2px 6px rgba(255, 220, 180, 0.3);
  animation: octioFabBreathe 4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes octioFabBreathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .octio-fab-orb { animation: none; }
}
@media (max-width: 760px) {
  .octio-fab { padding: 10px 14px 10px 10px; font-size: 13px; bottom: 16px; left: 16px; }
  .octio-fab-orb { width: 24px; height: 24px; }
  .octio-fab-label { display: none; }    /* mobile: just the orb */
  .octio-fab { padding: 12px; }
}

/* ─── Overlay backdrop + dialog ──────────────────────────────────────────── */
.octio-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(8, 8, 12, 0.55);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .3s ease;
}
.octio-overlay.is-open { display: flex; opacity: 1; }

.octio-dialog {
  position: relative;
  width: 100%;
  max-width: 860px;
  max-height: calc(100vh - 64px);
  background: var(--octio-slab);
  border-radius: 12px;
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  transition: transform .35s cubic-bezier(.2, .9, .25, 1);
}
.octio-overlay.is-open .octio-dialog { transform: translateY(0) scale(1); }

.octio-dialog-close {
  position: absolute;
  top: 18px; right: 18px;
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid var(--octio-rule);
  border-radius: 50%;
  font-size: 18px;
  color: var(--octio-ink);
  cursor: pointer;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.octio-dialog-close:hover { background: var(--octio-cream-soft); }

.octio-dialog-back {
  position: absolute;
  top: 22px;
  left: 22px;
  font-family: var(--octio-font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--octio-muted);
  background: transparent;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  z-index: 10;
}
.octio-dialog-back:hover { color: var(--octio-ink); }

/* ─── Wizard step ──────────────────────────────────────────────────────── */
.octio-wizard {
  display: flex;
  flex-direction: column;
  padding: 80px 64px 32px;
  min-height: 540px;
  gap: 32px;
}

.octio-wizard-eyebrow {
  font-family: var(--octio-font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--octio-muted);
  margin: 0;
}
.octio-wizard-eyebrow .num {
  color: var(--octio-orange);
  margin-right: 8px;
}

.octio-wizard-q {
  font-family: var(--octio-font-display);
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0;
  color: var(--octio-ink);
  max-width: 640px;
}

.octio-wizard-help {
  font-family: var(--octio-font-body);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--octio-muted);
  max-width: 540px;
  margin: 0;
}

.octio-wizard-input {
  width: 100%;
  max-width: 560px;
  padding: 16px 0 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--octio-rule);
  font-family: var(--octio-font-display);
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--octio-ink);
  outline: none;
  transition: border-color .2s ease;
}
.octio-wizard-input:focus { border-bottom-color: var(--octio-orange); }
.octio-wizard-input::placeholder { color: var(--octio-muted); opacity: 0.5; }

.octio-wizard-options {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 8px 0 0;
}
.octio-wizard-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--octio-slab);
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 14px;
  color: var(--octio-ink);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.octio-wizard-option:hover { border-color: var(--octio-orange); background: #fff7f0; }
.octio-wizard-option.is-selected {
  border-color: var(--octio-orange);
  background: var(--octio-orange);
  color: #fff;
}

.octio-wizard-error {
  font-family: var(--octio-font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #c1442b;
  margin: 8px 0 0;
}

.octio-wizard-footer {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
}

.octio-progress {
  display: inline-flex;
  gap: 8px;
}
.octio-progress-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--octio-rule);
  transition: background .25s ease, transform .25s ease;
}
.octio-progress-dot.is-current { background: var(--octio-orange); transform: scale(1.25); }
.octio-progress-dot.is-done { background: var(--octio-cream); }

.octio-wizard-cta {
  padding: 12px 22px;
  background: var(--octio-orange);
  color: #fff;
  border: 1px solid var(--octio-orange);
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background .15s ease;
}
.octio-wizard-cta:hover { background: var(--octio-orange-glow); border-color: var(--octio-orange-glow); }
.octio-wizard-cta[disabled] { opacity: 0.4; cursor: not-allowed; }

/* Mode-step (final): two big mode cards */
.octio-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
.octio-mode-card {
  text-align: left;
  background: var(--octio-slab);
  border: 1px solid var(--octio-rule);
  border-radius: 8px;
  padding: 28px 24px;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.octio-mode-card:hover {
  border-color: var(--octio-orange);
  background: #fff7f0;
}
.octio-mode-card-title {
  font-family: var(--octio-font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--octio-ink);
}
.octio-mode-card-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--octio-muted);
  margin: 0;
}

@media (max-width: 760px) {
  .octio-overlay { padding: 0; }
  /* Primary F5 path: dvh tracks the visual viewport — keyboard shrinks
     the dialog instead of pushing the bottom (input) off-screen.
     Modern browsers only (Safari 16.4+ / Chrome 108+ / Firefox 110+). */
  .octio-dialog {
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    width: 100%;
  }
  /* Fallback for older browsers without dvh — agent.js sets --chat-h
     from visualViewport.height on the .octio-no-dvh root. */
  html.octio-no-dvh .octio-dialog {
    max-height: var(--chat-h, 100vh);
    height: var(--chat-h, 100vh);
  }
  .octio-wizard { padding: 72px 24px 24px; min-height: auto; flex: 1; }
  .octio-mode-grid { grid-template-columns: 1fr; }

  /* Hide the back arrow once we're in chat/voice — no meaningful back state */
  .octio-dialog.in-chat .octio-dialog-back,
  .octio-dialog.in-voice .octio-dialog-back,
  .octio-dialog:has(.octio-chat) .octio-dialog-back,
  .octio-dialog:has(.octio-voice) .octio-dialog-back { display: none; }

  /* Chat mobile: fill the dialog, pin header, keep input above the keyboard */
  .octio-chat {
    height: 100%;
    min-height: 0;
    max-height: none;
    flex: 1;
  }
  .octio-chat-header {
    padding: 18px 60px 14px 20px;     /* right padding leaves room for × button */
    position: sticky;
    top: 0;
    background: var(--octio-slab);
    z-index: 2;
  }
  .octio-chat-title { font-size: 16px; line-height: 1.3; }
  .octio-chat-sub { font-size: 10px; margin-top: 3px; }
  .octio-chat-messages { padding: 16px 20px; }
  .octio-msg { font-size: 15px; max-width: 88%; }
  .octio-chat-form {
    padding: 12px 16px max(14px, env(safe-area-inset-bottom, 12px));
    gap: 10px;
  }
  .octio-chat-input {
    font-size: 16px;                  /* ≥16px stops iOS auto-zooming on focus */
    min-height: 40px;
  }
  .octio-chat-send { width: 40px; height: 40px; }

  /* Voice mobile: same fill-the-dialog pattern */
  .octio-voice {
    padding: 64px 24px 32px;
    min-height: 0;
    flex: 1;
    justify-content: flex-start;
    gap: 20px;
  }
  .octio-voice-orb { width: 140px; height: 140px; }
  .octio-voice-title { font-size: 22px; }
  .octio-voice-help { font-size: 14px; }
}

/* ─── Chat thread ──────────────────────────────────────────────────────── */
.octio-chat {
  display: flex;
  flex-direction: column;
  height: 70vh;
  min-height: 480px;
  max-height: calc(100vh - 64px);
}
.octio-chat-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--octio-rule);
}
.octio-chat-title {
  font-family: var(--octio-font-display);
  font-size: 18px;
  font-weight: 500;
  margin: 0;
  color: var(--octio-ink);
}
.octio-chat-sub {
  font-family: var(--octio-font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--octio-muted);
  margin: 4px 0 0;
}
.octio-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}
.octio-msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.octio-msg.is-user {
  align-self: flex-end;
  background: var(--octio-ink);
  color: #f4efe7;
  border-bottom-right-radius: 4px;
}
.octio-msg.is-agent {
  align-self: flex-start;
  background: var(--octio-cream);
  color: var(--octio-ink);
  border-bottom-left-radius: 4px;
}
.octio-msg.is-typing {
  background: var(--octio-cream);
  color: var(--octio-muted);
}
.octio-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px 18px 18px;
  border-top: 1px solid var(--octio-rule);
}
.octio-chat-input {
  padding: 12px 14px;
  background: #fbfaf7;
  border: 1px solid var(--octio-rule);
  border-radius: 8px;
  font-family: var(--octio-font-body);
  font-size: 15px;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  outline: none;
  color: var(--octio-ink);
}
.octio-chat-input:focus { border-color: var(--octio-orange); }
.octio-chat-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--octio-orange);
  color: #fff;
  border: none;
  cursor: pointer;
  align-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.octio-chat-send:hover { background: var(--octio-orange-glow); }
.octio-chat-send[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ─── Voice ───────────────────────────────────────────────────────────── */
.octio-voice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 80px 32px 48px;
  min-height: 540px;
  text-align: center;
}
.octio-voice-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--octio-cream);
  font-family: var(--octio-font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--octio-ink-soft);
}
.octio-voice-pill .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--octio-orange);
  animation: octioVoicePulse 1.4s ease-in-out infinite;
}
@keyframes octioVoicePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
@media (prefers-reduced-motion: reduce) {
  .octio-voice-pill .dot { animation: none; }
}
.octio-voice-orb {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #ffb877 0%, #f0902e 28%, #b85a2e 60%, #6a3a0f 100%);
  box-shadow:
    inset -8px -16px 32px rgba(0, 0, 0, 0.45),
    inset 8px 8px 24px rgba(255, 220, 180, 0.25),
    0 24px 64px -12px rgba(184, 90, 46, 0.5);
  transition: transform .4s ease, box-shadow .4s ease;
}
.octio-voice-orb.is-speaking {
  transform: scale(1.06);
  box-shadow:
    inset -8px -16px 32px rgba(0, 0, 0, 0.45),
    inset 8px 8px 24px rgba(255, 220, 180, 0.4),
    0 32px 80px -12px rgba(184, 90, 46, 0.65);
}
.octio-voice-orb.is-listening {
  animation: octioVoiceListening 2s ease-in-out infinite;
}
@keyframes octioVoiceListening {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.octio-voice-title {
  font-family: var(--octio-font-display);
  font-size: 28px;
  font-weight: 400;
  margin: 0;
  color: var(--octio-ink);
}
.octio-voice-help {
  font-size: 15px;
  color: var(--octio-muted);
  max-width: 440px;
  margin: 0;
}
.octio-voice-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.octio-voice-btn {
  padding: 12px 22px;
  background: var(--octio-orange);
  color: #fff;
  border: 1px solid var(--octio-orange);
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.octio-voice-btn.is-secondary {
  background: transparent;
  color: var(--octio-ink);
  border-color: var(--octio-rule);
}
.octio-voice-btn:hover { filter: brightness(1.05); }

/* F1 — Inline tool renderers (chat dialog) */
.octio-chat-tool { padding: 0; }
.octio-tool {
  padding: 12px 14px;
  background: var(--octio-slab, #fff);
  border: 1px solid var(--octio-rule);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 100%;
}
.octio-tool-q {
  font-family: var(--octio-font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--octio-ink);
}
.octio-tool-d {
  font-size: 13px;
  color: var(--octio-muted);
}
.octio-tool-empty {
  font-size: 13px;
  color: var(--octio-muted);
  font-style: italic;
}

/* Scheduler */
.octio-tool-scheduler-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}
.octio-tool-scheduler-day {
  display: flex; flex-direction: column; gap: 6px;
}
.octio-tool-scheduler-daylabel {
  font-size: 11px;
  color: var(--octio-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.octio-tool-slot {
  padding: 8px 10px;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  background: transparent;
  font-family: var(--octio-font-body);
  font-size: 13px;
  cursor: pointer;
  color: var(--octio-ink);
  text-align: center;
}
.octio-tool-slot:hover { background: var(--octio-cream-soft, rgba(0,0,0,0.04)); }

/* Choices + buttons */
.octio-tool-options {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.octio-tool-option-pill {
  padding: 8px 14px;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  background: transparent;
  font-family: var(--octio-font-body);
  font-size: 13px;
  cursor: pointer;
  color: var(--octio-ink);
}
.octio-tool-option-pill:hover { background: var(--octio-cream-soft, rgba(0,0,0,0.04)); }

/* Multi-select */
.octio-tool-checks { display: flex; flex-direction: column; gap: 6px; }
.octio-tool-check {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--octio-rule);
  border-radius: 8px;
  cursor: pointer;
}

/* Text input + form */
.octio-tool-input-row { display: flex; gap: 8px; }
.octio-tool-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--octio-rule);
  border-radius: 8px;
  font-family: var(--octio-font-body);
  font-size: 14px;
}
.octio-tool-submit {
  padding: 8px 16px;
  border: 1px solid var(--octio-orange);
  background: var(--octio-orange);
  color: #fff;
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 13px;
  cursor: pointer;
}
.octio-tool-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.octio-tool-form-body {
  display: flex; flex-direction: column; gap: 8px;
}
.octio-tool-form-label {
  font-size: 12px;
  color: var(--octio-muted);
}

/* File upload */
.octio-tool-fileinput {
  padding: 6px;
  border: 1px dashed var(--octio-rule);
  border-radius: 8px;
}
.octio-tool-skip {
  align-self: flex-start;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

/* Expand affordance + canvas overlay (F2) */
.octio-tool-expand {
  align-self: flex-start;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 12px;
  cursor: pointer;
  color: var(--octio-ink);
}
.octio-tool-expand:hover { background: var(--octio-cream-soft, rgba(0,0,0,0.04)); }

.octio-canvas {
  position: absolute;
  inset: 0;
  background: var(--octio-slab, #fff);
  z-index: 5;
  transform: translateY(16px);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.octio-canvas.is-open {
  opacity: 1;
  transform: translateY(0);
}
.octio-canvas-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  z-index: 6;
}
.octio-canvas-body {
  padding: 56px 24px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Diagram */
.octio-tool-mermaid {
  padding: 10px;
  background: var(--octio-cream-soft, rgba(0,0,0,0.04));
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
}
.octio-tool-diagram-img {
  max-width: 100%;
  border-radius: 8px;
}
.octio-tool-mermaid-svg {
  width: 100%;
  overflow-x: auto;
  padding: 8px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--octio-rule);
}
.octio-tool-mermaid-svg svg {
  max-width: 100%;
  height: auto;
}

/* F4 — Voice multimodal UI tool host (sits between voice content + actions) */
.octio-voice-ui-host {
  width: 100%;
  max-width: 520px;
  margin: 16px auto 0;
}
.octio-voice-ui-host:empty { display: none; }
.octio-voice-ui-host .octio-tool {
  /* Tighter padding inside voice modal — orb area is already vertical */
  padding: 12px;
}

/* ─── Popup header (P4.2) ──────────────────────────────────────────────────
 * Flex bar that owns History + Accent + Close. Replaces the broken
 * absolute-positioned kebab/close collision (was top:10/right:10 vs
 * top:18/right:18). Lives inside .cyma-dialog as its first child.
 */
.octio-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid var(--octio-rule);
  flex: 0 0 48px;
}
.octio-popup-header-center {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}
.octio-popup-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  color: var(--octio-ink);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.octio-popup-btn:hover { background: rgba(0,0,0,0.04); }
.octio-popup-btn:focus-visible { outline: 2px solid var(--octio-orange); outline-offset: 2px; }
.octio-popup-btn[hidden] { display: none; }
@media (max-width: 480px) {
  .octio-popup-btn { width: 40px; height: 40px; font-size: 18px; }
  .octio-popup-header { padding: 0 10px; }
}

/* A4 — Accent picker sub-panel + toast. The kebab itself is now an
 * .octio-popup-btn living in the header (above) — the absolute-positioned
 * .octio-voice-kebab rule was deleted to fix the collision with close. */
.octio-voice { position: relative; }

.octio-voice-accent-panel {
  position: absolute;
  top: 50px;
  right: 10px;
  width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--octio-slab, #fff);
  border: 1px solid var(--octio-rule);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
  padding: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.octio-voice-accent-panel[hidden] { display: none; }

.octio-voice-accent-title {
  font-family: var(--octio-font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--octio-ink);
}
.octio-voice-accent-sub {
  font-size: 12px;
  color: var(--octio-muted);
  margin-bottom: 4px;
}
.octio-voice-accent-card {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--octio-rule);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: var(--octio-font-body);
}
.octio-voice-accent-card:hover { background: rgba(0,0,0,0.03); }
.octio-voice-accent-card.is-selected {
  border-color: var(--octio-orange);
  background: rgba(255, 122, 41, 0.06);
}
.octio-voice-accent-flag {
  grid-row: 1 / span 2;
  font-size: 22px;
  line-height: 1;
}
.octio-voice-accent-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--octio-ink);
}
.octio-voice-accent-desc {
  font-size: 12px;
  color: var(--octio-muted);
}
.octio-voice-accent-close {
  align-self: flex-end;
  margin-top: 4px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 12px;
  cursor: pointer;
  color: var(--octio-ink);
}

.octio-voice-toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%) translateY(8px);
  background: var(--octio-ink);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 11;
}
.octio-voice-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── T13 — Identity phone-ask (shared chat + voice) ─────────────────────── */
.octio-phone-ask {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.octio-phone-ask-label {
  font-family: var(--octio-font-body);
  font-size: 14px;
  color: var(--octio-ink);
  margin: 0;
}
.octio-phone-ask-optional {
  font-family: var(--octio-font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--octio-muted);
}
.octio-phone-ask-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.octio-phone-ask-input {
  flex: 1;
  padding: 10px 12px;
  background: #fbfaf7;
  border: 1px solid var(--octio-rule);
  border-radius: 8px;
  font-family: var(--octio-font-body);
  font-size: 16px; /* ≥16px stops iOS auto-zooming on focus */
  color: var(--octio-ink);
  outline: none;
}
.octio-phone-ask-input:focus { border-color: var(--octio-orange); }
.octio-phone-ask-submit {
  padding: 10px 18px;
  background: var(--octio-orange);
  color: #fff;
  border: 1px solid var(--octio-orange);
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.octio-phone-ask-submit:hover { background: var(--octio-orange-glow); border-color: var(--octio-orange-glow); }
.octio-phone-ask-submit[disabled] { opacity: 0.5; cursor: not-allowed; }
.octio-phone-ask-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.octio-phone-ask-skip {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  font-family: var(--octio-font-body);
  font-size: 13px;
  color: var(--octio-ink);
  cursor: pointer;
}
.octio-phone-ask-skip:hover { background: var(--octio-cream-soft, rgba(0,0,0,0.04)); }

/* Voice identity host — sits below orb, above End-call. */
.octio-voice-identity-host {
  width: 100%;
  max-width: 420px;
  margin: 4px auto 0;
}
.octio-voice-identity-host:empty { display: none; }

/* ─── T15 — Accent action button (replaces the bare kebab) ───────────────── */
.octio-voice-accent-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 7px 14px;
  border: 1px solid var(--octio-rule);
  border-radius: 999px;
  background: transparent;
  color: var(--octio-ink);
  font-family: var(--octio-font-body);
  font-size: 13px;
  cursor: pointer;
}
.octio-voice-accent-btn:hover { background: rgba(0,0,0,0.04); }
.octio-voice-accent-btn:focus-visible { outline: 2px solid var(--octio-orange); outline-offset: 2px; }

/* ─── T16 — Prior conversation history (mode step) ───────────────────────── */
.octio-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.octio-history[hidden] { display: none; }
.octio-history-title {
  font-family: var(--octio-font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--octio-muted);
  margin: 0;
}
.octio-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.octio-history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--octio-rule);
  border-radius: 8px;
  font-family: var(--octio-font-body);
}
.octio-history-item-mode {
  font-family: var(--octio-font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--octio-orange);
}
.octio-history-item-summary {
  font-size: 13px;
  color: var(--octio-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.octio-history-item-when {
  font-size: 12px;
  color: var(--octio-muted);
  white-space: nowrap;
}

/* ─── Orb (P4.3) ─────────────────────────────────────────────────────────
 * Small SVG-replacement element used by the chat stage (P4.4). Two states
 * controlled by class swap: idle (gentle breathing) and is-thinking (pulse
 * + opacity wave). Same orb is reused for the "transcribing voice note"
 * upload state per the spec.
 */
.octio-orb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    var(--octio-cream) 0%,
    var(--octio-orange-glow) 60%,
    var(--octio-orange) 100%
  );
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.04),
    0 0 16px rgba(224, 122, 53, 0.25);
  margin: 24px auto 12px;
  flex: 0 0 44px;
  animation: octio-orb-idle 4s ease-in-out infinite;
}

.octio-orb.is-thinking {
  animation: octio-orb-thinking 1s ease-in-out infinite;
}

@keyframes octio-orb-idle {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

@keyframes octio-orb-thinking {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.10); opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
  .octio-orb,
  .octio-orb.is-thinking { animation: none; }
}

.octio-orb-caption {
  text-align: center;
  color: var(--octio-muted);
  font-family: var(--octio-font-mono, "SFMono-Regular", ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  min-height: 14px;
}

/* ─── Popup body + single-component stage (P4.4) ───────────────────────── */
.octio-popup-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  overflow-y: auto;
  min-height: 0;
}
.octio-popup-slot {
  flex: 1;
  min-height: 0;
}
.octio-tool-card-body {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
  color: var(--octio-ink);
  margin-bottom: 12px;
}
.octio-popup-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.octio-popup-input {
  flex: 1;
  border: 1px solid var(--octio-rule);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  font-size: 16px;
}
.octio-popup-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--octio-orange);
  color: var(--octio-cream);
  border: 0;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex: 0 0 40px;
}
.octio-popup-send:hover { background: var(--octio-orange-glow); }

/* ─── Mic button (P5.1) — sits between textarea and send ──────────────── */
.octio-popup-mic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--octio-rule);
  background: transparent;
  color: var(--octio-ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  position: relative;
  transition: background .15s ease;
}
.octio-popup-mic:hover { background: var(--octio-cream-soft); }
.octio-popup-mic.is-recording {
  background: #c1442b;
  color: #fff;
  border-color: #c1442b;
}
.octio-popup-mic.is-recording::after {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: octio-mic-pulse 1s ease-in-out infinite;
}
.octio-popup-mic.is-uploading {
  background: var(--octio-cream-soft);
  opacity: 0.6;
  cursor: wait;
}
@keyframes octio-mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@media (prefers-reduced-motion: reduce) {
  .octio-popup-mic.is-recording::after { animation: none; }
}

/* ─── History drawer (P4.6) ─────────────────────────────────────────────── */
.octio-history-drawer {
  position: absolute; top: 48px; right: 0; bottom: 0; width: 70%;
  background: var(--octio-slab);
  border-left: 1px solid var(--octio-rule);
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(.2, .7, .2, 1);
  z-index: 12;
  display: flex; flex-direction: column; overflow: hidden;
}
.octio-history-drawer.is-open { transform: translateX(0); }
.octio-history-drawer header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--octio-rule);
}
.octio-history-drawer h3 {
  font-family: var(--octio-font-display);
  font-size: 16px; margin: 0; color: var(--octio-ink);
}
.octio-history-drawer ul {
  list-style: none; margin: 0; padding: 8px 0;
  overflow-y: auto; flex: 1;
}
.octio-history-drawer li {
  padding: 12px 16px; cursor: pointer;
  color: var(--octio-ink); font-size: 14px;
  border-bottom: 1px solid var(--octio-rule);
  transition: background .15s ease;
}
.octio-history-drawer li:hover { background: var(--octio-cream-soft); }
.octio-history-drawer li em { font-style: normal; color: var(--octio-muted); font-size: 13px; }
@media (max-width: 480px) { .octio-history-drawer { width: 100%; } }

/* ─── Calendar overlay (P4.7) ─────────────────────────────────────────── */
.octio-cal {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px; width: 100%; max-width: 480px; margin: 0 auto;
}
.octio-cal-back {
  align-self: flex-start; background: transparent; border: 1px solid var(--octio-rule);
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
  font-family: var(--octio-font-mono); font-size: 12px;
  color: var(--octio-muted); letter-spacing: 0.04em;
}
.octio-cal-back:hover { color: var(--octio-ink); background: var(--octio-cream-soft); }
.octio-cal-header {
  display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; gap: 8px;
}
.octio-cal-nav {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--octio-rule); background: transparent;
  cursor: pointer; font-size: 14px; line-height: 1; color: var(--octio-ink);
}
.octio-cal-nav:hover:not([disabled]) { background: var(--octio-cream-soft); }
.octio-cal-nav[disabled] { opacity: 0.3; cursor: default; }
.octio-cal-month {
  text-align: center; font-family: var(--octio-font-display);
  font-size: 16px; font-weight: 500; color: var(--octio-ink);
}
.octio-cal-dayrow, .octio-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.octio-cal-dayhead {
  text-align: center; font-family: var(--octio-font-mono);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--octio-muted);
}
.octio-cal-day {
  position: relative; aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: 50%;
  color: var(--octio-ink); font-size: 14px; cursor: pointer; padding: 0;
}
.octio-cal-day.is-empty { visibility: hidden; }
.octio-cal-day.is-disabled { color: var(--octio-muted); opacity: 0.35; cursor: default; }
.octio-cal-day.has-slots:not([disabled]):hover { background: var(--octio-cream-soft); }
.octio-cal-day.is-selected {
  background: var(--octio-orange); color: #fff; border-color: var(--octio-orange);
}
.octio-cal-num { line-height: 1; }
.octio-cal-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--octio-orange); margin-top: 3px;
}
.octio-cal-day.is-selected .octio-cal-dot { background: #fff; }
.octio-cal-times-heading {
  font-family: var(--octio-font-mono); font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--octio-muted);
  border-top: 1px solid var(--octio-rule); padding-top: 12px;
}
.octio-cal-times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.octio-cal-hint {
  text-align: center; color: var(--octio-muted); font-size: 13px; padding: 16px 0;
}

/* === Cyma chat dialog === */
.cyma-backdrop {
  position: fixed; inset: 0;
  background: rgba(8,8,9,.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.cyma-backdrop.is-open { opacity: 1; pointer-events: auto; }
.cyma-dialog {
  /* The popup mounts here (appended to <body>), OUTSIDE .octio-agent — so the
     --octio-* palette defined on .octio-agent never reaches it. Re-declare the
     light palette here so var(--octio-*) resolves inside the dialog. */
  --octio-ink: #111111;
  --octio-ink-soft: #2a2a2a;
  --octio-muted: #6b6b6b;
  --octio-slab: #ffffff;
  --octio-cream: #e5d6c2;
  --octio-cream-soft: #efe2d1;
  --octio-orange: #b85a2e;
  --octio-orange-glow: #e07a35;
  --octio-rule: #ececec;
  --octio-radius: 6px;
  --octio-font-display: "Cabinet Grotesk", "General Sans", system-ui, sans-serif;
  --octio-font-body: "General Sans", "Inter", system-ui, sans-serif;
  --octio-font-mono: "SFMono-Regular", ui-monospace, Menlo, monospace;

  position: fixed;
  z-index: 100;
  top: 50%; left: 50%;
  width: min(640px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 64px));
  transform: translate(-50%, -45%) scale(.97);
  opacity: 0;
  pointer-events: none;
  background: #ffffff;
  color: var(--octio-ink);
  border: 1px solid var(--octio-rule);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 80px -20px rgba(0,0,0,.35);
  transition: opacity .35s cubic-bezier(.2,.7,.2,1), transform .35s cubic-bezier(.2,.7,.2,1);
  font-family: var(--octio-font-body);
}
/* Mobile: go full-bleed. The legacy rules at the top target .octio-dialog (the
   old overlay); the live element is .cyma-dialog, so it needs its own rule or it
   stays a floating 640×720 box that overflows small screens. dvh tracks the
   visual viewport so the keyboard shrinks the dialog instead of pushing the
   input off-screen. */
@media (max-width: 760px) {
  .cyma-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    top: 0; left: 0;
    transform: translateY(12px);
    border: none;
    border-radius: 0;
  }
  .cyma-dialog.is-open { transform: translateY(0); }
  html.octio-no-dvh .cyma-dialog {
    height: var(--chat-h, 100vh);
    max-height: var(--chat-h, 100vh);
  }
}
.cyma-dialog.is-open {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}
