:root {
  /* Claude-like warm neutral palette */
  --bg: #f6f3ee;
  --panel: #fffdf9;
  --line: #e9e2d8;
  --text: #26231d;
  --muted: #7c756a;
  --accent: #d97706;
  --accent-soft: #fff3e2;
  --user-bubble: #f3ede4;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: Inter, -apple-system, Segoe UI, Roboto, PingFang SC, Microsoft YaHei, sans-serif; }
body.no-scroll { overflow: hidden; }
.app { display: flex; height: 100dvh; min-height: 100dvh; }
.sidebar { width: 240px; border-right: 1px solid var(--line); background: #f1ece3; display: flex; flex-direction: column; min-height: 0; }
.sidebar-header { padding: 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.sidebar-header h1 { margin: 0; font-size: 14px; }
.sidebar-header button { border: 1px solid #e8dcc8; background: #fff8ee; color: #5e4930; border-radius: 7px; padding: 6px 8px; cursor: pointer; font-size: 12px; font-weight: 600; }
.sidebar-header button:hover { background: #fff2df; }
.session-list { overflow: auto; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.session-item { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; cursor: pointer; }
.session-item.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(217,119,6,.2); }
.session-item .title { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.session-item .sub { font-size: 11px; color: var(--muted); }

.main { flex: 1; display: flex; flex-direction: column; }
.topbar { height: 48px; border-bottom: 1px solid var(--line); background: var(--panel); display: flex; justify-content: space-between; align-items: center; padding: 0 12px; }
.topbar-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.menu-btn { display: none; border: 1px solid #eadcc7; background: #fff8ee; color: #6a4a2c; border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; }
.menu-btn:hover { background: #fff2df; }
.mobile-backdrop { display: none; }
.model-picker { display: flex; align-items: center; gap: 8px; }
.model-picker label { font-size: 12px; color: var(--muted); }
.model-picker select { min-width: 220px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 13px; }
.badge { font-size: 11px; color: #6f665a; padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); border: 1px solid #f3dfc2; }

.chat-area { flex: 1; overflow: auto; padding: 14px 14px 94px; display: flex; flex-direction: column; gap: 8px; }
.empty-state { margin: auto; text-align: center; padding: 20px; color: var(--muted); }
.empty-state .empty-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state .empty-sub { font-size: 13px; line-height: 1.6; }
.msg { max-width: 860px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
.msg.user { margin-left: auto; background: var(--user-bubble); border-color: #e7dccb; }
.msg .role { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg .content { white-space: pre-wrap; line-height: 1.35; font-size: 13px; }
.msg .content p { margin: 0 0 2px; }
.msg .content p:last-child { margin-bottom: 0; }
.msg .content h1, .msg .content h2, .msg .content h3, .msg .content h4, .msg .content h5, .msg .content h6 {
  margin: 5px 0 2px;
  line-height: 1.25;
  font-size: 13px;
}
.msg .content ul, .msg .content ol { margin: 1px 0 2px 16px; padding: 0; }
.msg .content li { margin: 1px 0; }
.msg .content li > p { margin: 0; display: inline; }
.msg .content strong { font-weight: 700; }
.msg .content code { background: #f3f3ef; border: 1px solid #e5e2d8; padding: 0 4px; border-radius: 4px; font-size: 11px; }
.msg .content pre { margin: 4px 0; background: #f7f6f1; border: 1px solid #e5e2d8; padding: 7px; border-radius: 6px; overflow-x: auto; }
.msg .content blockquote { margin: 4px 0; padding: 4px 8px; border-left: 2px solid #d8d4c5; background: #faf9f4; color: #5f5b50; }
.msg .content a { color: #9a3412; text-decoration-color: #d97706; }
.msg .content a:hover { color: #b45309; }
.msg .meta { margin-top: 4px; color: var(--muted); font-size: 11px; }

.chain-box { margin-top: 5px; border: 1px dashed #d4d1c4; background: #faf9f5; border-radius: 7px; padding: 6px; font-size: 11px; color: #5a574e; }
.chain-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.chain-seg { display: flex; align-items: baseline; gap: 5px; background: #fff; border: 1px solid #e7e2d2; border-radius: 6px; padding: 3px 6px; }
.chain-seg .k { font-weight: 600; color: #686354; font-size: 11px; }
.chain-seg .v { font-weight: 600; font-size: 11px; }
.chain-seg-thinking .v { color: #b45309; }
.chain-seg-steps .v { color: #7c5b2a; }
.chain-seg-tokens .v { color: #9a3412; }
.chain-sub { margin-top: 4px; color: #7a766b; font-size: 10px; }
.thinking { color: #7b7160; font-size: 13px; }

.composer { position: fixed; right: 0; bottom: 0; left: 240px; background: linear-gradient(to top, #f7f7f4 72%, rgba(247,247,244,.72)); padding: 8px 10px 10px; border-top: 1px solid var(--line); }
#inputBox { width: 100%; border: 1px solid var(--line); border-radius: 8px; resize: none; padding: 8px 10px; font-size: 13px; line-height: 1.35; }
.composer-actions { margin-top: 6px; display: flex; justify-content: space-between; align-items: center; }
.hint { font-size: 11px; color: var(--muted); }
#sendBtn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 12px; font-weight: 600; }
#sendBtn:hover { filter: brightness(0.97); }
#sendBtn:disabled { opacity: .6; cursor: not-allowed; }

@media (max-width: 960px) {
  .sidebar { width: 190px; }
  .composer { left: 190px; }
  .model-picker select { min-width: 160px; }
  .chain-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app { height: auto; min-height: 100dvh; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(84vw, 320px);
    height: 100dvh;
    z-index: 30;
    border-right: 1px solid var(--line);
    border-bottom: none;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
    background: #f1ece3;
  }
  .sidebar.open { transform: translateX(0); }

  .mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.28);
    z-index: 20;
  }
  .mobile-backdrop.open { display: block; }

  .sidebar-header { padding: 12px; }
  .sidebar-header h1 { font-size: 15px; }
  .sidebar-header button { font-size: 13px; padding: 8px 10px; }

  .session-list {
    gap: 8px;
    padding: 8px 10px 12px;
  }

  .main { min-height: 100dvh; width: 100%; }

  .topbar {
    height: auto;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
  }

  .topbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }

  .menu-btn { display: inline-flex; align-items: center; gap: 6px; }

  .model-picker {
    width: 100%;
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 6px 8px;
    align-items: center;
  }

  .model-picker select {
    min-width: 0;
    width: 100%;
    font-size: 14px;
    padding: 8px 10px;
  }

  .badge { align-self: flex-start; font-size: 12px; }

  .chat-area {
    padding: 10px 10px 12px;
    gap: 8px;
  }

  .msg {
    max-width: 100%;
    border-radius: 10px;
    padding: 9px 10px;
  }

  .msg .content { font-size: 14px; line-height: 1.5; }

  .composer {
    position: sticky;
    left: auto;
    right: auto;
    bottom: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: #f7f7f4;
  }

  #inputBox {
    min-height: 88px;
    font-size: 14px;
  }

  .composer-actions {
    gap: 8px;
    align-items: flex-start;
    flex-direction: column;
  }

  #sendBtn {
    width: 100%;
    font-size: 14px;
    padding: 10px 12px;
  }

  .hint { font-size: 12px; }
}
