/* ==========================================================================
   Trilogy Chat – App Styles (clean rebuild)
   - No "space-between" on .actions anywhere
   - Loading dots always sit to the right of the Send button
   ========================================================================== */

   :root {
    /* Design tokens */
    --bg: #ffffff;
    --ink: #1f2937;          /* slate-800 */
    --muted: #6b7280;        /* slate-500 */
    --brand: #0b5ea8;        /* accent */
    --ring: #e5e7eb;         /* slate-200 */
    --card: #ffffff;
    --card-border: #d1d5db;  /* slate-300 */
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 20px rgba(0,0,0,.06);
    --radius: 12px;
    --radius-sm: 10px;
    --gap: 12px;
    --container: 1040px;
  
    /* Dynamic viewport helpers (may be updated by JS) */
    --vvh: 100dvh;
    --safe-bottom: env(safe-area-inset-bottom);
  }
  
  * { box-sizing: border-box; }
  
  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial,"Noto Sans","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
    height: 100%;
  }
  
  .container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 20px 18px 28px;
    min-height: var(--vvh);
  }
  
  /* ----------------------------- Hero ----------------------------- */
  .hero { margin-bottom: 18px; text-align: center; }
  .hero .logo { margin: 0 auto 8px; }
  .logo { width: 200px; max-width: 90%; height: auto; display: block; margin: 0 0 8px; }
  h1 { font-size: 20px; line-height: 1.1; margin: 6px 0 8px; letter-spacing: -.015em; }
  .lede { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
  .lede em { font-size: 16px; font-style: italic; color: #475569; }
  
  /* -------------------------- Examples grid ------------------------ */
  .examples {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap);
    margin: 10px 0 18px;
  }
  @media (min-width: 600px) {
    .examples { grid-template-columns: repeat(3, 1fr); }
  }
  
  .example-btn {
    border: 1px solid var(--card-border);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: 12px;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .02s ease;
    box-shadow: var(--shadow);
  }
  .example-btn:hover { border-color: #93c5fd; }
  .example-btn:active { transform: translateY(1px); }
  .example-btn:focus { outline: 2px solid #bfdbfe; outline-offset: 2px; }
  
  /* ---------------------------- Chat area -------------------------- */
  .chat { border-top: 1px solid var(--ring); padding-top: 14px; }
  .messages { display: grid; gap: 12px; margin: 6px 0 14px; }
  
  /* message bubbles */
  .message .bubble {
    font-size: 14px;
    line-height: 1.2;
    text-align: left;
    border: 1px solid var(--ring);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: #fff;
    box-shadow: var(--shadow);
  }
  .message.user .bubble      { text-align: center; border-color: #bfdbfe; background: #eff6ff; }
  .message.assistant .bubble { border-color: var(--ring); }
  
  /* ------------------------- Ask form layout ----------------------- */
  .form-row {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    align-items: start;
    margin-top: 2px;
  }
  
  .input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(0,0,0,.02);
  }
  .input:focus { outline: 2px solid #bfdbfe; outline-offset: 2px; }
  
  .checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
  }
  
  /* Actions row – IMPORTANT: keep items grouped left with spacing */
  .actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;   /* never space-between */
    gap: 12px;
    margin-top: 10px;
  }
  
  /* Buttons */
  .btn {
    background: var(--brand);
    color: #fff;
    border: 0;
    padding: 12px 18px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    letter-spacing: .01em;
    box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 1px 2px rgba(0,0,0,.06);
    transition: filter .15s ease, transform .02s ease;
  }
  .btn:hover  { filter: brightness(.96); }
  .btn:active { transform: translateY(1px); }
  
  .hint { color: var(--muted); font-size: 12px; }
  
  /* -------------------------- Loading dots ------------------------- */
  /* Hidden by default; JS toggles to "inline". Anchored next to Send. */
  .loading-dots {
    display: none;
    margin-left: 8px;     /* sits immediately to the right of the Send button */
    vertical-align: middle;
    direction: ltr;       /* never mirror */
    text-align: left;
    white-space: nowrap;  /* keep the dots on one line */
    width: 24px;          /* fixed width to prevent layout shift */
    position: relative;   /* establish positioning context */
  }
  
  /* When JS sets display: inline, force it to inline-block for positioning */
  .loading-dots {
    display: none;
    margin-left: 8px;
    vertical-align: baseline;
    transform: translateY(-20px); /* Adjust the -8px value as needed */
    direction: ltr;
    text-align: left;
    white-space: nowrap;
    width: 24px;
    position: relative;
  }
  
  /* Simple text-based animation that works with inline elements */
  .loading-dots::after {
    content: "";
    font-size: 32px;
    display: inline-block;
    width: 4ch;
    animation: loading-ellipsis 9s steps(19, end) infinite;
  }
  
  /* Animates "", ".", "..", "..." and loops */
  @keyframes loading-ellipsis {
    0%   { content: ""; }
    5%   { content: "."; }
    10%  { content: ".."; }
    15%  { content: "..."; }
    20%  { content: "...."; }
    25%  { content: "....."; }
    30%  { content: "......"; }
    35%  { content: "......."; }
    40%  { content: "........"; }
    45%  { content: "........."; }
    50%  { content: ".........."; }
    55%  { content: "..........."; }
    60%  { content: "............"; }
    65%  { content: "............."; }
    70%  { content: ".............."; }
    75%  { content: "..............."; }
    80%  { content: "................"; }
    85%  { content: "................."; }
    90%  { content: ".................."; }
    95%  { content: "..................."; }
    100% { content: "...................."; }
  }
  
  /* --------------------------- Utilities --------------------------- */
  .mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}
  .mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}
  
  /* ------------------------- Mobile hardening ---------------------- */
  html { -webkit-text-size-adjust: 100%; } /* keep iOS from auto-scaling text */
  input, textarea, select, .input { font-size: 16px; } /* prevent focus zoom */
  
  @media (max-width: 480px) {
    .chat {
      padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
  
    /* Make the ask form sticky with a small shadow on mobile */
    #ask-form {
      position: sticky;
      bottom: 0;
      background: #fff;
      padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
      box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
      z-index: 10;
      border-top: 1px solid var(--ring);
    }
  
    /* Keep Send + dots together on the left (still no space-between) */
    .actions {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 12px;
    }
  }