/* ==========================================================================
   Literati — marketing site. Cursor-style shell + faithful Midnight app mockup
   ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --page-bg: #0a0f19;
  --page-bg-soft: #0f1420;
  --page-text: #e0e6f0;
  --page-muted: #9aa4b8;
  --page-faint: #6b7687;
  --page-border: rgba(255,255,255,0.08);

  /* app window — Deep Sea theme, sampled from the app */
  --bg-primary: #0f1420;     /* editor, pdf pane, inputs, active tab */
  --bg-secondary: #161c2b;   /* topbar, sidebar */
  --bg-tertiary: #20293f;    /* accent buttons (Compile, find papers) */
  --bg-hover: #1b2233;
  --bg-selected: #2a416b;
  --bg-iconactive: #232c42;
  --text-primary: #e0e6f0;
  --text-secondary: #9aa4b8;
  --text-muted: #6b7687;
  --accent: #79c0ff;
  --border: #232c42;
  --border-light: #303744;
  --success: #4caf50;
  --error: #f44336;
  --st-add: #2ea043;
  --st-mod: #2563eb;
  --st-del: #dc2626;

  --syntax-keyword: #79c0ff;
  --syntax-math: #b48ef5;
  --syntax-label: #ffa657;
  --syntax-number: #f78c6c;
  --syntax-comment: #6b7687;
  --syntax-string: #a8b3c2;
  --syntax-content: #e0e6f0;
  --syntax-bracket: #5b6578;

  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-xl: 14px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco, Consolas, monospace;
}

