:root {
  --bg: #f7f5fa;
  --page: #ffffff;
  --text: #1f1f1f;
  --subtle: #6b6b76;
  --line: #e2dfe8;
  --accent: #7b2fa8;
  --accent-text: #ffffff;
  --hover: #efe9f5;
  --link: #0563c1;
  --bad: #c42b1c;
  --bar: #7b2fa8;
  --bar-text: #ffffff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a1f;
    --page: #232227;
    --text: #ececf1;
    --subtle: #a3a2ad;
    --line: #3a3842;
    --accent: #b886de;
    --accent-text: #1b1a1f;
    --hover: #2e2b35;
    --link: #6cb4f5;
    --bad: #ff8a80;
    --bar: #2b2433;
    --bar-text: #ececf1;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Calibri, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  min-height: 52px; padding: env(safe-area-inset-top) 8px 0;
  background: var(--bar); color: var(--bar-text);
}
.bar h1 { flex: 1; margin: 0 6px; font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand img { width: 28px; height: 28px; border-radius: 6px; margin: 0 6px; display: block; }
.icon-btn { background: none; border: 0; color: inherit; width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:active { background: rgba(255, 255, 255, .15); }
.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico-more { stroke-width: 3.2; }

main { max-width: 760px; margin: 0 auto; padding: 8px 0 120px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list a, .list li > span.grow { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: inherit; text-decoration: none; min-height: 52px; }
.list li:has(> span.grow) { display: flex; align-items: center; padding-right: 12px; }
.list a:active { background: var(--hover); }
.list small { color: var(--subtle); display: block; font-size: 13px; }
.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dim { color: var(--subtle); font-style: italic; }
.swatch { width: 14px; height: 26px; border-radius: 3px; flex: none; }
.swatch.nb { width: 22px; height: 28px; border-radius: 4px; }
.results .snip { display: block; color: var(--subtle); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results b { display: block; }
.empty { padding: 24px 16px; color: var(--subtle); }

button.wide { display: block; width: calc(100% - 32px); margin: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--page); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.small { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--page); cursor: pointer; }
button[disabled] { opacity: .5; }
.form { padding: 8px 16px; }
.form label { display: block; margin: 12px 0; font-size: 14px; color: var(--subtle); }
.form input, .form > input { display: block; width: 100%; margin-top: 4px; padding: 12px; font-size: 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--page); color: var(--text); }
.form button.wide { width: 100%; margin: 16px 0; }
.form h2 { font-size: 16px; margin: 28px 0 8px; }
.msg { color: var(--subtle); padding: 0 16px; }
.form .msg { padding: 0; }
.picks button.wide { width: 100%; margin: 8px 0; text-align: left; }

.status { position: fixed; left: 0; right: 0; bottom: 0; padding: 6px 16px calc(6px + env(safe-area-inset-bottom)); font-size: 13px; color: var(--subtle); background: var(--bg); border-top: 1px solid var(--line); }
.status:empty { display: none; }
.status.bad { color: var(--bad); }

.lock { text-align: center; padding: 48px 24px; }
.lock .padlock .ico { width: 64px; height: 64px; color: var(--accent); stroke-width: 1.6; }
.lock h2 { font-size: 18px; font-weight: 600; }
.lock input { display: block; width: 100%; max-width: 360px; margin: 16px auto 0; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--page); color: var(--text); font-size: 16px; }
.lock button.wide { max-width: 360px; margin: 16px auto; }

/* The page */
main.page { background: var(--page); min-height: 100vh; padding: 16px 16px 140px; }
.title-input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; resize: none; overflow: hidden; font-size: 26px; font-weight: 300; padding: 4px 0; outline: none; font-family: "Calibri Light", -apple-system, "Segoe UI", sans-serif; }
.date { color: var(--subtle); font-size: 13px; margin: 6px 0 18px; }
.outline { margin: 0 0 18px; }
.para { display: flex; align-items: baseline; gap: 6px; min-height: 1.45em; }
.para .text { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; padding: 1px 0; border-radius: 4px; }
.para .text:active { background: var(--hover); }
.marker { min-width: 1.2em; text-align: right; color: var(--subtle); }
.tags { display: inline-flex; gap: 4px; align-items: center; }
.tags .todo { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); transform: translateY(3px); }
.tag { font-size: 15px; }
.s-h1 { font-size: 16pt; font-family: "Calibri Light", -apple-system, sans-serif; }
.s-h2 { font-size: 14pt; font-family: "Calibri Light", -apple-system, sans-serif; }
.s-h3, .s-h4 { font-size: 12pt; font-weight: 700; }
.s-h4, .s-h6, .s-quote { font-style: italic; }
.s-h5, .s-h6 { font-weight: 700; }
.s-title { font-size: 20pt; font-weight: 300; }
.s-cite { font-size: 9pt; }
.s-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.text a.link { color: var(--link); }
.math { font-family: "Cambria Math", "STIX Two Math", "Times New Roman", serif; font-style: italic; }
.pic { max-width: 100%; height: auto; border-radius: 4px; display: inline-block; vertical-align: bottom; background: var(--hover); }
.pic.missing { min-width: 120px; min-height: 60px; }
.file { display: inline-block; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: inherit; }
.editor { flex: 1; width: 100%; border: 0; outline: 2px solid var(--accent); border-radius: 4px; background: var(--page); resize: none; overflow: hidden; padding: 1px 2px; line-height: 1.45; }
.tablewrap { overflow-x: auto; margin: 6px 0; }
table { border-collapse: collapse; }
td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; min-width: 60px; }
table.noborders td { border-color: transparent; }
.ink-label { color: var(--subtle); font-size: 13px; margin-top: 12px; }
.inkwrap { border: 1px dashed var(--line); border-radius: 8px; padding: 6px; }
.ink { width: 100%; height: auto; display: block; }
.conflicts { border: 1px solid #e0b252; background: rgba(255, 196, 0, .12); border-radius: 10px; padding: 10px 12px; margin: 0 0 16px; font-size: 14px; }
.conflict { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.conflict .quote { flex: 1 1 100%; background: var(--page); border-radius: 6px; padding: 6px 8px; white-space: pre-wrap; }

.fab { position: fixed; right: 16px; bottom: calc(44px + env(safe-area-inset-bottom)); display: flex; gap: 12px; z-index: 6; }
.round { width: 54px; height: 54px; border-radius: 27px; border: 1px solid var(--line); background: var(--page); color: var(--text); display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0, 0, 0, .2); cursor: pointer; }
.round.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: 46px; min-width: 190px; background: var(--page); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); overflow: hidden; }
.menu-list button { display: block; width: 100%; text-align: left; padding: 14px 16px; border: 0; background: none; cursor: pointer; }
.menu-list button:active { background: var(--hover); }
.menu-list .danger { color: var(--bad); }

