    :root {
      --bg: #0d0d0d;
      --surface: #1a1a1a;
      --surface2: #222;
      --text: #e0d6c2;
      --text-dim: #887d6b;
      --accent: #c9a84c;
      --accent-glow: #e8c860;
      --border: #2a2520;
      --error: #c44;
      --radius: 12px;
      --font: 'Noto Serif TC', 'Noto Sans TC', 'Microsoft JhengHei', serif;
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }

    body {
      background: var(--bg);
      color: var(--text);
      font-family: var(--font);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    /* === HEADER === */
    header {
      text-align: center;
      padding: 1.5rem 1rem 0.5rem;
      border-bottom: 1px solid var(--border);
      position: relative;
    }

    header h1 {
      font-size: 2rem;
      font-weight: 400;
      letter-spacing: 0.15em;
      color: var(--accent);
      text-shadow: 0 0 40px rgba(201, 168, 76, 0.3);
    }

    header .subtitle {
      color: var(--text-dim);
      font-size: 0.85rem;
      margin-top: 0.3rem;
      letter-spacing: 0.1em;
    }

    .toolbar {
      display: flex;
      justify-content: flex-end;
      gap: 0.5rem;
      padding: 0.3rem 1rem 0;
      max-width: 720px;
      margin: 0 auto;
      width: 100%;
    }
    .toolbar button {
      background: none;
      border: 1px solid var(--border);
      color: var(--text-dim);
      font-size: 0.75rem;
      padding: 0.2rem 0.6rem;
      border-radius: 4px;
      cursor: pointer;
      font-family: var(--font);
      transition: color 0.2s, border-color 0.2s;
    }
    .toolbar button:hover {
      color: var(--accent);
      border-color: var(--accent);
    }

    /* === MAIN LAYOUT === */
    main {
      flex: 1;
      max-width: 720px;
      width: 100%;
      margin: 0 auto;
      padding: 0 1rem;
      display: flex;
      flex-direction: column;
    }

    /* === CHAT AREA === */
    #chat {
      flex: 1;
      overflow-y: auto;
      padding: 1rem 0;
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
      scroll-behavior: smooth;
    }

    .msg {
      max-width: 85%;
      padding: 0.75rem 1rem;
      border-radius: var(--radius);
      line-height: 1.7;
      font-size: 0.95rem;
      word-break: break-word;
      animation: fadeIn 0.25s ease;
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(8px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .msg.user {
      align-self: flex-end;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-bottom-right-radius: 4px;
    }

    .msg.bot {
      align-self: flex-start;
      background: var(--surface);
      border: 1px solid var(--border);
      border-bottom-left-radius: 4px;
      color: var(--text);
    }

    .msg.bot .role-tag {
      display: block;
      font-size: 0.7rem;
      color: var(--accent);
      letter-spacing: 0.1em;
      margin-bottom: 0.3rem;
      text-transform: uppercase;
    }

    .msg .content {
      display: block;
    }

    .msg .disclaimer {
      font-size: 0.78rem;
      color: var(--text-dim);
    }

    .msg.error {
      align-self: center;
      background: transparent;
      border: 1px solid var(--error);
      color: var(--error);
      font-size: 0.85rem;
      text-align: center;
    }

    .typing-indicator {
      align-self: flex-start;
      padding: 0.75rem 1rem;
      color: var(--text-dim);
      font-size: 0.85rem;
      animation: blink 1.2s infinite;
    }

    @keyframes blink {
      0%, 100% { opacity: 0.3; }
      50% { opacity: 1; }
    }

    /* Markdown rendering via marked.js */
    .msg.bot p { margin-bottom: 0.6rem; }
    .msg.bot p:last-child { margin-bottom: 0; }
    .msg.bot ul, .msg.bot ol { padding-left: 1.5rem; margin: 0.4rem 0 0.6rem; }
    .msg.bot li { margin-bottom: 0.2rem; }
    .msg.bot blockquote {
      border-left: 3px solid var(--accent);
      padding-left: 0.75rem;
      color: var(--text-dim);
      margin: 0.4rem 0 0.6rem;
    }
    .msg.bot pre {
      background: var(--bg);
      padding: 0.6rem 0.8rem;
      border-radius: 6px;
      overflow-x: auto;
      margin: 0.4rem 0 0.6rem;
      font-size: 0.85rem;
      border: 1px solid var(--border);
    }
    .msg.bot code {
      background: rgba(201,168,76,0.1);
      padding: 0.1rem 0.3rem;
      border-radius: 3px;
      font-size: 0.88rem;
    }
    .msg.bot pre code {
      background: none;
      padding: 0;
    }
    .msg.bot strong { color: var(--accent-glow); }
    .msg.bot em { color: #d4c496; }
    .msg.bot h1, .msg.bot h2, .msg.bot h3 {
      color: var(--accent);
      margin: 0.6rem 0 0.3rem;
      font-weight: 400;
    }
    .msg.bot a { color: var(--accent); }

    /* Reasoning fold */
    .reasoning-block {
      margin-bottom: 0.6rem;
    }
    .reasoning-block summary {
      color: var(--text-dim);
      font-size: 0.78rem;
      cursor: pointer;
      user-select: none;
      padding: 0.3rem 0;
      border-bottom: 1px dashed var(--border);
    }
    .reasoning-block summary:hover {
      color: var(--accent);
    }
    .reasoning-block .reasoning-content {
      margin-top: 0.4rem;
      padding: 0.5rem 0.7rem;
      background: rgba(201,168,76,0.06);
      border-left: 2px solid var(--border);
      border-radius: 0 4px 4px 0;
      color: var(--text-dim);
      font-size: 0.82rem;
      line-height: 1.6;
      white-space: pre-wrap;
    }

    /* === INPUT AREA === */
    #input-area {
      display: flex;
      gap: 0.5rem;
      padding: 0.5rem 0 1rem;
      border-top: 1px solid var(--border);
      align-items: flex-end;
    }

    #input-area textarea {
      flex: 1;
      background: var(--surface);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 0.75rem 1rem;
      font-family: var(--font);
      font-size: 0.95rem;
      resize: none;
      min-height: 3rem;
      max-height: 8rem;
      line-height: 1.5;
      outline: none;
      transition: border-color 0.2s;
    }

    #input-area textarea:focus {
      border-color: var(--accent);
    }

    #input-area textarea::placeholder {
      color: var(--text-dim);
    }

    #input-area .btn-group {
      display: flex;
      flex-direction: column;
      gap: 0.3rem;
    }

    #send-btn, #stop-btn {
      background: var(--accent);
      color: var(--bg);
      border: none;
      border-radius: var(--radius);
      padding: 0 1.2rem;
      font-family: var(--font);
      font-size: 0.9rem;
      cursor: pointer;
      transition: background 0.2s, transform 0.1s;
      white-space: nowrap;
      height: 2.4rem;
    }

    #stop-btn {
      background: var(--error);
      display: none;
    }
    #stop-btn.visible { display: block; }

    #send-btn:hover:not(:disabled), #stop-btn:hover:not(:disabled) {
      filter: brightness(1.2);
    }
    #send-btn:active:not(:disabled), #stop-btn:active:not(:disabled) {
      transform: scale(0.96);
    }
    #send-btn:disabled, #stop-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    #char-count {
      font-size: 0.7rem;
      color: var(--text-dim);
      text-align: right;
      padding-right: 0.3rem;
    }
    #char-count.warn { color: var(--error); }

    /* === FOOTER === */
    footer {
      text-align: center;
      padding: 1rem;
      border-top: 1px solid var(--border);
      font-size: 0.75rem;
      color: var(--text-dim);
    }

    footer a {
      color: var(--accent);
      text-decoration: none;
    }

    footer a:hover {
      text-decoration: underline;
    }

    /* === RESPONSIVE === */
    @media (max-width: 480px) {
      header h1 { font-size: 1.5rem; }
      .msg { max-width: 92%; font-size: 0.9rem; }
      #input-area { flex-direction: column; }
      #input-area .btn-group { flex-direction: row; }
      #send-btn, #stop-btn { padding: 0.5rem 1rem; }
    }

    /* Scrollbar */
    #chat::-webkit-scrollbar { width: 4px; }
    #chat::-webkit-scrollbar-track { background: transparent; }
    #chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
