/* ============================================================
   Amber · single-purpose Gemini Live voice assistant
   Public path: open → start talking → listen / respond → end
   Hidden classroom and instructor flows remain available.
   ============================================================ */

.aiw {
  position: fixed;
  right: clamp(14px, 2vw, 24px);
  bottom: clamp(14px, 2vw, 24px);
  z-index: 9999;
  color: var(--ink);
  font-family: var(--sans);
}

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

/* Floating entry: clear action first, product identity second. */
.aiw-bubble {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 180px;
  height: 60px;
  padding: 8px 17px 8px 9px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  background:
    radial-gradient(90% 160% at 8% 20%, rgba(55, 115, 255, .22), transparent 64%),
    rgba(13, 13, 15, .94);
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 18px 48px rgba(0, 0, 0, .54);
  backdrop-filter: blur(18px);
  transition: transform .22s var(--ease), border-color .22s var(--ease), box-shadow .22s var(--ease);
}

.aiw-bubble:hover {
  transform: translateY(-2px);
  border-color: rgba(111, 158, 255, .46);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 24px 58px rgba(0, 0, 0, .62);
}

.aiw-bubble:focus-visible,
.aiw-start:focus-visible,
.aiw-stop:focus-visible,
.aiw-close:focus-visible,
.aiw-claim-entry:focus-visible,
.aiw-gate-back:focus-visible,
.aiw-unlock:focus-visible,
.aiw-action:focus-visible {
  outline: 2px solid #78a2ff;
  outline-offset: 3px;
}

.aiw-bubble-orb {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 26%, #c7d8ff 0%, #6e9bff 18%, #2c6ef3 44%, #142e69 72%, #071126 100%);
  box-shadow: 0 0 22px rgba(51, 113, 255, .42), inset 0 1px 8px rgba(255, 255, 255, .3);
  animation: aiw-entry-breathe 2.8s ease-in-out infinite;
}

.aiw-bubble-orb i {
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(113, 158, 255, .25);
  border-radius: 50%;
  animation: aiw-entry-ring 2.8s ease-out infinite;
}

.aiw-bubble-orb i:nth-child(2) { animation-delay: 1.4s; }

.aiw-bubble-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
  text-align: left;
}

.aiw-bubble-title {
  font: 700 14px/1.1 var(--display);
  letter-spacing: -.01em;
  white-space: nowrap;
}

.aiw-bubble-subtitle {
  color: rgba(255, 255, 255, .54);
  font: 500 11px/1.2 var(--sans);
}

.aiw-bubble-dot {
  position: absolute;
  top: 7px;
  right: 10px;
  width: 7px;
  height: 7px;
  border: 2px solid #111114;
  border-radius: 50%;
  background: #39d98a;
  box-shadow: 0 0 10px rgba(57, 217, 138, .7);
}

@keyframes aiw-entry-breathe {
  0%, 100% { transform: scale(.96); }
  50% { transform: scale(1.035); }
}

@keyframes aiw-entry-ring {
  0% { opacity: .65; transform: scale(.9); }
  75%, 100% { opacity: 0; transform: scale(1.22); }
}

/* Panel */
.aiw-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  width: min(calc(100vw - 28px), 400px);
  height: min(610px, calc(100dvh - 104px));
  overflow: hidden;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 24px;
  background: #09090b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 32px 100px rgba(0, 0, 0, .72);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(.965);
  transform-origin: bottom right;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}

.aiw[data-state="open"] .aiw-panel,
.aiw[data-state="connecting"] .aiw-panel,
.aiw[data-state="live"] .aiw-panel,
.aiw[data-state="ended"] .aiw-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.aiw[data-state="idle"] .aiw-bubble { display: flex; }
.aiw:not([data-state="idle"]) .aiw-bubble { display: none; }

.aiw-head {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 9px;
  padding: 13px 15px 13px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .075);
  background: rgba(12, 12, 14, .94);
}

