    :root {
      --bg: #eef2f7;
      --card: #ffffff;
      --header: #ffffff;
      --thread: #f1f5f9;
      --border: #d7dee8;
      --text: #101828;
      --muted: #667085;
      --user: #0f62fe;
      --user-text: #ffffff;
      --assistant: #ffffff;
      --assistant-text: #101828;
      --system: #fff1f2;
      --system-text: #9f1239;
      --shadow: 0 14px 38px rgba(15, 23, 42, 0.14);
    }

    * { box-sizing: border-box; }

    html, body {
      margin: 0;
      min-height: 100%;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: var(--text);
      background: var(--bg);
    }

    body { padding: 18px; }

    .chat-shell {
      width: 100%;
      max-width: 820px;
      height: min(88vh, 880px);
      margin: 0 auto;
      display: grid;
      grid-template-rows: auto 1fr auto auto;
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 22px;
      box-shadow: var(--shadow);
      overflow: hidden;
    }

    .chat-header {
      background: var(--header);
      padding: 16px 18px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .chat-title {
      font-weight: 750;
      font-size: 18px;
      line-height: 1.2;
    }

    .chat-subtitle {
      margin-top: 4px;
      color: var(--muted);
      font-size: 13px;
    }

    .new-chat-button {
      border: 1px solid var(--border);
      background: #ffffff;
      border-radius: 999px;
      padding: 8px 12px;
      font: inherit;
      color: var(--user);
      cursor: pointer;
    }

    .thread {
      overflow-y: auto;
      background: var(--thread);
      padding: 18px 14px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .message-row {
      width: 100%;
      display: flex;
      align-items: flex-end;
      gap: 8px;
    }

    .message-row.user { justify-content: flex-end; }
    .message-row.assistant, .message-row.system { justify-content: flex-start; }

    .avatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      flex: 0 0 28px;
      display: grid;
      place-items: center;
      font-size: 11px;
      font-weight: 700;
      color: #ffffff;
      user-select: none;
    }

    .message-row.user .avatar {
      order: 2;
      background: #2563eb;
    }

    .message-row.assistant .avatar { background: #64748b; }
    .message-row.system .avatar { background: #e11d48; }

    .message-stack {
      display: flex;
      flex-direction: column;
      max-width: min(76%, 640px);
    }

    .message-row.user .message-stack { align-items: flex-end; }

    .bubble {
      padding: 10px 13px;
      border-radius: 18px;
      white-space: pre-wrap;
      word-break: break-word;
      line-height: 1.45;
      font-size: 14px;
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    }

    .message-row.user .bubble {
      background: var(--user);
      color: var(--user-text);
      border-bottom-right-radius: 5px;
    }

    .message-row.assistant .bubble {
      background: var(--assistant);
      color: var(--assistant-text);
      border-bottom-left-radius: 5px;
    }

    .message-row.system .bubble {
      background: var(--system);
      color: var(--system-text);
      border: 1px solid #fecdd3;
    }

    .timestamp {
      margin-top: 3px;
      color: var(--muted);
      font-size: 11px;
    }

    .message-row.user .timestamp { text-align: right; }

    .typing-indicator {
      background: var(--thread);
      color: var(--muted);
      padding: 0 18px 10px;
      display: flex;
      align-items: center;
      gap: 5px;
      font-size: 13px;
    }

    .typing-indicator[hidden] { display: none; }

    .dot {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: #94a3b8;
      animation: pulse 1.2s infinite ease-in-out;
    }

    .dot:nth-child(2) { animation-delay: 0.15s; }
    .dot:nth-child(3) { animation-delay: 0.3s; }

    @keyframes pulse {
      0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
      40% { opacity: 1; transform: translateY(-2px); }
    }

    .composer {
      background: #ffffff;
      border-top: 1px solid var(--border);
      padding: 14px;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      align-items: end;
    }

    .message-input {
      width: 100%;
      min-height: 46px;
      max-height: 140px;
      resize: none;
      overflow-y: auto;
      border: 1px solid var(--border);
      border-radius: 22px;
      padding: 12px 14px;
      font: inherit;
      outline: none;
    }

    .message-input:focus {
      border-color: var(--user);
      box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.14);
    }

    .send-button {
      height: 46px;
      border: 0;
      border-radius: 22px;
      padding: 0 18px;
      background: var(--user);
      color: #ffffff;
      font-weight: 700;
      cursor: pointer;
    }

    .send-button:disabled,
    .message-input:disabled,
    .new-chat-button:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    @media (max-width: 640px) {
      body { padding: 0; }
      .chat-shell {
        height: 100vh;
        max-width: none;
        border: 0;
        border-radius: 0;
      }
      .message-stack { max-width: 82%; }
    }

    /* Simple password gate for PoC only */
    .auth-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.auth-screen[hidden] {
  display: none !important;
}

    .auth-card {
      width: min(420px, 100%);
      background: #ffffff;
      border: 1px solid var(--border);
      border-radius: 22px;
      box-shadow: var(--shadow);
      padding: 24px;
    }

    .auth-title {
      margin: 0;
      font-size: 22px;
      line-height: 1.2;
      font-weight: 750;
    }

    .auth-text {
      margin: 8px 0 18px;
      color: var(--muted);
      font-size: 14px;
      line-height: 1.45;
    }

    .auth-input {
      width: 100%;
      min-height: 46px;
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 12px 14px;
      font: inherit;
      outline: none;
    }

    .auth-input:focus {
      border-color: var(--user);
      box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.14);
    }

    .auth-button {
      width: 100%;
      margin-top: 12px;
      height: 46px;
      border: 0;
      border-radius: 14px;
      background: var(--user);
      color: #ffffff;
      font-weight: 700;
      cursor: pointer;
    }

    .auth-error {
      min-height: 18px;
      margin-top: 10px;
      color: var(--system-text);
      font-size: 13px;
    }

    body.locked .chat-shell {
      display: none;
    }
