/* Open Margins brand tokens (brand.css); dark values follow prefers-color-scheme, the app's theme mechanism */
:root { --om-brand-ink:#27231D; --om-brand-accent:#994800; --om-brand-surface:#F6F7F5; --om-brand-mono:ui-monospace, Menlo, Consolas, monospace; }
@media (prefers-color-scheme: dark) { :root { --om-brand-ink:#F3EFE8; --om-brand-accent:#FFAC6B; --om-brand-surface:#211E19; } }
:root { --bg:#fff; --fg:#1d2127; --muted:#6b7280; --line:#e5e7eb; --accent:var(--om-brand-accent); --panel:#f8f9fb; --on-accent:#fff; color-scheme: light dark; }
@media (prefers-color-scheme: dark) { :root { --bg:#16181d; --fg:#e6e8eb; --muted:#9aa1ab; --line:#2b2f37; --accent:var(--om-brand-accent); --panel:#1d2026; --on-accent:#0b1220; } }
* { box-sizing: border-box; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--fg); font:15px/1.5 system-ui, -apple-system, Segoe UI, sans-serif; }
/* The server puts a note for AI agents in the HTML; agents read the raw page, people should never see it. */
#agent-help { display:none; }
.muted { color:var(--muted); } .pad { padding:2rem; }
button, input, select { font:inherit; color:inherit; }
button { background:var(--panel); border:1px solid var(--line); border-radius:6px; padding:.35rem .75rem; cursor:pointer; }
button:hover:not(:disabled) { border-color:var(--accent); }
button.primary { background:var(--accent); color:var(--on-accent); border-color:var(--accent); }
button:disabled { opacity:.45; cursor:default; }
.auth-form button:disabled { opacity:.75; cursor:progress; }
.auth-form button.done { opacity:1; cursor:default; background:#16a34a; border-color:#16a34a; color:#fff; }
input { background:var(--bg); border:1px solid var(--line); border-radius:6px; padding:.4rem .6rem; }
.home { max-width:640px; margin:4rem auto; padding:0 1rem; }
.home h1 { margin:0 0 .25rem; } .home form { display:flex; gap:.5rem; margin:1.5rem 0; } .home form input { flex:1; }
.home ul { list-style:none; padding:0; } .home li { padding:.4rem 0; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; }
a { color:var(--accent); text-decoration:none; } a:hover { text-decoration:underline; }
.shell { display:flex; flex-direction:column; height:100vh; }
.bar { display:flex; align-items:center; gap:.75rem; padding:.5rem .9rem; border-bottom:1px solid var(--line); background:var(--panel); flex-wrap:wrap; }
.bar .title { font-weight:600; margin-right:auto; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.seg { display:inline-flex; border:1px solid var(--line); border-radius:6px; overflow:hidden; }
.seg button { border:0; border-radius:0; background:transparent; } .seg button.on { background:var(--accent); color:var(--on-accent); }
.people { display:flex; gap:.25rem; }
.person { font-size:12px; padding:.1rem .5rem; border-radius:999px; color:#fff; white-space:nowrap; }
.status { font-size:12px; color:var(--muted); } .status.ok::before { content:'● '; color:#2f9e44; } .status.bad::before { content:'● '; color:#e03131; }
.panes { flex:1; display:flex; min-height:0; }
.pane { flex:1; min-width:0; overflow:auto; position:relative; } .pane + .pane { border-left:1px solid var(--line); }
.pane[hidden] { display:none; }
.cm-editor { height:100%; } .cm-editor.cm-focused { outline:none; }
.cm-scroller { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size:14px; }
.cm-content { padding:1rem 0; max-width:900px; }
.preview { padding:1.5rem 2rem; max-width:860px; margin:0 auto; }
.preview pre { background:var(--panel); padding:.8rem; border-radius:6px; overflow:auto; }
.preview code { font-family: ui-monospace, Menlo, monospace; font-size:.92em; }
.preview table { border-collapse:collapse; } .preview th, .preview td { border:1px solid var(--line); padding:.3rem .6rem; }
.preview img { max-width:100%; } .preview blockquote { margin-left:0; padding-left:1rem; border-left:3px solid var(--line); color:var(--muted); }
.toast { position:fixed; bottom:1rem; left:50%; transform:translateX(-50%); background:var(--fg); color:var(--bg); padding:.6rem 1rem; border-radius:8px; max-width:90vw; word-break:break-all; font-size:13px; }
dialog { border:1px solid var(--line); border-radius:10px; background:var(--bg); color:var(--fg); padding:1.25rem; width:min(460px, 92vw); }
dialog::backdrop { background:#0006; }
.share h3 { margin:0 0 .75rem; } .share label { display:block; padding:.3rem 0; }
.share .out input { width:100%; margin-top:.75rem; } .share .actions { display:flex; justify-content:flex-end; gap:.5rem; margin-top:1rem; }
.role { font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
.small { font-size:12.5px; } .narrow { max-width:460px; }
a.plain { color:inherit; }
.home-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; }
.stack { display:flex !important; flex-direction:column; gap:.75rem; } .stack label { display:flex; flex-direction:column; gap:.25rem; }
.notice { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:.75rem 1rem; margin:1rem 0; }
.who { display:inline-flex; align-items:center; gap:.4rem; color:var(--fg); font-size:13px; white-space:nowrap; }
.who:hover { text-decoration:none; } .who:hover span:not(.avatar):not(.badge) { text-decoration:underline; }
.avatar { width:22px; height:22px; border-radius:50%; color:#fff; display:inline-grid; place-items:center; font-size:12px; font-weight:600; }
.badge { font-size:11px; background:var(--panel); border:1px solid var(--line); border-radius:999px; padding:0 .4rem; }
.person.agent { border:1px dashed #fff8; }
.docs li a { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.inline { display:flex !important; align-items:center; gap:.75rem; flex-wrap:wrap; }
table.sessions { width:100%; border-collapse:collapse; font-size:13px; margin:.5rem 0 1rem; }
table.sessions th, table.sessions td { text-align:left; padding:.4rem .5rem; border-bottom:1px solid var(--line); }
table.sessions th { color:var(--muted); font-weight:500; }
button.small { padding:.15rem .5rem; font-size:12px; }
.connect { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:.75rem 1rem; margin:.5rem 0 1.5rem; }
.connect pre { white-space:pre-wrap; font-size:12.5px; background:var(--bg); border:1px solid var(--line); border-radius:6px; padding:.6rem; }
.invite-card { border:1px solid var(--line); border-radius:10px; padding:1rem 1.25rem; margin:1rem 0; }
.invite-card h2 { margin:.1rem 0 .5rem; }
.share .grid2 { display:grid; grid-template-columns:1fr 1fr; gap:.5rem; margin-bottom:.5rem; }
.share .grid2 label { display:flex; flex-direction:column; gap:.2rem; padding:0; }
.share h4 { margin:1rem 0 .25rem; font-size:13px; color:var(--muted); font-weight:500; }
.plain-list { list-style:none; padding:0; margin:0; } .plain-list li { display:flex; justify-content:space-between; gap:.5rem; padding:.3rem 0; border-bottom:1px solid var(--line); }

/* ---- landing page ---- */
a.button { display:inline-block; background:var(--panel); border:1px solid var(--line); border-radius:6px; padding:.35rem .9rem; color:var(--fg); }
a.button:hover { text-decoration:none; border-color:var(--accent); }
a.button.primary { background:var(--accent); border-color:var(--accent); color:var(--on-accent); }
a.button.big, .hero-form button.primary { padding:.65rem 1.25rem; font-size:1.05rem; font-weight:600; }
.landing { max-width:1120px; margin:0 auto; padding:0 1.25rem; }
.lp-nav { display:flex; align-items:center; justify-content:space-between; padding:1.25rem 0; }
.lp-nav nav { display:flex; align-items:center; gap:1.25rem; }
.brand { display:inline-flex; align-items:center; line-height:0; }
.brand img { display:block; height:32px; width:auto; }
.home h1 .brand img { height:36px; }
.bar .brand img { height:26px; border-radius:5px; }
.hero { display:grid; grid-template-columns:repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap:3rem; align-items:center; padding:3rem 0 4rem; }
.hero h1 { font-size:clamp(2rem, 4.5vw, 3.1rem); line-height:1.1; letter-spacing:-.02em; margin:0 0 1rem; text-wrap:balance; }
.lede { font-size:1.15rem; color:var(--muted); margin:0 0 2rem; text-wrap:pretty; }
.hero-form { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:1.25rem 1.5rem; }
.hero-form h2 { margin:0 0 .75rem; font-size:1.15rem; }
.hero-form .notice { margin:.25rem 0 0; background:var(--bg); }
.demo { margin:0; border:1px solid var(--line); border-radius:12px; overflow:hidden; background:var(--bg); box-shadow:0 1px 2px #0000000d, 0 12px 32px #0000001a; }
.demo-bar { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; padding:.6rem .8rem; background:var(--panel); border-bottom:1px solid var(--line); font-size:13px; }
.demo-bar b { margin-right:auto; }
.demo-doc { margin:0; padding:1.25rem 1.4rem; font:13.5px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; white-space:pre-wrap; }
.md-h { color:var(--accent); font-weight:700; } .md-note { color:var(--muted); font-style:italic; }
.caret { display:inline-block; width:2px; height:1.1em; vertical-align:text-bottom; margin-left:1px; background:var(--c); animation:blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity:0; } }
@media (prefers-reduced-motion: reduce) { .caret { animation:none; } }
.features, .steps, .cta { padding:3rem 0; border-top:1px solid var(--line); }
.features h2, .steps h2, .cta h2 { font-size:1.6rem; letter-spacing:-.01em; margin:0 0 1.5rem; text-wrap:balance; }
.features ul { list-style:none; padding:0; margin:0; display:grid; grid-template-columns:repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap:1.25rem; }
.feature { border:1px solid var(--line); border-radius:12px; padding:1.25rem; }
.feature-icon { font-size:1.5rem; } .feature h3 { margin:.5rem 0 .35rem; font-size:1.05rem; } .feature p { margin:0; color:var(--muted); }
.steps ol { margin:0; padding-left:1.25rem; display:grid; gap:.75rem; font-size:1.05rem; max-width:720px; }
.cta { text-align:center; }
.lp-foot { padding:2rem 0 3rem; border-top:1px solid var(--line); text-align:center; }

/* ---- document library ---- */
.lib { max-width:980px; margin:0 auto; padding:0 1.25rem 3rem; }
.lib-head { display:flex; align-items:center; gap:1rem; padding:1.25rem 0 1rem; }
.lib-head .brand { margin-right:auto; }
.lib-head button.primary { padding:.5rem 1rem; font-weight:600; }
.tabs { display:flex; align-items:center; gap:.25rem; border-bottom:1px solid var(--line); margin:.5rem 0 1rem; }
.tabs button { background:none; border:0; border-bottom:2px solid transparent; border-radius:0; padding:.6rem .9rem; color:var(--muted); font-weight:500; margin-bottom:-1px; }
.tabs button:hover:not(:disabled) { color:var(--fg); border-color:var(--line); }
.tabs button.on { color:var(--fg); border-bottom-color:var(--accent); }
.tabs .count { font-size:12px; color:var(--muted); margin-left:.2rem; }
.dot-new { background:var(--accent); color:var(--on-accent); border-radius:999px; padding:.05rem .45rem; font-size:11px; font-weight:600; }
.live-dot { margin-left:auto; width:8px; height:8px; border-radius:50%; background:var(--line); }
.live-dot.on { background:#2f9e44; box-shadow:0 0 0 3px #2f9e4433; }
.doc-list { display:flex; flex-direction:column; gap:.5rem; }
.doc-list .group { margin:1rem 0 .25rem; font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); font-weight:600; }
.doc-list .group:first-child { margin-top:0; }
.doc-row { display:grid; grid-template-columns:auto minmax(0,1fr) auto auto; align-items:center; gap:1rem; padding:.85rem 1rem;
  border:1px solid var(--line); border-radius:10px; background:var(--bg); transition:border-color .15s, box-shadow .15s; }
.doc-row:hover { border-color:color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow:0 2px 10px #0000000f; }
.doc-row.pending { background:color-mix(in srgb, var(--accent) 6%, var(--bg)); border-color:color-mix(in srgb, var(--accent) 35%, var(--line)); }
.doc-row.fresh { animation:fresh 2.4s ease-out; }
@keyframes fresh { 0%, 30% { box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow:none; } }
@media (prefers-reduced-motion: reduce) { .doc-row.fresh { animation:none; outline:2px solid var(--accent); } }
.doc-icon { width:36px; height:36px; border-radius:9px; display:grid; place-items:center; font-weight:700; color:var(--c);
  background:color-mix(in srgb, var(--c) 14%, var(--bg)); border:1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.doc-title { font-weight:600; color:var(--fg); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:inline-block; max-width:100%; vertical-align:bottom; }
a.doc-title:hover { color:var(--accent); text-decoration:none; }
.doc-meta { margin-top:.1rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.doc-people { display:flex; align-items:center; gap:.5rem; justify-self:end; }
.doc-actions { display:flex; gap:.4rem; }
.stack-avatars { display:inline-flex; } .stack-avatars .avatar + .avatar { margin-left:-6px; }
.avatar.sm { width:24px; height:24px; font-size:11px; border:2px solid var(--bg); box-sizing:content-box; }
.avatar.pending { opacity:.45; }
.avatar.more { background:var(--panel); color:var(--muted); }
.role-badge { font-size:11.5px; font-weight:600; padding:.1rem .5rem; border-radius:999px; border:1px solid var(--line); white-space:nowrap; }
.role-all { color:#7048e8; border-color:#7048e855; } .role-edit { color:#1c7ed6; border-color:#1c7ed655; } .role-view { color:var(--muted); }
.tag { display:inline-block; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--accent); background:color-mix(in srgb, var(--accent) 12%, transparent); padding:.1rem .45rem; border-radius:5px; }
.incoming { display:flex; align-items:center; gap:.6rem; flex-wrap:wrap; padding:.7rem 1rem; margin-bottom:.6rem; border-radius:10px;
  border:1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background:color-mix(in srgb, var(--accent) 8%, var(--bg)); animation:slide .25s ease-out; }
.incoming .grow { flex:1; } .incoming button.icon { border:0; background:none; font-size:1.2rem; line-height:1; color:var(--muted); }
@keyframes slide { from { transform:translateY(-6px); opacity:0; } }
@media (prefers-reduced-motion: reduce) { .incoming { animation:none; } }
.empty { text-align:center; padding:3rem 1rem; border:1px dashed var(--line); border-radius:12px; }
.empty h3 { margin:0 0 .4rem; }
.lib .foot { margin-top:2rem; text-align:center; }
@media (max-width:640px) {
  .doc-row { grid-template-columns:auto minmax(0,1fr); }
  .doc-people, .doc-actions { grid-column:2; justify-self:start; }
}
/* dialogs */
dialog.share-dlg { width:min(560px, 94vw); }
.create label { display:flex; flex-direction:column; gap:.3rem; margin:.25rem 0 1rem; }
.create .actions, .share .actions { display:flex; justify-content:flex-end; gap:.5rem; margin-top:1rem; }
.invite-row { display:grid; grid-template-columns:1fr 1.4fr auto auto; gap:.4rem; margin:.5rem 0; }
@media (max-width:520px) { .invite-row { grid-template-columns:1fr 1fr; } }
select { font:inherit; color:inherit; background:var(--bg); border:1px solid var(--line); border-radius:6px; padding:.3rem .4rem; }
.people-list { list-style:none; padding:0; margin:0; }
.people-list li { display:flex; align-items:center; gap:.6rem; padding:.45rem 0; border-bottom:1px solid var(--line); }
.people-list .who-text { flex:1; min-width:0; line-height:1.3; overflow:hidden; text-overflow:ellipsis; }
.people-list .ctl { display:flex; align-items:center; gap:.35rem; }
.tabs button, .dot-new { white-space:nowrap; }
@media (max-width:640px) {
  .hide-sm { display:none; }
  .lib-head .who > span:not(.avatar):not(.badge) { display:none; }
  .tabs button { padding:.6rem .55rem; }
}

/* ---- collaborator cursors ---- */
/* editor: keep each remote cursor's name label visible (y-codemirror only shows it on hover) */
.cm-editor .cm-ySelectionCaret { border-left-width:2px; border-right-width:0; }
.cm-editor .cm-ySelectionInfo { opacity:1 !important; top:-1.35em; left:-2px; padding:.05rem .4rem; border-radius:6px 6px 6px 0;
  font:600 11px/1.3 system-ui, -apple-system, sans-serif; color:#fff; white-space:nowrap; z-index:2; pointer-events:none; }
.cm-editor .cm-ySelectionCaretDot { display:none; }
.cm-content { padding-top:1.4rem !important; } /* room for a label on the first line */
/* preview (View / Split): carets drawn over the rendered document */
.pv-cursors { position:absolute; inset:0 auto auto 0; width:0; height:0; pointer-events:none; }
.pv-cursor { position:absolute; width:0; border-left:2px solid var(--c); margin-left:-1px; transition:top .15s, left .15s; }
.pv-flag { position:absolute; bottom:100%; left:-2px; display:inline-flex; align-items:center; gap:.3rem; padding:.1rem .45rem .1rem .15rem;
  background:var(--c); color:#fff; border-radius:999px 999px 999px 0; font:600 11px/1.3 system-ui, -apple-system, sans-serif; white-space:nowrap; box-shadow:0 1px 3px #0003; }
.pv-avatar { width:16px; height:16px; border-radius:50%; background:#fff3; display:inline-grid; place-items:center; font-size:10px; }
@media (prefers-reduced-motion: reduce) { .pv-cursor { transition:none; } }
.pv-sel { position:absolute; border-radius:2px; background:color-mix(in srgb, var(--c) 45%, transparent);
  box-shadow:inset 0 -2px 0 var(--c); mix-blend-mode:multiply; } /* like a marker: the text underneath stays crisp */
@media (prefers-color-scheme: dark) { .pv-sel { background:color-mix(in srgb, var(--c) 80%, transparent); mix-blend-mode:screen; } }
.pv-cursor.mine { border-left-width:2px; }
/* editing in the rendered view */
.preview.can-edit .md-block:not(.editing) { border-radius:6px; transition:background .12s; cursor:text; }
.preview.can-edit .md-block:not(.editing):hover { background:color-mix(in srgb, var(--accent) 6%, transparent); box-shadow:0 0 0 4px color-mix(in srgb, var(--accent) 6%, transparent); }
.md-block.editing { margin:.6rem -.6rem; }
.inline-editor { display:block; width:100%; min-height:2.4em; resize:none; overflow:hidden; padding:.5rem .6rem; border-radius:8px;
  border:1px solid color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
  background:var(--bg); color:var(--fg); font:14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; outline:none; }