/* Equations */
.math { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif; font-style: normal; white-space: nowrap; display: inline-block; vertical-align: middle; }
.math .mi { font-style: italic; }
.math .mo.bin { margin: 0 .2em; }
.math .mo.rel { margin: 0 .28em; }
.math .mfn { margin-right: .15em; }
.math .mscr { display: inline-block; }
.math sup, .math sub { font-size: 70%; }
.math .mfrac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .1em; }
.math .mfrac > .num { border-bottom: 1px solid currentColor; padding: 0 .2em; }
.math .mfrac.nobar > .num { border-bottom: 0; }
.math .mfrac > .den { padding: 0 .2em; }
.math .msqrt { white-space: nowrap; }
.math .msqrt .rad { border-top: 1px solid currentColor; padding: 0 .1em; }
.math .mop { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .15em; }
.math .mop .ul, .math .mop .ll { font-size: 70%; line-height: 1; min-height: .2em; }
.math .mop .sym.big { font-size: 140%; line-height: 1; }
.math .mop.side { flex-direction: row; align-items: center; }
.math .mop.side .ul { order: 3; align-self: flex-start; }
.math .mop.side .ll { order: 4; align-self: flex-end; }
.math .mfence { white-space: nowrap; }
.math .mslot { opacity: .5; }
