    /* --- Base/Reset --- */
    *,
    *::before,
    *::after {
      box-sizing: border-box
    }

    html,
    body {
      height: 100%
    }

    body {
      margin: 0;
      font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"
    }

    body.setup-active,
    body.convo-active {
      background: linear-gradient(120deg, #4834d4, #686de0);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
      overflow: hidden
    }

    button {
      cursor: pointer
    }

    :focus-visible {
      outline: 3px solid #ffd166;
      outline-offset: 2px
    }

    .hidden { display: none !important; }

    /* put near your other styles */
    .message-content .word {
      transition: background 0.08s linear;
    }

    .message-content .word.active {
      background: rgba(255, 255, 255, 0.25);
      border-radius: 6px;
    }

    /* Inline feedback card */
    .feedback-card {
      position: absolute;
      left: 24px;
      /* sits over the left side */
      top: 24px;
      width: 360px;
      max-width: calc(100vw - 48px);
      background: #fff;
      color: #111827;
      border-radius: 16px;
      padding: 18px 20px;
      box-shadow: 0 15px 40px rgba(0, 0, 0, .18);
      z-index: 600;
      /* above chat */
      display: none;
      /* hidden by default */
    }

    .feedback-card h3 {
      margin: 0 0 8px 0;
      font-size: 18px;
      font-weight: 800;
    }

    .feedback-card .feedback-body {
      font-size: 14px;
      line-height: 1.45;
    }

    .feedback-card .close-btn {
      position: absolute;
      right: 10px;
      top: 10px;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      border: 0;
      background: #f3f4f6;
      color: #111827;
      cursor: pointer;
    }

    @media (max-width: 800px) {
      .feedback-card {
        left: 12px;
        right: 12px;
        width: auto;
      }
    }



    /* --- Setup --- */
    .setup-wrapper {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 56px;
      padding: 24px;
      width: 100%;
      max-width: 900px
    }

    .setup-card {
      background: #fff;
      color: #111827;
      padding: 24px;
      border-radius: 16px;
      width: 100%;
      max-width: 420px;
      box-shadow: 0 15px 40px rgba(0, 0, 0, .18)
    }

    .setup-header {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 14px;
      font-weight: 800
    }

    .form-group {
      margin-bottom: 16px
    }

    .form-group label {
      display: block;
      font-size: 14px;
      font-weight: 700;
      margin-bottom: 6px;
      color: #374151
    }

    .form-group select {
      width: 100%;
      padding: 12px;
      border: 1px solid #d1d5db;
      border-radius: 10px;
      background: #f9fafb;
      appearance: none;
      background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
      background-position: right .7rem center;
      background-repeat: no-repeat;
      background-size: 1.5em 1.5em
    }

    .radio-group {
      display: flex;
      gap: 14px
    }

    .radio-group input[type=radio] {
      accent-color: #4834d4
    }

    .lets-go-btn {
      width: 100%;
      padding: 12px;
      border: none;
      border-radius: 10px;
      background: #4834d4;
      color: #fff;
      font-weight: 800
    }

    .branding-side {
      text-align: center
    }

    .branding-logo-wrapper {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      background: rgba(255, 255, 255, .95);
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0 auto 14px;
      box-shadow: 0 8px 25px rgba(0, 0, 0, .15);
      overflow: hidden;
    }

    .branding-logo-wrapper img,
    .popup-logo-img {
      width: 100%;
      height: 100%;
      display: block;
      /* remove inline-gap */
      object-fit: cover;
      /* fill the circle; crops if needed */
      border-radius: 50%;
      /* not strictly required with overflow, but safe */
    }

    @media (max-width:900px) {
      .setup-wrapper {
        flex-direction: column-reverse;
        gap: 20px
      }
    }

    /* --- Conversation Layout --- */
    .app-container {
      display: flex;
    }
    .convo-view {
      display: flex;
      position: relative;
      width: min(1400px, 98vw);
      height: 95vh;
      max-height: 900px;
      gap: 18px
    }

    /* COMPACT left panel: fixed narrow width like screenshot */
    .convo-left-panel {
      width: 340px;
      min-width: 300px;
      max-width: 380px;
      flex: 0 0 auto;
      background: #fff;
      color: #111827;
      border-radius: 18px;
      box-shadow: 0 8px 30px rgba(0, 0, 0, .1);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-between;
      padding: 22px 18px;
      text-align: center
    }

    .convo-right-panel {
      flex: 1 1 auto;
      min-width: 0;
      background: transparent;
      color: #fff;
      display: none;
      flex-direction: column;
      overflow: hidden
    }

    .convo-right-panel.visible {
      display: flex
    }

    .right-panel-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 6px 2px;
      font-weight: 800
    }

    .right-panel-header button {
      background: transparent;
      border: 0;
      color: #e5e7eb;
      font-size: 18px;
      cursor: pointer
    }

    .convo-chat-container {
      flex: 1;
      overflow-y: auto;
      padding-right: 6px;
      display: flex;
      flex-direction: column;
      gap: 14px
    }

    .message {
      display: flex;
      flex-direction: column
    }

    .message-header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 6px;
      font-size: 14px;
      font-weight: 800;
      color: #e5e7eb
    }

    .message-header svg {
      width: 22px;
      height: 22px;
      padding: 4px;
      border-radius: 50%
    }

    .bot-message .message-header svg {
      background: rgba(0, 0, 0, .25)
    }

    .user-message .message-header svg {
      background: rgba(255, 255, 255, .18)
    }

    .user-message {
      align-items: flex-end;
      /* parent .message is column-flex */
    }

    .user-message .message-header {
      align-self: flex-end;
      /* <-- key */
      display: flex;
      flex-direction: row-reverse;
      justify-content: flex-start;
      /* content flows [avatar][You] on the right */
      gap: 8px;
      /* remove any width:100% from earlier rules */
      width: auto;
    }




    .bot-message {
      align-items: flex-start;
    }

    /* Tidy spacing when reversed */
    .user-message .message-header svg {
      margin-left: 8px;
      /* space between name and avatar */
      margin-right: 0;
    }

    .user-message .message-header span {
      white-space: nowrap;
    }

    .user-message .message-header svg {
      margin-left: 8px;
      margin-right: 0;
    }

    /* (optional) keep bot header tidy on the left */
    .bot-message .message-header {
      justify-content: flex-start;
    }


    .message-content {
      padding: 12px 16px;
      border-radius: 12px;
      font-size: 16px;
      line-height: 1.55;
      word-wrap: break-word;
      max-width: 92%;
      position: relative
    }

    .bot-message .message-content {
      background: rgba(0, 0, 0, .22)
    }

    .user-message .message-content {
      background: #fff;
      color: #111827;
      align-self: flex-end
    }

    .bot-message-actions {
      display: flex;
      gap: 10px;
      margin-top: 6px
    }

    .bot-message-actions button {
      background: transparent;
      border: 0;
      color: #e5e7eb
    }

    .bot-message-actions svg {
      width: 18px;
      height: 18px
    }

    .right-panel-footer {
      padding: 10px 0
    }

    .chat-input-form {
      display: flex;
      gap: 10px
    }

    .chat-input-form input {
      flex: 1;
      border-radius: 12px;
      border: 1px solid rgba(255, 255, 255, .5);
      background: rgba(255, 255, 255, .2);
      color: #fff;
      padding: 12px 14px;
      outline: none
    }

    .chat-input-form input::placeholder {
      color: #f3f4f6;
      opacity: .85
    }

    .chat-input-form button {
      border-radius: 12px;
      padding: 0 14px;
      background: #111827;
      border: 1px solid #111827;
      color: #fff
    }

    /* Left panel states */
    .popup-logo-circle {
      width: 92px;
      height: 92px;
      border-radius: 50%;
      background: #e0e7ff;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0 auto 14px;
      overflow: hidden;

    }

    /* .popup-logo-img {
      width: 70px;
      height: 70px;
      border-radius: 50%
    } */

    .popup-logo-img {
      width: 100%;
      /* fill the circle */
      height: 100%;
      object-fit: cover;
      /* crop to circle */
      /* border-radius: 50%;  optional now due to overflow */
    }

    .popup-lets-talk {
      font-size: 22px;
      font-weight: 800;
      margin-top: 8px;
      color: #1f2937
    }

    .popup-mic-button {
      background: none;
      border: 1px solid #e5e7eb;
      border-radius: 50%;
      width: 52px;
      height: 52px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform .15s ease
    }

    .popup-mic-button:hover {
      transform: scale(1.05)
    }

    .popup-click-to-speak {
      font-size: 13px;
      color: #6b7280;
      margin-top: 8px
    }
    /* Scenario intro/details under logo */
    .scenario-intro {
      width: 100%;
      text-align: left;
      background: #f9fafb;
      color: #374151;
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      padding: 10px 12px;
      margin: 8px 0 6px;
      font-size: 13px;
      line-height: 1.35;
      white-space: pre-wrap;
    }
    .scenario-intro strong { color: #111827; }

    /* Scenario hint under intro */
    .scenario-hint {
      width: 100%;
      text-align: left;
      background: #eef2ff; /* subtle different bg */
      color: #374151;
      border: 1px dashed #c7d2fe;
      border-radius: 10px;
      padding: 8px 10px;
      margin: 6px 0 8px;
      font-size: 12.5px;
    }

    .left-panel-state {
      display: none
    }

    /* Left-panel feedback card */
    .left-feedback-card {
      /* hidden until used */
      width: 100%;
      background: #ffffff;
      color: #111827;
      border-radius: 16px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, .10);
      padding: 16px 18px;
      margin-top: 8px;
      /* space below the logo */
      text-align: left;
    }

    .left-feedback-card h3 {
      margin: 0 0 8px 0;
      font-size: 16px;
      font-weight: 800;
    }

    .left-feedback-card .body {
      font-size: 14px;
      line-height: 1.45;
      white-space: pre-wrap;
    }


    .left-panel-state.active {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%
    }

    #audioPlayer {
      width: 100%;
      margin: 10px 0
    }

    .recorded-actions {
      display: flex;
      gap: 10px;
      margin-top: 6px
    }

    .recorded-actions .primary {
      background: #4834d4;
      color: #fff;
      border: 1px solid #4834d4;
      border-radius: 10px;
      padding: 8px 14px
    }

    #endConversationBtn {
      width: 100%;
      padding: 10px;
      border: 1px solid #e5e7eb;
      background: #f9fafb;
      border-radius: 12px;
      font-weight: 800
    }

    .exit-conversation-btn {
      position: absolute;
      top: 10px;
      right: 10px;
      background: rgba(0, 0, 0, .22);
      color: #fff;
      border: none;
      border-radius: 50%;
      width: 34px;
      height: 34px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      z-index: 500
    }

    .lets-go-btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }


    /* Modals */
    .modal-overlay {
      position: fixed;
      inset: 0;
      align-items: center;
      justify-content: center;
      z-index: 400;
      background: rgba(0, 0, 0, .38)
    }

    .modal-content {
      background: #fff;
      color: #111827;
      border-radius: 16px;
      padding: 24px 26px;
      text-align: center;
      width: min(92vw, 420px);
      box-shadow: 0 10px 40px rgba(0, 0, 0, .2)
    }

    .modal-title {
      font-size: 20px;
      font-weight: 800;
      margin-bottom: 12px
    }

    .modal-buttons {
      display: flex;
      gap: 12px;
      justify-content: center
    }

    .modal-buttons .primary {
      background: #4834d4;
      color: #fff;
      border: 1px solid #4834d4;
      border-radius: 10px;
      padding: 10px 16px
    }

    /* Feedback page tweaks (re-uses your .modal-overlay/.modal-content) */
    .feedback-title {
      font-size: 22px;
      font-weight: 900;
      margin: 0 0 10px;
    }

    .feedback-summary {
      text-align: left;
      white-space: pre-wrap;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
      font-size: 13px;
      line-height: 1.45;
      color: #111827;
      background: #f9fafb;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      padding: 12px;
      max-height: 50vh;
      overflow: auto;
      margin: 10px 0 16px;
    }

    .feedback-actions {
      display: flex;
      gap: 10px;
      justify-content: center;
    }

    .feedback-actions .secondary {
      background: #f3f4f6;
      border: 1px solid #e5e7eb;
      border-radius: 10px;
      padding: 10px 16px;
    }

    .lf-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.lf-actions button {
  border-radius: 10px;
  padding: 8px 14px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-weight: 700;
}
.lf-actions .primary {
  background: #4834d4;
  color: #fff;
  border-color: #4834d4;
}
/* let the left column allow inner scroll areas */
.convo-left-panel { min-height: 0; }
.convo-view { min-height: 0; }


