  :root { --accent: #b5651d; --bg: #faf8f5; --border: #e0d9cf; }
  * { box-sizing: border-box; }
  body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
         max-width: 900px; margin: 40px auto; padding: 0 20px; background: var(--bg); color: #2b2a28; }
  h1 { font-size: 1.4rem; }
  #upload-section, #chat-section { background: white; border: 1px solid var(--border);
         border-radius: 10px; padding: 20px; margin-bottom: 20px; }
  #summary { line-height: 1.55; font-size: 0.95rem; }
  #summary:empty { display: none; }
  #messages { height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px;
         padding: 12px; margin-bottom: 12px; background: #fffdfb; }
  .msg { margin-bottom: 16px; line-height: 1.45; }
  .msg.user { color: #2b2a28; font-weight: 600; white-space: pre-wrap; }
  .msg.assistant { color: #4a4642; }
  .msg.assistant > .sender { display: block; font-size: 0.72rem; font-weight: 700;
         text-transform: uppercase; letter-spacing: 0.05em; color: #9a9087;
         margin-bottom: 4px; }

  /* Rendered Markdown — shared by the summary and assistant replies */
  .rich > :first-child { margin-top: 0; }
  .rich > :last-child { margin-bottom: 0; }
  .rich h1, .rich h2, .rich h3 { line-height: 1.3; margin: 1.2em 0 0.4em; }
  .rich h1 { font-size: 1.1rem; }
  .rich h2 { font-size: 1.04rem; }
  .rich h3 { font-size: 0.97rem; }
  .rich p { margin: 0.6em 0; }
  .rich ul, .rich ol { margin: 0.5em 0; padding-left: 1.5em; }
  .rich li { margin: 0.3em 0; }
  .rich li > p { margin: 0.3em 0; }
  .rich code { background: #f0ece6; padding: 0.1em 0.32em; border-radius: 3px;
         font-size: 0.88em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
  .rich pre { background: #f0ece6; padding: 10px 12px; border-radius: 6px; overflow-x: auto; }
  .rich pre code { background: none; padding: 0; }
  .rich strong { color: #1f1e1c; }
  .rich blockquote { margin: 0.6em 0; padding-left: 12px; border-left: 3px solid var(--border);
         color: #6b645e; }
  .rich table { border-collapse: collapse; margin: 0.6em 0; }
  .rich th, .rich td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
  .rich .fallback { white-space: pre-wrap; font-family: inherit; margin: 0; background: none;
         padding: 0; }

  #chat-input-row { display: flex; gap: 8px; }
  input[type=text] { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 6px; }
  button { padding: 10px 16px; border: none; border-radius: 6px; background: var(--accent);
           color: white; cursor: pointer; font-weight: 600; }
  button:disabled { opacity: 0.5; cursor: not-allowed; }
  #chat-section { display: none; }
  #upload-section .sample { font-size: 0.85rem; color: #77706a; margin: 12px 0 0; }
  #upload-section .sample a { color: var(--accent); }
  #status { color: #77706a; font-size: 0.9rem; margin-top: 8px; }
  #terms-panel { background: white; border: 1px solid var(--border); border-radius: 10px;
         padding: 14px 20px; margin-bottom: 20px; font-size: 0.9rem; display: none; }
  #terms-panel summary { cursor: pointer; font-weight: 600; color: var(--accent); }
  #terms-panel-body { margin-top: 12px; line-height: 1.5; }
  #terms-panel-body h3 { font-size: 0.95rem; margin: 1.1em 0 0.3em; }

  /* Sits above the file picker, not buried in a panel: a client uploading a
     proprietary model has to see this before choosing a file. */
  #before-upload { background: #fdf6ec; border: 1px solid #e6d3ad; border-left: 3px solid var(--accent);
         border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; font-size: 0.88rem;
         line-height: 1.45; }
  #before-upload ul { margin: 8px 0 10px; padding-left: 1.3em; }
  #before-upload li { margin: 5px 0; }
  #before-upload a { color: var(--accent); font-size: 0.85rem; }

  #terms-gate { background: white; border: 1px solid var(--border); border-radius: 10px;
         padding: 20px; margin-bottom: 20px; display: none; }
  #terms-gate h2 { font-size: 1.15rem; margin: 0 0 4px; }
  #terms-gate .intro { color: #77706a; font-size: 0.9rem; margin: 0 0 14px; }
  #terms-body { max-height: 340px; overflow-y: auto; border: 1px solid var(--border);
         border-radius: 8px; padding: 14px 18px; background: #fffdfb; font-size: 0.88rem;
         line-height: 1.5; }
  #terms-body h3 { font-size: 0.95rem; margin: 1.1em 0 0.3em; }
  #terms-body > :first-child { margin-top: 0; }
  #terms-gate .agree { display: block; margin: 14px 0 12px; font-size: 0.92rem; font-weight: 600; }
  #terms-gate .agree input { margin-right: 8px; }
  #terms-msg { margin-top: 8px; min-height: 1.1em; font-size: 0.88rem; color: #a3352b; }

  #userbar { display: none; justify-content: space-between; align-items: center;
         font-size: 0.85rem; color: #77706a; margin-bottom: 14px; }
  #userbar button { padding: 5px 12px; font-size: 0.8rem; background: none;
         color: var(--accent); border: 1px solid var(--border); }
  #login-section { background: white; border: 1px solid var(--border); border-radius: 10px;
         padding: 20px; margin-bottom: 20px; max-width: 380px; display: none; }
  #login-section p { margin-top: 0; font-size: 0.9rem; color: #77706a; }
  #login-section input { width: 100%; margin-bottom: 10px; padding: 10px;
         border: 1px solid var(--border); border-radius: 6px; }
  #login-error { color: #a3352b; font-size: 0.9rem; margin-top: 8px; min-height: 1.1em; }
  #models { background: white; border: 1px solid var(--border); border-radius: 10px;
         padding: 14px 20px; margin-bottom: 20px; font-size: 0.9rem; display: none; }
  #models h2 { font-size: 1rem; margin: 0 0 10px; }
  #models ul { list-style: none; margin: 0; padding: 0; }
  #models li { display: flex; justify-content: space-between; align-items: center;
         gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); }
  #models li:first-child { border-top: none; }
  #models .meta { color: #77706a; font-size: 0.82rem; }
  #account, #activity { background: white; border: 1px solid var(--border); border-radius: 10px;
         padding: 14px 20px; margin-bottom: 20px; font-size: 0.9rem; display: none; }
  #account summary, #activity summary { cursor: pointer; font-weight: 600; color: var(--accent); }
  #account form { margin-top: 12px; max-width: 340px; }
  #account input { width: 100%; margin-bottom: 10px; padding: 9px;
         border: 1px solid var(--border); border-radius: 6px; }
  #account .note { color: #77706a; font-size: 0.85rem; margin: 0 0 10px; }
  #pw-msg { margin-top: 8px; min-height: 1.1em; font-size: 0.88rem; }
  #pw-msg.err { color: #a3352b; }
  #pw-msg.ok { color: #3f7a3f; }
  #admin { background: white; border: 1px solid var(--border); border-radius: 10px;
         padding: 14px 20px; margin-bottom: 20px; font-size: 0.9rem; display: none; }
  #admin summary { cursor: pointer; font-weight: 600; color: var(--accent); }
  #admin form { margin: 12px 0; max-width: 340px; }
  #admin input[type=text] { width: 100%; margin-bottom: 10px; padding: 9px;
         border: 1px solid var(--border); border-radius: 6px; }
  #admin .note { color: #77706a; font-size: 0.85rem; margin: 0 0 10px; }
  #admin .check { display: block; margin-bottom: 10px; font-size: 0.88rem; }
  #admin .check input { width: auto; margin-right: 6px; }
  #new-user-msg { margin-top: 8px; min-height: 1.1em; font-size: 0.88rem; }
  #new-user-msg.err { color: #a3352b; }
  #new-user-msg.ok { color: #3f7a3f; }
  #new-user-msg code { background: #f0ece6; padding: 2px 6px; border-radius: 3px;
         font-family: ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all; }
  #admin table { border-collapse: collapse; width: 100%; margin-top: 6px; font-size: 0.84rem; }
  #admin th, #admin td { border-bottom: 1px solid var(--border); padding: 6px; text-align: left; }
  #admin th { color: #77706a; font-weight: 600; }
  #admin td.off { color: #a3352b; }
  #admin td button { padding: 3px 8px; font-size: 0.76rem; background: none;
         color: var(--accent); border: 1px solid var(--border); margin-right: 4px; }

  #activity table { border-collapse: collapse; width: 100%; margin-top: 12px; font-size: 0.83rem; }
  #activity th, #activity td { border-bottom: 1px solid var(--border); padding: 5px 6px;
         text-align: left; vertical-align: top; }
  #activity th { color: #77706a; font-weight: 600; }
  #activity td.denied { color: #a3352b; font-weight: 600; }
  #activity .detail { color: #77706a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
         font-size: 0.78rem; word-break: break-all; }
  #models button { padding: 4px 10px; font-size: 0.78rem; background: none;
         color: #a3352b; border: 1px solid var(--border); }
  #chat-section .panel-title { font-size: 1.1rem; }