.aiw-title {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 8px;
  color: #f5f7fb;
  font: 700 14px/1.2 var(--display);
}

.aiw-live {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #5c6370;
}

.aiw[data-state="open"] .aiw-live { background: #78a2ff; box-shadow: 0 0 10px rgba(120, 162, 255, .56); }
.aiw[data-state="connecting"] .aiw-live { background: #f2b84b; animation: aiw-blink 1s ease-in-out infinite; }
.aiw[data-state="live"] .aiw-live { background: #39d98a; box-shadow: 0 0 11px rgba(57, 217, 138, .72); }
.aiw[data-state="ended"] .aiw-live { background: #7e8797; }

@keyframes aiw-blink { 50% { opacity: .28; } }

.aiw-timer {
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 999px;
  color: rgba(255, 255, 255, .58);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.aiw-close {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: rgba(255, 255, 255, .56);
  cursor: pointer;
  font: 400 22px/1 var(--sans);
}

.aiw-close:hover { background: rgba(255, 255, 255, .06); color: #fff; }

/* Main voice stage */
.aiw-stage {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  background: #06070a;
}

.aiw-stage::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, .016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .016) 1px, transparent 1px);
  background-size: 32px 32px;
  content: "";
  mask-image: linear-gradient(to bottom, #000 10%, transparent 88%);
  pointer-events: none;
}

.aiw-overlay,
.aiw-live-active {
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 26px 28px 22px;
  text-align: center;
}

.aiw-overlay {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 28%, rgba(44, 111, 247, .18), transparent 31%),
    radial-gradient(circle at 50% 74%, rgba(45, 83, 170, .08), transparent 36%);
}

.aiw[data-state="live"] .aiw-overlay { display: none; }

.aiw-preview-orb,
.aiw-orb {
  position: relative;
  display: block;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 26%, #d6e2ff 0%, #8eb0ff 15%, #3979ff 36%, #193d8c 67%, #081127 100%);
  box-shadow: 0 0 52px rgba(49, 111, 255, .34), inset 0 1px 14px rgba(255, 255, 255, .32);
}

.aiw-preview-orb {
  width: 112px;
  height: 112px;
  margin-bottom: 25px;
  animation: aiw-orb-float 3.2s ease-in-out infinite;
}

.aiw-preview-orb i,
.aiw-orb i {
  position: absolute;
  inset: -12px;
  border: 1px solid rgba(124, 166, 255, .25);
  border-radius: 50%;
  animation: aiw-orb-ring 3s ease-out infinite;
}

.aiw-preview-orb i:nth-child(2),
.aiw-orb i:nth-child(2) { animation-delay: 1s; }
.aiw-preview-orb i:nth-child(3),
.aiw-orb i:nth-child(3) { animation-delay: 2s; }

.aiw[data-state="connecting"] .aiw-preview-orb { animation-duration: 1.2s; }

@keyframes aiw-orb-float {
  0%, 100% { transform: translateY(2px) scale(.97); }
  50% { transform: translateY(-3px) scale(1.025); }
}

@keyframes aiw-orb-ring {
  0% { opacity: .62; transform: scale(.86); }
  78%, 100% { opacity: 0; transform: scale(1.42); }
}

.aiw-intro { transition: opacity .2s ease, transform .2s ease; }

.aiw[data-state="connecting"] .aiw-intro {
  opacity: .38;
  transform: scale(.985);
}

.aiw-kicker {
  display: block;
  margin-bottom: 9px;
  color: #7fa5ff;
  font: 700 10px/1.2 var(--sans);
  letter-spacing: .17em;
}

.aiw-intro h2 {
  margin: 0;
  color: #f7f8fb;
  font: 700 clamp(24px, 7vw, 30px)/1.16 var(--display);
  letter-spacing: -.035em;
  text-wrap: balance;
}

.aiw-intro p {
  max-width: 290px;
  margin: 12px auto 0;
  color: rgba(255, 255, 255, .57);
  font: 400 14px/1.6 var(--sans);
  line-break: strict;
  text-wrap: pretty;
  word-break: auto-phrase;
}

.aiw-keep { white-space: nowrap; }

.aiw-status {
  min-height: 21px;
  margin: 22px 0 11px;
  color: rgba(255, 255, 255, .68);
  font: 500 13px/1.5 var(--sans);
  line-break: strict;
  text-wrap: pretty;
  word-break: auto-phrase;
}

.aiw-start {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 22px;
  border: 1px solid rgba(255, 255, 255, .96);
  border-radius: 999px;
  background: #f6f7f9;
  color: #090a0c;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .32);
  font: 700 14px/1 var(--display);
  white-space: nowrap;
  transition: transform .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}

.aiw-start:hover {
  background: #fff;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .42);
  transform: translateY(-1px);
}

.aiw-start:disabled { opacity: .55; cursor: default; transform: none; }

.aiw-start-icon {
  position: relative;
  display: block;
  width: 12px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 8px;
}

.aiw-start-icon::before {
  position: absolute;
  right: -5px;
  bottom: -6px;
  left: -5px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-radius: 0 0 8px 8px;
  content: "";
}

.aiw-start-icon::after {
  position: absolute;
  bottom: -10px;
  left: 50%;
  width: 8px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  content: "";
  transform: translateX(-50%);
}

.aiw-privacy {
  margin: 15px 0 0;
  color: rgba(255, 255, 255, .34);
  font: 400 11px/1.4 var(--sans);
}

.aiw-spin {
  position: absolute;
  top: 38px;
  left: 50%;
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, .12);
  border-top-color: #7fa5ff;
  border-radius: 50%;
  animation: aiw-rotate .8s linear infinite;
  transform: translateX(-50%);
}

@keyframes aiw-rotate { to { transform: translateX(-50%) rotate(360deg); } }

/* Active conversation */
.aiw-live-active {
  display: none;
  flex-direction: column;
  gap: 9px;
  background:
    radial-gradient(circle at 50% 42%, rgba(46, 111, 255, .22), transparent 31%),
    radial-gradient(circle at 50% 80%, rgba(34, 75, 157, .1), transparent 38%);
}

.aiw[data-state="live"] .aiw-live-active { display: flex; }

.aiw-orb {
  width: 126px;
  height: 126px;
  margin-bottom: 25px;
  animation: aiw-orb-float 2.6s ease-in-out infinite;
}

.aiw[data-live-activity="speaking"] .aiw-orb {
  animation-duration: .72s;
  box-shadow: 0 0 68px rgba(64, 124, 255, .55), inset 0 1px 16px rgba(255, 255, 255, .36);
}

.aiw-live-state {
  color: #f7f8fb;
  font: 700 21px/1.2 var(--display);
  letter-spacing: -.02em;
}

.aiw-live-hint {
  max-width: 250px;
  color: rgba(255, 255, 255, .5);
  font: 400 12px/1.55 var(--sans);
  line-break: strict;
  text-wrap: pretty;
  word-break: auto-phrase;
}

.aiw-stop {
  margin-top: 24px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 999px;
  background: rgba(255, 255, 255, .045);
  color: rgba(255, 255, 255, .66);
  cursor: pointer;
  font: 600 12px/1 var(--sans);
}

.aiw-stop:hover { border-color: rgba(255, 255, 255, .25); color: #fff; }

.aiw-caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 1.4em;
  margin: 0;
  padding: 22px 18px 13px;
  background: linear-gradient(to top, rgba(0, 0, 0, .8), transparent);
  color: #fff;
  font: 400 13px/1.45 var(--sans);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease);
}

.aiw[data-state="live"] .aiw-caption.show { opacity: 1; }

/* Secondary layer */
.aiw-foot {
  margin: 0;
  padding: 10px 16px 7px;
  color: rgba(255, 255, 255, .32);
  font: 500 10px/1.3 var(--sans);
  text-align: center;
}

.aiw-classroom-entry {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 3px 14px 12px;
  color: rgba(255, 255, 255, .34);
  font-size: 10px;
}

.aiw-claim-entry {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: rgba(151, 181, 245, .74);
  cursor: pointer;
  font: 600 10px/1.3 var(--sans);
}

.aiw-claim-entry:hover { color: #c9d9ff; }

/* Hidden classroom / instructor text surfaces */
.aiw-chat,
.aiw-controls { display: none; }

.aiw[data-flow="instructor"][data-access="granted"] .aiw-stage,
.aiw[data-flow="classroom"][data-access="granted"] .aiw-stage,
.aiw[data-flow="instructor"] .aiw-classroom-entry,
.aiw[data-flow="classroom"] .aiw-classroom-entry,
.aiw[data-flow="instructor"] .aiw-foot,
.aiw[data-flow="classroom"] .aiw-foot { display: none; }

.aiw[data-flow="instructor"][data-access="granted"] .aiw-chat,
.aiw[data-flow="classroom"][data-access="granted"] .aiw-chat {
  display: flex;
  min-height: 0;
  flex: 1;
}

.aiw[data-flow="instructor"][data-access="granted"] .aiw-controls { display: flex; }

.aiw-chat {
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px 14px 8px;
}

.aiw-msg { display: flex; align-items: flex-end; gap: 6px; }
.aiw-msg-me { justify-content: flex-end; }

.aiw-msg-b {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 14px;
  font: 400 14px/1.55 var(--sans);
  line-break: strict;
  text-wrap: pretty;
  white-space: pre-wrap;
  word-break: auto-phrase;
}

.aiw-msg-bot .aiw-msg-b { border-bottom-left-radius: 5px; background: #17171a; color: var(--ink); }
.aiw-msg-me .aiw-msg-b { border-bottom-right-radius: 5px; background: #286fff; color: #fff; }

.aiw-play { padding: 2px; border: 0; background: transparent; cursor: pointer; font-size: 14px; opacity: .55; }
.aiw-play:hover { opacity: 1; }

.aiw-typing { display: inline-flex; align-items: center; gap: 4px; }
.aiw-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: aiw-typing 1s var(--ease) infinite; }
.aiw-typing i:nth-child(2) { animation-delay: .15s; }
.aiw-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes aiw-typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.aiw-controls {
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, .075);
}

.aiw-input {
  min-width: 0;
  height: 42px;
  flex: 1;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px;
  outline: none;
  background: #111113;
  color: #fff;
  font: 400 14px/1 var(--sans);
}

.aiw-input:focus { border-color: rgba(84, 141, 255, .66); box-shadow: 0 0 0 3px rgba(41, 102, 236, .12); }
.aiw-input::placeholder { color: var(--dim); }

.aiw-send {
  height: 42px;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px;
  background: #17171a;
  color: #fff;
  cursor: pointer;
  font: 600 13px/1 var(--sans);
}

.aiw-actions { display: grid; gap: 7px; margin: 2px 0 6px; }

.aiw-action {
  width: fit-content;
  max-width: 92%;
  padding: 9px 12px;
  border: 1px solid rgba(84, 141, 255, .42);
  border-radius: 10px;
  background: rgba(40, 111, 255, .09);
  color: #dce8ff;
  cursor: pointer;
  font: 600 13px/1.4 var(--sans);
  text-align: left;
}

.aiw-action:hover { border-color: #6192f7; background: rgba(40, 111, 255, .16); }
.aiw-action:disabled { opacity: .45; cursor: default; }

.aiw-role-tag {
  margin-left: 3px;
  padding: 3px 7px;
  border: 1px solid rgba(84, 141, 255, .35);
  border-radius: 999px;
  color: #91b2f8;
  font-size: 10px;
}

/* Classroom passcode gate */
.aiw-gate {
  display: none;
  min-height: 0;
  flex: 1;
  padding: 58px 28px 30px;
  background: radial-gradient(circle at 50% 15%, rgba(40, 111, 255, .18), transparent 34%), #0a0a0b;
}

.aiw[data-access="locked"] .aiw-gate { display: block; }
.aiw[data-access="locked"] .aiw-classroom-entry,
.aiw[data-access="locked"] .aiw-stage,
.aiw[data-access="locked"] .aiw-chat,
.aiw[data-access="locked"] .aiw-controls,
.aiw[data-access="locked"] .aiw-foot { display: none; }

.aiw-gate-kicker {
  margin: 0 0 12px;
  color: #75a2ff;
  font: 700 12px/1.2 var(--sans);
  letter-spacing: .08em;
}

.aiw-gate-title {
  margin: 0;
  color: var(--ink);
  font: 700 27px/1.2 var(--display);
  text-wrap: balance;
}

.aiw-gate-copy {
  margin: 12px 0 28px;
  color: var(--body);
  font: 400 14px/1.55 var(--sans);
  line-break: strict;
  text-wrap: pretty;
  word-break: auto-phrase;
}

.aiw-gate-form { display: flex; gap: 8px; }

.aiw-passcode {
  min-width: 0;
  flex: 1;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  outline: none;
  background: #111113;
  color: #fff;
  font: 700 19px/1 var(--sans);
  letter-spacing: .18em;
  text-align: center;
}

.aiw-passcode:focus { border-color: #4f86f7; box-shadow: 0 0 0 3px rgba(40, 111, 255, .13); }
.aiw-passcode.is-wrong { border-color: #e35d6a; animation: aiw-shake .28s ease; }
@keyframes aiw-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.aiw-unlock {
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: #286fff;
  color: #fff;
  cursor: pointer;
  font: 700 14px/1 var(--sans);
}

.aiw-unlock:hover { background: #3d7dff; }
.aiw-gate-msg { min-height: 21px; margin: 12px 0 0; color: #ef8791; font-size: 13px; }

.aiw-gate-back {
  display: block;
  margin: 18px auto 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  font: 500 12px/1.4 var(--sans);
}

.aiw-gate-back:hover { color: var(--ink); }
.aiw[data-flow="instructor"] .aiw-gate-back { display: none; }

.instructor-toast {
  position: fixed;
  top: 76px;
  left: 50%;
  z-index: 10000;
  margin: 0;
  padding: 10px 15px;
  border: 1px solid rgba(97, 146, 247, .5);
  border-radius: 999px;
  background: rgba(9, 9, 11, .94);
  color: #e8efff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .45);
  font: 600 13px/1.2 var(--sans);
  transform: translateX(-50%);
}

@media (max-width: 480px) {
  .aiw { right: 8px; bottom: 8px; }
  .aiw-bubble { width: 170px; height: 56px; padding-right: 15px; }
  .aiw-bubble-orb { width: 39px; height: 39px; }
  .aiw-panel {
    bottom: 66px;
    width: calc(100vw - 16px);
    height: min(620px, calc(100dvh - 82px));
    border-radius: 21px;
  }
  .aiw-overlay,
  .aiw-live-active { padding-right: 21px; padding-left: 21px; }
  .aiw-preview-orb { width: 102px; height: 102px; margin-bottom: 22px; }
  .aiw-orb { width: 116px; height: 116px; }
  .aiw-intro h2 { font-size: 26px; }
  .aiw-gate { padding: 48px 20px 24px; }
  .aiw-gate-title { font-size: 24px; }
}

@media (max-height: 660px) {
  .aiw-panel { height: calc(100dvh - 82px); }
  .aiw-preview-orb { width: 86px; height: 86px; margin-bottom: 15px; }
  .aiw-intro h2 { font-size: 24px; }
  .aiw-intro p { margin-top: 8px; }
  .aiw-status { margin-top: 14px; }
  .aiw-privacy { margin-top: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .aiw *,
  .aiw *::before,
  .aiw *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