/* make the feedback text scroll instead of growing forever */
.left-feedback-card .body {
  max-height: clamp(280px, 60vh, 640px); /* responsive cap */
  overflow: auto;
  padding-right: 6px; /* space for scrollbar */
}

/* hide the close “✕” and End Conversation while feedback is active */
body.feedback-active #endConversationBtn,
body.feedback-active .exit-conversation-btn {
  display: none !important;
}


/* optional: tidy scrollbar */
.left-feedback-card .body::-webkit-scrollbar { width: 8px; }
.left-feedback-card .body::-webkit-scrollbar-thumb {
  background: #e5e7eb; border-radius: 8px;
}


    /* Small screens: stack with chat first and left panel below */
    @media (max-width:800px) {
      .convo-view {
        flex-direction: column-reverse;
        height: 94vh
      }

      .convo-left-panel {
        width: 100%;
        max-width: none
      }
    }

    /* AlphaHowl Chatbot UI Styles
   Moved from inline <style> in alphahowl_chat.html
   Edit this file to update chatbot UI styles. */

    /* Styles for conversational bot speaker select and action button */
    #convoSpeakerSelect {
      margin-left: 16px;
      border-radius: 8px;
      padding: 4px 8px;
      font-size: 1rem;
      border: 1px solid #ccc;
      background: #f9fafb;
      color: #222;
    }

    #convoSpeakerSelect:focus {
      outline: none;
      border-color: #6c63ff;
    }

    .convo-stop-btn {
      margin-left: 16px;
    }

    /* Optional: dark mode for select */
    .dark-mode #convoSpeakerSelect {
      background: #232336;
      color: #eee;
      border: 1px solid #4b8aff44;
    }

    .footer-powered {
      width: 100%;
      position: absolute;
      left: 0;
      bottom: 0;
      text-align: center;
      padding: 16px;
      font-size: 14px;
      color: #555;
      background: transparent;
      z-index: 20;
    }

    .footer-logo {
      height: 20px;
      vertical-align: middle;
      margin-left: 8px;
    }

    .main-content {
      position: relative;
      padding-bottom: 56px;
      /* Height of footer + some margin */
    }

    audio#ttsAudio {
      display: none;
    }

    /* Animated dots for Listening/Processing/Thinking states */
    .pulsing-dots::after {
      content: '...';
      display: inline-block;
      overflow: hidden;
      width: 0;
      animation: ellipsis 1s steps(4, end) infinite;
    }

    .d-none { display: none !important; }
      .loading-overlay {
        position: fixed; inset: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5);
        display: flex; align-items: center; justify-content: center;
        z-index: 2000;
      }
      .loading-box {
        background: #fff; color: #111;
        padding: 2em 2.25em; border-radius: 12px; text-align: center;
        box-shadow: 0 10px 30px rgba(0,0,0,0.25); min-width: 260px;
      }
      .spinner {
        width: 44px; height: 44px; margin: 0 auto 12px auto;
        border: 4px solid #e5e7eb; border-top: 4px solid var(--primary-color, #3b82f6);
        border-radius: 50%; animation: spin 1s linear infinite;
      }
      @keyframes spin { 100% { transform: rotate(360deg); } }
      .loading-text { margin: 0.25rem 0 0; font-weight: 500; }
      .loading-subtext { margin: 0.25rem 0 0; font-size: 0.9rem; color: #6b7280; }

      /* "Go to Home" in top bar */
      .user-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
      }
      .user-actions {
        display: flex;
        gap: 1.25rem;
        align-items: center;
      }
      .user-bar a.home-link {
        color: var(--primary-color, #3b82f6);
        font-weight: 500;
        text-decoration: none;
      }
      .user-bar a.home-link:hover {
        text-decoration: underline;
      }

    @keyframes ellipsis {
      to {
        width: 1.2em;
      }
    }
    /* Small Hint under bot question */
    .bot-message .hint-text {
      margin-top: 6px;
      font-size: 12px;
      opacity: 0.85;
      color: #d1d5db;
    }
