/* ===================== Deep Research Workbench ===================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e6e8f0;
  --text: #1a1d29;
  --text-2: #6b7186;
  --text-3: #9aa0b5;
  --accent: #5b5bd6;
  --accent-2: #7c6ff0;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --amber: #d97706;
  --amber-soft: #fdf1e1;
  --red: #dc2626;
  --red-soft: #fdecec;
  --blue: #2563eb;
  --shadow: 0 8px 30px rgba(20, 24, 60, .08);
  --shadow-sm: 0 2px 10px rgba(20, 24, 60, .06);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 264px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}
html[data-theme="dark"] {
  --bg: #10131c;
  --surface: #171b27;
  --surface-2: #1f2433;
  --border: #2a3042;
  --text: #e8eaf2;
  --text-2: #a6adc2;
  --text-3: #6b7289;
  --accent: #7c7cff;
  --accent-2: #9a8cff;
  --accent-soft: #232540;
  --accent-text: #b0a8ff;
  --green: #34d399;
  --green-soft: #12352a;
  --amber: #fbbf24;
  --amber-soft: #3a2d15;
  --red: #f87171;
  --red-soft: #3a1c1c;
  --blue: #60a5fa;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; font-size: 15px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: var(--text); }
a { color: var(--accent); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== Login ===================== */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, var(--accent-soft), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 36px 34px; box-shadow: var(--shadow);
}
.login-logo { font-size: 46px; text-align: center; }
.login-card h1 { text-align: center; margin: 14px 0 6px; font-size: 24px; letter-spacing: .5px; }
.login-sub { text-align: center; color: var(--text-2); margin: 0 0 26px; font-size: 13.5px; }
#login-form label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--text-2); }
#login-form input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 15px; outline: none; transition: border-color .15s;
}
#login-form input:focus { border-color: var(--accent); background: var(--surface); }
.form-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  transition: background .15s, transform .05s, box-shadow .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 4px 14px rgba(91,91,214,.35); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.ghost:hover { background: var(--border); }
.btn.soft { background: var(--accent-soft); color: var(--accent-text); }
.btn.soft:hover { filter: brightness(1.03); }
.btn.danger-soft { background: var(--red-soft); color: var(--red); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-2); font-size: 16px; transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.plus { font-size: 18px; font-weight: 400; line-height: 0; }

