:root {
  --bg: #f4f8ff;
  --bg-2: #ffffff;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --line: #d7e4f4;
  --line-strong: #a8bfdc;
  --text: #142f4f;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #1e40af;
  --green: #15803d;
  --red: #b91c1c;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(30, 64, 175, .10);
  --radius: 18px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(96,165,250,.20), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(191,219,254,.35), transparent 30rem),
    linear-gradient(135deg, #eef6ff 0%, #f8fbff 100%);
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
body.is-busy { cursor: progress; }
a { color: inherit; }

#app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  transition: grid-template-columns .2s ease;
}
body.sidebar-collapsed #app-shell { grid-template-columns: 76px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(239,246,255,.92) 100%);
  box-shadow: 14px 0 40px rgba(30,64,175,.06);
  z-index: 60;
}
.workspace-shell { min-width: 0; }
body.sidebar-collapsed .sidebar { padding-inline: 10px; overflow-x: hidden; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .brand strong,
body.sidebar-collapsed .brand em,
body.sidebar-collapsed .sidebar-search,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .nav-btn em,
body.sidebar-collapsed .sidebar-footer p { display: none; }
body.sidebar-collapsed .nav-btn { justify-content: center; padding-inline: 8px; }
body.sidebar-collapsed .nav-btn span { font-size: 12px; max-width: 42px; text-align: center; line-height: 1.25; }

.brand { display: flex; align-items: center; gap: 12px; user-select: none; }
.sidebar-brand { padding: 8px 8px 4px; cursor: pointer; }
.brand strong { display: block; font-size: 19px; letter-spacing: .01em; color: var(--accent-2); }
.brand em { display: block; color: var(--muted); font-style: normal; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; }
.brand-mark { width: 28px; height: 28px; position: relative; }
.brand-mark span { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); position: absolute; box-shadow: 0 0 0 4px rgba(37, 99, 235, .10); }
.brand-mark span:nth-child(1) { left: 2px; top: 3px; }
.brand-mark span:nth-child(2) { right: 3px; top: 7px; background: #38bdf8; }
.brand-mark span:nth-child(3) { left: 8px; bottom: 2px; background: #60a5fa; }
.brand-mark span:nth-child(4) { right: 1px; bottom: 4px; background: #1d4ed8; }

.sidebar-search { display: flex; align-items: center; gap: 8px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; padding: 0 10px; height: 40px; box-shadow: 0 8px 22px rgba(30,64,175,.04); }
.sidebar-search input { flex: 1; border: 0; outline: 0; background: transparent; min-width: 0; font-size: 13px; }

.main-nav { display: flex; flex-direction: column; align-items: stretch; gap: 6px; overflow: visible; }
.nav-section-label {
  margin: 8px 8px 2px;
  color: #8aa0bc;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.nav-btn {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  border-radius: 14px;
  transition: .18s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}
.nav-btn span { font-size: 14px; font-weight: 680; }
.nav-btn em { font-size: 10px; font-style: normal; letter-spacing: .08em; color: #8aa0bc; text-transform: uppercase; }
.nav-btn:hover { background: rgba(37,99,235,.08); color: var(--accent-2); border-color: rgba(37,99,235,.14); }
.nav-btn.active { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); color: #ffffff; font-weight: 720; box-shadow: 0 12px 24px rgba(37,99,235,.18); }
.nav-btn.active em { color: rgba(255,255,255,.72); }
body.user-mode [data-admin-only="true"] { display: none !important; }
[data-chem-only="true"] { display: none !important; }
body.chemistry-mode [data-chem-only="true"] { display: flex !important; }

.sidebar-footer { display: grid; gap: 10px; padding: 8px; border-top: 1px solid var(--line); }
.sidebar-footer p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.view-mode-toggle, .sidebar-collapse-toggle, .subject-mode-toggle, .account-action-toggle { width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px; background: #ffffff; color: var(--accent-2); font-size: 12px; font-weight: 760; cursor: pointer; }
.account-action-toggle.danger { color: var(--red); }
body.admin-mode .view-mode-toggle { color: #ffffff; background: #0f2f5f; border-color: #0f2f5f; }
body.chemistry-mode .subject-mode-toggle { color: #ffffff; background: #2563eb; border-color: #2563eb; }
body.sidebar-collapsed .view-mode-toggle, body.sidebar-collapsed .sidebar-collapse-toggle, body.sidebar-collapsed .subject-mode-toggle, body.sidebar-collapsed .account-action-toggle { padding-inline: 4px; font-size: 11px; }
kbd { color: var(--muted); border: 1px solid var(--line); border-bottom-color: var(--line-strong); border-radius: 6px; padding: 1px 6px; font-size: 11px; background: #ffffff; }
.api-status { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; color: var(--muted); font-size: 12px; text-align: center; background: #ffffff; }
.api-status.ok { color: var(--green); border-color: rgba(21,128,61,.25); background: rgba(240,253,244,.82); }
.api-status.error { color: var(--red); border-color: rgba(185,28,28,.25); background: rgba(254,242,242,.82); }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 16% 12%, rgba(96,165,250,.28), transparent 30rem),
    radial-gradient(circle at 84% 82%, rgba(37,99,235,.18), transparent 34rem),
    linear-gradient(145deg, #eaf3ff 0%, #f8fbff 52%, #edf5ff 100%);
}
.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(168,191,220,.8);
  border-radius: 26px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 30px 80px rgba(30,64,175,.16);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.login-brand strong { display: block; color: var(--accent-2); font-size: 21px; }
.login-brand em { display: block; color: var(--muted); font-size: 10px; font-style: normal; letter-spacing: .18em; text-transform: uppercase; }
.login-eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.login-card h1 { margin: 0; color: #102f57; font-size: 30px; letter-spacing: -.035em; }
.login-description { margin: 10px 0 24px; color: var(--muted); line-height: 1.7; }
.login-form, .password-form { display: grid; gap: 15px; }
.login-form label, .password-form label { display: grid; gap: 7px; color: #38536f; font-size: 12px; font-weight: 720; }
.login-form input, .password-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 12px 13px;
  background: #fff;
  outline: none;
}
.login-form input:focus, .password-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.1); }
.login-submit { width: 100%; padding-block: 12px; }
.login-error { margin: 0; padding: 10px 12px; border: 1px solid rgba(185,28,28,.25); border-radius: 11px; background: #fff3f3; color: var(--red); font-size: 12px; }
.login-security { margin: 20px 0 0; color: #8293a8; font-size: 11px; text-align: center; }
.password-dialog { width: min(440px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 20px; padding: 0; box-shadow: 0 28px 80px rgba(15,47,95,.25); }
.password-dialog::backdrop { background: rgba(15,47,95,.42); backdrop-filter: blur(3px); }
.password-form { padding: 24px; }
.password-form .checkbox-row { display: flex; grid-template-columns: none; align-items: center; gap: 9px; font-weight: 600; }
.password-form .checkbox-row input { width: auto; margin: 0; }
.account-security-list { display: grid; gap: 8px; margin-bottom: 18px; }
.account-security-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 11px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbff; }
.account-security-row strong, .account-security-row span { display: block; }
.account-security-row span { color: var(--muted); font-size: 11px; }

.app-view { max-width: 1480px; margin: 0 auto; padding: 28px 30px 46px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.page-head h1 { font-size: clamp(26px, 4vw, 42px); line-height: 1.08; margin: 4px 0 0; letter-spacing: -0.04em; }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .18em; font-size: 11px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

.panel, .knowledge-board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 16px; min-width: 0; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 720; margin-bottom: 12px; }
.panel-actions { display: inline-flex; gap: 6px; align-items: center; }
.scroll-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.panel-sticky-head { position: relative; z-index: 4; min-width: 0; padding-bottom: 10px; background: rgba(255,255,255,.98); border-bottom: 1px solid var(--line); }
.panel-sticky-head .panel-title { margin-bottom: 0; }
.panel-scroll-body { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding-top: 10px; padding-right: 3px; }
.mt { margin-top: 20px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.65; }

.primary-btn, .secondary-btn, .small-btn, .link-btn {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 680;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-btn:hover { background: #1d4ed8; }
.primary-btn.dark { background: #0f2f5f; }
.secondary-btn, .small-btn, .link-btn { background: #ffffff; color: var(--accent-2); border-color: var(--line); }
.secondary-btn:hover, .small-btn:hover { border-color: var(--line-strong); background: #edf5ff; }
.small-btn { padding: 6px 9px; font-size: 12px; border-radius: 999px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.button-row.vertical { flex-direction: column; align-items: stretch; }

.input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 11px;
  outline: 0;
  color: #111827;
  font-weight: 520;
  opacity: 1;
}
.input::placeholder, textarea::placeholder { color: #8996a8; font-weight: 400; opacity: 1; }
select option { color: #111827; background: #ffffff; }
.input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.textarea { resize: vertical; line-height: 1.55; }
.input.slim { max-width: 220px; }
.stack-form { display: grid; gap: 12px; }
.stack-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.stack-form .check-row { display: flex; align-items: center; gap: 8px; color: var(--text); }
.stack-form .check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.stack-form.compact { gap: 8px; }
.form-help { margin: -3px 0 0; color: #596779; font-size: 12px; line-height: 1.5; }
.operation-feedback { display: flex; align-items: flex-start; gap: 9px; border: 1px solid #b9cce6; border-radius: 12px; background: #f3f8ff; color: #234a78; padding: 10px 11px; font-size: 13px; line-height: 1.45; }
.operation-feedback b { flex: 0 0 auto; }
.operation-feedback.loading b { animation: pulse 1s ease-in-out infinite; }
.operation-feedback.success { border-color: #a9cfb7; background: #f1faf4; color: #2f6b46; }
.operation-feedback.error { border-color: #e2b3aa; background: #fff5f2; color: #993c2e; }
@keyframes pulse { 50% { opacity: .35; } }
.file-picker-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-input-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-picker-button { flex: 0 0 auto; font-size: 13px; }
.file-picked-name { min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-status { color: var(--muted); font-size: 12px; line-height: 1.45; margin-top: -6px; }
.file-status.ready { color: var(--green); font-weight: 700; }
.file-status.error { color: var(--red); font-weight: 700; }
.upload-result { display: grid; gap: 4px; border: 1px solid rgba(46,99,230,.22); background: rgba(46,99,230,.06); border-radius: 8px; padding: 11px 12px; }
.upload-result strong { color: var(--accent-strong); font-size: 13px; }
.upload-result span { color: var(--text); font-weight: 800; line-height: 1.35; }
.upload-result small { color: var(--muted); line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }

.stat-row, .result-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.result-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); margin-top: 16px; }
.stat-card { background: rgba(255, 255, 255, .86); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat-card b { display: block; font-size: 22px; line-height: 1; color: var(--accent-2); }
.stat-card span { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }

.three-column { display: grid; grid-template-columns: 280px minmax(0, 1fr) 360px; gap: 16px; align-items: stretch; }
.chat-workspace { grid-template-columns: 270px minmax(520px, 1fr) minmax(360px, .66fr); height: calc(100vh - 128px); min-height: 620px; }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.span-2 { grid-column: span 2; }
.side-panel, .insight-panel { min-height: calc(100vh - 142px); max-height: calc(100vh - 104px); overflow: auto; }

/* Chat */
.chat-workspace > .side-panel, .chat-workspace > .insight-panel { min-height: 0; max-height: none; height: 100%; }
.chat-sidebar { display: flex; flex-direction: column; }
.session-drawer { border: 1px solid var(--line); border-radius: 14px; padding: 8px; background: rgba(255,255,255,.54); }
.session-drawer summary { cursor: pointer; color: var(--accent-2); font-size: 12px; font-weight: 760; margin: 0 0 8px; }
.session-drawer .session-list { max-height: 230px; overflow: auto; padding-right: 3px; }
.paper-drawer { margin-top: 18px; }
.paper-drawer summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.paper-drawer summary em { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 650; }
.paper-drawer .paper-compact-list { max-height: 260px; overflow: auto; padding-right: 3px; }
.chat-paper-scope { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.chat-paper-scope .small-btn { width: 100%; border-radius: 10px; }
.chat-paper-scope .small-btn b { margin-left: 3px; }
.chat-paper-search { display: block; }
.chat-paper-search .input { width: 100%; padding: 9px 10px; }
.chat-paper-tools { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.chat-paper-tools > span:last-child { display: inline-flex; gap: 4px; }
.chat-paper-tools .small-btn { padding: 5px 7px; }
.chat-paper-hint { margin: 7px 1px 8px; line-height: 1.45; }
.chat-paper-option { grid-template-columns: 18px minmax(0, 1fr); align-items: start; cursor: pointer; }
.chat-paper-option input { margin: 3px 0 0; accent-color: var(--accent); }
.chat-paper-copy { min-width: 0; display: grid; gap: 3px; }
.chat-paper-option[hidden] { display: none !important; }
.research-goal-input { min-height: 136px; max-height: 240px; }
.chat-panel { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; height: 100%; padding: 0; overflow: hidden; }
.chat-history { min-height: 0; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.message { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; align-items: start; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #eaf2ff; display: grid; place-items: center; font-size: 12px; font-weight: 760; color: var(--accent-2); }
.message.assistant .avatar { background: #e7f7ef; color: #3f745f; }
.bubble { background: #ffffff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; line-height: 1.72; box-shadow: 0 8px 22px rgba(30, 64, 175, .05); max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble .answer-heading { margin-top: 14px; color: var(--accent-2); font-weight: 780; font-size: 15px; }
.bubble .answer-list { margin: 6px 0 12px 20px; padding: 0; }
.bubble .answer-list li { margin: 6px 0; }
.bubble strong { font-weight: 780; color: #16345d; }
.inline-code { display: inline; padding: 1px 5px; border-radius: 6px; font-size: 12px; }
.message.user .bubble { background: #e8f1ff; border-color: #b7cae8; }
.chat-form { border-top: 1px solid var(--line); padding: 14px; background: rgba(255,255,255,.88); }
.chat-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 12px; resize: vertical; background: #ffffff; outline: none; line-height: 1.55; }
.chat-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.session-list, .compact-list, .paper-list, .knowledge-card-list, .insight-list, .run-list, .memory-list { display: grid; gap: 8px; }
.session-item, .compact-item, .paper-item, .knowledge-card-button { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.72); border-radius: 14px; padding: 10px; display: grid; gap: 4px; }
.session-item { grid-template-columns: minmax(0, 1fr) auto; align-items: start; padding: 0; overflow: hidden; }
.session-main { border: 0; background: transparent; text-align: left; display: grid; gap: 4px; padding: 10px; min-width: 0; cursor: pointer; }
.delete-session { border: 0; background: transparent; color: var(--red); padding: 9px 10px; font-size: 12px; cursor: pointer; align-self: start; }
.delete-session:hover { background: rgba(181,77,60,.08); }
.session-item strong, .compact-item strong, .paper-item strong, .knowledge-card-button strong { font-size: 13px; }
.session-item span, .compact-item span, .paper-item span, .knowledge-card-button p, .knowledge-card-button span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.session-item em, .paper-item em { color: var(--accent); font-style: normal; font-size: 11px; }
.session-item.active, .compact-item.active, .paper-item.active, .knowledge-card-button.active { border-color: var(--accent); background: #eaf2ff; }
.paper-progress { display: grid; gap: 5px; margin-top: 4px; color: var(--muted); }
.paper-progress-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.paper-progress-row b, .paper-progress-row i { font-size: 11px; font-style: normal; font-weight: 650; color: var(--text); }
.paper-progress small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--muted); }
.insight-card { border: 1px solid var(--line); background: #ffffff; border-radius: 14px; padding: 11px; }
.insight-card span { display: block; color: var(--accent); font-size: 11px; margin-bottom: 4px; }
.insight-card strong { display: block; font-size: 13px; }
.insight-card p { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 6px 0 0; }
.json-detail { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: #ffffff; }
pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 11px; line-height: 1.5; color: #244665; max-height: 380px; overflow: auto; }

/* Library */
.library-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; }
.library-sidebar { height: calc(100vh - 122px); max-height: calc(100vh - 122px); }
.library-sidebar .library-search { margin-bottom: 10px; }
.knowledge-board { overflow: hidden; }
.knowledge-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.68); }
.knowledge-head h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.knowledge-head p { margin: 0; color: var(--muted); }
.knowledge-metrics { display: flex; gap: 8px; flex-wrap: wrap; justify-content: end; }
.knowledge-metrics span, .pill { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: #ffffff; color: var(--muted); font-size: 12px; }
.pill.mini { padding: 4px 8px; font-size: 11px; }
.library-tabs { padding: 12px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.knowledge-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 330px; height: 620px; min-height: 620px; align-items: stretch; }
.card-column, .detail-column { padding: 14px; max-height: none; height: 100%; min-height: 0; }
.detail-column { overflow: auto; scrollbar-gutter: stable; }
.card-column { border-right: 1px solid var(--line); }
.detail-column { border-left: 1px solid var(--line); background: rgba(255,255,255,.42); }
.graph-column { height: 620px; min-height: 0; align-self: start; }
.graph-shell { height: 620px; min-height: 0; }
.chat-graph-viewer { height: 300px; min-height: 300px; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; background: #f6faff; }
.graph-canvas { width: 100%; height: 100%; display: block; }
.detail-card h3 { margin: 4px 0 10px; font-size: 21px; }
.detail-card h4 { margin: 18px 0 8px; font-size: 13px; color: var(--accent-2); }
.detail-card p { line-height: 1.66; color: #1f3a5a; }
.pill-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-wrap.danger .pill { border-color: rgba(181,77,60,.24); color: var(--red); }
blockquote { margin: 10px 0; border-left: 3px solid var(--accent); padding: 9px 12px; background: #ffffff; border-radius: 0 12px 12px 0; color: #244665; line-height: 1.55; }
blockquote footer { margin-top: 6px; color: var(--muted); font-size: 12px; }
.mini-block { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; background: #ffffff; }
.mini-block p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.node-detail h3 { margin: 5px 0 8px; }
.node-detail p { color: var(--muted); line-height: 1.6; }

/* Papers */
.paper-workspace { align-items: stretch; }
.paper-workspace .panel { min-height: 240px; }
.paper-workspace > .panel { min-height: 0; }
.paper-queue-panel { display: grid; grid-template-rows: auto auto minmax(0, 1fr); align-content: stretch; gap: 10px; height: min(72vh, 760px); overflow: hidden; }
.paper-queue-panel .panel-title { margin-bottom: 0; align-items: start; }
.paper-queue-panel .panel-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; min-width: 0; }
.paper-list.tall { min-height: 0; max-height: none; overflow: auto; padding-right: 4px; }
.paper-control { display: flex; justify-content: space-between; gap: 18px; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.paper-control h2 { margin: 4px 0 4px; }
.batch-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 42px; padding: 0; color: var(--muted); font-size: 12px; }
.batch-toolbar .primary-btn { flex: 0 0 auto; white-space: nowrap; min-height: 38px; padding-inline: 18px; }
.paper-row-select { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; align-items: stretch; }
.paper-row-select .paper-item { width: 100%; }
.batch-check { display: grid; place-items: start center; padding-top: 16px; }
.batch-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.checkbox-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 16px; }
.result-preview-panel { height: min(62vh, 620px); min-height: 360px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248,251,255,.76); padding: 12px; }
.result-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-preview-head h3 { margin: 0; }
.result-preview-head span { color: var(--muted); font-size: 11px; text-align: right; }
.result-record-list { display: grid; grid-auto-rows: max-content; align-content: start; gap: 8px; }
.result-record { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.result-record summary { cursor: pointer; display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 10px 12px; color: var(--text); font-weight: 700; }
.result-record summary span { min-width: 0; overflow-wrap: anywhere; }
.result-record summary em { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-style: normal; font-weight: 500; }
.result-record[open] summary { border-bottom: 1px solid var(--line); background: #f6f9ff; }
.result-record-content { min-height: 0; }
.result-detail-placeholder { padding: 12px; color: var(--muted); font-size: 12px; line-height: 1.55; background: #fbfdff; }
.result-detail-placeholder p { margin: 0 0 8px; max-height: 76px; overflow: hidden; }
.result-detail-placeholder span { display: block; font-weight: 700; color: #526985; }
.result-record-text { padding: 12px; color: #3f526b; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.paper-result-figure { display: grid; gap: 10px; margin: 0; padding: 12px; background: #fff; }
.paper-result-figure img { display: block; width: 100%; max-height: 520px; object-fit: contain; border-radius: 9px; background: #f4f7fb; }
.paper-result-figure figcaption,
.paper-result-table-wrap figcaption { color: #536984; font-size: 12px; line-height: 1.6; }
.paper-result-table-wrap { padding: 12px; overflow: auto; background: #fff; }
.paper-result-table { width: 100%; min-width: 520px; border-collapse: collapse; color: #30445f; font-size: 12px; line-height: 1.45; }
.paper-result-table th,
.paper-result-table td { padding: 8px 10px; border: 1px solid #cfdbeb; text-align: left; vertical-align: top; white-space: normal; }
.paper-result-table th { position: sticky; top: 0; z-index: 1; background: #edf4ff; color: var(--text); font-weight: 700; }
.paper-result-table tbody tr:nth-child(even) { background: #f8fbff; }
.result-asset-missing { padding: 20px; border: 1px dashed #cbd8e9; border-radius: 9px; color: var(--muted); text-align: center; background: #f8fbff; }
.line-item { border-bottom: 1px solid var(--line); padding: 8px 0; margin: 0; display: grid; gap: 2px; }
.line-item b { font-size: 13px; }
.line-item span { color: var(--muted); font-size: 12px; line-height: 1.4; }

/* Molecule */
.molecule-page { grid-template-columns: 300px minmax(0, 1fr) 360px; }
.molecule-sidebar { height: calc(100vh - 142px); min-height: 620px; max-height: none; overflow: hidden; display: flex; flex-direction: column; }
.molecule-sidebar .panel-sticky-head .button-row { margin-top: 10px; }
.molecule-search-field { display: block; margin-top: 12px; }
.molecule-search-field .input { width: 100%; }
.molecule-index-scroll { flex: 1 1 auto; min-height: 220px; overflow-y: auto; overflow-x: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.molecule-virtual-spacer { position: relative; width: 100%; }
.molecule-virtual-items { position: absolute; inset: 0 0 auto 0; will-change: transform; }
.molecule-index-item { width: calc(100% - 2px); height: 58px; min-height: 58px; margin: 3px 1px; box-sizing: border-box; overflow: hidden; }
.molecule-index-item strong, .molecule-index-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.molecule-manage-tools { flex: 0 0 auto; max-height: 42%; overflow: auto; border-top: 1px solid var(--line); background: rgba(248,251,255,.94); }
.molecule-manage-tools > summary { cursor: pointer; padding: 10px 2px; color: var(--muted); font-size: 12px; font-weight: 800; }
.molecule-manage-body { padding-bottom: 12px; }
.molecule-list-status { padding: 10px 2px; }
.error-text { color: var(--danger); }
.molecule-evidence-text { max-height: 240px; overflow: auto; white-space: pre-wrap; line-height: 1.65; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbff; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.molecule-stage { padding: 0; overflow: hidden; }
.molecule-viewer { position: relative; min-height: 360px; border-radius: 15px; overflow: hidden; border: 1px solid var(--line); background: #f6faff; }
.molecule-viewer.small { height: 300px; min-height: 300px; }
.molecule-viewer.large { height: calc(100vh - 142px); min-height: 620px; border: 0; border-radius: 18px; }
.molecule-canvas { width: 100%; height: 100%; display: block; }
.molecule-three-host, .molecule-three-host canvas { width: 100%; height: 100%; display: block; }
.asset-group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.asset-group summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; list-style: none; }
.asset-group summary::-webkit-details-marker { display: none; }
.asset-group summary::before { content: "▸"; color: var(--muted); font-size: 12px; transform: translateY(-1px); }
.asset-group[open] summary::before { content: "▾"; }
.asset-group summary span { flex: 1; }
.asset-group summary b { min-width: 24px; text-align: center; padding: 2px 6px; border-radius: 999px; background: var(--soft); color: var(--text); }
.asset-group .compact-list { margin-top: 8px; }
.viewer-info { position: absolute; left: 10px; right: auto; bottom: 10px; max-width: calc(100% - 20px); display: flex; align-items: center; gap: 7px; box-sizing: border-box; background: rgba(255,255,255,.72); border: 1px solid rgba(191,210,235,.78); border-radius: 10px; padding: 6px 9px; backdrop-filter: blur(7px); pointer-events: none; }
.viewer-info strong { flex: 0 0 auto; display: inline; font-size: 12px; margin: 0; }
.viewer-info span { min-width: 0; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; line-height: 1.3; }
code { display: block; background: #ffffff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-family: var(--mono); overflow: auto; }
.descriptor-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 7px 0; margin: 0; }
.descriptor-row span { color: var(--muted); }
.descriptor-row b { color: var(--accent-2); }

/* Runs */
.runs-workspace { align-items: start; }
.run-item { border: 1px solid var(--line); border-radius: 14px; background: #ffffff; padding: 10px 12px; }
.run-item summary { cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.run-item summary span { color: var(--muted); font-size: 12px; }
.memory-card { border: 1px solid var(--line); border-radius: 14px; background: #ffffff; padding: 11px; }
.memory-card span, .memory-card em { color: var(--muted); font-size: 12px; font-style: normal; }
.memory-card p { margin: 8px 0; line-height: 1.55; }

.empty-state { display: grid; place-items: center; text-align: center; min-height: 300px; padding: 26px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin-bottom: 4px; }
.toast-zone { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; }
.toast { background: #ffffff; color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { border-color: rgba(181,77,60,.35); color: var(--red); }
.toast.info { border-color: rgba(83,111,159,.25); }

@media (max-width: 1180px) {
  .three-column, .molecule-page { grid-template-columns: 250px minmax(0, 1fr); }
  .chat-workspace { grid-template-columns: 250px minmax(0, 1fr); }
  .insight-panel { grid-column: span 2; min-height: auto; max-height: none; }
  .knowledge-grid { grid-template-columns: 280px minmax(0, 1fr); }
  .detail-column { grid-column: span 2; border-left: 0; border-top: 1px solid var(--line); }
  .stat-row, .result-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-view { padding: 18px 14px 34px; }
  .three-column, .two-column, .library-layout, .molecule-page { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .side-panel, .insight-panel { min-height: auto; max-height: none; }
  .knowledge-grid { grid-template-columns: 1fr; }
  .card-column, .detail-column { border: 0; max-height: none; }
  .graph-column, .graph-shell { height: 420px; min-height: 0; }
  .stat-row, .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paper-control { display: block; }
}

/* Step 3: jobs and curation */
.job-history { margin: 14px 0; min-width: 0; }
.job-history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.job-history-head > div { display: flex; align-items: baseline; gap: 9px; }
.job-history-head strong { color: var(--text); font-size: 14px; }
.job-history-head span { color: var(--muted); font-size: 11px; }
.job-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(300px, calc((100% - 16px) / 3)); grid-template-rows: 330px; gap: 8px; margin: 0; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 10px; scroll-snap-type: x proximity; scrollbar-color: #9eb3ce #edf2f7; }
.job-strip.muted { display: block; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); background: rgba(255,255,255,.58); }
.job-chip { border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: #ffffff; display: grid; grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto; gap: 7px; height: 320px; overflow: hidden; scroll-snap-align: start; }
.job-chip-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.job-chip strong { font-size: 12px; color: var(--accent-2); }
.job-chip span { font-size: 12px; color: var(--text); }
.job-chip em { font-size: 11px; font-style: normal; color: var(--muted); line-height: 1.35; }
.job-chip small { display: block; color: var(--muted); font-size: 10px; line-height: 1.35; }
.job-chip small.heartbeat { color: #6b7f99; }
.job-chip.running { border-color: rgba(83,111,159,.3); background: #f6faff; }
.job-chip.completed { border-color: rgba(77,132,103,.3); background: #f4faf4; }
.job-chip.failed { border-color: rgba(181,77,60,.34); background: #fff4ef; }
.job-stages { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(54px, 1fr)); gap: 3px; margin: 2px 0; padding: 0; }
.job-stages li { min-width: 0; display: grid; justify-items: center; gap: 3px; color: #9b958d; text-align: center; }
.job-stages li span { width: 100%; height: 4px; border-radius: 999px; background: rgba(97,84,73,.14); }
.job-stages li b { font-size: 9px; font-weight: 620; line-height: 1.15; }
.job-stages li.done { color: #48765e; }
.job-stages li.done span { background: #6b9f79; }
.job-stages li.active { color: #365d94; }
.job-stages li.active span { background: #547bb2; box-shadow: 0 0 0 3px rgba(84,123,178,.13); }
.job-stages li.failed { color: #a84232; }
.job-stages li.failed span { background: #b54d3c; }
.job-timeline, .job-error { border-top: 1px solid rgba(97,84,73,.12); padding-top: 6px; }
.job-timeline summary, .job-error summary { cursor: pointer; color: var(--accent-2); font-size: 10px; font-weight: 680; }
.job-timeline > div { display: grid; gap: 4px; max-height: 120px; overflow: auto; margin-top: 6px; }
.job-timeline small { display: grid; grid-template-columns: 58px 34px auto minmax(0,1fr); align-items: start; gap: 5px; border-left: 2px solid rgba(83,111,159,.22); padding-left: 6px; }
.job-timeline small time, .job-timeline small b, .job-timeline small i { font-size: 9px; font-style: normal; color: #6b7f99; }
.job-timeline small span { font-size: 10px; overflow-wrap: anywhere; }
.job-error code { display: block; max-height: 130px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; padding: 7px; border-radius: 8px; background: rgba(181,77,60,.07); color: #8f3529; font-size: 10px; }
.retry-job-btn { justify-self: start; }
.job-record-actions { display: flex; align-items: center; gap: 7px; margin-top: auto; }
.progress-bar { display: block; width: 100%; height: 8px; overflow: hidden; border-radius: 999px; background: rgba(97, 84, 73, .14); border: 1px solid rgba(97, 84, 73, .08); }
.progress-bar span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: linear-gradient(90deg, #4f74a8, #6b9f79); transition: width .24s ease; }
.progress-bar.queued span { background: linear-gradient(90deg, #9a8a72, #b8a777); }
.progress-bar.running span { background: linear-gradient(90deg, #4f74a8, #7b8fc4); }
.progress-bar.completed span { background: linear-gradient(90deg, #4d8467, #84a86c); }
.progress-bar.failed span { background: linear-gradient(90deg, #b54d3c, #cf8a45); }
.progress-bar.mini { height: 6px; }
.small-btn.loading, .secondary-btn.loading, .primary-btn.loading { opacity: .72; cursor: wait; }

.curation-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.curation-main, .curation-editor { max-height: calc(100vh - 124px); overflow: auto; }
.quality-head { display: flex; justify-content: space-between; gap: 18px; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 15px; margin-bottom: 14px; }
.quality-head h2 { margin: 2px 0 4px; font-size: 42px; letter-spacing: -0.04em; color: var(--accent-2); }
.quality-head p { margin: 0; color: var(--muted); line-height: 1.5; }
.quality-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: end; }
.bad { border-radius: 999px; padding: 6px 10px; font-size: 12px; border: 1px solid var(--line); background: #ffffff; }
.bad.blocker { border-color: rgba(181,77,60,.35); color: var(--red); }
.bad.warn { border-color: rgba(190,120,45,.35); color: var(--accent-2); }
.bad.info { border-color: rgba(83,111,159,.28); color: #2563eb; }
.issue-box { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: #ffffff; margin-bottom: 14px; }
.issue-box summary { cursor: pointer; font-weight: 720; }
.issue-list { display: grid; gap: 8px; margin-top: 10px; }
.issue { border-left: 3px solid var(--line); background: rgba(255,255,255,.76); border-radius: 0 12px 12px 0; padding: 8px 10px; }
.issue.blocker { border-left-color: var(--red); }
.issue.warn { border-left-color: var(--accent); }
.issue.info { border-left-color: #2563eb; }
.issue b { text-transform: uppercase; font-size: 11px; color: var(--accent-2); }
.issue span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.issue p { margin: 5px 0 0; line-height: 1.45; }
.curation-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.tab-btn { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: #ffffff; color: var(--muted); cursor: pointer; }
.tab-btn.active { border-color: var(--accent); color: var(--accent-2); background: #eaf2ff; }
.curation-object-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.curation-object { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.72); border-radius: 15px; padding: 11px; display: grid; gap: 5px; min-height: 114px; }
.curation-object.active { border-color: var(--accent); background: #eaf2ff; }
.curation-object span { font-size: 11px; color: var(--accent); }
.curation-object strong { font-size: 14px; }
.curation-object p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 12px; }
.curation-form { padding-bottom: 20px; }
.curation-form .textarea { min-height: 78px; }
.danger-btn { border: 1px solid rgba(181,77,60,.36); background: #fff4ef; color: var(--red); border-radius: 999px; padding: 9px 14px; cursor: pointer; }
.button-row.vertical { display: grid; }

@media (max-width: 1180px) {
  .curation-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .curation-editor { grid-column: span 2; max-height: none; }
}
@media (max-width: 820px) {
  .curation-layout { grid-template-columns: 1fr; }
  .curation-editor { grid-column: auto; }
}

/* Step 4: retrieval pipeline lab */
.retrieval-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.retrieval-sidebar, .retrieval-results { max-height: calc(100vh - 124px); overflow: auto; }
.retrieval-head { display: flex; justify-content: space-between; gap: 18px; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.retrieval-head h2 { margin: 2px 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.retrieval-head p { margin: 0; color: var(--muted); line-height: 1.55; }
.retrieval-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.retrieval-group { border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.66); padding: 12px; min-height: 220px; }
.retrieval-group .panel-title { margin-bottom: 8px; }
.retrieval-group .panel-title em { color: var(--muted); font-style: normal; font-size: 12px; }
.retrieval-card-list { display: grid; gap: 9px; max-height: 410px; overflow: auto; }
.retrieval-card { border: 1px solid var(--line); background: #ffffff; border-radius: 14px; padding: 10px 11px; display: grid; gap: 5px; }
.retrieval-card strong { font-size: 14px; }
.retrieval-card span, .retrieval-card em { font-size: 11px; color: var(--muted); font-style: normal; }
.retrieval-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.48; }
.retrieval-card ol { margin: 2px 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.45; padding: 0; }
.diagnostic-list { display: grid; gap: 9px; }
.diagnostic-card { border: 1px solid var(--line); border-radius: 14px; background: #ffffff; padding: 9px 11px; }
.diagnostic-card summary { cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.diagnostic-card summary span { color: var(--accent-2); font-size: 12px; }
.diagnostic-card pre { max-height: 260px; overflow: auto; }

@media (max-width: 1180px) {
  .retrieval-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .retrieval-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .retrieval-layout { grid-template-columns: 1fr; }
  .retrieval-sidebar, .retrieval-results { max-height: none; }
}

/* Step 5: hypothesis and proposal studio */
.proposal-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr) 460px; gap: 16px; align-items: start; }
.proposal-sidebar, .proposal-list-panel, .proposal-detail-panel { max-height: calc(100vh - 124px); overflow: auto; }
.proposal-sidebar.scroll-shell, .proposal-list-panel.scroll-shell { height: calc(100vh - 124px); overflow: hidden; }
.proposal-status-row { display: flex; flex-wrap: wrap; gap: 8px; }
.proposal-list { display: grid; gap: 10px; }
.proposal-item { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.74); border-radius: 16px; padding: 12px; display: grid; gap: 6px; }
.proposal-item.active { border-color: var(--accent); background: #eaf2ff; }
.proposal-item span { color: var(--accent); font-size: 11px; }
.proposal-item strong { font-size: 15px; line-height: 1.35; }
.proposal-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.52; }
.proposal-item em { color: var(--muted); font-style: normal; font-size: 11px; }
.proposal-detail h3 { font-size: 22px; margin-top: 6px; }
.proposal-actions { margin: 12px 0 16px; }
.proposal-form { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; margin: 14px 0; }
.source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.source-grid div { border: 1px solid var(--line); border-radius: 12px; background: #ffffff; padding: 8px 10px; display: grid; gap: 3px; }
.source-grid b { font-size: 12px; color: var(--accent-2); }
.source-grid span { font-size: 12px; color: var(--muted); word-break: break-word; }
.deep-dive { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.deep-dive ol { margin: 8px 0 12px 20px; padding: 0; color: var(--muted); line-height: 1.55; }
.deep-dive p { color: var(--muted); line-height: 1.62; }

@media (max-width: 1180px) {
  .proposal-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .proposal-detail-panel { grid-column: span 2; max-height: none; }
}
@media (max-width: 820px) {
  .proposal-layout { grid-template-columns: 1fr; }
  .proposal-detail-panel { grid-column: auto; }
  .proposal-sidebar, .proposal-list-panel, .proposal-detail-panel { max-height: none; }
}

/* Step 6: project-level memory */
.project-brief { border: 1px solid var(--line); background: rgba(255,255,255,.76); border-radius: 14px; padding: 10px 11px; margin-top: 8px; display: grid; gap: 6px; }
.project-brief strong { font-size: 13px; color: var(--accent-2); }
.project-brief p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 12px; }
.project-brief em, .compact-hint { color: var(--muted); font-size: 11px; font-style: normal; }
.project-workspace { align-items: start; }
.project-main, .project-workspace .insight-panel { max-height: calc(100vh - 124px); overflow: auto; }
.project-sidebar { height: calc(100vh - 124px); min-height: 0; max-height: calc(100vh - 124px); overflow: hidden; }
.project-list .compact-item em { display: block; color: var(--muted); font-style: normal; font-size: 11px; line-height: 1.35; margin-top: 2px; }
.project-head h2 { font-size: 28px; letter-spacing: -0.02em; }
.project-form { border-top: 1px solid var(--line); padding-top: 14px; }
.association-fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin: 0; }
.association-fieldset legend { color: var(--text); font-size: 13px; font-weight: 700; padding: 0 5px; }
.association-list { display: grid; gap: 7px; max-height: 260px; overflow-y: auto; margin-top: 8px; padding-right: 3px; }
.association-option { display: flex !important; grid-template-columns: none !important; align-items: flex-start; gap: 9px !important; border: 1px solid #dbe4ef; border-radius: 10px; padding: 8px; background: #ffffff; cursor: pointer; }
.association-option input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); }
.association-option span { display: grid; gap: 2px; color: var(--text); }
.association-option b { font-size: 12px; }
.association-option em { color: #526174; font-size: 12px; font-style: normal; line-height: 1.35; }
.project-memory-edit-form[hidden] { display: none; }
.project-memory-edit-form { border-top: 1px solid var(--line); margin-top: 9px; padding-top: 9px; }
.project-profile .context-preview { white-space: pre-wrap; max-height: 320px; overflow: auto; font-size: 12px; line-height: 1.5; background: #ffffff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.memory-list.compact { display: grid; gap: 8px; }
@media (max-width: 1180px) {
  .project-workspace { grid-template-columns: 300px minmax(0, 1fr); }
  .project-workspace .insight-panel { grid-column: span 2; max-height: none; }
}
@media (max-width: 820px) {
  .project-workspace { grid-template-columns: 1fr; }
  .project-workspace .insight-panel { grid-column: auto; }
  .project-main, .project-workspace .insight-panel { max-height: none; }
}

/* Step 7: agent auto-action display */
.auto-action-list { display: grid; gap: 10px; }
.auto-action { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: rgba(255,255,255,.72); }
.auto-action strong { display: inline-block; font-size: 12px; letter-spacing: .02em; }
.auto-action span { float: right; font-size: 11px; border-radius: 999px; padding: 2px 7px; background: rgba(15,23,42,.08); color: var(--muted); }
.auto-action p { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--text); }
.auto-action em { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); font-style: normal; }
.auto-action.ok { border-color: rgba(20,128,72,.22); background: rgba(240,253,244,.7); }
.auto-action.warn { border-color: rgba(180,83,9,.24); background: rgba(255,251,235,.75); }
.auto-action.error { border-color: rgba(185,28,28,.24); background: rgba(254,242,242,.75); }
.auto-action.preview { border-style: dashed; background: rgba(248,250,252,.75); }

/* Step 8: action queue */
.button-row.wrap { flex-wrap: wrap; gap: 8px; }
.small-btn.active { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.small-btn.danger { color: #9f1239; border-color: rgba(159,18,57,.28); background: #fff1f2; }
.action-queue-item summary span { font-size: 12px; color: var(--muted); }
.auto-action.pending_confirmation { border-color: rgba(37,99,235,.25); background: rgba(239,246,255,.75); }
.auto-action.queued { border-color: rgba(147,51,234,.22); background: rgba(250,245,255,.72); }
.auto-action.completed { border-color: rgba(20,128,72,.22); background: rgba(240,253,244,.7); }
.auto-action.failed, .auto-action.rejected, .auto-action.canceled { border-color: rgba(185,28,28,.22); background: rgba(254,242,242,.72); }

/* Settings */
.settings-layout { grid-template-columns: 310px minmax(0, 1fr) 390px; }
.settings-form .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-form label { font-size: 12px; color: var(--muted); }
.settings-form label .input { margin-top: 6px; }
.mini-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.config-form { display: grid; gap: 12px; }
.config-form fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: rgba(255,255,255,.52); }
.config-form legend { padding: 0 6px; color: var(--accent-2); font-size: 12px; font-weight: 760; }
.config-row { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.config-row:last-child { border-bottom: 0; }
.config-row b { display: block; font-size: 12px; }
.config-row em { display: block; color: var(--muted); font-size: 11px; font-style: normal; line-height: 1.35; margin-top: 2px; }
.config-row .input { padding: 8px 9px; border-radius: 10px; }
@media (max-width: 1280px) { .settings-layout { grid-template-columns: 280px minmax(0, 1fr); } .settings-layout .insight-panel { grid-column: 1 / -1; min-height: auto; max-height: none; } }
.main-nav { overflow-x: auto; scrollbar-width: thin; justify-content: flex-start; }
.nav-btn { white-space: nowrap; }

/* Step 10: diagnostics, backup, acceptance */
.system-layout { grid-template-columns: 310px minmax(0, 1fr) 430px; }
.count-list .compact-item.static { cursor: default; }
.acceptance-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.acceptance-card { border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: rgba(255,255,255,.72); display: grid; gap: 8px; }
.acceptance-card div { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.acceptance-card strong { color: var(--accent-2); font-size: 14px; }
.acceptance-card span { color: var(--muted); font-size: 12px; }
.acceptance-card p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 12px; }
.acceptance-card ol { margin: 0 0 0 18px; padding: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.acceptance-card.ok { border-color: rgba(20,128,72,.22); background: rgba(240,253,244,.65); }
.acceptance-card.warn { border-color: rgba(180,83,9,.24); background: rgba(255,251,235,.72); }
.acceptance-card.error { border-color: rgba(185,28,28,.24); background: rgba(254,242,242,.72); }
.diagnostic-card.ok { border-color: rgba(20,128,72,.18); }
.diagnostic-card.warn { border-color: rgba(180,83,9,.24); background: rgba(255,251,235,.72); }
.diagnostic-card.error { border-color: rgba(185,28,28,.24); background: rgba(254,242,242,.72); }
.diagnostic-card p { margin: 8px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.backup-list { display: grid; gap: 10px; max-height: 420px; overflow: auto; }
.backup-card { border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.72); padding: 10px 11px; display: grid; gap: 7px; }
.backup-card div:first-child { display: grid; gap: 3px; }
.backup-card strong { color: var(--accent-2); font-size: 12px; word-break: break-all; }
.backup-card span, .backup-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
@media (max-width: 1280px) { .system-layout { grid-template-columns: 290px minmax(0, 1fr); } .system-layout .insight-panel { grid-column: 1 / -1; max-height: none; } }
@media (max-width: 860px) { .system-layout { grid-template-columns: 1fr; } .acceptance-grid { grid-template-columns: 1fr; } }

/* Step 11: delivery and legacy model migration */
.setup-card { margin-bottom: 14px; border-color: rgba(37,99,235,.16); background: linear-gradient(135deg, rgba(239,246,255,.72), rgba(255,255,255,.72)); }
.panel-title.inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.runtime-box { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: rgba(255,255,255,.72); display: grid; gap: 4px; margin-top: 10px; }
.runtime-box b { color: var(--accent-2); font-size: 13px; }
.runtime-box p { margin: 0; color: var(--text); font-size: 12px; word-break: break-all; }
.runtime-box em { color: var(--muted); font-size: 11px; font-style: normal; }
.issue-list.compact { margin: 10px 0 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.issue-list.compact li { border-radius: 10px; padding: 7px 9px; font-size: 11px; line-height: 1.35; }
.issue-list.compact li.warn { background: rgba(255,251,235,.8); border: 1px solid rgba(180,83,9,.18); color: #92400e; }


/* Step 12: blue-white sidebar shell fixes */
.sidebar .main-nav { flex-direction: column; overflow-y: auto; overflow-x: hidden; scrollbar-width: auto; justify-content: flex-start; padding-bottom: 12px; }
.sidebar .nav-btn { white-space: normal; }
.app-view { max-width: 1680px; margin: 0 auto; padding: 28px 30px 46px; }
.panel, .knowledge-board, .stat-card, .bubble, .insight-card, .mini-block, .run-item, .memory-card, .retrieval-group, .retrieval-card, .proposal-item, .acceptance-card, .backup-card {
  backdrop-filter: blur(10px);
}
.primary-btn { box-shadow: 0 10px 24px rgba(37,99,235,.18); }
.primary-btn:hover { background: #1d4ed8; }
.secondary-btn:hover, .small-btn:hover { border-color: #93b4e8; background: #eff6ff; color: var(--accent-2); }
.input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

@media (max-width: 980px) {
  #app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    height: auto;
    max-height: 72vh;
    grid-template-rows: auto auto auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }
  .main-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-btn { min-height: 46px; }
  .app-view { padding: 18px 14px 34px; }
}

@media (max-width: 560px) {
  .main-nav { grid-template-columns: 1fr; }
  .sidebar-search { height: auto; min-height: 40px; }
  .brand em, .nav-btn em { display: none; }
}

@media (max-width: 980px) { .nav-section-label { grid-column: 1 / -1; margin-top: 4px; } }

/* 2026 system refinement: denser research workspace, stable responsive columns */
:root {
  --accent-strong: #173f78;
  --shadow: 0 14px 36px rgba(29, 78, 216, .075);
  --radius: 16px;
  font-family: "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}
html { scrollbar-color: #b8c9df transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #b8c9df; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }
body { font-size: 14px; letter-spacing: .002em; }
#app-shell { grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { padding: 16px 12px; gap: 13px; box-shadow: 10px 0 34px rgba(30,64,175,.045); }
.sidebar-brand { padding-top: 4px; }
.brand strong { font-size: 18px; font-weight: 760; }
.sidebar-search { border-radius: 12px; }
.nav-btn { padding: 10px 11px; border-radius: 12px; }
.nav-btn span { font-size: 13px; }
.app-view { max-width: 1720px; padding: 22px 24px 38px; }
.page-head { align-items: center; margin-bottom: 16px; }
.page-head h1 { font-size: clamp(27px, 3vw, 36px); font-weight: 760; letter-spacing: -.035em; }
.eyebrow { letter-spacing: .14em; font-size: 10px; font-weight: 700; }
.panel { padding: 14px; }
.panel-title { margin-bottom: 10px; }
.bubble { line-height: 1.68; box-shadow: 0 6px 18px rgba(30,64,175,.04); }
.chat-workspace { grid-template-columns: 248px minmax(460px, 1fr) minmax(310px, .58fr); gap: 14px; }
.session-drawer .session-list { max-height: 210px; }
.paper-drawer .paper-compact-list { max-height: 220px; }
.research-goal-input { min-height: 96px; max-height: 170px; }
.chat-history { padding: 16px; }
.insight-card, .session-item, .compact-item, .paper-item, .knowledge-card-button { border-radius: 12px; }
.agent-foundation-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.foundation-card { min-width: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.86); box-shadow: 0 8px 24px rgba(30,64,175,.045); }
.foundation-card span { display: block; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .09em; }
.foundation-card strong { display: block; margin-top: 6px; font-size: 15px; color: var(--accent-strong); }
.foundation-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.evaluation-summary { border: 1px solid var(--line); border-radius: 14px; padding: 13px; background: rgba(248,251,255,.86); }
.evaluation-summary > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.evaluation-summary span { color: var(--muted); font-size: 11px; }
.evaluation-metrics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.evaluation-metrics span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px; background: #fff; }
.evaluation-metrics span.ok { color: var(--green); border-color: rgba(21,128,61,.22); }
.evaluation-metrics span.warn { color: #9a6700; border-color: rgba(202,138,4,.28); }
.evaluation-metrics b { color: inherit; }
.hygiene-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

@media (max-width: 1550px) {
  .three-column:not(.chat-workspace), .molecule-page { grid-template-columns: 250px minmax(0, 1fr); }
  .three-column:not(.chat-workspace) > .insight-panel { grid-column: 1 / -1; min-height: 0; max-height: none; }
  .chat-workspace { grid-template-columns: 238px minmax(0, 1fr); height: auto; min-height: 0; align-items: start; }
  .chat-workspace > .chat-sidebar, .chat-workspace > .chat-panel { height: min(720px, calc(100vh - 122px)); min-height: 560px; }
  .chat-workspace > .insight-panel { grid-column: 1 / -1; height: auto; min-height: 0; max-height: none; }
  .chat-workspace > .insight-panel .insight-list { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .library-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .knowledge-grid { grid-template-columns: 240px minmax(300px, 1fr); }
  .knowledge-grid { height: auto; }
  .knowledge-grid > .card-column, .knowledge-grid > .graph-column { height: 620px; }
  .knowledge-grid > .detail-column { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); height: auto; max-height: none; }
}

@media (max-width: 980px) {
  #app-shell { grid-template-columns: 1fr; }
  .app-view { padding: 18px 16px 32px; }
  .page-head h1 { font-size: clamp(25px, 6vw, 34px); }
}

@media (max-width: 820px) {
  .chat-workspace { grid-template-columns: 1fr; }
  .chat-workspace > .chat-sidebar, .chat-workspace > .chat-panel { height: auto; min-height: 520px; }
  .chat-workspace > .chat-sidebar { min-height: 0; }
  .chat-workspace > .insight-panel { grid-column: auto; }
  .agent-foundation-strip, .hygiene-grid { grid-template-columns: 1fr; }
  .preview-grid { grid-template-columns: 1fr; }
  .library-sidebar, .proposal-sidebar.scroll-shell, .proposal-list-panel.scroll-shell, .project-sidebar, .molecule-sidebar { height: auto; min-height: 0; max-height: none; }
  .library-sidebar .panel-scroll-body, .proposal-sidebar .panel-scroll-body, .proposal-list-panel .panel-scroll-body, .project-sidebar .panel-scroll-body, .molecule-sidebar .panel-scroll-body { max-height: 620px; }
}

/* 2026 cognition graph and text clarity pass */
html, body, button, input, textarea, select {
  font-family: "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: subpixel-antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}
body { font-size: 15px; line-height: 1.55; }
.panel, .knowledge-board, .stat-card, .bubble, .insight-card, .mini-block, .run-item, .memory-card, .retrieval-group, .retrieval-card, .proposal-item, .acceptance-card, .backup-card {
  backdrop-filter: none;
  background-color: rgba(255,255,255,.97);
}
.muted, .bubble, .insight-card p, .knowledge-card-button p, .retrieval-card p { font-weight: 450; }
.panel-title, .nav-btn span, .compact-item strong, .paper-item strong { font-weight: 700; }

.graph-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid #c9d9ec;
  border-radius: 16px;
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 12px 28px rgba(30,64,175,.07);
}
.graph-stage { position: relative; width: 100%; height: 100%; min-height: inherit; overflow: hidden; }
.graph-canvas { width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
.graph-toolbar {
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 10px;
  display: inline-flex;
  gap: 5px;
  padding: 5px;
  border: 1px solid rgba(148,163,184,.42);
  border-radius: 12px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 8px 20px rgba(15,47,95,.10);
}
.graph-toolbar button {
  min-width: 30px;
  height: 29px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #244665;
  font-size: 12px;
  font-weight: 700;
}
.graph-toolbar button:hover { background: #e9f2ff; color: #1d4ed8; }
.graph-tooltip {
  position: absolute;
  z-index: 5;
  left: 0;
  top: 0;
  width: 215px;
  pointer-events: none;
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid rgba(148,163,184,.45);
  border-radius: 10px;
  background: rgba(15,47,95,.94);
  color: #fff;
  box-shadow: 0 12px 26px rgba(15,47,95,.2);
}
.graph-tooltip[hidden] { display: none; }
.graph-tooltip strong { font-size: 12px; line-height: 1.35; }
.graph-tooltip span { color: rgba(255,255,255,.72); font-size: 10px; }
.chat-graph-viewer { height: 360px; min-height: 360px; }
.chat-graph-detail {
  min-height: 62px;
  margin-top: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
}
.chat-graph-detail > p { margin: 0; color: var(--muted); font-size: 12px; }
.chat-graph-detail .node-detail h3 { font-size: 15px; }
.chat-graph-detail .node-detail p { max-height: 92px; overflow: auto; }
.node-detail h3 { color: #173f78; line-height: 1.35; }
.node-detail p { color: #52657a; line-height: 1.65; }
.node-evidence-summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.node-evidence-summary span { border: 1px solid #c9d9ec; border-radius: 999px; padding: 4px 8px; background: #fff; color: #244665; font-size: 11px; }
.mode-badge { color: #2563eb; font-size: 11px; font-style: normal; font-weight: 700; }

@media (max-width: 820px) {
  .chat-graph-viewer { height: 320px; min-height: 320px; }
  .graph-column, .graph-shell { height: 480px; min-height: 0; }
}
