    :root {
      color-scheme: light;
      --bg: #f5f7fb;
      --panel: #ffffff;
      --text: #1f2937;
      --muted: #687386;
      --border: #d8dee8;
      --accent: #335cff;
      --accent-hover: #2448d8;
      --user: #e8efff;
      --assistant: #ffffff;
      --error-bg: #fff1f1;
      --error-text: #9b1c1c;
      --shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
      --radius: 16px;
    }

    * {
      box-sizing: border-box;
    }

    html, body {
      height: 100%;
    }

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

    button, input, textarea {
      font: inherit;
    }

    button {
      cursor: pointer;
    }

    .app {
      min-height: 100%;
      display: grid;
      grid-template-rows: auto 1fr auto;
    }

    header {
      background: rgba(255, 255, 255, 0.94);
      border-bottom: 1px solid var(--border);
      padding: 14px 20px;
      position: sticky;
      top: 0;
      z-index: 10;
      backdrop-filter: blur(8px);
    }

    .header-inner {
      max-width: 900px;
      margin: 0 auto;
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .brand {
      min-width: 0;
      flex: 1;
    }

    h1 {
      font-size: 1.15rem;
      margin: 0;
      line-height: 1.2;
    }

    .subtitle {
      color: var(--muted);
      font-size: 0.83rem;
      margin-top: 2px;
    }

    .status {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      color: var(--muted);
      font-size: 0.8rem;
      white-space: nowrap;
    }

    .status-dot {
      width: 9px;
      height: 9px;
      border-radius: 50%;
      background: #9aa4b2;
    }

    .status-dot.busy {
      background: #e3a008;
    }

    .status-dot.ok {
      background: #159447;
    }

    .status-dot.error {
      background: #d13c3c;
    }

    .secondary-button {
      border: 1px solid var(--border);
      background: var(--panel);
      color: var(--text);
      border-radius: 10px;
    }

    .secondary-button {
      padding: 8px 11px;
    }

    .secondary-button:hover {
      background: #f7f8fb;
    }

    main {
      width: 100%;
      max-width: 900px;
      margin: 0 auto;
      padding: 24px 18px 180px;
    }

    #messages {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .message {
      display: flex;
      gap: 10px;
      align-items: flex-start;
    }

    .message.user {
      justify-content: flex-end;
    }

    .bubble {
      max-width: min(760px, 88%);
      padding: 13px 15px;
      border-radius: var(--radius);
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      box-shadow: var(--shadow);
    }

    .assistant .bubble {
      background: var(--assistant);
      border: 1px solid var(--border);
      border-top-left-radius: 5px;
    }

    .user .bubble {
      background: var(--user);
      border: 1px solid #ccd9ff;
      border-top-right-radius: 5px;
    }

    .message-label {
      display: block;
      color: var(--muted);
      font-size: 0.72rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      margin-bottom: 5px;
      text-transform: uppercase;
    }

    .error-message .bubble {
      background: var(--error-bg);
      color: var(--error-text);
      border-color: #f2baba;
    }

    .thinking {
      color: var(--muted);
      font-style: italic;
    }

    .katex-display {
      overflow-x: auto;
      overflow-y: hidden;
    }

    .composer-wrap {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(
        to bottom,
        rgba(245, 247, 251, 0),
        rgba(245, 247, 251, 0.97) 24%,
        rgba(245, 247, 251, 1)
      );
      padding: 30px 18px 18px;
    }

    .composer {
      max-width: 900px;
      margin: 0 auto;
      background: var(--panel);
      border: 1px solid var(--border);
      box-shadow: var(--shadow);
      border-radius: 18px;
      padding: 10px;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      align-items: end;
    }

    textarea {
      width: 100%;
      min-height: 52px;
      max-height: 180px;
      resize: none;
      border: 0;
      outline: 0;
      padding: 10px 11px;
      background: transparent;
      color: var(--text);
      line-height: 1.45;
    }

    .send-button {
      border: 0;
      background: var(--accent);
      color: white;
      font-weight: 700;
      border-radius: 12px;
      min-width: 82px;
      height: 44px;
      padding: 0 16px;
    }

    .send-button:hover {
      background: var(--accent-hover);
    }

    .send-button:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    .composer-note {
      max-width: 900px;
      margin: 7px auto 0;
      padding: 0 8px;
      color: var(--muted);
      font-size: 0.72rem;
      text-align: center;
    }

    .field {
      margin-bottom: 16px;
    }

    label {
      display: block;
      font-weight: 700;
      font-size: 0.88rem;
      margin-bottom: 5px;
    }

    input {
      width: 100%;
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 10px 11px;
      color: var(--text);
      background: white;
    }

    .primary-button {
      border: 0;
      background: var(--accent);
      color: white;
      border-radius: 10px;
      padding: 9px 14px;
      font-weight: 700;
    }

    .login-main {
      display: grid;
      place-items: center;
      padding: 48px 18px;
    }

    .login-card {
      width: min(420px, 100%);
      padding: 28px;
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
    }

    .login-card h2 {
      margin: 0;
      font-size: 1.35rem;
      line-height: 1.25;
    }

    .login-intro {
      margin: 8px 0 22px;
      color: var(--muted);
      font-size: 0.9rem;
    }

    .login-button {
      width: 100%;
      min-height: 44px;
    }

    .login-button:hover {
      background: var(--accent-hover);
    }

    @media (max-width: 620px) {
      header {
        padding-inline: 12px;
      }

      .subtitle {
        display: none;
      }

      .status {
        display: none;
      }

      main {
        padding-inline: 12px;
      }

      .bubble {
        max-width: 94%;
      }

      .composer-wrap {
        padding-inline: 10px;
      }

      .login-main {
        padding: 32px 12px;
      }

      .login-card {
        padding: 22px;
      }
    }