html { scroll-behavior: smooth; scroll-padding-top: 90px; }
body { font-family: var(--font-ui); background: var(--page-bg); color: var(--page-text); line-height: 1.6; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ---------- Nav ---------- */
.nav { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; background: rgba(11,11,16,0.72); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid transparent; transition: border-color .25s ease; }
.nav.scrolled { border-bottom-color: var(--page-border); }
.nav-inner { max-width: 1320px; margin: 0 auto; height: 64px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.nav-brand { display: flex; align-items: center; }
.nav-wordmark { height: 22px; width: auto; display: block; }
.nav-links { display: flex; gap: 30px; position: absolute; left: 50%; transform: translateX(-50%); }
.nav-links a, .nav-link-quiet { font-size: .92rem; font-weight: 500; color: var(--page-muted); transition: color .18s ease; }
.nav-links a:hover, .nav-link-quiet:hover { color: var(--page-text); }
.nav-actions { display: flex; align-items: center; gap: 14px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-ui); font-size: .95rem; font-weight: 600; padding: 11px 20px; border-radius: 999px; cursor: pointer; border: 1px solid transparent; white-space: nowrap; transition: transform .15s ease, background .18s ease, border-color .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-white { background: #f4f4f5; color: #111; } .btn-white:hover { background: #fff; }
.btn-ghost { background: rgba(255,255,255,0.04); color: var(--page-text); border-color: var(--page-border); } .btn-ghost:hover { background: rgba(255,255,255,0.09); }
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.nav-actions .btn { padding: 9px 16px; font-size: .9rem; }

/* ---------- Section scaffold ---------- */
.section { padding: 110px 0; position: relative; }
.section-head { max-width: 760px; margin-bottom: 40px; }
.section-head.center { margin-left: auto; margin-right: auto; text-align: center; }
.eyebrow { display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #79c0ff; margin-bottom: 16px; }
.section h2 { font-size: 2.4rem; line-height: 1.1; font-weight: 700; letter-spacing: -.03em; color: #fff; margin-bottom: 16px; }
.section h2 em { font-style: italic; color: #c9a8ff; }
.section h2 .accent2 { color: #79c0ff; }
.section .lede { font-size: 1.18rem; color: var(--page-muted); max-width: 640px; }
.section .lede .hl { color: var(--page-text); font-weight: 500; }
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
.demo-caption { margin-top: 22px; text-align: center; font-size: 1.05rem; font-weight: 600; color: var(--page-text); }
.demo-caption .glow { background: linear-gradient(110deg,#9aa6ff,#c9a8ff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* demo wallpaper stage (same computer-screen backdrop as the hero) */
.demo-stage { position: relative; width: 100%; padding: 70px 24px; margin: 28px 0; overflow: hidden;
  background:
    linear-gradient(180deg, var(--page-bg), transparent 90px),
    linear-gradient(0deg, var(--page-bg), transparent 90px),
    linear-gradient(180deg,#d7c6a4 0%,#c8c1a6 22%,#aeb6ad 46%,#95a7b0 70%,#7f95a4 100%); }
.demo-stage::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(70% 60% at 75% 6%, rgba(255,247,225,.6), transparent 60%), radial-gradient(80% 50% at 14% 100%, rgba(70,92,120,.4), transparent 65%), radial-gradient(55% 45% at 96% 80%, rgba(120,140,120,.32), transparent 60%); }
.demo-stage .ide-window { position: relative; z-index: 1; max-width: 1060px; margin: 0 auto; box-shadow: 0 44px 96px rgba(0,0,0,.55), 0 0 0 1px rgba(0,0,0,.4); }

/* ====================== APP WINDOW ====================== */
.ide-window { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; color: var(--text-primary); box-shadow: 0 30px 70px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,0.04); }
.section .ide-window { max-width: 1060px; margin: 0 auto; }

/* top bar */
.app-topbar { height: 46px; display: flex; align-items: center; background: var(--bg-secondary); border-bottom: 1px solid var(--border); padding: 0 14px; position: relative; }
.tb-left { display: flex; align-items: center; z-index: 1; }
.tb-logo { width: 22px; height: 22px; display: block; }
.tb-center { position: absolute; left: 50%; transform: translateX(-50%); font-size: 13px; color: var(--text-primary); font-weight: 500; }
.tb-right { margin-left: auto; z-index: 1; }
.tb-share { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-primary); background: rgba(255,255,255,0.06); border: 1px solid var(--border-light); border-radius: 999px; padding: 5px 14px; }
.tb-share svg { width: 13px; height: 13px; }

/* body / 3-pane */
.app-body { display: flex; height: 560px; position: relative; overflow: hidden; }
.hero-window .app-body { height: 460px; }

/* sidebar */
.app-side { width: 252px; flex: 0 0 252px; background: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.side-icons { display: flex; gap: 2px; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.side-ic { width: 30px; height: 30px; border: none; background: transparent; color: var(--text-secondary); opacity: .55; border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; transition: opacity .12s ease, background .12s ease; }
.side-ic svg { width: 18px; height: 18px; }
.side-ic:hover { opacity: 1; background: var(--bg-hover); }
.side-ic.active { opacity: 1; color: #dbe3f2; background: var(--bg-iconactive); }
.side-ic[data-tip]:hover::after { content: attr(data-tip); position: absolute; top: 34px; left: 0; background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary); font-size: 11px; padding: 3px 8px; border-radius: 4px; white-space: nowrap; z-index: 40; font-family: var(--font-ui); }
.side-views { flex: 1; min-height: 0; position: relative; }
/* with Claude Code docked, the tree gives up width to the document — same
   chrome in every demo, just narrower */
.ide-window:has(.mcp-term) .app-side { width: 186px; flex: 0 0 186px; }
.ide-window:has(.mcp-term) .tree-row, .ide-window:has(.mcp-term) .lb-row { font-size: 12px; }
.side-view { display: none; }
.side-view.active { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow-y: auto; }
.side-view[data-view="chat"].active { overflow: hidden; }

/* sidebar headings */
.sv-head { display: flex; align-items: center; gap: 6px; padding: 9px 14px 5px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.sv-head--mt { margin-top: 8px; }
.sv-plus { margin-left: auto; opacity: .7; } .sv-plus svg { width: 13px; height: 13px; }
.sv-badge { background: var(--bg-tertiary); color: var(--text-secondary); border-radius: 999px; font-size: 10px; padding: 0 6px; }
.sv-empty { padding: 8px 16px; font-size: 12px; color: var(--text-muted); }

/* file tree */
.tree { padding: 2px 0; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 4px 14px; font-size: 12.5px; color: var(--text-secondary); cursor: default; }
.tree-row:hover { background: var(--bg-hover); }
.tree-row svg { width: 14px; height: 14px; color: var(--text-muted); flex: 0 0 14px; }
.tree-row .tw { width: 10px; flex: 0 0 10px; color: var(--text-muted); font-size: 9px; }
.tree-row .tn { color: var(--text-primary); }
.tree-row.indent { padding-left: 28px; }
.tree-row .tlock { margin-left: 6px; opacity: .7; } .tree-row .tlock svg { width: 11px; height: 11px; }
.tree-row .ic-sty svg { color: #a78bfa; }
.tree-row.flash { background: var(--bg-selected); }

/* file outline */
.ol-row .ol-sec { color: #79c0ff; font-size: 11px; width: 14px; flex: 0 0 14px; text-align: center; }
.ol-row .ol-ln { margin-left: auto; color: var(--text-muted); font-size: 10.5px; font-family: var(--font-mono); opacity: .8; }

/* git panel */
.vc-commit { padding: 4px 12px 8px; }
.vc-commit-input { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 9px; min-height: 32px; font-size: 12.5px; color: var(--text-primary); font-family: var(--font-ui); }
.vc-commit-input .ph { color: var(--text-muted); }
.vc-commit-btn { width: 100%; margin-top: 8px; background: var(--bg-iconactive); color: var(--text-primary); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 6px 12px; font-size: 12px; font-weight: 600; font-family: var(--font-ui); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.vc-commit-btn svg { width: 13px; height: 13px; } .vc-commit-btn.flash { background: #2a416b; }
.vc-file { display: flex; align-items: center; gap: 6px; padding: 4px 14px; font-size: 12.5px; color: var(--text-secondary); }
.vc-file:hover { background: var(--bg-hover); }
.vc-dot { color: var(--st-mod); font-size: 9px; } .vc-name { color: var(--text-primary); } .vc-dir { color: var(--text-muted); font-size: 11px; } .vc-sp { flex: 1; }
.vc-pill { width: 15px; height: 15px; border-radius: 3px; font-size: 10px; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center; }
.vc-pill.m { background: var(--st-mod); } .vc-pill.a { background: var(--st-add); } .vc-pill.d { background: var(--st-del); }
.vc-history { margin-top: 4px; }
.vc-hist { display: flex; align-items: center; gap: 6px; padding: 5px 14px; font-size: 12px; }
.vc-chev { color: var(--text-muted); } .vc-msg { flex: 1; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .vc-meta { color: var(--text-muted); font-size: 11px; }
.vc-revert { color: #79c0ff; font-size: 11px; display: none; }
.vc-hist:hover .vc-meta { display: none; } .vc-hist:hover .vc-revert { display: inline; }
.vc-hist.head .vc-chev { color: #79c0ff; }

/* version-control panel — sections, stage/unstage buttons, refresh */
.vc-mainhead { align-items: center; }
.vc-refresh { margin-left: auto; opacity: .65; cursor: pointer; display: inline-flex; }
.vc-refresh:hover { opacity: 1; } .vc-refresh svg { width: 14px; height: 14px; }
.vc-sec[hidden] { display: none; }
.vc-sechead .vc-secact { margin-left: auto; opacity: 0; cursor: pointer; display: inline-flex; color: var(--text-secondary); transition: opacity .15s ease; }
.vc-sechead:hover .vc-secact { opacity: .85; } .vc-secact:hover { color: var(--text-primary); }
.vc-secact.vc-click { opacity: 1 !important; color: var(--text-primary); background: var(--bg-hover); border-radius: 4px; padding: 2px; margin: -2px 0 -2px auto; animation: vcClickPulse .32s ease; }
@keyframes vcClickPulse { 0% { transform: scale(1); } 42% { transform: scale(.78); } 100% { transform: scale(1); } }
.vc-secact svg { width: 14px; height: 14px; }
.vc-sechead .sv-badge { margin-left: 8px; }
.vc-clean { padding: 8px 16px; font-size: 12px; color: var(--text-muted); }
.vc-fic { display: inline-flex; color: var(--st-mod); flex: 0 0 auto; } .vc-fic svg { width: 14px; height: 14px; }
.vc-acts { display: inline-flex; gap: 1px; opacity: 0; transition: opacity .15s ease; flex: 0 0 auto; }
.vc-file:hover .vc-acts { opacity: 1; }
.vc-act { display: inline-flex; align-items: center; justify-content: center; width: 19px; height: 19px; border-radius: 4px; color: var(--text-secondary); cursor: pointer; }
.vc-act:hover { background: var(--bg-hover); color: var(--text-primary); }
.vc-act svg { width: 13px; height: 13px; }
.vc-appear { animation: vcAppear .3s cubic-bezier(.2,.7,.3,1); }
@keyframes vcAppear { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

/* chat */
.chat-msgs { flex: 1; min-height: 0; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-suggest { display: flex; justify-content: flex-end; }
.suggest-pill { background: var(--bg-tertiary); color: #cfe3ff; font-size: 12px; border-radius: 999px; padding: 5px 14px; }
.msg { font-size: 13px; line-height: 1.5; animation: msgIn .3s ease; }
.msg.user { align-self: flex-end; max-width: 88%; background: var(--bg-tertiary); color: #e0e6f0; padding: 8px 12px; border-radius: var(--radius-md); }
.msg.assistant { color: var(--text-primary); }
.msg code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; color: var(--syntax-keyword); }
.msg.assistant ul { margin: 6px 0 0 16px; } .msg.assistant li { margin: 3px 0; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tool-card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 7px 10px; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-secondary); animation: msgIn .3s ease; }
.tool-card { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool-card .tc-ic { color: #79c0ff; flex: 0 0 auto; }
.tool-card.running .tc-ic { display: inline-block; animation: spin .9s linear infinite; }
.tool-card.done .tc-ic { color: var(--success); }
.tool-card .tc-name { color: var(--syntax-keyword); } .tool-card .tc-args { color: var(--text-muted); }
.tool-card .tc-preview { flex-basis: 100%; margin-top: 5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-card.err .tc-ic { color: var(--error); animation: none; }
.tc-api { flex: 0 0 auto; font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #c9531f; background: rgba(215,119,87,.14); border: 1px solid rgba(215,119,87,.4); border-radius: 4px; padding: 1px 6px; }
/* grouped skim card (read_paper) */
.skim-group { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 10px; animation: msgIn .3s ease; }
.skim-group .sg-head { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12.5px; }
.skim-group.running .sg-head { color: var(--text-muted); }
.skim-group.running .sg-ic { display: inline-block; animation: spin .9s linear infinite; color: #79c0ff; }
.skim-group.done .sg-head .sg-ic { color: var(--success); }
.skim-group.done .sg-head .sg-title { color: var(--success); font-weight: 700; }
.skim-group .sg-chev { margin-left: auto; color: var(--text-muted); font-size: 11px; }
.skim-group .sg-items { margin-top: 7px; border-top: 1px solid var(--border); padding-top: 5px; display: flex; flex-direction: column; gap: 3px; }
.skim-group .sg-item { padding: 4px 8px; border-radius: var(--radius-sm); background: rgba(255,255,255,.02); display: flex; align-items: center; gap: 7px; }
.skim-group .sgi-ic { color: var(--success); font-size: 11px; flex: 0 0 auto; }
.skim-group .sgi-tool { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--text-primary); }
.skim-group .sgi-key { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skim-group .sgi-sub { flex-basis: 100%; margin-left: 18px; font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-diff { flex-basis: 100%; margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; display: flex; flex-direction: column; gap: 1px; }
.tcd { font-size: 11px; line-height: 1.5; white-space: pre-wrap; border-radius: 2px; padding: 0 5px; }
.tcd.a { color: #7ee2a8; background: rgba(46,160,67,.13); }
.tcd.d { color: #ff9f97; background: rgba(220,38,38,.13); }
.tcd.h { color: #79c0ff; }
.found { display: flex; flex-direction: column; gap: 6px; animation: msgIn .3s ease; }
.found-item { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 9px; display: flex; flex-direction: column; gap: 2px; }
.found-item .fi-key { font-family: var(--font-mono); font-size: 10.5px; color: #79c0ff; }
.found-item .fi-ttl { font-size: 12px; color: var(--text-primary); }
.found-item .fi-meta { font-size: 11px; color: var(--text-muted); }
.permission { border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 10px 12px; background: rgba(255,255,255,0.02); animation: msgIn .3s ease; }
.perm-title { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text-primary); }
.perm-desc { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin: 4px 0 8px; }
.perm-opt { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.perm-opt .perm-ind { width: 12px; color: var(--accent); } .perm-opt .perm-num { color: var(--text-muted); }
.perm-opt.sel { background: var(--bg-tertiary); color: var(--text-primary); } .perm-opt.clicked { background: var(--bg-selected); }
.perm-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: typing 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.chat-input { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 10px 12px; }
.chat-box { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 9px 11px; font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
.chat-box.typing { display: block; gap: 0; padding: 9px 11px; color: var(--text-primary); }
.chat-box.typing::after { content: ''; display: inline-block; width: 2px; height: 1.05em; vertical-align: text-bottom; background: var(--text-primary); margin-left: 1px; animation: caretBlink 1s steps(1) infinite; }
.chat-box.live { color: var(--text-primary); caret-color: var(--text-primary); }
.chat-box:focus { outline: none; border-color: #3a6ea8; }
.msg.assistant a { color: #79c0ff; text-decoration: underline; text-underline-offset: 2px; }
.chat-hint { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--text-muted); }

/* editor */
.app-editor { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-primary); }
.ed-tabs { height: 36px; display: flex; align-items: center; background: var(--bg-primary); border-bottom: 1px solid var(--border); padding-right: 10px; overflow: hidden; }
.ed-tab { flex: 0 1 auto; min-width: 0; }
.ed-tab .ed-tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-tab { display: flex; align-items: center; gap: 7px; height: 100%; padding: 0 14px; font-size: 12.5px; color: var(--text-primary); border-right: 1px solid var(--border); }
.ed-tab svg { width: 14px; height: 14px; color: #79c0ff; }
.ed-x { opacity: .5; } .ed-sub { color: var(--text-muted); opacity: .7; }
.ed-mode { margin-left: auto; font-size: 12px; color: var(--text-secondary); border: 1px solid var(--border-light); border-radius: 6px; padding: 3px 10px; }
.ed-host { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.cm { height: 100%; overflow: auto; padding: 12px 0; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; color: var(--syntax-content); position: relative; }
.cm-line { display: flex; padding: 0 16px; white-space: pre-wrap; }
.cm-ln { width: 30px; flex: 0 0 30px; margin-right: 16px; text-align: right; color: var(--text-muted); opacity: .5; user-select: none; }
.cm-tx { flex: 1; min-width: 0; white-space: pre-wrap; }
.cm-gut { width: 12px; flex: 0 0 12px; margin-right: 4px; }
.cm-line.add { background: rgba(46,160,67,.16); } .cm-line.add .cm-gut { color: var(--st-add); }
.cm-line.del { background: rgba(220,38,38,.16); } .cm-line.del .cm-gut { color: var(--st-del); }
.tok-kw { color: var(--syntax-keyword); } .tok-math { color: var(--syntax-math); } .tok-label { color: var(--syntax-label); } .tok-num { color: var(--syntax-number); } .tok-com { color: var(--syntax-comment); font-style: italic; } .tok-str { color: var(--syntax-string); } .tok-br { color: var(--syntax-bracket); } .tok-cite { color: var(--syntax-label); }
.cm-caret { display: inline-block; width: 2px; height: 1.05em; vertical-align: text-bottom; background: var(--text-primary); margin-left: 1px; animation: caretBlink 1s steps(1) infinite; }
@keyframes caretBlink { 50% { opacity: 0; } }
.cite-pop { position: absolute; left: 58px; top: 60px; width: 320px; background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: 0 16px 40px rgba(0,0,0,.5); z-index: 25; overflow: hidden; }
.cite-pop-head { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); padding: 7px 10px; border-bottom: 1px solid var(--border); }
.cite-opt { display: flex; align-items: baseline; gap: 10px; padding: 6px 10px; font-size: 12px; }
.cite-opt.selected { background: var(--bg-selected); }
.cite-opt .cite-key { font-family: var(--font-mono); color: #79c0ff; } .cite-opt .cite-ttl { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-note { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border); background: rgba(121,192,255,.07); color: var(--text-secondary); font-size: 12.5px; opacity: 0; transform: translateY(6px); transition: all .4s ease; }
.pane-note.show { opacity: 1; transform: none; }
.pane-note svg { width: 16px; height: 16px; flex: 0 0 16px; color: #79c0ff; }

/* pdf pane */
.app-pdf { flex: 0 0 38%; max-width: 42%; min-width: 0; display: flex; flex-direction: column; background: var(--bg-primary); border-left: 1px solid var(--border); }
.pdf-bar { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-bottom: 1px solid var(--border); }
.pdf-compile { background: var(--bg-tertiary); color: #e3e7f0; border: none; border-radius: var(--radius-sm); padding: 5px 14px; font-size: 12.5px; font-weight: 600; font-family: var(--font-ui); cursor: pointer; }
.pdf-compile.cancel { background: transparent; border: 1px solid var(--text-muted); color: var(--text-secondary); }
.pdf-iconbtn { color: var(--text-secondary); opacity: .85; display: inline-flex; align-items: center; position: relative; cursor: pointer; background: none; border: none; }
.pdf-iconbtn svg { width: 16px; height: 16px; }
.pdf-iconbtn.has-err { color: #ffb3ad; opacity: 1; }
.pdf-errbadge { position: absolute; top: -6px; right: -8px; background: var(--error); color: #fff; border-radius: 999px; font-size: 9px; padding: 0 4px; }
.pdf-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.2); border-top-color: #79c0ff; animation: spin .7s linear infinite; }
.pdf-status { font-size: 12px; color: var(--text-muted); }
.pdf-sp { flex: 1; }
.pdf-pagebox { border: 1px solid var(--border-light); border-radius: 4px; padding: 1px 8px; font-size: 11px; color: var(--text-primary); }
.pdf-pagetot { font-size: 11px; color: var(--text-muted); } .pdf-zoom { font-size: 12px; color: var(--text-secondary); }
.pdf-bar--redline .rl-toggle { border: 1px solid var(--border-light); border-radius: 3px; padding: 3px 9px; font-size: 11.5px; color: var(--text-secondary); }
.pdf-bar--redline .rl-toggle.active { background: var(--bg-tertiary); color: var(--text-primary); border-color: #3a6ea8; }
.rl-meta { font-size: 11px; color: var(--text-muted); margin-left: 4px; }
.pdf-body { flex: 1; overflow: auto; padding: 16px; display: flex; justify-content: center; align-items: flex-start; }
.pdf-page { background: #fff; color: #1a1a1a; width: 100%; max-width: 320px; aspect-ratio: 8.5 / 11; border-radius: 2px; box-shadow: 0 8px 24px rgba(0,0,0,.4); padding: 22px 24px; font-family: 'Times New Roman', Georgia, serif; font-size: 7px; line-height: 1.5; transition: opacity .2s ease; overflow: hidden; }
.pdf-page.flash { animation: pdfFlash .55s ease; }
@keyframes pdfFlash { 0% { opacity: .2; filter: brightness(1.7); } 100% { opacity: 1; filter: none; } }
.pp-rule { border-top: 1.5px solid #111; margin: 2px 0 8px; }
.pdf-page h4 { font-size: 9.5px; text-align: center; font-weight: bold; margin: 4px 0; }
.pp-authors { text-align: center; font-size: 6.5px; line-height: 1.5; margin: 8px 0; }
.pp-abs { text-align: center; font-weight: bold; font-size: 8.5px; margin: 10px 0 5px; }
.pp-sec { font-weight: bold; font-size: 8px; margin: 8px 0 3px; }
.pp-body { font-size: 7.5px; margin: 3px 0; display: flex; gap: 6px; }
.pp-n { color: #999; }
.pp-foot { font-size: 5.5px; text-align: center; color: #444; margin-top: 56px; }
.pdf-eq { position: relative; font-family: 'Times New Roman', Georgia, serif; font-size: 8.5px; color: #111; text-align: center; margin: 8px 0; padding: 6px 22px; background: #f4f4f4; border-radius: 2px; font-style: italic; }
.pdf-eq sub { font-size: .72em; vertical-align: -.22em; font-style: normal; }
.pdf-eq sup { font-size: .72em; vertical-align: .5em; font-style: normal; }
.pp-eqn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 7px; color: #444; }
.redline-page { font-size: 9px; }
.redline-page .pp-body, .redline-page p { font-size: 9px; margin: 6px 0; line-height: 1.6; }
.rl-add { color: #1558d6; text-decoration: underline; } .rl-del { color: #d11; text-decoration: line-through; }

/* log panel (Overleaf-style logs & errors) */
.logpanel { border-top: 1px solid var(--border); background: var(--bg-secondary); max-height: 0; overflow: hidden; transition: max-height .35s ease; }
.logpanel.open { max-height: 200px; }
.log-tabs { display: flex; border-bottom: 1px solid var(--border); }
.log-tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 12px; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; }
.log-tab:hover { color: var(--text-secondary); }
.log-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.log-cnt { background: var(--bg-hover); color: var(--text-secondary); border-radius: 8px; font-size: 10px; padding: 0 5px; }
.log-cnt:empty { display: none; }
.log-tab.active .log-cnt { background: var(--accent); color: var(--bg-primary); }
.log-fail { padding: 6px 12px; font-size: 12px; font-weight: 600; color: #ffb3ad; border-bottom: 1px solid var(--border); }
.log-list { overflow: auto; max-height: 140px; }
.log-row { display: flex; flex-direction: column; gap: 2px; padding: 7px 12px; border-left: 3px solid var(--border); border-bottom: 1px solid var(--border); font-family: var(--font-mono); }
.log-row.error { border-left-color: var(--error); }
.log-row.warning { border-left-color: #e0a92e; }
.log-row.info { border-left-color: var(--accent); }
.log-row .log-loc { font-size: 11px; color: var(--text-secondary); } .log-row .log-msg { font-size: 12.5px; color: var(--text-primary); }
.log-list[data-filter="error"] .log-row:not(.error) { display: none; }
.log-list[data-filter="warning"] .log-row:not(.warning) { display: none; }
.log-list[data-filter="info"] .log-row:not(.info) { display: none; }

/* peer cursors */
.peer-caret { position: absolute; width: 2px; height: 18px; z-index: 12; cursor: grab; display: none; }
.peer-caret.show { display: block; } .peer-caret.dragging { cursor: grabbing; }
.peer-flag { position: absolute; top: -15px; left: 0; white-space: nowrap; font-family: var(--font-ui); font-size: 10px; font-weight: 600; color: #fff; padding: 1px 6px; border-radius: 3px 3px 3px 0; }

/* palette */
.palette-overlay { position: absolute; inset: 0; z-index: 40; background: rgba(5,5,12,.4); display: flex; justify-content: center; padding-top: 54px; opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.palette-overlay.show { opacity: 1; }
.palette { width: 520px; max-width: 84%; background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(0,0,0,.55); overflow: hidden; transform: translateY(-8px) scale(.98); transition: transform .18s ease; }
.palette-overlay.show .palette { transform: none; }
.palette-input { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-primary); }
.palette-input svg { width: 15px; height: 15px; color: var(--text-muted); }
.pal-typed { border-right: 2px solid #79c0ff; min-height: 18px; } .pal-ph { color: var(--text-muted); }
.palette-hint { padding: 4px 16px 6px; font-size: 11px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.palette-results { padding: 6px; max-height: 200px; overflow: auto; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-secondary); }
.palette-item .pal-key { font-family: var(--font-mono); color: var(--text-primary); } .palette-item .pal-sub { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .pal-actions { margin-left: auto; display: flex; gap: 4px; } .palette-item .pal-act { font-size: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 8px; color: var(--text-muted); }
.palette-item.sel { background: var(--bg-selected); color: var(--text-primary); }

/* editor panes / tabs */
.ed-tab .ed-tab-ic { display: inline-flex; }
.ed-tab .ed-sub { color: var(--text-muted); opacity: .75; font-size: 11.5px; }
.ed-tab .ed-x { cursor: pointer; }
.ed-tab .ed-x:hover { opacity: 1; }
.ed-tab:not(.active) { opacity: .55; cursor: pointer; }
.ed-tab:not(.active):hover { opacity: .85; }
.ed-pane { display: none; height: 100%; min-height: 0; }
.ed-pane.active { display: block; }
.cm-diff { color: var(--syntax-content); }

/* literati.bib pane — read-only, generated from the library */
.ed-pane[data-pane="bib"].active { display: flex; flex-direction: column; }
.ed-pane[data-pane="bib"] .cm { flex: 1; min-height: 0; }
.ed-banner { display: flex; align-items: center; gap: 7px; padding: 6px 16px; font-size: 11.5px; color: #e8c66a; background: rgba(224,169,46,.08); border-bottom: 1px solid var(--border); }
.ed-banner svg { width: 12px; height: 12px; flex: 0 0 12px; }
.cm-line.bib-new { background: transparent; animation: bibNew 2.2s ease forwards; }
.cm-line.cm-ins { background: transparent; animation: bibNew 2.2s ease forwards; }
@keyframes bibNew { 0% { background: rgba(46,160,67,.5); } 55% { background: rgba(46,160,67,.32); } 100% { background: transparent; } }

/* find & replace */
.fr-panel { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.fr-row { display: flex; align-items: center; gap: 6px; }
.fr-input { flex: 1; min-width: 0; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 9px; font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); }
.fr-input:focus { outline: none; border-color: #3a6ea8; }
.fr-input::placeholder { color: var(--text-muted); }
.fr-btn { background: var(--bg-tertiary); color: #e3e7f0; border: none; border-radius: var(--radius-sm); padding: 6px 10px; font-size: 11.5px; font-weight: 600; cursor: pointer; font-family: var(--font-ui); white-space: nowrap; }
.fr-btn:hover { background: var(--bg-selected); }
.fr-opts { display: flex; gap: 6px; }
.fr-tog { width: 26px; height: 22px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 4px; font-size: 11px; color: var(--text-muted); cursor: pointer; font-family: var(--font-mono); user-select: none; }
.fr-tog:hover { background: var(--bg-hover); }
.fr-tog.on { background: var(--bg-iconactive); color: #dbe3f2; border-color: #3a6ea8; }
.fr-count { font-size: 11.5px; color: var(--text-muted); padding-top: 2px; }
mark.fr-hit { background: #5a4a1c; color: #ffe6a3; border-radius: 2px; }
mark.fr-hit.cur { background: #e0a92e; color: #201a08; }
.cm-code.fr-flash { animation: pdfFlash .5s ease; }

/* library */
.lib-filter { margin: 8px 12px 4px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 9px; font-size: 12px; color: var(--text-primary); font-family: var(--font-ui); }
.lib-filter:focus { outline: none; border-color: #3a6ea8; }
.lib-filter::placeholder { color: var(--text-muted); }
.lib-list { display: flex; flex-direction: column; }
.lib-item { padding: 9px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.lib-item:hover { background: var(--bg-hover); }
.lib-item.sel { background: var(--bg-selected); box-shadow: inset 2px 0 0 #79c0ff; }
.lib-item .lib-key { font-family: var(--font-mono); font-size: 10px; color: #79c0ff; }
.lib-item .lib-ttl { font-size: 12.5px; color: var(--text-primary); line-height: 1.35; }
.lib-item .lib-meta { font-size: 10.5px; color: var(--text-muted); }

/* git — clickable changed files */
.vc-file[data-diff] { cursor: pointer; }
.vc-file.sel { background: var(--bg-selected); box-shadow: inset 2px 0 0 #79c0ff; }

/* pdf viewer (opened library paper) */
.pdf-viewer { height: 100%; overflow: auto; background: #2a2c31; padding: 22px 0 30px; }
.fig-card { background: #fff; width: 90%; max-width: 500px; margin: 0 auto; padding: 24px 20px 18px; border-radius: 2px; box-shadow: 0 12px 44px rgba(0,0,0,.5); }
.fig-card svg { display: block; width: 100%; height: auto; }
.paper { background: #fff; color: #14151a; width: 90%; max-width: 560px; margin: 0 auto; padding: 40px 46px 46px; font-family: Georgia, 'Times New Roman', serif; box-shadow: 0 12px 44px rgba(0,0,0,.5); font-size: 12.5px; line-height: 1.6; }
.paper h1 { font-size: 18px; line-height: 1.28; text-align: center; margin: 0 0 14px; font-weight: 700; }
.paper .p-authors { text-align: center; font-size: 11.5px; color: #2a2a2a; margin-bottom: 3px; }
.paper .p-aff { text-align: center; font-size: 10.5px; color: #777; margin-bottom: 18px; }
.paper .p-abs { font-size: 11.5px; margin: 0 18px 18px; color: #222; text-align: justify; }
.paper .p-abs b { display: block; text-align: center; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 5px; font-size: 11px; }
.paper h2 { font-size: 13px; margin: 16px 0 6px; font-weight: 700; }
.paper p { margin: 0 0 9px; text-align: justify; }
.paper i { font-style: italic; }
.paper .p-fig { border: 1px solid #d5d5d5; background: #fbfbfb; padding: 16px 14px 12px; margin: 14px 0; text-align: center; }
.paper .p-fig .bars { display: flex; align-items: flex-end; justify-content: center; gap: 16px; height: 96px; margin: 6px 0 22px; }
.paper .p-fig .bar { width: 34px; border-radius: 2px 2px 0 0; position: relative; }
.paper .p-fig .bar span { position: absolute; top: -15px; left: -6px; right: -6px; font-size: 9px; color: #222; font-family: var(--font-ui); }
.paper .p-fig .bar small { position: absolute; bottom: -16px; left: -8px; right: -8px; font-size: 8.5px; color: #666; font-family: var(--font-ui); }
.paper .p-cap { font-size: 10px; color: #555; text-align: left; }
.paper .p-refs { font-size: 10px; color: #444; margin-top: 16px; border-top: 1px solid #e2e2e2; padding-top: 10px; }
.paper .p-refs div { margin-bottom: 4px; padding-left: 16px; text-indent: -16px; }

/* demo controls */
.demo-controls { display: flex; align-items: center; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--bg-secondary); }
.replay-btn { width: 28px; height: 28px; flex: 0 0 28px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--border-light); color: var(--text-secondary); border-radius: 50%; padding: 0; cursor: pointer; position: relative; transition: background .15s ease, color .15s ease; }
.replay-btn svg { width: 13px; height: 13px; }
.replay-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.replay-btn[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: 34px; left: 0; background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary); font-size: 11px; padding: 3px 8px; border-radius: 4px; white-space: nowrap; z-index: 40; font-family: var(--font-ui); }
.ctrl-tip { font-size: 11px; color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* footer */
.footer { border-top: 1px solid var(--page-border); padding: 40px 0; text-align: center; color: var(--page-faint); font-size: .88rem; }
.footer a { color: var(--page-muted); margin: 0 12px; } .footer a:hover { color: var(--page-text); }
.footer .legal { margin-bottom: 12px; }

/* responsive */
@media (max-width: 860px) { .app-pdf { display: none; } }
@media (max-width: 760px) {
  .section { padding: 70px 0; } .section h2 { font-size: 1.8rem; }
  .app-body { height: 500px; } .app-side { width: 210px; flex: 0 0 210px; }
}
@media (max-width: 560px) {
  .nav-inner { padding: 0 16px; }
  .app-side { display: none; }
}

/* ==========================================================================
   Phone-portrait embed mode (?m=1 → body.mock-mobile)
   The landing page renders the demo at a 560px internal width on phones and
   scales it far less than the 1060px desktop layout, so fonts stay legible.
   Layout: chat/files ~46% · editor ~34% · pdf ~20%, bigger sidebar type,
   tighter padding, secondary chrome hidden. Must sit AFTER the media queries
   above — at 560px internal width they hide .app-pdf and .app-side.
   ========================================================================== */
body.mock-mobile .app-body { height: 600px; }
body.mock-mobile .app-side { display: flex; width: 46%; flex: 0 0 46%; }
body.mock-mobile .app-editor { flex: 1; }
body.mock-mobile .app-pdf { display: flex; flex: 0 0 20%; max-width: 20%; }

/* topbar: drop the share button (collab peer avatars stay) */
body.mock-mobile .tb-share { display: none; }

/* sidebar — the star of the show: bigger type, tighter rows */
body.mock-mobile .side-icons { padding: 5px 6px; }
body.mock-mobile .sv-head { font-size: 12px; }
body.mock-mobile .tree-row { font-size: 15px; padding: 5px 12px; }
body.mock-mobile .tree-row svg { width: 16px; height: 16px; flex: 0 0 16px; }
body.mock-mobile .chat-msgs { padding: 12px 10px; gap: 10px; }
body.mock-mobile .msg { font-size: 15px; }
body.mock-mobile .msg code { font-size: 13px; }
body.mock-mobile .suggest-pill { font-size: 13px; }
body.mock-mobile .tool-card { font-size: 12.5px; }
body.mock-mobile .skim-group .sg-head { font-size: 13.5px; }
body.mock-mobile .found-item .fi-ttl { font-size: 13.5px; }
body.mock-mobile .found-item .fi-meta { font-size: 12px; }
body.mock-mobile .perm-title, body.mock-mobile .perm-opt { font-size: 14px; }
body.mock-mobile .perm-desc { font-size: 13px; }
body.mock-mobile .chat-input { padding: 8px 10px; }
body.mock-mobile .chat-box { font-size: 14px; }
body.mock-mobile .chat-hint { display: none; }
body.mock-mobile .vc-file, body.mock-mobile .vc-commit-input { font-size: 14px; }
body.mock-mobile .vc-hist { font-size: 13.5px; }
body.mock-mobile .lib-item .lib-ttl { font-size: 14px; }

/* editor — narrow and secondary: slimmer gutter, tighter tabs */
body.mock-mobile .ed-tab { padding: 0 10px; font-size: 12px; }
body.mock-mobile .cm-line { padding: 0 8px; }
body.mock-mobile .cm-ln { width: 20px; flex: 0 0 20px; margin-right: 8px; }
body.mock-mobile .cite-pop { left: 8px; top: 48px; width: 250px; max-width: 94%; }
body.mock-mobile .pane-note { padding: 8px 10px; font-size: 11.5px; }

/* pdf — a slim thumbnail column: compact bar, page fills the width */
body.mock-mobile .pdf-bar { padding: 0 6px; gap: 5px; }
body.mock-mobile .pdf-compile { font-size: 10px; padding: 3px 8px; }
body.mock-mobile .pdf-status { font-size: 10px; }
body.mock-mobile .pdf-pagebox, body.mock-mobile .pdf-pagetot,
body.mock-mobile .pdf-zoom, body.mock-mobile .rl-meta { display: none; }
body.mock-mobile .pdf-iconbtn:not(.has-err) { display: none; }
body.mock-mobile .pdf-body { padding: 8px 6px; }
body.mock-mobile .pdf-page { padding: 10px 10px; }


/* ==========================================================================
   Live editor — real typing on the left, live PDF on the right
   ========================================================================== */
.live-wrap { display: flex; height: 100%; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; background: var(--bg-primary); }
.live-gutter { flex: 0 0 46px; padding: 12px 10px 12px 0; text-align: right; color: var(--text-muted); opacity: .5; white-space: pre; user-select: none; overflow: hidden; font-variant-numeric: tabular-nums; }
.live-code { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.live-hl, .live-ta { margin: 0; padding: 12px 16px 12px 0; font: inherit; line-height: inherit; white-space: pre-wrap; word-break: break-word; border: 0; }
.live-hl { position: absolute; top: 0; left: 0; right: 0; bottom: auto; min-height: 100%; color: var(--syntax-content); pointer-events: none; overflow: visible; }
.live-ta { position: absolute; inset: 0; width: 100%; height: 100%; background: transparent; color: transparent; caret-color: var(--text-primary); resize: none; outline: none; overflow: auto; -webkit-text-fill-color: transparent; }
.live-ta::selection { background: var(--bg-selected); -webkit-text-fill-color: transparent; }
.live-ta:focus { outline: none; }
.live-gutter-in { white-space: pre; }
.live-gn { }
.live-ln { white-space: pre-wrap; word-break: break-word; }
.live-edge { position: absolute; }

/* live PDF page */
.pdf-page.live-page { display: flex; gap: 8px; align-items: flex-start; overflow: hidden; }
.live-page .pp-lines { flex: 0 0 14px; white-space: pre; font-family: var(--font-mono); font-size: 4px; line-height: 2.5; color: #b8b8b8; padding-top: 4px; }
.live-page .pp-doc { flex: 1; min-width: 0; }
.pp-para { font-size: 7.5px; margin: 3px 0; text-align: justify; }
.pp-sub { font-weight: bold; font-size: 7.5px; margin: 6px 0 2px; font-style: italic; }
.pp-ref { font-size: 6px; color: #333; margin: 1.5px 0; }
.pp-warn { color: #c0392b; }
.pdf-page.live-pulse { animation: livePulse .3s ease; }
@keyframes livePulse { 0% { filter: brightness(1.18); } 100% { filter: none; } }
.pdf-status.live-ok { color: var(--success); }

/* ==========================================================================
   Cmd+K palette
   ========================================================================== */
.ck-pop { position: absolute; left: 50%; top: 26px; transform: translateX(-50%); width: min(520px, 88%); z-index: 40;
  background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.6); overflow: hidden; animation: msgIn .18s ease; }
.ck-pop[hidden] { display: none; }
.ck-head { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 11.5px; color: var(--text-muted); }
.ck-kbd { font-family: var(--font-mono); font-size: 10.5px; color: var(--accent); background: var(--bg-tertiary); border: 1px solid var(--border-light); border-radius: 4px; padding: 1px 6px; }
.ck-input { width: 100%; background: var(--bg-primary); border: 0; border-bottom: 1px solid var(--border); padding: 11px 13px; font-family: var(--font-mono); font-size: 13px; color: var(--text-primary); outline: none; }
.ck-input::placeholder { color: var(--text-muted); }
.ck-body:empty { display: none; }
.ck-body { padding: 10px 12px; }
.ck-run { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.ck-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(255,255,255,.16); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.ck-diff { display: flex; flex-direction: column; gap: 1px; }
.ck-note { margin-top: 8px; font-size: 11.5px; color: var(--text-muted); }
.ck-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--border); }
.ck-hint { font-size: 11px; color: var(--text-muted); }
.ck-acts { display: inline-flex; gap: 7px; }
.ck-acts[hidden] { display: none; }
.ck-btn { font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; border-radius: var(--radius-sm); padding: 5px 11px; cursor: pointer; border: 1px solid var(--border-light); background: transparent; color: var(--text-secondary); }
.ck-btn.ck-accept { background: var(--bg-selected); border-color: #3a6ea8; color: #dbe3f2; }
.ck-btn:hover { background: var(--bg-hover); }
.ck-btn.ck-accept:hover { background: #325280; }

/* ==========================================================================
   Add-paper panel (Papers sidebar) + PDF download badges
   ========================================================================== */
.ap-panel { padding: 6px 12px 10px; border-bottom: 1px solid var(--border); }
.ap-row { display: flex; gap: 6px; }
.ap-input { flex: 1; min-width: 0; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 9px; font-family: var(--font-ui); font-size: 12.5px; color: var(--text-primary); outline: none; }
.ap-input::placeholder { color: var(--text-muted); }
.ap-input:focus { border-color: #3a6ea8; }
.ap-btn { background: var(--bg-tertiary); color: #cfe3ff; border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 5px 12px; font-family: var(--font-ui); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ap-btn:hover { background: var(--bg-selected); }
.ap-btn[disabled] { opacity: .45; cursor: default; }
.ap-src { margin-top: 6px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }
.ap-hits { margin-top: 7px; display: flex; flex-direction: column; gap: 5px; }
.ap-hit { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.ap-hit:hover, .ap-hit.sel { border-color: #3a6ea8; background: var(--bg-hover); }
.ap-hit .aph-ttl { font-size: 11.5px; color: var(--text-primary); line-height: 1.35; }
.ap-hit .aph-meta { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.lib-item .lib-pdf { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .03em; text-transform: uppercase; color: #7ee2a8; }
.lib-item .lib-pdf.pending { color: var(--text-muted); }
.ext-chip { display: flex; align-items: center; gap: 8px; margin: 7px 0 0; padding: 7px 9px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: rgba(121,192,255,.07); font-size: 11.5px; color: var(--text-secondary); }
.ext-chip .ext-ico { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.16); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: 0 0 auto; }
.ext-chip.done .ext-ico { border: 0; animation: none; color: var(--success); display: flex; align-items: center; justify-content: center; }
.ext-bar { flex: 1; height: 3px; border-radius: 3px; background: var(--bg-tertiary); overflow: hidden; }
.ext-bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s linear; }

/* ==========================================================================
   MCP terminal — Claude Code driving Literati from outside
   ========================================================================== */
.mcp-term { position: absolute; right: 14px; bottom: 62px; width: 372px; max-width: 60%; z-index: 45;
  background: #080c14; border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  box-shadow: 0 26px 66px rgba(0,0,0,.72); overflow: hidden; opacity: 0; transform: translateY(14px);
  transition: opacity .32s ease, transform .32s ease; pointer-events: none; }
.mcp-term.show { opacity: 1; transform: none; }
.mcp-bar { height: 28px; display: flex; align-items: center; gap: 7px; padding: 0 10px; background: #10161f; border-bottom: 1px solid var(--border); }
.mcp-dot { width: 9px; height: 9px; border-radius: 50%; }
.mcp-title { margin-left: 6px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }
.mcp-badge { margin-left: auto; font-family: var(--font-mono); font-size: 9px; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--border-light); border-radius: 4px; padding: 1px 5px; }
.mcp-body { padding: 9px 11px 11px; font-family: var(--font-mono); font-size: 10.5px; line-height: 1.6; color: #c3ccd9; overflow: hidden; white-space: pre-wrap; }
.mcp-l { margin: 1px 0; }
.mcp-l .p { color: #7ee2a8; }
.mcp-l.tool { color: var(--accent); }
.mcp-l.ok { color: #7ee2a8; }
.mcp-l.dim { color: var(--text-muted); }
/* collaborator flag riding the live editor */
.peer-flag { position: absolute; left: 62px; width: 2px; height: 20px; background: var(--rc); border-radius: 1px; z-index: 30; pointer-events: none; animation: rc-blink 1.1s steps(1) infinite; }
.peer-flag::after { content: attr(data-name); position: absolute; left: 0; top: -13px; background: var(--rc); color: #fff; font-family: var(--font-ui); font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: 3px 3px 3px 0; white-space: nowrap; line-height: 1.35; }

.mcp-caret::after { content: ''; display: inline-block; width: 6px; height: 1em; background: #7ee2a8; vertical-align: text-bottom; animation: caretBlink 1s steps(1) infinite; }


/* ==========================================================================
   Library — browse tree (sidebar) + the Library editor tab
   ========================================================================== */
.side-view[data-view="library"].active { overflow-y: auto; }
.lb-sect { display: flex; align-items: center; gap: 7px; padding: 10px 14px 6px; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-secondary); font-weight: 600; }
.lb-sect--mt { margin-top: 6px; }
.lb-caret { color: var(--text-muted); font-size: 9px; }
.lb-add { margin-left: auto; opacity: .7; display: inline-flex; }
.lb-add svg { width: 13px; height: 13px; }
.lb-row { display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 14px; font-size: 12.5px; color: var(--text-primary); cursor: default; }
.lb-row:hover { background: var(--bg-hover); }
.lb-row.lb-sel { background: var(--bg-selected); }
.lb-chev { color: var(--text-muted); font-size: 11px; width: 9px; flex: 0 0 9px; }
.lb-fic { display: inline-flex; color: var(--text-muted); flex: 0 0 auto; }
.lb-fic svg { width: 13px; height: 13px; }
.lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { margin-left: auto; padding-left: 8px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); flex: 0 0 auto; }
.lb-db { margin-top: 4px; color: var(--accent); }
.lb-db .lb-fic { color: var(--accent); }
.lb-db.lb-sel { background: var(--bg-selected); color: var(--text-primary); }
.lb-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 8px; }
.lb-tag { background: var(--bg-tertiary); color: #cfe3ff; border-radius: 999px; font-size: 11px; padding: 2px 9px; }
.lb-tagfilter { margin: 0 12px 12px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 9px; font-size: 12px; color: var(--text-muted); }

/* library tab */
.ed-pane[data-pane="library"] { display: none; flex-direction: column; }
.ed-pane[data-pane="library"].active { display: flex; }
.lib-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--bg-secondary); }
.lib-scope { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 4px 10px; flex: 0 0 auto; }
.lib-scope i { font-style: normal; color: var(--text-muted); }
.lib-search { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; font-family: var(--font-ui); font-size: 13px; color: var(--text-primary); }
.lib-search::placeholder { color: var(--text-muted); }
.lib-count { font-size: 11.5px; color: var(--text-muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.lib-filters { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-selected); border: 1px solid #3a6ea8; border-radius: var(--radius-sm); padding: 4px 9px; font-size: 12px; color: var(--text-primary); flex: 0 0 auto; cursor: pointer; }
.lib-filters svg { width: 13px; height: 13px; }
.lib-fbadge { font-style: normal; background: var(--accent); color: var(--bg-primary); border-radius: 999px; font-size: 9.5px; font-weight: 700; padding: 0 5px; }
.lib-fx { font-weight: 400; color: var(--text-secondary); }
.lib-sort { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 4px 10px; flex: 0 0 auto; }
.lib-sort svg { width: 13px; height: 13px; }
.lib-src { flex: 0 0 auto; padding: 7px 14px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); background: rgba(121,192,255,.05); }
.lib-src[hidden] { display: none; }
.lib-rows { flex: 1; min-height: 0; overflow-y: auto; }

.lr { display: flex; align-items: flex-start; gap: 14px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.lr:hover { background: var(--bg-hover); }
.lr-year { flex: 0 0 34px; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); padding-top: 2px; }
.lr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lr-ttl { font-size: 13.5px; font-weight: 500; line-height: 1.35; color: var(--text-primary); text-wrap: pretty; }
.lr-by { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.lr-au { font-size: 12px; color: var(--text-secondary); flex: 0 0 auto; }
.lr-key { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-tags { display: flex; align-items: center; gap: 6px; }
.lr-tag { background: var(--bg-tertiary); color: #cfe3ff; border-radius: 999px; font-size: 10.5px; padding: 1px 8px; }
.lr-tagadd { width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border-light); color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.lr-tagadd svg { width: 9px; height: 9px; }
.lib-filters svg, .lib-sort svg { width: 12px; height: 12px; }
.lib-sort svg { width: 13px; height: 13px; }
.lr-tagadd:hover { color: var(--text-primary); border-color: var(--accent); }
.lr-acts { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding-top: 1px; }
.lr-act { display: inline-flex; color: var(--text-secondary); cursor: pointer; }
.lr-act svg { width: 16px; height: 16px; }
.lr-act:hover { color: var(--accent); }
.lr-act.lr-busy { color: var(--accent); animation: lrPulse .8s ease-in-out infinite; }
.lr-act.lr-has { color: #7ee2a8; }
@keyframes lrPulse { 50% { opacity: .35; } }
.lr-col { display: inline-flex; align-items: center; gap: 5px; color: var(--text-secondary); }
.lr-col svg { width: 15px; height: 15px; }
.lr-col i { font-style: normal; font-family: var(--font-mono); font-size: 11px; }
.lr-col--none { color: var(--text-muted); }
.lr-rm { background: transparent; border: 1px solid var(--border-light); border-radius: var(--radius-sm); color: var(--text-muted); font-family: var(--font-ui); font-size: 11.5px; padding: 4px 11px; cursor: pointer; }
.lr-rm:hover { color: #ff9f97; border-color: #6b3a3a; }
.lr-rm.lr-addbtn { color: #cfe3ff; background: var(--bg-tertiary); border-color: var(--border-light); font-weight: 600; }
.lr-rm.lr-addbtn:hover { background: var(--bg-selected); color: #e0e6f0; border-color: #3a6ea8; }
.lr.lr-new { animation: vcAppear .34s cubic-bezier(.2,.7,.3,1); }
.lr.lr-hi { background: rgba(46,160,67,.12); }
.lib-empty { padding: 26px 16px; text-align: center; font-size: 12.5px; color: var(--text-muted); }

/* live editor + library in phone-portrait embed mode */
body.mock-mobile .live-wrap { font-size: 12px; line-height: 1.6; }
body.mock-mobile .live-gutter { flex: 0 0 28px; padding-right: 6px; }
body.mock-mobile .live-hl, body.mock-mobile .live-ta { padding: 10px 8px 10px 0; }
body.mock-mobile .ck-pop { width: 92%; top: 14px; }
body.mock-mobile .mcp-term { width: 88%; max-width: none; right: 6%; bottom: 54px; }
body.mock-mobile .mcp-body { font-size: 10px; }
body.mock-mobile .lb-row, body.mock-mobile .lb-sect { font-size: 14px; }
body.mock-mobile .lib-bar { flex-wrap: wrap; gap: 7px; padding: 8px 10px; }
body.mock-mobile .lib-scope, body.mock-mobile .lib-sort { display: none; }
body.mock-mobile .lib-search { font-size: 14px; }
body.mock-mobile .lr { padding: 10px; gap: 9px; }
body.mock-mobile .lr-year { flex: 0 0 28px; }
body.mock-mobile .lr-ttl { font-size: 14px; }
body.mock-mobile .lr-acts { gap: 8px; }
body.mock-mobile .ap-panel { padding: 6px 10px 9px; }


/* ==========================================================================
   Trustable-AI demos: docked Claude Code, debug button, new-paper flash
   ========================================================================== */
.mcp-term.mcp-side { position: absolute; top: 38px; right: 0; bottom: 0; width: 392px; max-width: 44%;
  border-radius: 0; border-left: 1px solid var(--border-light); border-top: 0; border-right: 0; border-bottom: 0;
  box-shadow: -18px 0 46px rgba(0,0,0,.45); display: flex; flex-direction: column; }
.mcp-term.mcp-side .mcp-body { flex: 1; overflow: auto; font-size: 11px; line-height: 1.62; }
body.mock-mobile .mcp-term.mcp-side { width: 100%; max-width: none; top: auto; height: 46%; border-left: 0; border-top: 1px solid var(--border-light); }
.dbg-btn { margin-left: 10px; font-family: var(--font-ui); font-size: 11px; font-weight: 600; color: #ffd9d4;
  background: #3a1f1c; border: 1px solid #7a3b33; border-radius: 999px; padding: 3px 11px; cursor: pointer; }
.dbg-btn:hover { background: #4a2723; }
.lib-item.lib-flash { animation: libflash 1.4s ease; }
@keyframes libflash { 0% { background: rgba(63,110,168,.34); } 100% { background: transparent; } }
.rv-check:hover { filter: brightness(1.25); }

.mcp-side .mcp-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcp-side .mcp-badge { white-space: nowrap; flex: 0 0 auto; }
