.auth-card { background:#fff; border:0.5px solid rgba(0,0,0,0.08); border-radius:16px; padding:28px; }
.auth-title { font-family:var(--font-d); font-size:20px; font-weight:600; letter-spacing:-0.2px; color:#1c1f1e; margin-bottom:20px; }
.auth-label { display:block; font-size:11px; color:#8e9896; text-transform:uppercase; letter-spacing:0.6px; margin-bottom:4px; margin-top:12px; }
.auth-input { width:100%; padding:9px 11px; border:0.5px solid rgba(0,0,0,0.16); border-radius:8px; font-family:var(--font-b); font-size:14px; color:#1c1f1e; background:#faf9f6; outline:none; transition:border-color 0.15s; }
.auth-input:focus { border-color:var(--teal); background:#fff; }
#pendingCodeInput { caret-color:transparent; }
#pendingCodeInput:focus { border-color:var(--teal); background:#fff; box-shadow:var(--sg-focus-ring); }
.auth-btn { width:100%; padding:11px; background:var(--teal); color: var(--sg-on-accent, #fff); border:none; border-radius:8px; font-size:14px; font-family:var(--font-b); font-weight:500; cursor:pointer; margin-top:16px; transition:background 0.15s; }
.auth-btn:hover { background:var(--sg-teal-700); }
.auth-btn:disabled { background:#8e9896; cursor:not-allowed; }
.auth-switch { text-align:center; font-size:13px; color:#8e9896; margin-top:16px; }
.auth-switch a { color:var(--teal); text-decoration:none; }
.auth-divider { text-align:center; position:relative; margin:16px 0; color:#8e9896; font-size:12px; }
.auth-divider::before { content:''; position:absolute; top:50%; left:0; right:0; height:0.5px; background:rgba(0,0,0,0.08); }
.auth-divider span { background:#fff; padding:0 12px; position:relative; }
.auth-error { background:#f5e6e2; color:#8a3628; border-radius:8px; padding:10px 12px; font-size:13px; margin-bottom:12px; }
.auth-success { background:#e2f0e9; color:#2d6648; border-radius:8px; padding:10px 12px; font-size:13px; margin-bottom:12px; }
.google-btn { display:flex; align-items:center; justify-content:center; gap:10px; width:100%; padding:10px; background:#fff; border:0.5px solid rgba(0,0,0,0.16); border-radius:8px; font-size:14px; font-family:var(--font-b); color:#1c1f1e; cursor:pointer; text-decoration:none; transition:background 0.12s; }
.google-btn:hover { background:#faf9f6; }

.settings-section { margin-bottom:14px; }
.settings-section-title { font-size:11px; font-weight:500; text-transform:uppercase; letter-spacing:0.6px; color:var(--text3); margin-bottom:7px; }
.settings-row { display:flex; align-items:center; justify-content:space-between; padding:7px 0; border-bottom:0.5px solid var(--border); font-size:13px; }
.settings-row:last-child { border-bottom:none; }
.settings-row-label { color:var(--text2); }
.settings-row-value { color:var(--text3); font-size:12px; }
.key-status-dot { width:8px; height:8px; border-radius:50%; display:inline-block; margin-right:5px; }
.key-status-dot.active { background:var(--green); }
.key-status-dot.none { background:var(--text3); }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #faf9f6; --bg2: #f2f0eb; --surface: #ffffff;
  --border: rgba(0,0,0,0.08); --border2: rgba(0,0,0,0.14);
  --text: #1f1e1c; --text2: #4b4945; --text3: #6e6b65;
  --teal: #7e4a5d; --teal-light: #f0e9ec; --teal-mid: #986e7d;
  --green: #2d6648; --green-light: #e2f0e9;
  --amber: #7a5a1a; --amber-light: #f5edd8;
  --coral: #b8321a; --coral-light: #fdeae4; --coral-border: #f2b3a3; 
  --r: 8px; --r-lg: 12px; --r-xl: 16px;
  --rail-w: 212px;  --inner-w: 196px; --topbar-h: 58px;
--rail-bg: #f5f3ef;
  --font-d: 'IBM Plex Sans', system-ui, sans-serif;
  --font-b: 'IBM Plex Sans', system-ui, sans-serif;
  --font-m: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}
body { font-family: var(--font-b); background: var(--bg); color: var(--text); height: 100vh; height: 100dvh; overflow: hidden; font-size: 14px; line-height: 1.5; }
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 0.5px solid var(--border); display: flex; align-items: center; padding: 0 18px; gap: 12px; flex-shrink: 0; z-index: 100; }
.body { display: flex; flex: 1; overflow: hidden; overflow: clip; min-height: 0; }

.grants-rail { width: var(--rail-w); background: var(--rail-bg); border-right: 0.5px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; transition: width 0.22s ease; }
.grants-rail.collapsed { width: 40px; }
.grants-rail.collapsed .rail-top, .grants-rail.collapsed .rail-scroll, .grants-rail.collapsed .new-grant-btn { opacity: 0; pointer-events: none; }
.rail-top { padding: 10px 14px 6px; flex-shrink: 0; }
.rail-lbl { font-size: 10px; font-weight: 500; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text3); padding: 0 4px; margin-bottom: 4px; }
.rail-scroll { flex: 1; overflow-y: auto; padding: 0 10px 8px; }
.rail-divider { height: 0.5px; background: var(--border); margin: 6px 2px 8px; }
.grants-rail.collapsed .rail-icon-strip { display: flex; }
.rail-icon-strip { display: none; flex-direction: column; align-items: center; padding: 4px 0; gap: 3px; flex: 1; overflow: hidden; }  
.rail-icon-item { width: 28px; height: 28px; border-radius: var(--r); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text3); cursor: pointer; transition: background 0.12s; flex-shrink: 0; }
.rail-icon-item:hover { background: rgba(0,0,0,0.07); }
.rail-icon-item.active { background: var(--surface); color: var(--teal); }
.rail-new-grant {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 9px; margin-top: 2px;
  background: transparent; border: 1px dashed var(--sg-border3);
  border-radius: var(--sg-r); font-family: var(--font-b); font-size: 12px;
  font-weight: 500; color: var(--teal); cursor: pointer;
  transition: background .12s, border-color .12s;
}
.rail-new-grant:hover { background: var(--sg-teal-50); border-color: var(--sg-teal); }
.rail-new-grant span[data-icon] { display: inline-flex; }
.rail-new-grant svg { display: block; }
.rail-icon-plus { color: var(--sg-teal); }
.rail-icon-plus:hover { background: var(--sg-teal-50); }
.portfolio-btn { display: flex; align-items: center; gap: 7px; padding: 7px 8px; border-radius: var(--r); font-size: 12px; font-weight: 500; color: var(--text2); cursor: pointer; transition: background 0.12s; margin-bottom: 2px; }
.portfolio-btn:hover { background: rgba(0,0,0,0.05); }
.portfolio-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.grant-item { padding: 8px 9px; border-radius: var(--r); cursor: pointer; transition: background 0.12s; margin-bottom: 3px; }
.grant-item:hover { background: rgba(0,0,0,0.05); }
.grant-item.active { background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,0.07); }
.gi-funder { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px; }
.gi-title { font-size: 12px; font-weight: 500; color: var(--text); line-height: 1.35; margin-bottom: 5px; }
.gi-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.gi-score { font-family: var(--font-m); font-size: 10px; font-weight: 500; color: var(--teal); }
.gi-dl { font-family: var(--font-m); font-size: 10px; color: var(--text3); }
.gi-bar { height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.gi-bar-fill { height: 100%; border-radius: 2px; background: var(--teal); }
.new-grant-btn { margin: 0 10px 12px; margin-bottom: calc(12px + env(safe-area-inset-bottom)); padding: 8px 12px; border: none; border-radius: var(--r); font-size: 12px; font-weight: 500; color: var(--sg-on-accent, #fff); cursor: pointer; background: var(--teal); font-family: var(--font-b); width: calc(100% - 20px); text-align: left; display: flex; align-items: center; gap: 6px; flex-shrink: 0; transition: all 0.15s; }
.new-grant-btn:hover { background: var(--sg-teal-700); }
.collapse-btn { width: 20px; height: 20px; border-radius: 4px; border: 0.5px solid var(--border2); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--text3); flex-shrink: 0; transition: all 0.12s; line-height: 1; }
.collapse-btn:hover { background: var(--bg2); color: var(--text2); }
.collapse-btn:disabled { opacity:0.5; cursor:not-allowed; }

.inner-sb { width: var(--inner-w); background: var(--surface); border-right: 0.5px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; padding: 0; transition: width 0.22s ease; }
.inner-sb.hidden { display: none; }
.inner-sb.collapsed { width: 40px; }
.inner-sb-content { flex: 1; overflow-y: auto; padding: 12px 0 24px; min-width: var(--inner-w); display: flex; flex-direction: column; }
.inner-sb.collapsed .inner-sb-content { opacity: 0; pointer-events: none; }
.inner-sb-collapse-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 6px; flex-shrink: 0; border-bottom: 0.5px solid var(--border); }
.inner-sb.collapsed .inner-sb-collapse-bar { display: none; }  
.inner-sb-label { font-size: 10px; font-weight: 500; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text3); white-space: nowrap; overflow: hidden; }
.inner-sb.collapsed .inner-icon-strip { display: flex; }
.inner-icon-strip { display: none; flex-direction: column; align-items: center; padding: 4px 0; gap: 3px; flex: 1; }
.inner-icon-item { width: 28px; height: 28px; border-radius: var(--r); display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text3); cursor: pointer; transition: background 0.12s; }
.inner-icon-item:hover { background: var(--bg2); }
.inner-icon-item.active { background: var(--teal-light); color: var(--teal); }
.nav-item { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: var(--r); font-size: 11px; color: var(--text2); cursor: pointer; margin: 0 6px 1px; transition: background 0.12s; }
.nav-item:hover { background: var(--bg2); }
.nav-item.active { background: var(--teal-light); color: var(--teal); font-weight: 500; }
.nav-icon { width: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-icon svg, .inner-icon-item svg, .rail-icon-item svg { display: block; }
.inner-divider { height: 0.5px; background: var(--border); margin: 7px 8px; }
.inner-lbl { font-size: 10px; font-weight: 500; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text3); padding: 0 14px; margin-bottom: 3px; }
.sec-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: var(--r); font-size: 11px; color: var(--text2); cursor: pointer; margin: 0 6px 1px; transition: background 0.12s; }
.sec-item:hover { background: var(--bg2); }
.sec-item.active { background: var(--teal-light); color: var(--teal); }
.chk { width: 13px; height: 13px; border-radius: 3px; border: 1.5px solid var(--border2); flex-shrink: 0; display: none; align-items: center; justify-content: center; font-size: 8px; }
.chk.done { background: var(--green); border-color: var(--green); color: white; }
.chk.over { background: var(--coral); border-color: var(--coral); color: white; }
.chk.partial { border-color: var(--teal); }
.sec-prog { padding: 0 8px 4px 6px; margin: 0 8px; }
.sec-prog-track { height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.sec-prog-fill { height: 100%; background: var(--teal); border-radius: 2px; }

.rail-group { margin-bottom: 4px; }
.rail-group-hd { display: flex; align-items: center; gap: 6px; padding: 3px 14px; cursor: pointer; user-select: none; border-radius: var(--r); transition: background 0.12s; }
.rail-group-hd:hover { background: var(--bg2); }
.rail-group-chevron { color: var(--text2); transition: transform 0.15s; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1; }
.rail-group-chevron svg { display: block; }
.rail-group.collapsed .rail-group-chevron { transform: rotate(-90deg); }
.rail-group.collapsed .rail-group-body { display: none; }
.fig-rail-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: var(--r); font-size: 11px; color: var(--text2); cursor: pointer; margin: 0 6px 1px; transition: background 0.12s; }
.fig-rail-item:hover { background: var(--bg2); }
.fig-rail-item.active { background: var(--teal-light); color: var(--teal); }
.fig-rail-empty { font-size: 10px; color: var(--text3); padding: 4px 14px 6px; line-height: 1.5; }
.fig-rail-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fig-rail-item.off { color: var(--text3); }
.fig-rail-item.off .fig-rail-label { text-decoration: line-through; text-decoration-color: var(--border2); }
.fig-rail-add { display: block; width: calc(100% - 12px); margin: 3px 6px 4px; padding: 4px 8px; border: 0.5px dashed var(--border2); border-radius: var(--r); background: none; font-size: 11px; color: var(--text3); cursor: pointer; font-family: var(--font-b); text-align: left; transition: all 0.12s; }
.fig-rail-add:hover { color: var(--teal); border-color: var(--teal-mid); background: var(--teal-light); }
.fig-off-chip { font-size: 11px; color: var(--text2); background: var(--bg2); border: 0.5px solid var(--border2); border-radius: 10px; padding: 1px 8px; cursor: pointer; font-family: var(--font-b); }
.fig-off-chip:hover { color: var(--teal); border-color: var(--teal-mid); }
.fe-thumb { width: 44px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--bg2); border: 0.5px solid var(--border); border-radius: 4px; overflow: hidden; }
.fe-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.cus-row.disabled .fe-thumb { opacity: 0.5; }

.strength-panel { border-top: 0.5px solid var(--border); padding: 12px 8px 12px; margin-top: auto; flex-shrink: 0; }
.ring-wrap { display: flex; align-items: center; gap: 10px; background: var(--bg2); border-radius: var(--r-lg); padding: 10px 11px; margin-bottom: 9px; }
.ring-svg { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.ring-svg svg { transform: rotate(-90deg); display: block; }
.ring-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-m); font-size: 13px; font-weight: 500; }
.ring-title { font-size: 12px; font-weight: 500; }
.ring-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }
.crit-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px; border-bottom: 0.5px solid var(--border); font-size: 12px; }
.crit-row:last-child { border-bottom: none; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; overflow: clip; min-width: 0; min-height: 0; }
.screen { display: none; flex: 1; flex-direction: column; overflow: hidden; overflow: clip; min-height: 0; min-width: 0; }
.screen.active { display: flex; }
.scroll-body { flex: 1; overflow-y: auto; padding: 26px 30px 60px; }
.page-title { font-family: var(--font-d); font-size: 24px; font-weight: 500; margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--text3); margin-bottom: 22px; }
.page-title.editable-title { font-size: 22px; }
.editable-title { cursor: text; border-radius: 4px; padding: 0 4px; margin-left: -4px; display: inline-block; }
.editable-title:hover { background: var(--teal-light); }
.title-edit-hint { font-size: 13px; color: var(--text3); margin-left: 8px; opacity: 0; transition: opacity 0.12s; vertical-align: middle; }
.editable-title:hover .title-edit-hint { opacity: 1; }
.page-title-input { font-family: var(--font-d); font-size: 22px; font-weight: 500; color: var(--text); border: 1px solid var(--teal); border-radius: 4px; padding: 1px 5px; margin: -2px 0; width: min(560px, 70vw); background: var(--bg); outline: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; margin-bottom: 22px; }
.metric-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); padding: 13px 15px; }
.m-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.m-val { font-size: 21px; font-weight: 500; }
.m-sub { font-size: 11px; color: var(--text3); margin-top: 3px; }
.section-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin-bottom: 22px; }
.sec-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); padding: 13px 15px; cursor: pointer; transition: border-color 0.15s; }
.sec-card:hover { border-color: var(--teal-mid); }
.sc-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 7px; }
.sc-name { font-size: 13px; font-weight: 500; }
.badge { font-size: 10px; font-weight: 500; padding: 2px 7px; border-radius: 10px; }
.b-done { background: var(--green-light); color: var(--green); }
.b-prog { background: var(--amber-light); color: var(--amber); }
.b-todo { background: var(--bg2); color: var(--text3); }
.b-strong { background: var(--green-light); color: var(--green); }
.b-moderate { background: var(--amber-light); color: var(--amber); }
.b-weak { background: var(--coral-light); color: var(--coral); }
.sc-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.sc-bar-fill { height: 100%; border-radius: 2px; }
.sc-words { font-size: 11px; color: var(--text3); margin-top: 4px; }

