/* Sculpted Madness skull. Input, playback and backend state are independent. */
.madness-live[hidden], .madness-live [hidden] { display: none !important; }
.madness-live {
  --live-jaw: 0px;
  --live-level: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
  margin-top: 16px;
  color: #f5f1eb;
  background: radial-gradient(ellipse at 2% 50%, #3c261e 0%, transparent 48%), #191a1e;
  border: 1px solid #35343a;
  border-radius: 16px;
  box-shadow: 0 5px 16px #1711140d;
}
.live-skull { width: 78px; height: 78px; flex: 0 0 78px; }
.live-skull svg { width: 100%; height: 100%; overflow: visible; }
.live-skull-backplate { fill: url(#live-skull-backplate); }
.live-skull-ring { fill: none; stroke: url(#live-skull-rim); stroke-width: 1; }
.live-skull-inner-rim { fill: none; stroke: #867560; stroke-width: .4; opacity: .3; }
.live-skull-ticks { stroke: #b79c76; stroke-width: 1; opacity: .6; }
.live-skull-art { pointer-events: none; }
.live-skull-mouth-interior { fill: #12100e; }
.live-skull-eye, .live-skull-mouth-glow { fill: url(#live-skull-ember); opacity: 0; transition: opacity .16s ease; }
.live-copy { flex: 1; min-width: 0; }
.live-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 4px; }
.live-heading h2 { font-family: var(--font-display); font-size: 15px; font-weight: 400; line-height: 1.6; color: #f7f2ea; margin: 0; }
.live-heading h2 span { color: #ff9467; }
.live-ai-label { font-size: 10px; color: #c3b8ad; letter-spacing: .065em; text-transform: uppercase; border: 1px solid #4a4340; border-radius: 4px; padding: 1px 5px; }
.live-status { font-size: 14px; line-height: 1.4; color: #efe6de; margin: 0; }
.live-help { font-size: 12px; color: #b5aea7; line-height: 1.5; margin: 4px 0 0; }
.live-signals { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 5px; }
.live-signal { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: #b7b0a8; }
.live-signal i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #736d67; }
.live-signal[data-active="true"] { color: #e9ddce; }
#live-mic-signal[data-active="true"] i { background: #a6d490; box-shadow: 0 0 6px #a6d49066; }
#live-audio-signal[data-active="true"] i { background: #ff8e54; box-shadow: 0 0 6px #ff8e5488; }
.live-controls { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; justify-content: flex-end; max-width: 210px; }
.live-start, .live-control { font: 600 12px var(--font-body); border-radius: 8px; min-height: 42px; padding: 9px 12px; cursor: pointer; transition: background .15s; }
.live-start { color: #fff; background: #bd3d09; border: 1px solid #ed7540; white-space: nowrap; }
.live-start span { font-size: 15px; margin-left: 8px; }
.live-start:hover { background: #d34306; }
.live-control { color: #ece1d7; background: #302c2c; border: 1px solid #514640; }
.live-control:hover { background: #453932; }
.live-stop { color: #ffc6ad; }
.live-control[aria-pressed="true"] { background: #704229; border-color: #ce875e; }
.live-start:disabled, .live-control:disabled { opacity: .5; cursor: default; }
.madness-live button:focus-visible { outline: 2px solid #ffad83; outline-offset: 3px; }
.madness-live[data-state="listening"] .live-skull-eye { opacity: .12; }
.madness-live[data-speaking="true"] .live-skull-eye { opacity: calc(.48 + var(--live-level) * .46); }
.madness-live[data-speaking="true"] .live-skull-mouth-glow { opacity: calc(.35 + var(--live-level) * .6); }
.madness-live[data-state="working"] .live-skull-ring,
.madness-live[data-state="connecting"] .live-skull-ring { animation: live-ring-turn 9s linear infinite; transform-origin: 60px 60px; stroke: #ff9467; stroke-dasharray: 26 9 2 9; }
.madness-live[data-state="working"] .live-skull-eye { opacity: .22; }
.madness-live[data-state="error"] { border-color: #a86d53; }
.madness-live[data-state="error"] .live-status { color: #ffc6ad; }
.madness-live[data-state="muted"]:not([data-speaking="true"]) .live-skull-eye { opacity: .04; }
@keyframes live-ring-turn { to { transform: rotate(360deg); } }
.live-history[hidden], .live-history [hidden] { display: none !important; }
.live-history { flex: 0 0 auto; margin-top: 9px; border: 1px solid var(--border-color-light); background: white; border-radius: 10px; font-size: 13px; }
.live-history > summary { padding: 11px 14px; cursor: pointer; color: var(--text-secondary); font-weight: 500; min-height: 44px; }
.live-history > summary:focus-visible { outline: 2px solid var(--orange-500); outline-offset: 2px; border-radius: 8px; }
.live-history > summary span { color: var(--text-tertiary); font-weight: 400; margin-left: 6px; }
.live-history-body { padding: 0 14px 12px; }
.live-history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; }
.live-history-toolbar p { margin: 0; color: var(--text-tertiary); font-size: 12px; }
.live-history button { min-height: 36px; padding: 5px 10px; border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-secondary); background: var(--light-50); font: 500 12px var(--font-body); cursor: pointer; }
.live-history button:disabled { opacity: .6; cursor: default; }
.live-history-list { overflow-y: auto; max-height: 320px; overscroll-behavior: contain; }
.live-history-call + .live-history-call { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border-color-light); }
.live-history-call h3 { color: var(--text-secondary); font: 500 12px var(--font-body); margin: 0 0 8px; }
.live-history-call-status { display: inline-block; margin-left: 7px; color: var(--text-tertiary); font-weight: 400; }
.live-history-line { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; padding: 7px 0; line-height: 1.55; }
.live-history-line strong { font-size: 11px; font-weight: 600; padding-top: 2px; color: var(--text-secondary); }
.live-history-line p { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; color: var(--text-primary); }
.live-history-line[data-role="assistant"] strong { color: #a63d13; }
.live-history-more { margin-top: 10px; width: 100%; }
@media (max-width: 600px) {
  .madness-live { gap: 10px; padding: 12px; border-radius: 12px; flex-wrap: wrap; }
  .live-skull { width: 58px; height: 58px; flex-basis: 58px; }
  .live-heading h2 { font-size: 13px; }
  .live-status { font-size: 13px; }
  .live-help { font-size: 11px; }
  .live-controls { max-width: none; margin-left: auto; }
  .madness-live[data-active="true"] .live-controls { width: 100%; padding-top: 3px; border-top: 1px solid #38302c; }
  .madness-live[data-active="true"] .live-help { display: none; }
  .live-start, .live-control { min-height: 44px; }
  .live-history-line { grid-template-columns: 74px minmax(0, 1fr); }
  .live-history button { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .madness-live *, .madness-live *::before, .madness-live *::after { animation: none !important; transition: none !important; }
  .madness-live[data-speaking="true"] .live-skull-eye { opacity: .7; }
  .madness-live[data-speaking="true"] .live-skull-mouth-glow { opacity: .6; }
}

/* A reserved row above the fixed composer keeps the skull clear of chat text. */
.live-dock[hidden], .live-dock [hidden] { display: none !important; }
.live-dock { position: relative; display: flex; justify-content: flex-end; align-items: flex-end; gap: 8px; max-width: 900px; margin: 0 auto 8px; }
.live-dock-toggle { display: flex; align-items: center; gap: 6px; flex-shrink: 0; min-height: 48px; padding: 4px 10px 4px 4px; border: 1px solid #514640; border-radius: 24px; background: #191a1e; color: #d4ccc4; cursor: pointer; font: 600 12px var(--font-body); }
.live-dock-toggle img { object-fit: contain; }
.live-dock[data-state="live"] .live-dock-toggle { color: #b6e5a0; }
.live-dock[data-state="muted"] .live-dock-toggle { color: #ffca91; }
.live-dock-controls { padding: 10px; border: 1px solid #514640; border-radius: 12px; background: #191a1e; color: #f5f1eb; max-width: 310px; }
.live-dock-controls p { margin: 0 0 8px; font-size: 12px; line-height: 1.4; }
.live-dock .live-control { min-height: 44px; margin: 2px; }
.live-dock button:focus-visible { outline: 2px solid #ff9467; outline-offset: 3px; }
body:has(.live-dock:not([hidden])) .bottom-input-area {
  bottom: var(--live-keyboard-offset, 0px);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  padding-left: max(var(--space-6), env(safe-area-inset-left));
  padding-right: max(var(--space-6), env(safe-area-inset-right));
}
body:has(.live-dock:not([hidden])) .chat-container { margin-bottom: var(--live-composer-space, 190px); }
@media (max-width: 380px) {
  .live-dock { flex-wrap: wrap; }
  .live-dock-controls { width: 100%; max-width: none; }
}