/* ===================== App shell ===================== */
#app-shell { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); height: 100%;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 8px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.brand-logo { font-size: 22px; }
#sidebar-close { display: none; }
.new-chat { margin: 6px 14px 12px; width: calc(100% - 28px); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14.5px; font-weight: 500; text-align: left; transition: background .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-ico { font-size: 17px; width: 20px; text-align: center; }

#conv-list-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 14px 10px 8px; }
.conv-list-title { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .8px; padding: 0 8px 8px; font-weight: 600; }
.conv-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.conv-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 9px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; font-size: 14px; transition: background .15s;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-soft); color: var(--accent-text); }
.conv-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .conv-del { opacity: 0; transition: opacity .15s; }
.conv-item:hover .conv-del { opacity: 1; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-user { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; position: relative; }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view-header { padding: 18px 26px 4px; }
.view-header h2 { margin: 0; font-size: 20px; }
.view-header .sub { color: var(--text-2); margin: 5px 0 0; font-size: 13.5px; }

.sidebar-mask { display: none; }

/* ===================== Chat ===================== */
#chat-header { padding: 12px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; min-height: 52px; }
#chat-header .conv-title-h { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
#chat-header .conv-meta { color: var(--text-3); font-size: 12px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12.5px; }
.breadcrumb a { color: var(--accent); cursor: pointer; }

.messages { flex: 1; overflow-y: auto; padding: 26px 0 18px; scroll-behavior: smooth; }
.msg-row { max-width: 780px; margin: 0 auto; padding: 6px 22px; display: flex; gap: 14px; }
.msg-avatar { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 17px; margin-top: 4px; }
.msg-row.user .msg-avatar { background: var(--accent-soft); }
.msg-row.assistant .msg-avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.msg-body { flex: 1; min-width: 0; }
.msg-row.user .msg-body {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px 14px 4px 14px;
  padding: 11px 15px; line-height: 1.6;
}
.msg-row.assistant .msg-body { line-height: 1.65; }
.msg-actions { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity .15s; }
.msg-row:hover .msg-actions { opacity: 1; }
.msg-actions .icon-btn { font-size: 14px; }

/* markdown */
.md { word-wrap: break-word; overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 10px; line-height: 1.35; }
.md h1 { font-size: 1.5em; } .md h2 { font-size: 1.3em; } .md h3 { font-size: 1.12em; }
.md p { margin: 9px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 4px 0; }
.md code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.md pre { background: #0f1420; color: #e6edf3; padding: 14px 16px; border-radius: 12px; overflow-x: auto; margin: 12px 0; position: relative; }
.md pre code { background: transparent; border: none; padding: 0; font-size: 13px; color: inherit; }
.md pre code.hljs { background: transparent; padding: 0; }
.md blockquote { border-left: 3px solid var(--accent); margin: 10px 0; padding: 4px 14px; color: var(--text-2); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.md table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md tr:nth-child(even) td { background: var(--surface-2); }
.md img { max-width: 100%; border-radius: 8px; }
.md a { text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.copy-code-btn {
  position: absolute; top: 8px; right: 8px; padding: 3px 8px; font-size: 11px; border-radius: 7px;
  background: rgba(255,255,255,.1); color: #c8d1dc; opacity: 0; transition: opacity .15s;
}
.md pre:hover .copy-code-btn { opacity: 1; }

/* sources */
.sources-block { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.sources-title { font-size: 12px; color: var(--text-3); font-weight: 600; margin-bottom: 8px; }
.sources-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.source-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px;
  font-size: 12.5px; display: flex; flex-direction: column; gap: 5px; transition: border-color .15s;
}
.source-card .src-top { display: flex; align-items: center; gap: 7px; }
.source-card .src-idx { width: 20px; height: 20px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.source-card .src-title { font-weight: 600; color: var(--text); line-height: 1.3; }
.source-card .src-site { color: var(--text-3); font-size: 11px; }
.source-card .src-snippet { color: var(--text-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.source-card .src-foot { display: flex; justify-content: space-between; align-items: center; }
.source-card .src-open { font-size: 12px; color: var(--accent); text-decoration: none; font-weight: 600; }
.bookmark-btn { font-size: 12px; padding: 3px 9px; border-radius: 7px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.bookmark-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.bookmark-btn.saved { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }

/* composer */
.composer-wrap { padding: 12px 22px 18px; }
.composer {
  max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  width: 100%; border: none; resize: none; background: transparent; padding: 15px 16px 4px;
  font-size: 15px; line-height: 1.5; outline: none; max-height: 220px; min-height: 30px;
}
.composer-tools { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; gap: 10px; }
.composer-left { display: flex; align-items: center; gap: 8px; }
.toggle {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--border); font-size: 13px; color: var(--text-2); cursor: pointer; transition: all .15s; font-weight: 500;
}
.toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.toggle .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.toggle.on .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.send-btn {
  width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 18px; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px rgba(91,91,214,.35); transition: filter .15s;
}
.send-btn:hover { filter: brightness(1.06); }
.send-btn:disabled { opacity: .5; }
.composer-hint { max-width: 780px; margin: 8px auto 0; font-size: 12px; color: var(--text-3); text-align: center; }

/* typing */
.typing { display: flex; gap: 5px; align-items: center; padding: 10px 0; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; transform: scale(.85);} 40% { opacity: 1; transform: scale(1);} }

/* empty chat */
.empty-chat { height: 100%; display: flex; align-items: center; justify-content: center; }
.empty-chat-inner { text-align: center; max-width: 460px; padding: 30px; }
.empty-chat .ec-icon { font-size: 54px; margin-bottom: 14px; }
.empty-chat h2 { margin: 0 0 8px; font-size: 22px; }
.empty-chat p { color: var(--text-2); margin: 0 0 22px; font-size: 14px; line-height: 1.6; }
.ec-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ec-chip { padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; color: var(--text-2); cursor: pointer; }
.ec-chip:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }

/* ===================== Research ===================== */
.research-create { max-width: 760px; margin: 8px auto; padding: 10px 22px 0; width: 100%; }
.research-form { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow-sm); }
.research-form label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 8px; }
.research-form textarea { width: 100%; min-height: 74px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 15px; background: var(--surface-2); outline: none; resize: vertical; }
.research-form textarea:focus { border-color: var(--accent); background: var(--surface); }
.research-form .row { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.research-hints { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.research-hint { font-size: 12.5px; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 5px 11px; cursor: pointer; }

.research-workspace { max-width: 820px; margin: 6px auto; padding: 8px 22px 30px; width: 100%; }
.rw-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.rw-head h3 { margin: 0; font-size: 18px; flex: 1; min-width: 0; }
.status-pill { padding: 5px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 600; }
.status-pill.running { background: var(--amber-soft); color: var(--amber); }
.status-pill.completed { background: var(--green-soft); color: var(--green); }
.status-pill.failed { background: var(--red-soft); color: var(--red); }

.rw-progress { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.rw-progress h4 { margin: 0 0 14px; font-size: 14px; color: var(--text-2); font-weight: 600; }
.step-list { display: flex; flex-direction: column; gap: 6px; }
.step-item { display: flex; align-items: center; gap: 11px; font-size: 14px; color: var(--text-2); padding: 7px 10px; border-radius: 10px; background: var(--surface-2); }
.step-item .step-ico { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.step-item.running .step-ico { background: var(--amber-soft); }
.step-item.done .step-ico { background: var(--green-soft); }
.step-item.failed .step-ico { background: var(--red-soft); }
.step-item .step-label { flex: 1; }
.step-item.running .step-label { color: var(--text); font-weight: 500; }
.step-item .step-detail { color: var(--text-3); font-size: 12.5px; }
.step-item.running .spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--amber); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.rw-sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.rw-sources h4 { grid-column: 1 / -1; margin: 4px 0 2px; font-size: 14px; color: var(--text-2); }

.report-view { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px 28px; box-shadow: var(--shadow-sm); }
.report-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.report-tools .report-title { font-weight: 700; font-size: 16px; flex: 1; min-width: 0; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===================== Projects ===================== */
.projects-wrap { max-width: 900px; margin: 0 auto; width: 100%; padding: 10px 22px 30px; }
.projects-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.project-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.project-card .pc-ico { font-size: 30px; margin-bottom: 10px; }
.project-card .pc-name { font-weight: 700; font-size: 16px; margin-bottom: 5px; }
.project-card .pc-desc { color: var(--text-2); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.project-card .pc-meta { color: var(--text-3); font-size: 12px; margin-top: 12px; }

/* project detail */
.pd-head { display: flex; align-items: center; gap: 14px; padding: 14px 0 4px; flex-wrap: wrap; }
.pd-head .back { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 14px; }
.pd-head .pd-title { font-size: 19px; font-weight: 700; }
.pd-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 12px 0; overflow-x: auto; }
.pd-tab { padding: 10px 16px; font-size: 14px; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.pd-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.pd-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* bookmarks (资料库) */
.bookmarks-wrap { max-width: 860px; margin: 0 auto; width: 100%; padding: 6px 22px 30px; }
.bookmarks-search { position: relative; max-width: 420px; margin-bottom: 16px; }
.bookmarks-search input { width: 100%; padding: 10px 14px 10px 36px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); font-size: 14px; outline: none; }
.bookmarks-search input:focus { border-color: var(--accent); }
.bookmarks-search .srch-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.bookmarks-list { display: flex; flex-direction: column; gap: 10px; }
.bookmark-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.bm-head { display: flex; align-items: center; gap: 10px; }
.bm-title { font-weight: 600; flex: 1; }
.bm-title a { color: var(--text); text-decoration: none; }
.bm-title a:hover { color: var(--accent); }
.bm-url { color: var(--accent); font-size: 12.5px; text-decoration: none; word-break: break-all; }
.bm-snippet { color: var(--text-2); font-size: 13px; margin-top: 7px; line-height: 1.5; }
.bm-meta { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; margin-top: 9px; }
.bm-site { background: var(--surface-2); padding: 2px 9px; border-radius: 12px; font-size: 11px; }

/* notes */
.notes-wrap { max-width: 860px; margin: 0 auto; width: 100%; padding: 6px 22px 30px; }
.note-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.note-item textarea { width: 100%; border: none; outline: none; background: transparent; font-size: 14.5px; line-height: 1.6; min-height: 90px; resize: vertical; }
.note-item .note-foot { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }

/* ===================== History ===================== */
.history-list { max-width: 860px; margin: 0 auto; width: 100%; padding: 6px 22px 30px; display: flex; flex-direction: column; gap: 12px; }
.history-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; cursor: pointer; transition: box-shadow .15s; }
.history-item:hover { box-shadow: var(--shadow-sm); }
.hist-ico { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.hist-main { flex: 1; min-width: 0; }
.hist-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-meta { color: var(--text-3); font-size: 12.5px; margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }
.hist-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ===================== Generic ===================== */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty-state { text-align: center; color: var(--text-3); padding: 60px 20px; }
.empty-state .es-ico { font-size: 44px; margin-bottom: 12px; }
.empty-state p { margin: 6px 0; }

.toast-container { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; max-width: 340px; animation: toast-in .2s ease; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* modal */
.modal-mask { position: fixed; inset: 0; background: rgba(10,14,30,.5); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: 16px; padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { color: var(--text-2); font-size: 14px; margin: 0 0 18px; }
.modal input, .modal textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px; background: var(--surface-2); outline: none; margin-bottom: 14px; }
.modal input:focus, .modal textarea:focus { border-color: var(--accent); background: var(--surface); }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; }

/* report viewer in project/report tab */
.report-list-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.report-list-item .rl-title { font-weight: 600; flex: 1; }
.report-list-item .rl-date { color: var(--text-3); font-size: 12.5px; }

/* code copy feedback on toast handled by .toast */

/* ===================== Responsive ===================== */
@media (max-width: 820px) {
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  #app-shell.sidebar-open #sidebar { transform: none; }
  #sidebar-close { display: inline-flex; }
  .sidebar-mask { position: fixed; inset: 0; background: rgba(10,14,30,.4); z-index: 35; }
  #app-shell.sidebar-open .sidebar-mask { display: block; }
  #main { width: 100%; }
  .msg-row { padding: 6px 14px; gap: 10px; }
  .msg-actions { opacity: 1; }
  .composer-wrap { padding: 10px 12px 14px; }
  .view-header { padding: 14px 16px 4px; }
  .projects-wrap, .history-list, .research-workspace, .research-create, .bookmarks-wrap, .notes-wrap { padding-left: 14px; padding-right: 14px; }
  .report-view { padding: 18px 16px; }
  .toast-container { left: 14px; right: 14px; top: 14px; align-items: stretch; }
}
@media (max-width: 480px) {
  .sources-grid, .rw-sources { grid-template-columns: 1fr; }
}