.tbl-wrap { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; padding: 9px 14px; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); border-bottom: 0.5px solid var(--border); background: var(--bg2); }
.tbl td { padding: 11px 14px; font-size: 13px; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--bg2); cursor: pointer; }
.tbl-funder { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }
.tbl-name { font-weight: 500; line-height: 1.3; }
.prog-wrap { display: flex; align-items: center; gap: 7px; }
.prog-track { width: 72px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; flex-shrink: 0; }
.prog-fill { height: 100%; border-radius: 2px; }

.editor-header { display: flex; align-items: center; justify-content: space-between; padding: 7px 14px 6px; border-bottom: 0.5px solid var(--border); background: var(--surface); flex-shrink: 0; gap: 10px; }
.editor-header-title { flex: 1; min-width: 0; font-family: var(--font-d); font-size: 19px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.editor-toolbar { height: 38px; background: var(--surface); border-bottom: 0.5px solid var(--border); display: flex; flex-wrap: nowrap; align-items: center; padding: 0 10px; gap: 1px; flex-shrink: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.editor-toolbar::-webkit-scrollbar { display: none; }
.editor-toolbar .sg-btn, .editor-toolbar .tbtn { flex-shrink: 0; }
.editor-toolbar .tselect { flex-shrink: 1; }
.editor-toolbar .sg-btn.is-icon { width: 24px; }
.editor-toolbar .tsep { margin: 0 2px; }
#fontFamilySelect { min-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fontSizeSelect   { min-width: 42px; }
#headingSelect    { min-width: 66px; }
.editor-toolbar::after { content: ''; flex: 0 0 8px; }
.editor-toolbar.fl { mask-image: linear-gradient(90deg, transparent, #000 26px); -webkit-mask-image: linear-gradient(90deg, transparent, #000 26px); }
.editor-toolbar.fr { mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); }
.editor-toolbar.fl.fr { mask-image: linear-gradient(90deg, transparent, #000 26px, #000 calc(100% - 26px), transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 26px, #000 calc(100% - 26px), transparent); }
.tbtn { padding: 4px 6px; border-radius: 4px; font-size: 12px; color: var(--text2); cursor: pointer; border: none; background: none; font-family: var(--font-b); transition: background 0.12s; white-space: nowrap; line-height: 1.4; }
.tbtn:hover { background: var(--bg2); }
.tbtn.active { background: var(--teal-light); color: var(--teal); }
.editor-toolbar .sg-btn.active { background: var(--sg-teal-100); color: var(--sg-teal); }
#btn-super, #btn-sub { font-weight: 300; font-size: 15px; }
#btn-super:not(.active), #btn-sub:not(.active) { color: var(--sg-text2); } 
.tbtn.ai { color: var(--teal); font-weight: 500; }
.tsep { width: 0.5px; height: 16px; background: var(--border); margin: 0 3px; flex-shrink: 0; }
.tbreak { width: 100%; height: 0.5px; background: var(--border); margin: 2px 0; }
.tselect { padding: 3px 4px; border-radius: 4px; font-size: 12px; color: var(--text2); cursor: pointer; border: 0.5px solid transparent; background: none; font-family: var(--font-b); outline: none; transition: all 0.12s; }
.tselect:hover { background: var(--bg2); border-color: var(--border); }
.tselect:focus { background: var(--bg2); border-color: var(--border2); }
.editor-body { flex: 1; overflow-y: auto; padding: 28px 36px 60px; }
.sec-heading { font-family: var(--font-d); font-size: 24px; font-weight: 500; margin-bottom: 5px; line-height: 1.3; } 
.sec-meta { font-size: 12px; color: var(--text3); margin-bottom: 22px; display: flex; align-items: center; gap: 12px; }
.wbar { width: 56px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 4px; }
.wbar-fill { height: 100%; background: var(--teal); border-radius: 2px; }
.editor-content { zoom: 0.9; font-size: 11pt; line-height: 1.85; color: var(--text); outline: none; min-height: 300px; }
.editor-content p { margin-bottom: 13px; }
.editor-content.show-placeholder::before {
  content: attr(data-placeholder);
  white-space: pre-line;
  color: var(--text3);
  font-style: italic;
  font-size: 12px;
  line-height: 1.6;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

#continuousStack { display: none; flex-direction: column; flex: 1; background: var(--bg2); padding: 26px 20px max(220px, calc(100vh - 300px)); }
.ms-page {
  background: var(--surface); width: 100%; max-width: 800px; margin: 0 auto;
  border: 0.5px solid var(--border); border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 10px 30px rgba(0,0,0,0.05);
padding: clamp(28px, 5%, 56px) min(64px, 8%) clamp(36px, 7%, 72px);
}
.ms-titleblock { text-align: center; margin-bottom: 36px; padding-bottom: 24px; border-bottom: 0.5px solid var(--border); }
.ms-journal { font-family: var(--font-b); font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text3); margin-bottom: 10px; }
.ms-title { font-family: var(--font-d); font-size: 20px; font-weight: 500; line-height: 1.3; color: var(--text); }
.ms-title.editable-title { margin: 0; padding: 2px 6px; }
.ms-title-input { font-family: var(--font-d); font-size: 20px; font-weight: 500; line-height: 1.3; text-align: center; color: var(--text); border: 1px solid var(--teal); border-radius: 4px; padding: 2px 6px; width: 100%; background: var(--surface); outline: none; }

.ms-page + .ms-page { margin-top: 28px; }
#editorContent [style*="color"], .csec-body [style*="color"],
#editorContent font[color], .csec-body font[color] { color: inherit !important; }
#editorContent [style*="background"], .csec-body [style*="background"] { background: transparent !important; }
.csec-heading { position: relative; display: flex; align-items: baseline; gap: 10px; margin: 30px 0 8px; }
.csec:first-of-type .csec-heading { margin-top: 0; }
.csec-heading .csec-title { font-family: var(--font-d); font-size: 19px; font-weight: 600; color: var(--text); line-height: 1.3; }
.csec-heading .csec-meta { display: flex; align-items: center; gap: 7px; margin-left: auto; font-family: var(--font-b); font-size: 10.5px; color: var(--text3); white-space: nowrap; opacity: 0; transition: opacity 0.15s; }
.csec:hover .csec-heading .csec-meta, .csec-active .csec-heading .csec-meta { opacity: 1; }
.csec-wbar { width: 56px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; display: inline-block; vertical-align: middle; }
.csec-wbar-fill { height: 100%; width: 0; background: var(--teal); border-radius: 2px; transition: width 0.15s, background 0.15s; }
.csec-active .csec-heading::before { content: ''; position: absolute; left: -20px; top: 3px; bottom: 3px; width: 3px; border-radius: 2px; background: var(--teal); }
.csec-body { zoom: 0.9; font-size: 11pt; line-height: 1.85; color: var(--text); outline: none; min-height: 44px; }
.csec-body p { margin-bottom: 13px; }
.csec-body.csec-empty::before {
  content: attr(data-placeholder);
  white-space: pre-line; color: var(--text3); font-style: italic;
  font-size: 12px; line-height: 1.6; pointer-events: none;
  -webkit-user-select: none; user-select: none;
}
.sd-sug { border-radius: 2px; padding: 0 1px; cursor: pointer; transition: background 0.12s; }
.sd-sug-del { background: rgba(200, 72, 62, 0.10); color: var(--coral, #c8483e); text-decoration: line-through; text-decoration-thickness: 1px; }
.sd-sug-ins { background: rgba(58, 138, 82, 0.12); color: var(--green, #3a8a52); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.sd-sug-del:hover { background: rgba(200, 72, 62, 0.20); }
.sd-sug-ins:hover { background: rgba(58, 138, 82, 0.22); }
.sd-sug-focus { outline: 1.5px solid var(--teal); outline-offset: 1px; }
.csec-body.sd-reviewing { caret-color: transparent; }
.sd-sug-popover {
  position: fixed; z-index: 60; width: 340px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 0.5px solid var(--border2);
  border-radius: var(--r-lg); box-shadow: 0 4px 16px rgba(0,0,0,0.13);
  padding: 11px 13px; font-family: var(--font-b);
}
.sd-sug-kind { font-size: 9.5px; font-weight: 500; letter-spacing: 0.6px; text-transform: uppercase; color: var(--teal); margin-bottom: 5px; }
.sd-sug-reason { font-size: 12.5px; line-height: 1.55; color: var(--text2); margin-bottom: 10px; }
.sd-sug-revised { font-size: 12.5px; line-height: 1.55; color: var(--text); background: var(--bg2); border-left: 2px solid var(--green); border-radius: 0 4px 4px 0; padding: 6px 9px; margin-bottom: 10px; }
.sd-sug-acts { display: flex; gap: 6px; }
.sd-sug-btn { font-family: var(--font-b); font-size: 11px; padding: 3px 11px; border-radius: 20px; border: 0.5px solid var(--border2); background: none; color: var(--text2); cursor: pointer; transition: all 0.12s; }
.sd-sug-btn:hover { background: var(--bg2); }
.sd-sug-btn.accept { border-color: var(--green); color: var(--green); }
.sd-sug-btn.accept:hover { background: var(--green-light, rgba(58,138,82,0.10)); }
.sd-sug-btn.reject { border-color: var(--border2); color: var(--text2); }

.sd-review-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 22px; padding: 8px 12px;
  background: var(--teal-light); border: 0.5px solid var(--border2);
  border-radius: var(--r); font-family: var(--font-b); font-size: 11.5px; color: var(--text2);
}
.sd-review-bar.done { background: var(--bg2); }
.sd-review-label { display: flex; align-items: center; gap: 7px; }
.sd-review-acts { display: flex; gap: 6px; margin-left: auto; }

#sdClearBtn, #sdSuggestBtn { border: 0.5px solid var(--border); border-radius: var(--r); padding: 3px 9px; font-size: 11px; font-family: var(--font-b); color: var(--text2); background: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; flex-shrink: 0; transition: all 0.12s; }
#sdSuggestBtn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }
#sdClearBtn:hover { border-color: var(--coral); color: var(--coral); background: var(--coral-light); }
.ai-sug { background: var(--bg2); border: 0.5px solid var(--border); border-left: 2px solid var(--teal); border-radius: 0 var(--r) var(--r) 0; padding: 9px 13px; margin: 13px 0; font-size: 13px; color: var(--text2); }
.ai-sug-lbl { font-size: 10px; font-weight: 500; letter-spacing: 0.5px; color: var(--teal); text-transform: uppercase; margin-bottom: 5px; }
.inline-acts { display: flex; gap: 5px; margin-top: 7px; }
.ibtn { font-size: 11px; font-family: var(--font-b); padding: 3px 9px; border-radius: 20px; border: 0.5px solid; cursor: pointer; background: none; }
.ibtn.accept { border-color: var(--green); color: var(--green); }
.ibtn.accept:hover { background: var(--green-light); }
.ibtn.other { border-color: var(--border2); color: var(--text2); }
.ibtn.other:hover { background: var(--bg2); }

.editor-screen-wrap { display: flex; flex: 1; overflow: hidden; overflow: clip; min-height: 0; position: relative; }
.editor-pane { width: 55%; min-width: 280px; max-width: calc(100% - 220px); display: flex; flex-direction: column; overflow: hidden; overflow: clip; min-height: 0; border-right: none; flex-shrink: 0; }
.ai-pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 180px; min-height: 0; background: var(--surface); transition: width 0.22s ease, min-width 0.22s ease, flex 0.22s ease; }
.ai-pane.collapsed { flex: none; width: 40px; min-width: 40px; }
.ai-pane.collapsed .ai-pane-body,
.ai-pane.collapsed .ai-input-bar { opacity: 0; pointer-events: none; }
.ai-pane.collapsed .ai-pane-header { display: none; }
.ai-pane-icon-strip { display: none; flex-direction: column; align-items: center; padding: 10px 0; gap: 8px; flex: 1; cursor: pointer; }
.ai-pane-icon-strip:hover .ai-pane-icon-label { color: var(--text2); }
.ai-pane.collapsed .ai-pane-icon-strip { display: flex; }
.ai-pane-icon-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; font-weight: 500; color: var(--text3); white-space: nowrap; margin-top: 6px; transition: color 0.12s; }
.split-handle { width: 3px; background: var(--border); cursor: col-resize; flex-shrink: 0; position: relative; transition: background 0.15s; display: flex; align-items: center; justify-content: center; }
.split-handle.ai-hidden { display: none; }
.split-handle:hover, .split-handle.dragging { background: var(--border2); }
.split-handle::after { content: ''; position: absolute; width: 3px; height: 24px; background: rgba(0,0,0,0.15); border-radius: 99px; pointer-events: none; transition: opacity 0.15s; opacity: 0; }
.split-handle:hover::after, .split-handle.dragging::after { opacity: 1; }
.ai-pane-header { height: 40px; background: var(--surface); border-bottom: 0.5px solid var(--border); display: flex; align-items: center; padding: 0 16px; gap: 6px; flex-shrink: 0; }
.ai-pane-title { font-size: 12px; font-weight: 500; color: var(--text2); }
.ai-pane-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.ai-msg-wrap { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.ai-msg { padding: 10px 12px; border-radius: var(--r-lg); font-size: 13px; line-height: 1.65; }
.ai-msg.user { background: var(--bg2); border: 0.5px solid var(--border); color: var(--text); align-self: flex-end; max-width: 90%; border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg); }
.ai-msg.assistant { background: var(--teal-light); border: 0.5px solid rgba(126,74,93,0.18); color: var(--text); position: relative; }
.ai-msg.draft { background: var(--surface); border: 0.5px solid var(--teal); color: var(--text); position: relative; }
.ai-msg.draft::before { content: 'Proposed text'; position: absolute; top: -8px; left: 12px; font-size: 10px; font-weight: 500; color: var(--teal); background: var(--surface); padding: 0 4px; font-family: var(--font-b); border-radius: 3px; }
.ai-msg.draft .copy-btn { position: absolute; bottom: 7px; right: 8px; background: var(--teal-light); border: none; border-radius: 4px; padding: 2px 7px; font-size: 10px; color: var(--teal); cursor: pointer; font-family: var(--font-b); }
.ai-msg.draft .copy-btn.copied { color: var(--green); }
.ai-msg.user { position: relative; }
.msg-delete-btn { position:absolute; top:6px; right:6px; display:none; background:none; border:none; cursor:pointer; font-size:11px; color:var(--text3); padding:2px 4px; border-radius:3px; line-height:1; }
.msg-delete-btn:hover { color:var(--coral); background:rgba(0,0,0,0.05); }
.ai-msg:hover .msg-delete-btn { display:block; }
.ai-msg h1,.ai-msg h2,.ai-msg h3 { font-family: var(--font-b); font-weight: 600; margin: 10px 0 4px; font-size: 13px; color: var(--text); }
.ai-msg h1 { font-size: 14px; }
.ai-msg p { margin: 0 0 7px; }
.ai-msg p:last-child { margin-bottom: 0; }
.ai-msg ul,.ai-msg ol { margin: 4px 0 7px 18px; padding: 0; }
.ai-msg li { margin-bottom: 3px; }
.ai-msg strong { font-weight: 600; }
.ai-msg em { font-style: italic; }
.ai-msg code { font-family: monospace; background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.ai-msg pre { background: rgba(0,0,0,0.05); border-radius: var(--r); padding: 10px 12px; overflow-x: auto; margin: 6px 0; }
.ai-msg pre code { background: none; padding: 0; font-size: 12px; }
.ai-input-bar { flex-shrink: 0; padding: 10px 14px 14px; border-top: 0.5px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--bg2); border: 0.5px solid var(--border); border-radius: 20px; padding: 3px 8px; font-size: 11px; color: var(--text2); cursor: pointer; font-family: var(--font-b); transition: all 0.12s; }
.chip:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }
.ai-row { display: flex; gap: 5px; }
.ai-in { flex: 1; padding: 8px 10px; font-size: 13px; border: 0.5px solid var(--border2); border-radius: var(--r); background: var(--bg2); color: var(--text); font-family: var(--font-b); outline: none; transition: border-color 0.15s; }
.ai-in:focus { border-color: var(--teal); }
.ai-in::placeholder { color: var(--text3); }
.ai-btn { width: 32px; height: 32px; border-radius: var(--r); background: var(--teal); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--sg-on-accent, #fff); font-size: 14px; flex-shrink: 0; }
.ai-btn:hover { background: var(--sg-teal-700); }
.ai-btn:disabled { background: var(--border2); cursor: not-allowed; }

.ref-row { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding:14px 16px; background:var(--surface); border:0.5px solid var(--border); border-radius:var(--r-lg); margin-bottom:10px; transition:border-color 0.15s; }
.ref-row:hover { border-color:var(--border2); }
.ref-row-main { flex:1; min-width:0; }
.ref-row-title { font-size:14px; font-weight:500; color:var(--text); line-height:1.4; margin-bottom:4px; }
.ref-row-authors { font-size:12px; color:var(--text2); margin-bottom:5px; }
.ref-row-meta { display:flex; align-items:center; gap:12px; }
.ref-journal { font-size:12px; color:var(--text3); font-style:italic; }
.ref-doi { font-size:11px; color:var(--teal); text-decoration:none; padding:2px 7px; background:var(--teal-light); border-radius:4px; }
.ref-doi:hover { background:#cde2e7; }
.ref-verify-btn { font-size:10px; padding:2px 8px; border-radius:4px; border:0.5px solid var(--border2); background:var(--surface); color:var(--text3); cursor:pointer; font-family:var(--font-b); white-space:nowrap; transition:all 0.15s; }
.ref-verify-btn:hover { border-color:var(--teal); color:var(--teal); }
.doi-verified   { font-size:10px; color:#2d7a47; background:#e6f4ea; padding:2px 7px; border-radius:4px; font-weight:500; }
.doi-failed     { font-size:10px; color:#c0392b; background:#fde8e8; padding:2px 7px; border-radius:4px; font-weight:500; }
.doi-mismatch   { font-size:10px; color:#7d3c98; background:#f5eef8; padding:2px 7px; border-radius:4px; font-weight:500; cursor:help; }
.doi-checking   { font-size:10px; color:var(--text3); padding:2px 7px; }
.doi-missing    { font-size:10px; color:#a06000; background:#fff4e0; padding:2px 7px; border-radius:4px; font-weight:500; }
.doi-manual-verify { font-size:10px; padding:1px 6px; border-radius:4px; border:0.5px solid var(--border2); background:var(--surface); color:var(--text3); cursor:pointer; font-family:var(--font-b); white-space:nowrap; transition:all 0.15s; }
.doi-manual-verify:hover { border-color:#2d7a47; color:#2d7a47; background:#e6f4ea; }
.kw-chip { display:inline-flex;align-items:center;gap:5px;padding:4px 10px;background:var(--teal-light);border:0.5px solid var(--teal);border-radius:12px;font-size:12px;color:var(--teal);font-family:var(--font-b);cursor:grab; }
.kw-chip:active { cursor:grabbing; }
.kw-chip button { background:none;border:none;color:var(--teal);cursor:pointer;font-size:11px;padding:0;line-height:1;opacity:0.7; }
.kw-chip button:hover { opacity:1; }
.kw-broad { background:var(--bg2);border-color:var(--border2);color:var(--text3);cursor:grab; }
.kw-broad button { color:var(--text3); }
.composer-chip { cursor:default !important; }
.pm-result { display:flex;align-items:flex-start;gap:10px;padding:10px 12px;border:0.5px solid var(--border);border-radius:8px;margin-bottom:6px;cursor:pointer;transition:border-color 0.15s,background 0.15s; }
.pm-result:hover { border-color:var(--teal);background:var(--teal-light); }
.pm-result.selected { border-color:var(--teal);background:var(--teal-light); }
.pm-result input[type=checkbox] { flex-shrink:0;accent-color:var(--teal);width:15px;height:15px;margin-top:2px;cursor:pointer; }
.pm-result-body { flex:1;min-width:0; }
.pm-result-title { font-size:13px;font-weight:500;color:var(--text);line-height:1.4;margin-bottom:3px; }
.pm-result-meta { font-size:11px;color:var(--text3); }
.pm-dismiss-btn { flex-shrink:0;background:none;border:none;color:var(--border2);font-size:12px;cursor:pointer;padding:2px 4px;line-height:1;border-radius:4px;align-self:flex-start;margin-top:1px; }
.pm-dismiss-btn:hover { color:var(--coral);background:rgba(192,57,43,0.08); }
.pm-pubtype-badge { display:inline-block;font-size:10px;font-weight:500;padding:1px 6px;border-radius:8px;margin-left:6px;vertical-align:middle; }
.pm-pubtype-review   { background:#e6f4ea;color:#2d7a47; }
.pm-pubtype-meta     { background:#e6f4ea;color:#2d7a47; }
.pm-pubtype-article  { background:var(--bg2);color:var(--text3); }
.pm-pubtype-other    { background:var(--bg2);color:var(--text3); }
.pm-cite-badge { font-size:10px;color:var(--text3);margin-left:6px;white-space:nowrap; }
.pm-cite-badge.high { color:var(--teal,#7e4a5d);font-weight:600; }
.pm-cite-badge.very-high { color:var(--teal);font-weight:600; }
.ref-type-btn { background:none;border:none;padding:5px 10px;font-size:11px;font-family:var(--font-b);color:var(--text3);cursor:pointer;font-weight:500; }
.ref-type-btn:hover { background:var(--bg2); }
.ref-type-btn.active { background:var(--teal-light);color:var(--teal); }
.pm-rel-badge { display:inline-block;font-size:10px;font-weight:500;padding:1px 6px;border-radius:8px;background:var(--teal-light,#f0e9ec);color:var(--teal,#7e4a5d);margin-left:6px; }
.pm-status-bar { padding:8px 12px;font-size:11px;color:var(--text3);background:var(--bg2);border-radius:6px;margin-bottom:8px; }
.pm-status-bar code { display:block;margin-top:3px;color:var(--text2); }
.review-panel { background:var(--surface);border:0.5px solid var(--border);border-radius:var(--r-lg);overflow:hidden; }
.review-panel-hdr { display:flex;align-items:center;justify-content:space-between;padding:12px 16px;cursor:pointer;transition:background 0.12s; }
.review-panel-hdr:hover { background:var(--bg2); }
.streaming-cursor { display:inline-block; color:var(--teal); animation:blink 0.8s step-end infinite; }
@keyframes blink { 50% { opacity:0; } }
.md-table { border-collapse:collapse; width:100%; margin:12px 0; font-size:12.5px; }
.md-table th { background:var(--bg2); color:var(--text); font-weight:600; text-align:left; padding:7px 12px; border:0.5px solid var(--border2); white-space:nowrap; }
.md-table td { padding:6px 12px; border:0.5px solid var(--border2); color:var(--text); vertical-align:top; line-height:1.5; }
.md-table tbody tr:nth-child(even) { background:var(--bg2); }
.md-table tbody tr:hover { background:var(--surface); }
.review-panel-chevron { font-size:12px;color:var(--text3);transition:transform 0.2s;flex-shrink:0; }
.preset-btn { padding:5px 12px;border:0.5px solid var(--border2);border-radius:10px;background:var(--bg2);color:var(--text2);font-size:11px;font-weight:500;cursor:pointer;font-family:var(--font-b);transition:all 0.12s; }
.preset-btn:hover { border-color:var(--teal);color:var(--teal);background:var(--teal-light); }
.preset-btn.active { border-color:var(--teal);color:var(--teal);background:var(--teal-light);font-weight:600; }
.sim-section { margin-bottom:18px;padding:12px 14px;background:var(--bg2);border-radius:var(--r-lg);border-left:3px solid var(--teal); }
.sim-section-title { font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--teal);margin-bottom:8px; }
.sim-score { display:inline-block;font-size:18px;font-weight:700;color:var(--teal);margin-right:8px; }
.sim-label { font-size:11px;font-weight:500;color:var(--text3);text-transform:uppercase;letter-spacing:.05em;margin:8px 0 4px; }
.sim-item { font-size:12px;color:var(--text2);line-height:1.7;padding-left:12px;position:relative; }
.sim-item::before { content:'•';position:absolute;left:0;color:var(--teal); }
.comment-cat { margin-bottom:14px;padding:10px 14px;border-radius:var(--r-lg);border:0.5px solid var(--border); }
.comment-cat-title { font-size:12px;font-weight:600;margin-bottom:6px; }
.priority-high   { border-left:3px solid #c0392b;background:#fde8e8; }
.priority-medium { border-left:3px solid #a06000;background:#fff4e0; }
.priority-low    { border-left:3px solid #2d7a47;background:#e6f4ea; }
.concept-block { background:var(--bg2);border:0.5px solid var(--border);border-radius:var(--r-lg);padding:10px 12px; }
.cblk-header { display:flex;align-items:flex-start;gap:8px;margin-bottom:8px; }
.cblk-icon { font-size:16px;line-height:1;flex-shrink:0;margin-top:1px; }
.cblk-label { font-size:12px;font-weight:500;color:var(--text); }
.cblk-hint { font-size:10px;color:var(--text3);margin-top:1px; }
.cblk-chips { display:flex;flex-wrap:wrap;gap:4px;min-height:28px;padding:4px;border-radius:4px;transition:background 0.15s; }
.cblk-inp { flex:1;padding:4px 8px;font-size:11px;border:0.5px solid var(--border2);border-radius:var(--r);background:var(--surface);color:var(--text);font-family:var(--font-b);outline:none; }
.ref-row-side { display:flex; flex-direction:column; align-items:flex-end; gap:7px; flex-shrink:0; min-width:90px; }
.ref-rel-wrap { display:flex; align-items:center; gap:6px; }
.ref-rel-bar { width:60px; height:3px; background:var(--border2); border-radius:2px; overflow:hidden; }
.ref-rel-fill { height:100%; background:var(--teal); border-radius:2px; }
.ref-rel-pct { font-size:11px; color:var(--text3); min-width:28px; text-align:right; }
.ref-sec-badge { font-size:10px; font-weight:500; padding:2px 7px; border-radius:10px; background:var(--teal-light); color:var(--teal); white-space:nowrap; }
.ref-del-btn { background:none; border:none; color:var(--text3); cursor:pointer; font-size:11px; padding:2px 4px; border-radius:3px; transition:all 0.12s; line-height:1; }
.ref-del-btn:hover { color:var(--coral); background:var(--coral-light); }

.cus-row { display:flex; align-items:center; gap:8px; background:var(--bg2); border:0.5px solid var(--border); border-radius:var(--r); padding:8px 10px; cursor:default; }
.cus-row.disabled { opacity:1; }
.cus-drag { color:var(--text3); font-size:14px; cursor:grab; flex-shrink:0; padding:0 2px; user-select:none; }
.cus-drag:active { cursor:grabbing; }
.cus-toggle { width:32px; height:18px; border-radius:9px; border:none; cursor:pointer; flex-shrink:0; position:relative; transition:background 0.2s; }
.cus-toggle.on { background:var(--teal); }
.cus-toggle.off { background:var(--border2); }
.cus-toggle::after { content:''; position:absolute; top:2px; width:14px; height:14px; border-radius:50%; background:white; transition:left 0.15s; }
.cus-toggle.on::after { left:16px; }
.cus-toggle.off::after { left:2px; }
.cus-name { flex:1; font-size:13px; border:none; background:transparent; font-family:var(--font-b); color:var(--text); outline:none; min-width:0; }
.cus-name:focus { background:var(--surface); border-radius:4px; padding:1px 4px; }
.cus-wl-wrap { display:flex; align-items:center; gap:4px; flex-shrink:0; }
.cus-wl { width:64px; padding:3px 6px; font-size:12px; border:0.5px solid var(--border2); border-radius:4px; background:var(--surface); color:var(--text2); font-family:var(--font-b); outline:none; text-align:right; }
.cus-wl:focus { border-color:var(--teal); }
.cus-wl-lbl { font-size:11px; color:var(--text3); white-space:nowrap; }
.cus-weight { width:48px; padding:3px 6px; font-size:12px; border:0.5px solid var(--border2); border-radius:4px; background:var(--surface); color:var(--text2); font-family:var(--font-b); outline:none; text-align:right; }
.cus-weight:focus { border-color:var(--teal); }
.cus-score-toggle { width:28px; height:28px; border-radius:4px; border:0.5px solid var(--border2); background:var(--surface); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:12px; flex-shrink:0; transition:all 0.15s; }
.cus-score-toggle.on { background:var(--teal-light); border-color:var(--teal); color:var(--teal); }
.cus-score-toggle.off { color:var(--text3); }
.cus-col-header { display:flex; align-items:center; gap:8px; padding:0 10px 6px; font-size:10px; font-weight:500; letter-spacing:0.5px; text-transform:uppercase; color:var(--text3); }
.cus-del { background:none; border:none; color:var(--text3); cursor:pointer; font-size:13px; padding:2px 4px; border-radius:3px; flex-shrink:0; }
.cus-del:hover { color:var(--coral); background:var(--coral-light); }
.add-sec-btn { display:flex; align-items:center; gap:6px; padding:8px 12px; border:0.5px dashed var(--border2); border-radius:var(--r); font-size:12px; color:var(--text3); cursor:pointer; background:none; font-family:var(--font-b); width:100%; transition:all 0.12s; }
.add-sec-btn:hover { color:var(--teal); border-color:var(--teal-mid); background:var(--teal-light); }
.sec-lbl-row { display:flex; align-items:center; justify-content:space-between; padding:0 14px 3px 14px; flex-shrink:0; }
.sec-lbl-btn { background:none; border:none; font-size:10px; color:var(--text3); cursor:pointer; font-family:var(--font-b); padding:2px 5px; border-radius:3px; transition:all 0.12s; }
.sec-lbl-btn:hover { color:var(--teal); background:var(--teal-light); }
.sec-lbl-btn:disabled { opacity:0.5; cursor:not-allowed; }

.logo { display: flex; align-items: center; white-space: nowrap; }
.logo span { color: var(--teal); }
.pill { background: var(--teal-light); color: var(--teal); font-size: 11px; font-weight: 500; padding: 2px 9px; border-radius: 20px; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.p01nav-label { background: var(--teal); color: var(--sg-on-accent, #fff); font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: 20px; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.p01nav-label:hover { opacity: 0.85; }
.p01nav-sep { color: var(--text3); font-size: 14px; padding: 0 2px; }
.p01nav-chip { background: var(--bg2); color: var(--text2); font-size: 11px; padding: 3px 10px; border-radius: 14px; white-space: nowrap; cursor: pointer; border: 0.5px solid transparent; transition: background 0.1s, border-color 0.1s; }
.p01nav-chip:hover { background: var(--teal-light); color: var(--teal); border-color: var(--teal-light); }
.p01nav-chip.active { background: var(--teal); color: var(--sg-on-accent, #fff); cursor: default; }
.p01nav-chip.active:hover { background: var(--teal); color: var(--sg-on-accent, #fff); border-color: var(--teal); }
.opt-chip { background: var(--bg); color: var(--text2); font-size: 11px; padding: 2px 9px; border-radius: 11px; cursor: pointer; border: 0.5px solid var(--border); transition: background 0.12s, border-color 0.12s, color 0.12s; user-select: none; font-family: var(--font-b); line-height: 1.5; }
.opt-chip:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }
.opt-chip.active { background: var(--teal); color: var(--sg-on-accent, #fff); border-color: var(--teal); }
.opt-chip.active:hover { background: var(--teal); color: var(--sg-on-accent, #fff); }
.opt-chip-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.opt-chip-grouplbl { font-size: 11px; color: var(--text3); font-weight: 500; margin-top: 9px; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tb-accent { background: var(--sg-teal-700); color: var(--sg-on-accent, #fff); }
html[data-theme="dark"] .tb-accent { background: var(--teal); color: var(--sg-on-accent); }
.score-badge { display: flex; align-items: center; gap: 5px; background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--r); padding: 3px 10px; font-size: 12px; color: var(--text2); }
#topScoreBadge { display: none !important; }
.score-num { font-family: var(--font-m); font-size: 13px; font-weight: 500; color: var(--green); }
.dl-chip { display: flex; align-items: center; gap: 5px; background: var(--coral-light); border: 0.5px solid var(--coral-border, var(--coral)); border-radius: var(--r); padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--coral); white-space: nowrap; }
.dl-chip.submitted { background: var(--green-light); border-color: var(--green); }
.status-seg { display: inline-flex; border: 0.5px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.status-seg label { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; font-size: 12px; color: var(--text2); cursor: pointer; border-right: 0.5px solid var(--border); user-select: none; transition: background 0.12s, color 0.12s; }
.status-seg label:last-child { border-right: none; }
.status-seg label:hover { background: var(--bg2); }
.status-seg input[type="radio"] { display: none; }
.status-seg label:has(input:checked) { background: var(--teal); color: var(--sg-on-accent, #fff); font-weight: 500; }
.section-hdr-row td { padding: 8px 14px !important; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); background: rgba(0,0,0,0.03); }
.section-hdr-row.collapsible { cursor: pointer; transition: background 0.12s; }
.section-hdr-row.collapsible:hover td { background: rgba(0,0,0,0.06); }
.section-hdr-row .caret { float: right; font-size: 12px; font-weight: 400; color: var(--text3); }
.nav-item.disabled, .inner-icon-item.disabled, .sec-item.disabled { opacity: 0.35; cursor: not-allowed; }
.nav-item.disabled:hover, .inner-icon-item.disabled:hover, .sec-item.disabled:hover { background: none; color: inherit; }
.readonly-banner { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 0 0 12px; border-radius: var(--r); font-size: 13px; line-height: 1.5; }
.readonly-banner.submitted { background: var(--green-light, #e6f3ec); border: 0.5px solid #a8d4b8; color: #2a6a45; }
.readonly-banner.archived  { background: var(--bg2); border: 0.5px solid var(--border); color: var(--text2); }
.readonly-banner .ro-text { flex: 1; }
.readonly-banner .ro-cta  { background: var(--surface); border: 0.5px solid var(--border2); border-radius: var(--r); padding: 5px 12px; font-size: 12px; color: var(--text); cursor: pointer; font-family: var(--font-b); white-space: nowrap; transition: background 0.12s; }
.readonly-banner .ro-cta:hover { background: var(--teal); color: var(--sg-on-accent, #fff); border-color: var(--teal); }
.tb-btn { background: none; border: 0.5px solid var(--border2); border-radius: var(--r); padding: 4px 11px; font-size: 12px; font-family: var(--font-b); color: var(--text2); cursor: pointer; transition: background 0.12s; }
.tb-btn:hover { background: var(--bg2); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--teal-light); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 500; color: var(--sg-teal-900); flex-shrink: 0; cursor: pointer; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.42); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--r-xl); padding: 20px 24px; width: 420px; max-width: 92vw; max-height: 90vh; overflow-y: auto; border: 0.5px solid var(--border); }
.modal-title { font-family: var(--font-d); font-size: 19px; font-weight: 500; margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--text2); margin-bottom: 12px; line-height: 1.5; }
.m-lbl { font-size: 11px; color: var(--text3); margin-bottom: 3px; }
.m-inp { width: 100%; padding: 7px 10px; border: 0.5px solid var(--border2); border-radius: var(--r); font-family: var(--font-b); font-size: 13px; color: var(--text); background: var(--bg2); outline: none; margin-bottom: 9px; transition: border-color 0.15s; }
.m-inp:focus { border-color: var(--teal); }
.m-row { display: flex; gap: 8px; margin-bottom: 9px; }
.m-row .m-inp { margin-bottom: 0; }
.m-actions { display: flex; gap: 7px; justify-content: flex-end; margin-top: 4px; }

.ng-page-wrap { max-width: 620px; margin: 0 auto; }
.ng-group-lbl {
  font-family: var(--font-d);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 0.5px solid var(--border);
}
.ng-group-lbl:first-child { margin-top: 0; }
#screen-newgrant:not(.ng-edit-mode) .eg-modal-only-note { display: none; }
.ng-page-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 0.5px solid var(--border);
}
.modal .sg-modal-footer {
  margin: 16px -24px -20px;
  border-bottom-left-radius: var(--r-xl);
  border-bottom-right-radius: var(--r-xl);
}
.btn-primary { background: var(--teal); color: var(--sg-on-accent, #fff); border: none; border-radius: var(--r); padding: 6px 15px; font-size: 13px; font-family: var(--font-b); cursor: pointer; font-weight: 500; }
.btn-primary:hover { background: var(--sg-teal-700); }
.btn-ghost { background: none; color: var(--text2); border: 0.5px solid var(--border2); border-radius: var(--r); padding: 6px 15px; font-size: 13px; font-family: var(--font-b); cursor: pointer; }
.btn-ghost:hover { background: var(--bg2); }

.spinner { display: inline-block; width: 11px; height: 11px; border: 2px solid rgba(126,74,93,0.3); border-top-color: var(--teal); border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.save-indicator { font-size: 11px; color: var(--text3); transition: color 0.3s; }
.save-indicator.saving { color: var(--amber); }
.save-indicator.saved { color: var(--green); }
.save-indicator.failed { color: var(--coral); font-weight: 500; }
#rubricPasteEditor:empty:before {
  content: attr(placeholder);
  color: var(--text3);
  pointer-events: none;
}
#abstractEditor:empty:before { content: attr(data-placeholder); color: var(--text3); pointer-events: none; }
#rubricPasteEditor, #rubricPasteEditor * {
  font-family: var(--font-b) !important;
  font-size: 13px !important;
  color: var(--text) !important;
  background: transparent !important;
  line-height: 1.65 !important;
}
#rubricPasteEditor b, #rubricPasteEditor strong { font-weight: 600 !important; }
#rubricPasteEditor i, #rubricPasteEditor em     { font-style: italic !important; }
#rubricPasteEditor u                            { text-decoration: underline !important; }
#rubricPasteEditor h1, #rubricPasteEditor h2,
#rubricPasteEditor h3, #rubricPasteEditor h4    { font-size: 13px !important; font-weight: 600 !important; margin: 8px 0 4px !important; }
#rubricPasteEditor p                            { margin: 0 0 8px 0 !important; }
#rubricPasteEditor ul, #rubricPasteEditor ol    { margin: 4px 0 8px 16px !important; padding: 0 !important; }
#rubricPasteEditor li                           { margin-bottom: 3px !important; }
#rubricPasteEditor blockquote                   { border-left: 3px solid var(--border2) !important; padding-left: 10px !important; margin: 6px 0 !important; }
#rubricPasteEditor table  { border-collapse: collapse !important; width: 100% !important; margin: 8px 0 !important; }
#rubricPasteEditor td,
#rubricPasteEditor th     { border: 0.5px solid var(--border2) !important; padding: 5px 9px !important; vertical-align: top !important; }
#rubricPasteEditor th     { background: var(--bg2) !important; font-weight: 600 !important; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
#notesDragHandle:hover, #notesDragHandle.dragging { background: var(--border2); }
#notesDragHandle:hover .notes-handle-pill, #notesDragHandle.dragging .notes-handle-pill { opacity: 1; }
#sectionNotes::placeholder { color: var(--text3); font-style: italic; }
.b-sec-title { background: none; border: none; outline: none; font-size: 13px; font-weight: 500; color: var(--text); font-family: var(--font-b); width: 100%; cursor: text; }
.b-sec-title:hover, .b-sec-title:focus { background: var(--bg2); border-radius: 4px; padding: 1px 4px; margin: -1px -4px; }
.b-th { background: none; border: none; outline: none; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text3); font-family: var(--font-b); width: 100%; cursor: text; padding: 0; }
.b-th:hover, .b-th:focus { color: var(--teal); }

.dd-wrap { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 24px 36px 80px; box-sizing: border-box; width: 100%; }
.dd-wrap > * { max-width: 980px; margin-left: auto; margin-right: auto; }
.dd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.dd-head .dd-title { font-family: var(--font-d); font-size: 26px; font-weight: 600; color: var(--text); margin: 0 0 4px; letter-spacing: -0.2px; }
.dd-head .dd-sub { font-size: 13px; color: var(--text2); line-height: 1.5; max-width: 620px; }
.dd-head .dd-beta { display:inline-block; font-size:9px; padding:2px 7px; border-radius:8px; background: var(--coral,#e07a5f); color:#fff; letter-spacing:.5px; margin-left:8px; vertical-align: middle; font-weight:600; }
.dd-actions { display:flex; gap:8px; flex-shrink:0; }
.dd-run-btn { padding: 9px 16px; font-size: 13px; font-weight: 500; background: var(--teal); color: var(--sg-on-accent, #fff); border: none; border-radius: var(--r); cursor: pointer; display:inline-flex; align-items:center; gap:6px; }
.dd-run-btn:hover { background: var(--sg-teal-700); }
.dd-run-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.dd-secondary-btn { padding: 9px 14px; font-size: 12px; background: var(--bg2); color: var(--text2); border: 0.5px solid var(--border); border-radius: var(--r, 6px); cursor: pointer; }
.dd-secondary-btn:hover { background: var(--bg3, var(--bg2)); }
.dd-steps { display:flex; gap:4px; margin: 4px 0 22px; padding: 14px; background: var(--bg2); border: 0.5px solid var(--border); border-radius: 8px; overflow-x:auto; }
.dd-step { flex: 1; min-width: 110px; display:flex; flex-direction: column; align-items:flex-start; padding: 8px 10px; border-radius: 6px; border: 0.5px solid transparent; background: transparent; }
.dd-step .dd-step-num { font-size: 10px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--text3); }
.dd-step .dd-step-name { font-size: 12px; color: var(--text2); margin-top: 2px; line-height: 1.35; }
.dd-step.active { background: var(--teal-light); border-color: var(--teal); }
.dd-step.active .dd-step-num { color: var(--teal); }
.dd-step.active .dd-step-name { color: var(--text); font-weight: 500; }
.dd-step.done { background: var(--bg); border-color: var(--border); }
.dd-step.done .dd-step-num::before { content: "✓ "; color: #3a8a5a; }
.dd-step.done .dd-step-name { color: var(--text2); }
.dd-card { background: var(--bg); border: 0.5px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 14px; overflow-wrap: anywhere; word-break: break-word; }
.dd-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 8px; display:flex; align-items:center; gap:8px; }
.dd-card-title .dd-pill { font-size:9px; font-weight:600; letter-spacing:.4px; padding:2px 7px; border-radius:8px; background: var(--bg2); color: var(--text2); text-transform: uppercase; border: 0.5px solid var(--border); }
.dd-card-title .dd-pill.pending  { background:#fff7e6; color:#a85d00; border-color:#f3d9a8; }
.dd-card-title .dd-pill.error    { background:#fbe6e6; color:#a83232; border-color:#f3a8a8; }
.dd-card-title .dd-pill.complete { background:#e6f3ec; color:#2a6a45; border-color:#a8d4b8; }
.dd-card .dd-sub { font-size: 11px; color: var(--text3); margin-bottom: 8px; }
.dd-card .dd-prose { font-size: 13px; color: var(--text); line-height: 1.55; }
.dd-card .dd-kv { display: grid; grid-template-columns: 130px 1fr; row-gap: 6px; column-gap: 14px; font-size: 12px; line-height: 1.5; }
.dd-card .dd-kv .dd-k { color: var(--text3); font-weight: 500; }
.dd-card .dd-kv .dd-v { color: var(--text); }
.dd-card .dd-aim { padding: 6px 0; border-top: 0.5px dashed var(--border); }
.dd-card .dd-aim:first-of-type { border-top: 0; }
.dd-card .dd-aim-id { font-weight: 600; color: var(--teal); font-size: 12px; }
.dd-card .dd-aim-body { font-size: 12px; color: var(--text2); margin-top: 2px; line-height: 1.5; }
.dd-cluster { background: var(--bg); border: 0.5px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.dd-cluster .dd-cluster-name { font-size: 13px; font-weight: 600; color: var(--text); display:flex; align-items:center; gap:8px; }
.dd-cluster .dd-cluster-type { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text3); }
.dd-cluster .dd-cluster-rationale { font-size: 12px; color: var(--text2); margin: 6px 0 8px; line-height: 1.5; }
.dd-cluster .dd-queries { margin: 6px 0; }
.dd-cluster .dd-queries .dd-query { display:inline-block; font-family: var(--font-m, ui-monospace, SFMono-Regular, monospace); font-size: 11px; padding: 3px 7px; background: var(--bg2); border: 0.5px solid var(--border); border-radius: 4px; margin: 2px 4px 2px 0; color: var(--text); }
.dd-cluster .dd-cluster-status { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .4px; margin-top: 6px; }
.dd-cluster .dd-cluster-status::before { content: "○ "; color: var(--text3); }
.dd-cluster .dd-cluster-status.searched { color: #2a6a45; }
.dd-cluster .dd-cluster-status.searched::before { content: "● "; color: #2a6a45; }
.dd-cluster .dd-cluster-status.search_failed { color: #a83232; }
.dd-cluster .dd-cluster-status.search_failed::before { content: "✕ "; color: #a83232; }
.dd-papers { margin-top: 10px; border-top: 0.5px dashed var(--border); padding-top: 8px; }
.dd-paper  { padding: 6px 0; border-top: 0.5px dotted var(--border); font-size: 12px; line-height: 1.45; }
.dd-paper:first-of-type { border-top: 0; }
.dd-paper .dd-paper-title { color: var(--text); font-weight: 500; }
.dd-paper .dd-paper-title a { color: var(--text); text-decoration: none; }
.dd-paper .dd-paper-title a:hover { color: var(--teal); text-decoration: underline; }
.dd-paper .dd-paper-meta { color: var(--text3); font-size: 11px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dd-paper .dd-paper-badge { display: inline-block; font-size: 9px; padding: 1px 6px; border-radius: 8px; background: var(--bg2); color: var(--text3); border: 0.5px solid var(--border); text-transform: uppercase; letter-spacing: .3px; font-weight: 600; }
.dd-paper .dd-paper-badge.preprint { background:#fff7e6; color:#a85d00; border-color:#f3d9a8; }
.dd-paper .dd-paper-badge.cites    { background: var(--bg2); color: var(--text2); }
.dd-cluster .dd-cluster-search-meta { font-size: 10px; color: var(--text3); margin-top: 6px; font-style: italic; }
.mr-item { padding: 10px 0; border-top: 0.5px dashed var(--border); }
.mr-item:first-of-type { border-top: 0; padding-top: 0; }
.mr-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.mr-item-topic { font-size: 12px; font-weight: 600; color: var(--text); }
.mr-item-loc { font-size: 10px; color: var(--text3); font-style: italic; }
.mr-sev { font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 8px; text-transform: uppercase; letter-spacing: .3px; border: 0.5px solid var(--border); }
.mr-sev.major   { background: #fbe6e6; color: #a83232; border-color: #f3a8a8; }
.mr-sev.minor   { background: #fff7e6; color: #a85d00; border-color: #f3d9a8; }
.mr-sev.nitpick { background: var(--bg2); color: var(--text3); }
.mr-verdict { font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 8px; text-transform: uppercase; letter-spacing: .3px; border: 0.5px solid var(--border); }
.mr-verdict.supported           { background: #e6f3ec; color: #2a6a45; border-color: #a8d4b8; }
.mr-verdict.partially_supported { background: #fff7e6; color: #a85d00; border-color: #f3d9a8; }
.mr-verdict.unsupported         { background: #fbe6e6; color: #a83232; border-color: #f3a8a8; }
.mr-verdict.overstated          { background: #fbe6e6; color: #a83232; border-color: #f3a8a8; }
.mr-verdict.data_not_shown      { background: #fff7e6; color: #a85d00; border-color: #f3d9a8; }
.mr-verdict.novel             { background: #e6f3ec; color: #2a6a45; border-color: #a8d4b8; }
.mr-verdict.partial_overlap   { background: #fff7e6; color: #a85d00; border-color: #f3d9a8; }
.mr-verdict.precedent_exists  { background: #fbe6e6; color: #a83232; border-color: #f3a8a8; }
.mr-verdict.incremental       { background: var(--bg2); color: var(--text2); }
.mr-verdict.partial_match     { background: #fff7e6; color: #a85d00; border-color: #f3d9a8; }
.mr-verdict.mismatch          { background: #fbe6e6; color: #a83232; border-color: #f3a8a8; }
.mr-verdict.cannot_verify     { background: var(--bg2); color: var(--text3); }
.mr-verdict.not_cited         { background: var(--bg2); color: var(--text3); font-style: italic; }
.mr-ref { padding: 8px 0; border-top: 0.5px dashed var(--border); }
.mr-ref:first-of-type { border-top: 0; padding-top: 0; }
.mr-ref-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.mr-ref-num { font-size: 11px; font-weight: 600; color: var(--text3); min-width: 26px; }
.mr-ref-title { font-size: 12px; color: var(--text); font-weight: 500; }
.mr-ref-title a { color: var(--text); text-decoration: none; }
.mr-ref-title a:hover { color: var(--teal); text-decoration: underline; }
.mr-ref-meta { font-size: 11px; color: var(--text3); margin: 2px 0 4px 32px; }
.mr-ref-body { font-size: 12px; color: var(--text2); line-height: 1.5; margin-left: 32px; }
.mr-ref-body .mr-quote { display: block; padding: 5px 8px; background: var(--bg2); border-left: 2px solid var(--border); border-radius: 0 4px 4px 0; color: var(--text); margin: 4px 0; font-style: italic; font-size: 11.5px; }
.mr-ref-body p { margin: 3px 0; }
.mr-ref-section { margin-top: 16px; }
.mr-ref-section-title { font-size: 11px; font-weight: 600; color: var(--text3); letter-spacing: .3px; text-transform: uppercase; margin: 0 0 6px; }
.mr-paper { padding: 6px 0; border-top: 0.5px dotted var(--border); font-size: 12px; line-height: 1.45; }
.mr-paper:first-of-type { border-top: 0; }
.mr-paper-title a { color: var(--text); text-decoration: none; font-weight: 500; }
.mr-paper-title a:hover { color: var(--teal); text-decoration: underline; }
.mr-paper-meta { color: var(--text3); font-size: 11px; margin-top: 2px; }
.mr-paper-relevance { color: var(--text2); font-size: 11px; margin-top: 3px; font-style: italic; }
.mr-item-body { font-size: 12px; color: var(--text2); line-height: 1.55; }
.mr-item-body p { margin: 4px 0; }
.mr-item-body .mr-quote { display: block; padding: 6px 10px; background: var(--bg2); border-left: 2px solid var(--border); border-radius: 0 4px 4px 0; color: var(--text); margin: 4px 0; font-style: italic; }
.mr-overall { padding: 10px 12px; background: var(--bg2); border-radius: 6px; font-size: 12px; color: var(--text2); line-height: 1.55; margin-top: 12px; }
.mr-overall::before { content: "📊 "; }
.mr-overall strong { color: var(--text); font-weight: 500; }
.mr-count { font-size: 11px; color: var(--text3); margin-bottom: 8px; }
.dd-empty { padding: 40px 20px; text-align: center; color: var(--text3); font-size: 13px; line-height: 1.6; background: var(--bg2); border: 0.5px dashed var(--border); border-radius: 10px; }
.dd-empty strong { display: block; font-size: 14px; color: var(--text2); margin-bottom: 6px; }
.dd-reasoning { margin-top: 18px; }
.dd-reasoning details { background: var(--bg2); border: 0.5px solid var(--border); border-radius: 6px; padding: 8px 12px; margin-bottom: 6px; }
.dd-reasoning summary { font-size: 11px; color: var(--text2); cursor: pointer; user-select: none; font-weight: 500; }
.dd-reasoning summary::-webkit-details-marker { display: none; }
.dd-reasoning summary::before { content: "▸ "; color: var(--text3); }
.dd-reasoning details[open] summary::before { content: "▾ "; }
.dd-reasoning .dd-trace { font-family: var(--font-m, ui-monospace, SFMono-Regular, monospace); font-size: 11px; color: var(--text2); margin-top: 6px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

#fig-dropzone.drag { border-color: var(--teal) !important; background: var(--teal-light) !important; }
.fig-frame.drag { outline: 2px solid var(--teal); outline-offset: -2px; background: var(--teal-light) !important; }


.settings-page { display: flex; gap: 28px; margin-top: 6px; align-items: flex-start; max-width: 1240px; }
.settings-nav-col { flex: 0 0 196px; }
.settings-back { padding: 5px 12px; font-size: 12.5px; white-space: nowrap; margin-bottom: 16px; }
.settings-nav-col .page-sub { font-size: 12px; line-height: 1.4; margin-bottom: 14px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav-item { text-align: left; background: none; border: none; font-family: var(--font-b); font-size: 13px; color: var(--text2); padding: 9px 12px; border-radius: var(--r); cursor: pointer; transition: background 0.12s, color 0.12s; }
.settings-nav-item:hover { background: var(--bg2); color: var(--text); }
.settings-nav-item.active { background: var(--teal-light); color: var(--teal); font-weight: 500; }
.settings-content { flex: 1; min-width: 0; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
#set-panel-account, #set-panel-tokens, #set-panel-ai { max-width: 600px; margin-top: 40px; }
@media (max-width: 760px) {
  .settings-page { flex-direction: column; gap: 14px; }
  .settings-nav-col { flex: 1 1 auto; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; margin-top: 8px; }
}

.settings-plans .sp-head { text-align: center; margin-bottom: 8px; }
.settings-plans .sp-lede { font-size: 13.5px; color: var(--text2); margin-bottom: 18px; }
.settings-plans .sp-current { display: inline-block; background: var(--teal-light); color: var(--teal); font-size: 12.5px; font-weight: 500; padding: 5px 14px; border-radius: 999px; margin-bottom: 12px; }
.settings-plans .sp-current strong { color: var(--teal); font-weight: 700; }
.settings-plans .billing-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; margin: 0 auto 8px; }
.settings-plans .billing-toggle button { font-family: var(--font-b); font-size: 13px; font-weight: 500; padding: 8px 18px; border: none; background: transparent; color: var(--text2); border-radius: 999px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.settings-plans .billing-toggle button.active { background: var(--teal); color: var(--sg-on-accent, #fff); }
.settings-plans .save-badge { display: inline-block; font-size: 11px; background: var(--teal); color: var(--sg-on-accent, #fff); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.settings-plans .billing-toggle button.active .save-badge { background: #fff; color: var(--teal); }
.settings-plans .pricing-grid { display: grid; grid-template-columns: repeat(var(--plan-cols, 5), 1fr); gap: 14px; padding: 22px 0 8px; align-items: stretch; }
@media (max-width: 1240px) { .settings-plans .pricing-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) { .settings-plans .pricing-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .settings-plans .pricing-grid { grid-template-columns: 1fr; } }
.settings-plans .tier { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 24px 20px; display: flex; flex-direction: column; position: relative; }
.settings-plans .tier.popular { border: 2px solid var(--teal); box-shadow: 0 8px 28px rgba(126,74,93,0.10); padding-top: 46px; }
.settings-plans .tier.institutional { background: linear-gradient(160deg, var(--plan-inst-a, #3a1f2b), var(--plan-inst-b, #56303f)); color: #fff; border: 1px solid var(--plan-inst-a, #3a1f2b); }
.settings-plans .popular-tag { position: absolute; top: 0; left: 0; right: 0; background: var(--teal); color: var(--sg-on-accent, #fff); font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px; padding: 7px; text-align: center; border-radius: 14px 14px 0 0; text-transform: uppercase; }
.settings-plans .tier.early { border: 2px solid var(--teal); box-shadow: 0 8px 28px rgba(126,74,93,0.10); padding-top: 46px; }
.settings-plans .early-tag { position: absolute; top: 0; left: 0; right: 0; background: var(--teal); color: var(--sg-on-accent, #fff); font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px; padding: 7px; text-align: center; border-radius: 14px 14px 0 0; text-transform: uppercase; }
.settings-plans .tier-price-original { font-family: var(--font-d); font-size: 20px; color: var(--text3); text-decoration: line-through; line-height: 1; margin-bottom: 4px; }
.settings-plans .discount-chip { display: inline-block; background: var(--teal-light); color: var(--teal); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px; margin-top: 8px; }
.settings-plans .tier.coming-soon { opacity: 0.78; padding-top: 46px; }
.settings-plans .coming-soon-tag { position: absolute; top: 0; left: 0; right: 0; background: var(--text3); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px; padding: 7px; text-align: center; border-radius: 14px 14px 0 0; text-transform: uppercase; }
.settings-plans .current-chip { display: inline-block; background: var(--green); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; padding: 3px 10px; border-radius: 999px; margin-bottom: 10px; text-transform: uppercase; }
.settings-plans .tier-name { font-family: var(--font-d); font-size: 22px; font-weight: 600; color: var(--teal); margin-bottom: 6px; }
.settings-plans .tier.institutional .tier-name { color: #fff; }
.settings-plans .tier-tagline { font-size: 12.5px; color: var(--text2); min-height: 34px; margin-bottom: 16px; line-height: 1.4; }
.settings-plans .tier.institutional .tier-tagline { color: rgba(255,255,255,0.85); }
.settings-plans .tier-price { font-family: var(--font-d); font-size: 37px; font-weight: 600; color: var(--teal); line-height: 1; margin-bottom: 2px; }
.settings-plans .tier.institutional .tier-price { color: #fff; font-size: 28px; }
.settings-plans .currency-prefix { font-size: 20px; font-weight: 500; color: var(--text2); margin-right: 2px; }
.settings-plans .tier-price-sub { font-size: 13px; color: var(--text2); font-family: var(--font-b); font-weight: 400; }
.settings-plans .tier.institutional .tier-price-sub { color: rgba(255,255,255,0.8); }
.settings-plans .tier-billing-note { font-size: 11.5px; color: var(--text3); margin-top: 4px; min-height: 16px; }
.settings-plans .tier.institutional .tier-billing-note { color: rgba(255,255,255,0.7); }
.settings-plans .tier-tokens { background: var(--bg2); border-radius: 10px; padding: 12px 13px; margin-top: 16px; font-size: 13px; }
.settings-plans .tier.institutional .tier-tokens { background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.15); }
.settings-plans .tier-tokens-main { font-weight: 600; color: var(--teal); }
.settings-plans .tier.institutional .tier-tokens-main { color: #fff; }
.settings-plans .tier-tokens-sub { font-size: 11.5px; color: var(--text2); margin-top: 2px; }
.settings-plans .tier.institutional .tier-tokens-sub { color: rgba(255,255,255,0.75); }
.settings-plans .tier-cta { display: block; width: 100%; box-sizing: border-box; background: var(--teal); color: var(--sg-on-accent, #fff); border: none; padding: 12px 18px; border-radius: 10px; font-family: var(--font-b); font-size: 13.5px; font-weight: 600; cursor: pointer; margin-top: 18px; transition: background 0.2s; text-decoration: none; text-align: center; }
.settings-plans .tier-cta:hover { background: var(--teal-mid); }
.settings-plans .tier.popular .tier-cta { background: var(--teal); }
.settings-plans .tier.popular .tier-cta:hover { background: var(--teal); filter: brightness(0.92); }
.settings-plans .tier.outline .tier-cta { background: var(--surface); color: var(--teal); border: 1.5px solid var(--teal); }
.settings-plans .tier.outline .tier-cta:hover { background: var(--teal-light); }
.settings-plans .tier.institutional .tier-cta { background: #fff; color: var(--teal); }
.settings-plans .tier.institutional .tier-cta:hover { background: var(--bg2); }
.settings-plans .tier-cta.is-locked { background: var(--bg2) !important; color: var(--text2) !important; border: 1px solid var(--border) !important; cursor: default; pointer-events: none; }
.settings-plans .tier-cta.is-current { background: var(--teal-light) !important; color: var(--teal) !important; border: 1px solid rgba(126,74,93,0.25) !important; font-weight: 600; cursor: default; pointer-events: none; }
.settings-plans .tier-cta-disabled { display: block; width: 100%; box-sizing: border-box; background: var(--bg2); color: var(--text3); border: 1px solid var(--border); padding: 12px 18px; border-radius: 10px; font-family: var(--font-b); font-size: 13.5px; font-weight: 600; margin-top: 18px; text-align: center; cursor: not-allowed; pointer-events: none; }
.settings-plans .tier-features { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); flex-grow: 1; }
.settings-plans .tier.institutional .tier-features { border-top: 1px solid rgba(255,255,255,0.18); }
.settings-plans .tier-features-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text2); margin-bottom: 11px; }
.settings-plans .tier.institutional .tier-features-label { color: rgba(255,255,255,0.75); }
.settings-plans .tier-features ul { list-style: none; margin: 0; padding: 0; }
.settings-plans .tier-features li { font-size: 13px; color: var(--text); margin-bottom: 8px; padding-left: 21px; position: relative; line-height: 1.45; }
.settings-plans .tier.institutional .tier-features li { color: rgba(255,255,255,0.95); }
.settings-plans .tier-features li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--green); font-weight: 700; }
.settings-plans .tier.institutional .tier-features li::before { color: rgba(255,255,255,0.85); }

.settings-plans .tier.outline:not(.coming-soon) { --teal:#4b4945; --teal-light:#f1f0ee; --sg-on-accent:#ffffff; }
.settings-plans .tier.popular { --teal:#35577e; --teal-light:#e6edf5; --sg-on-accent:#ffffff; }
.settings-plans .tier.coming-soon { --teal:#52704b; --teal-light:#e8efe5; --sg-on-accent:#ffffff; }
.settings-plans .tier.institutional { --plan-inst-a:#3a1f2b; --plan-inst-b:#56303f; }
html[data-theme="dark"] .settings-plans .tier.outline:not(.coming-soon) { --teal:#c9c4bd; --teal-light:#34322f; --sg-on-accent:#1c1a19; }
html[data-theme="dark"] .settings-plans .tier.popular { --teal:#9db8d9; --teal-light:#22303f; --sg-on-accent:#1c1a19; }
html[data-theme="dark"] .settings-plans .tier.coming-soon { --teal:#a6c49e; --teal-light:#26301f; --sg-on-accent:#1c1a19; }
html[data-theme="dark"] .settings-plans .tier.institutional { --plan-inst-a:#2a1820; --plan-inst-b:#432735; }

.faq-badge { display: inline-block; width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 50%; background: var(--teal-light); color: var(--sg-teal-900); font-family: var(--font-b); font-size: 11px; font-weight: 600; vertical-align: middle; position: relative; top: -1px; margin: 0 2px; }
#sgDialogBody .sg-dlg-p { margin: 0; }
#sgDialogBody .sg-dlg-p + .sg-dlg-p { margin-top: 1.6em; }
.overlay.sg-dialog-gentle { animation: sgDlgFade 220ms ease-out; }
.overlay.sg-dialog-gentle .modal { animation: sgDlgRise 260ms ease-out; }
@keyframes sgDlgFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sgDlgRise { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .overlay.sg-dialog-gentle, .overlay.sg-dialog-gentle .modal { animation: none; } }

.reb-response { position: relative; min-height: 180px; padding: 12px 14px; border: 0.5px solid var(--border2); border-radius: var(--r-lg); background: var(--bg2); }
.reb-response:focus { border-color: var(--teal); }
.reb-response.reb-empty::before { content: attr(data-placeholder); position: absolute; left: 14px; right: 14px; top: 12px; color: var(--text3); pointer-events: none; }
.reb-response[contenteditable="false"] { opacity: .75; }
.reb-toolbar { height: auto; min-height: 34px; flex-wrap: wrap; overflow: visible; margin: 0 0 8px; padding: 3px 6px; border: 0.5px solid var(--border2); border-radius: var(--r); background: var(--bg2); }