    :root { color-scheme: light; --bg: #ffffff; --panel: #f4f4f4; --card: #fafafa; --line: #dedede; --text: #1f1f1f; --muted: #6d6d6d; --accent: #1f1f1f; --accent-text: #fff; --assistant: #1f1f1f; --assistant-text: #fff; --shadow: #0002; }
    :root[data-theme="dark"] { color-scheme: dark; --bg: #212121; --panel: #2f2f2f; --card: #292929; --line: #424242; --text: #ececec; --muted: #a7a7a7; --accent: #fff; --accent-text: #222; --assistant: #ececec; --assistant-text: #222; --shadow: #0004; }
    * { box-sizing: border-box; }
    body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
    .shell { min-height: 100vh; display: flex; flex-direction: column; }
    header { height: 58px; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; border-bottom: 1px solid var(--line); position: relative; }
    .theme-toggle { position: absolute; right: 18px; width: auto; height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: 13px inherit; }
    main { width: min(820px, 100%); margin: 0 auto; padding: 38px 24px 24px; flex: 1; }
    #chat { width: 100%; overflow-y: auto; }
    #chat .welcome, #chat .message { max-width: 820px; margin-left: auto; margin-right: auto; }
    .welcome { margin: 18vh auto 0; text-align: center; max-width: 540px; }
    .welcome h1 { font-size: clamp(28px, 5vw, 38px); margin: 0 0 10px; letter-spacing: -.04em; }
    .welcome p { color: var(--muted); margin: 0; }
    .message { display: grid; grid-template-columns: 30px 1fr; gap: 14px; margin: 0 0 28px; }
    .avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 700; }
    .user .avatar { background: #5b5fc7; } .assistant .avatar { background: var(--assistant); color: var(--assistant-text); }
    .body { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; padding-top: 2px; }
    .user .body { padding-top: 4px; }
    .work { margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
    .work > summary { cursor: pointer; padding: 10px 12px; color: var(--muted); font-size: 13px; list-style: none; }
    .work > summary::before { content: "+"; display: inline-block; width: 18px; color: var(--muted); } .work[open] > summary::before { content: "-"; }
    .work-body { display: grid; gap: 12px; padding: 0 12px 12px; }
    .thinking, .tool { border-top: 1px solid var(--line); padding-top: 10px; }
    .work-body > :first-child { border-top: 0; padding-top: 0; }
    .block-label { margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
    pre { margin: 0; color: var(--muted); white-space: pre-wrap; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
    .answer:empty { display: none; }
    .answer { white-space: normal; overflow-wrap: anywhere; }
    .answer-text { white-space: pre-wrap; }
    .answer p { margin: 0 0 10px; } .answer p:last-child { margin-bottom: 0; }
    .answer ul, .answer ol { margin: 0 0 10px; padding-left: 22px; } .answer li { margin: 2px 0; }
    .answer h1, .answer h2, .answer h3, .answer h4, .answer h5, .answer h6 { margin: 14px 0 8px; line-height: 1.3; } .answer > :first-child { margin-top: 0; } .answer > :last-child { margin-bottom: 0; }
    .answer blockquote { margin: 0 0 10px; padding: 2px 0 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
    .answer hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
    .answer code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
    .answer pre { margin: 0 0 10px; color: var(--text); border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 10px 12px; overflow-x: auto; }
    .answer pre code { background: none; border: 0; padding: 0; }
    .answer a { color: var(--text); }
    .table-wrap { max-width: 100%; margin: 12px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
    table { width: 100%; border-collapse: collapse; font-size: 14px; }
    th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
    th { background: var(--panel); font-weight: 600; } tr:last-child td { border-bottom: 0; }
    .note, .error { color: var(--muted); font-size: 14px; margin-top: 8px; }
    .note.running { font-style: italic; }
    .error { color: #ff9b9b; }
    form { padding: 14px 24px 18px; background: var(--bg); border-top: 1px solid var(--line); }
    .composer { width: min(820px, 100%); margin: 0 auto; display: flex; align-items: end; gap: 10px; padding: 10px 10px 10px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; box-shadow: 0 8px 28px var(--shadow); }
    textarea { flex: 1; max-height: 180px; resize: none; border: 0; outline: 0; padding: 4px 0; background: transparent; color: var(--text); font: inherit; }
    textarea::placeholder { color: var(--muted); }
    button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 18px; cursor: pointer; } button:disabled { opacity: .35; cursor: default; }
    .hint { width: min(820px, 100%); margin: 8px auto 0; color: var(--muted); text-align: center; font-size: 12px; }
    @media (max-width: 600px) { main { padding: 24px 16px 16px; } form { padding: 12px 12px 14px; } .message { gap: 10px; } }
    [hidden] { display: none !important; }
    .login-main { flex: 1; display: flex; justify-content: center; padding: 18vh 24px 40px; }
    .login-card { width: min(340px, 100%); border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 22px; box-shadow: 0 8px 28px var(--shadow); }
    .login-card h1 { font-size: 20px; margin: 0 0 14px; text-align: center; letter-spacing: -.02em; }
    #login-form label { display: block; color: var(--muted); font-size: 12px; font-weight: 600; margin: 0 0 10px; }
    #login-form input { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; outline: 0; }
    #login-form button { width: 100%; height: auto; margin-top: 6px; border-radius: 8px; padding: 9px 0; font-size: 14px; }
    .login-error { color: #ff9b9b; font-size: 13px; margin: 10px 0 0; text-align: center; }
    .user-area { position: absolute; left: 18px; display: flex; align-items: center; gap: 10px; }
    .who { color: var(--muted); font-size: 13px; }
    .logout-btn { width: auto; height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: 13px inherit; cursor: pointer; }
    #app-view { height: 100vh; }
    .app-body { flex: 1; display: flex; min-height: 0; position: relative; }
    .sidebar { width: 280px; flex: none; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; }
    .new-chat-btn { width: calc(100% - 24px); margin: 12px; height: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font: 13px inherit; padding: 9px 0; cursor: pointer; }
    .conversation-list { list-style: none; margin: 0; padding: 4px 8px 16px; overflow-y: auto; flex: 1; }
    .conversation-item { position: relative; display: flex; align-items: center; border-radius: 8px; }
    .conversation-item:hover { background: var(--card); }
    .conversation-item.selected { background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
    .conv-title { flex: 1; min-width: 0; width: auto; height: auto; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: 12px inherit; text-align: left; padding: 9px 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .conv-action { position: absolute; top: 50%; display: none; width: 26px; height: 26px; border: 0; border-radius: 6px; background: var(--card); color: var(--muted); font-size: 12px; cursor: pointer; transform: translateY(-50%); }
    .conv-rename { right: 28px; } .conv-delete { right: 2px; }
    .conversation-item:hover .conv-action { display: block; }
    .chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
    .load-older-btn { align-self: center; margin: 10px 0 0; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font: 12px inherit; padding: 6px 14px; cursor: pointer; }
    .load-older-btn:hover { color: var(--text); background: var(--card); }
    .sidebar-toggle { display: none; position: absolute; left: 18px; width: 36px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font-size: 14px; cursor: pointer; }
    .has-sidebar .user-area { left: 64px; }
    .sidebar-backdrop { position: fixed; inset: 58px 0 0 0; background: #0006; z-index: 19; }
    @media (max-width: 720px) {
      .sidebar { position: fixed; top: 58px; bottom: 0; left: 0; z-index: 20; width: min(80vw, 320px); transform: translateX(-102%); transition: transform .18s ease; }
      .sidebar.open { transform: none; box-shadow: 0 8px 28px var(--shadow); }
      .sidebar-toggle { display: inline-block; }
    }