    :root {
      color-scheme: dark;
      --ink: #edf7ff;
      --muted: #9cb2c5;
      --panel: rgba(10, 25, 43, 0.78);
      --line: rgba(167, 216, 255, 0.15);
      --cyan: #67e8f9;
      --blue: #60a5fa;
      --violet: #a78bfa;
      --skin: #c8efff;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      min-height: 100svh;
      display: grid;
      place-items: center;
      overflow-x: hidden;
      padding: 28px 18px;
      color: var(--ink);
      background:
        radial-gradient(circle at 20% 12%, rgba(37, 99, 235, .24), transparent 32rem),
        radial-gradient(circle at 85% 80%, rgba(124, 58, 237, .2), transparent 28rem),
        linear-gradient(145deg, #050b14 0%, #071426 55%, #09101f 100%);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    }

    body::before {
      content: "";
      position: fixed;
      inset: 0;
      pointer-events: none;
      opacity: .22;
      background-image:
        linear-gradient(rgba(103, 232, 249, .08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(103, 232, 249, .08) 1px, transparent 1px);
      background-size: 42px 42px;
      mask-image: radial-gradient(circle, black, transparent 78%);
    }

    .app {
      position: relative;
      width: min(100%, 720px);
      padding: clamp(24px, 5vw, 44px);
      padding-top: 104px;
      text-align: center;
      border: 1px solid var(--line);
      border-radius: 30px;
      background: var(--panel);
      box-shadow: 0 30px 80px rgba(0, 0, 0, .42), inset 0 1px rgba(255, 255, 255, .05);
      backdrop-filter: blur(22px);
    }

    .app-logo {
      position: absolute;
      top: 18px;
      left: 18px;
      display: block;
      width: 64px;
      height: auto;
      mix-blend-mode: screen;
      filter: contrast(1.08) brightness(.94);
    }


    .logout-power {
      position: absolute;
      top: 18px;
      left: 50%;
      transform: translateX(-50%);
      display: grid;
      place-items: center;
      width: 64px;
      height: 64px;
      padding: 12px;
      border: 5px solid #00dced;
      border-radius: 50%;
      color: #00dced;
      background: radial-gradient(circle, #06232b 35%, #001015 75%);
      box-shadow: 0 0 18px #00dced80, inset 0 0 12px #00dced70;
      cursor: pointer;
    }
    .logout-power:hover {
      transform: translateX(-50%);
      border-color: #78f5ff;
      box-shadow: 0 0 26px #00dcedb0, inset 0 0 16px #00dced80;
    }
    .logout-power:active { transform: translateX(-50%) scale(.96); }
    .logout-power svg { width: 100%; height: 100%; }

    .eyebrow {
      margin: 0 0 6px;
      color: var(--cyan);
      font-size: .74rem;
      font-weight: 800;
      letter-spacing: .18em;
      text-transform: uppercase;
    }

    .profile-link {
      display: inline-block;
      margin-top: 20px;
      padding: 7px 12px;
      color: var(--muted);
      border: 1px solid var(--line);
      border-radius: 999px;
      font-size: .78rem;
      text-decoration: none;
    }
    .profile-link:hover { color: var(--ink); border-color: var(--cyan); }

    h1 { margin: 0; font-size: clamp(1.2rem, 3.6vw, 1.7rem); letter-spacing: -.03em; }

    .subtitle { margin: 7px 0 26px; color: var(--muted); font-size: .96rem; }

    .avatar-stage {
      position: relative;
      display: grid;
      place-items: center;
      width: min(100%, 410px);
      height: 330px;
      margin: 0 auto 12px;
      isolation: isolate;
    }

    .halo,
    .halo::before,
    .halo::after {
      position: absolute;
      border-radius: 50%;
      border: 1px solid rgba(103, 232, 249, .2);
      content: "";
    }

    .halo { width: 292px; height: 292px; animation: none; }
    .halo::before { inset: 18px; border-style: dashed; border-color: rgba(167, 139, 250, .25); }
    .halo::after { inset: -10px; border-width: 2px 0 0; filter: drop-shadow(0 0 8px var(--cyan)); }

    .avatar {
      position: relative;
      width: 218px;
      height: 256px;
      border: 1px solid rgba(212, 244, 255, .42);
      border-radius: 47% 47% 44% 44% / 39% 39% 52% 52%;
      background:
        radial-gradient(circle at 50% 35%, rgba(255,255,255,.18), transparent 42%),
        linear-gradient(145deg, #8bd8f0 0%, #5b99cb 55%, #426caa 100%);
      box-shadow: inset 12px 8px 28px rgba(255,255,255,.18), inset -18px -12px 36px rgba(25,46,95,.3), 0 0 55px rgba(96,165,250,.25);
      z-index: 2;
      animation: float 4s ease-in-out infinite, glow 2.6s ease-in-out infinite;
    }

    .avatar::before {
      content: "";
      position: absolute;
      inset: 13px;
      border: 1px solid rgba(255,255,255,.12);
      border-radius: inherit;
    }

    .temple {
      position: absolute;
      top: 102px;
      width: 17px;
      height: 46px;
      border: 1px solid rgba(103,232,249,.5);
      background: #183c68;
      box-shadow: 0 0 14px rgba(103,232,249,.34);
    }
    .temple.left { left: -12px; border-radius: 12px 3px 3px 12px; }
    .temple.right { right: -12px; border-radius: 3px 12px 12px 3px; }

    .brow {
      position: absolute;
      top: 84px;
      width: 49px;
      height: 9px;
      border-top: 3px solid rgba(10,34,64,.55);
      border-radius: 50%;
    }
    .brow.left { left: 38px; transform: rotate(-3deg); }
    .brow.right { right: 38px; transform: rotate(3deg); }

    .eye {
      position: absolute;
      top: 99px;
      width: 47px;
      height: 25px;
      overflow: hidden;
      border-radius: 50%;
      background: #e9fbff;
      box-shadow: 0 0 18px rgba(103,232,249,.45);
      animation: blink 7s infinite;
    }
    .eye.left { left: 40px; }
    .eye.right { right: 40px; }

    .iris {
      position: absolute;
      inset: 4px auto auto 15px;
      width: 18px;
      height: 18px;
      border: 5px solid #173c67;
      border-radius: 50%;
      background: var(--cyan);
      box-shadow: 0 0 8px var(--cyan);
    }

    .nose {
      position: absolute;
      top: 124px;
      left: 50%;
      width: 25px;
      height: 42px;
      translate: -50%;
      border: solid rgba(24,60,104,.25);
      border-width: 0 0 2px 2px;
      border-radius: 0 0 0 14px;
      transform: skew(-6deg);
    }

    .mouth-wrap {
      position: absolute;
      top: 183px;
      left: 50%;
      display: grid;
      place-items: center;
      width: 80px;
      height: 48px;
      translate: -50%;
    }

    .mouth {
      width: 58px;
      height: 9px;
      overflow: hidden;
      border: 2px solid rgba(216,251,255,.65);
      border-radius: 50%;
      background: #11213b;
      box-shadow: 0 0 10px rgba(103,232,249,.2);
      transition: width 140ms ease-out, height 140ms ease-out;
    }

    .mouth::after {
      content: "";
      display: block;
      width: 80%;
      height: 8px;
      margin: 15px auto 0;
      border-radius: 50%;
      background: #f38aa6;
    }

    .chest {
      position: absolute;
      bottom: 3px;
      width: 286px;
      height: 102px;
      z-index: 1;
      border: 1px solid rgba(96,165,250,.3);
      border-radius: 52% 52% 22px 22px;
      background: linear-gradient(145deg, #173e69, #0a1c34 70%);
      box-shadow: 0 20px 42px rgba(0,0,0,.28);
    }

    .chest::after {
      content: "N";
      position: absolute;
      left: 50%;
      top: 40px;
      display: grid;
      place-items: center;
      width: 30px;
      height: 30px;
      translate: -50%;
      color: var(--cyan);
      font-size: 12px;
      font-weight: 900;
      border: 1px solid rgba(103,232,249,.55);
      border-radius: 9px;
      box-shadow: 0 0 18px rgba(103,232,249,.22);
    }

    .avatar.speaking { animation: none; }
    .avatar.speaking + .chest::after { animation: pulse 1s ease-in-out infinite; }

    .photo-avatar {
      width: 292px;
      height: 292px;
      overflow: hidden;
      border-radius: 50%;
      background:
        radial-gradient(circle at 50% 42%, rgba(255,255,255,.18), transparent 42%),
        #eaf4f8;
      box-shadow:
        0 0 0 7px rgba(103,232,249,.1),
        0 0 0 1px rgba(190,239,255,.55),
        0 0 55px rgba(96,165,250,.3);
    }

    .photo-avatar::before {
      z-index: 3;
      inset: 0;
      pointer-events: none;
      border: 2px solid rgba(190, 239, 255, .58);
      box-shadow: inset 0 0 32px rgba(7, 20, 38, .12);
    }

    .photo-avatar img,
    .photo-avatar video {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: 50% 50%;
      filter: contrast(1.03) saturate(.96);
    }

    .photo-avatar video {
      background: #071426;
      transform: translateZ(0);
    }

    .photo-avatar.video-fallback {
      background:
        radial-gradient(circle at 50% 42%, rgba(255,255,255,.14), transparent 48%),
        url("profjoe-transparent.png") center / cover no-repeat,
        #071426;
    }

    .photo-avatar.video-fallback video { display: none; }
    .video-avatar.video-fallback .photo-mouth { display: block; }

    .talkinghead-stage {
      position: absolute;
      inset: 0;
      z-index: 5;
      display: none;
      overflow: hidden;
      background: #071426;
    }

    .talkinghead-stage.active { display: block; }

    .talkinghead-stage canvas {
      display: block;
      width: 100%;
      height: 100%;
    }

    .liveavatar-frame {
      position: absolute;
      inset: 0;
      z-index: 7;
      display: none;
      width: 100%;
      height: 100%;
      border: 0;
      background: #071426;
    }

    .liveavatar-frame.active { display: block; }

    .video-avatar .photo-mouth { display: none; }

    .photo-mouth {
      position: absolute;
      z-index: 4;
      top: 45%;
      left: 50%;
      width: 36px;
      height: 4px;
      translate: -50% -50%;
      opacity: 0;
      border-radius: 50%;
      background: rgba(62, 28, 25, .9);
      box-shadow: inset 0 -2px 2px rgba(234, 139, 139, .32);
      transition: width 140ms ease-out, height 140ms ease-out, opacity .2s ease;
    }

    .photo-avatar.speaking .photo-mouth { opacity: .82; }

    .photo-mouth .teeth,
    .photo-mouth .tongue {
      position: absolute;
      left: 50%;
      display: block;
      translate: -50%;
      pointer-events: none;
      transition: opacity 50ms linear;
    }

    .photo-mouth .teeth {
      top: 0;
      width: 82%;
      height: 27%;
      opacity: .72;
      border-radius: 0 0 50% 50%;
      background: #f6eee8;
    }

    .photo-mouth .tongue {
      bottom: -1px;
      width: 72%;
      height: 32%;
      opacity: .62;
      border-radius: 50% 50% 30% 30%;
      background: #b85e68;
    }

    .photo-mouth[data-viseme="closed"] { opacity: 0 !important; }
    .photo-mouth[data-viseme="o"] { border-radius: 50%; }
    .photo-mouth[data-viseme="o"] .teeth { opacity: .08; }
    .photo-mouth[data-viseme="o"] .tongue { opacity: .42; }
    .photo-mouth[data-viseme="e"] { border-radius: 45% 45% 38% 38%; }
    .photo-mouth[data-viseme="a"] { border-radius: 45% 45% 48% 48%; }

    .status {
      display: inline-flex;
      align-items: center;
      gap: 9px;
      min-height: 28px;
      margin: 3px 0 16px;
      color: var(--muted);
      font-size: .9rem;
    }

    .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #64748b;
      box-shadow: 0 0 0 4px rgba(100,116,139,.12);
    }
    .status.speaking .status-dot { background: var(--cyan); box-shadow: 0 0 0 4px rgba(103,232,249,.12), 0 0 14px var(--cyan); animation: pulse .9s infinite; }
    .status.error { color: #fda4af; }
    .status.error .status-dot { background: #fb7185; }

    .controls { display: none !important; }
    #playButton[hidden] { display: none !important; }

    button {
      min-height: 48px;
      padding: 0 22px;
      color: #05121f;
      font: inherit;
      font-weight: 800;
      border: 0;
      border-radius: 14px;
      background: linear-gradient(135deg, var(--cyan), var(--blue));
      box-shadow: 0 10px 24px rgba(37,99,235,.24);
      cursor: pointer;
      transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
    }
    button:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(37,99,235,.34); }
    button:active { transform: translateY(0); }
    button:focus-visible { outline: 3px solid rgba(103,232,249,.38); outline-offset: 4px; }
    button:disabled { cursor: wait; opacity: .65; transform: none; }

    .conversation {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      margin: 2px 0 13px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 18px;
      background: rgba(3, 13, 25, .48);
    }

    .question-input {
      min-width: 0;
      min-height: 48px;
      padding: 0 15px;
      color: var(--ink);
      font: inherit;
      border: 1px solid rgba(156, 178, 197, .25);
      border-radius: 13px;
      outline: none;
      background: rgba(5, 16, 30, .72);
      transition: border-color .18s ease, box-shadow .18s ease;
    }
    .question-input::placeholder { color: #74899c; }
    .question-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(103,232,249,.1); }

    .icon-button {
      display: inline-grid;
      place-items: center;
      width: 74px;
      height: 74px;
      padding: 0;
      font-size: 1.35rem;
      border-radius: 50%;
    }
    .icon-button svg { width: 28px; height: 28px; stroke-width: 2.4; }
    .icon-button.listening { color: white; background: linear-gradient(135deg, #fb7185, #e11d48); animation: pulse .85s infinite; }
    .send-button { padding-inline: 18px; }
    .oral-instruction { margin: 0; color: var(--muted); font-size: .88rem; }
    .champ-cache { display: none !important; }

    .hint { margin: 0 0 14px; color: #74899c; font-size: .78rem; }

    .answer {
      padding: 18px 20px;
      text-align: left;
      border: 1px solid var(--line);
      border-radius: 18px;
      background: rgba(3, 13, 25, .56);
    }

    .answer-label { margin: 0 0 8px; color: var(--cyan); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
    #textResponse { margin: 0; color: #dcebf7; font-size: 1rem; line-height: 1.65; white-space: pre-wrap; }

    @keyframes orbit { to { transform: rotate(360deg); } }
    @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
    @keyframes glow { 50% { box-shadow: inset 12px 8px 28px rgba(255,255,255,.2), inset -18px -12px 36px rgba(25,46,95,.3), 0 0 72px rgba(103,232,249,.5); } }
    @keyframes pulse { 50% { transform: scale(1.18); opacity: .68; } }
    @keyframes blink { 0%, 45%, 48%, 100% { transform: scaleY(1); } 46%, 47% { transform: scaleY(.08); } }

    @media (max-width: 520px) {
      body { padding: 0; }
      .app { min-height: 100svh; border: 0; border-radius: 0; padding: 88px 16px 24px; }
      .app-logo { top: 14px; left: 14px; width: 52px; }
      .avatar-stage { height: 310px; transform: scale(.91); margin: -8px auto -5px; }
      .answer { padding: 16px; }
      .icon-button { width: 72px; height: 72px; }
      .controls button { width: 100%; }
    }

    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
    }
