/* MIANU Notes: a glass sidebar of topics and their trees, and the open page on a brighter pane. */
html, body { overflow: hidden; }
.shell { display: grid; grid-template-columns: minmax(250px, 310px) minmax(0, 1fr); gap: 12px; padding: 0 12px 12px; height: calc(100dvh - 82px); }
.side-toggle { display: none; }

/* ---------- The sidebar ---------- */
.side { display: flex; flex-direction: column; min-height: 0; padding: 14px 8px 10px; }
.side__head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 10px; }
.side__head h2 { margin: 0; font: 600 11.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.tree { flex: 1; min-height: 0; overflow: auto; padding: 0 2px 20px; scrollbar-width: thin; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree__empty { padding: 8px 10px; font-size: 14px; }
.tree__topic { margin-bottom: 2px; }
.tree__topic.is-active { margin: 4px 0 8px; }
.tree__group { position: relative; }
/* Lines that join a page to the pages inside it, like traces on a board. */
.tree__group::before { content: ''; position: absolute; top: 2px; bottom: 12px; left: calc(14px + (var(--depth) - 1) * 16px); width: 1px; background: linear-gradient(var(--line-2), rgb(15 110 70 / .06)); }
.row { position: relative; display: flex; align-items: center; gap: 2px; min-height: 34px; padding: 0 4px 0 calc(2px + (var(--depth, 0) * 16px)); border-radius: 10px; transition: background .15s; }
.row:hover { background: rgb(255 255 255 / .55); }
.row.is-current { background: linear-gradient(100deg, rgb(182 239 114 / .5), rgb(95 240 180 / .38)); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .75); }
.row--topic { min-height: 40px; padding-left: 4px; }
.row--topic .row__link { font-weight: 650; font-size: 14.5px; }
.row__chev { flex: none; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--dim); cursor: pointer; }
.row__chev svg { width: 14px; height: 14px; transition: transform .2s var(--ease); }
.row__chev[aria-expanded="true"] svg { transform: rotate(90deg); }
.row__chev:hover { background: rgb(255 255 255 / .8); color: var(--ink); }
.row__chev--none { visibility: hidden; }
.row__link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 4px; color: var(--ink); text-decoration: none; font-size: 14px; }
.row__link > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__link > .ico { color: var(--emerald); }
.row__lock { display: inline-flex; color: #a38f66; }
.row__lock .ico { width: 13px; height: 13px; }
.row__count { flex: none; padding: 2px 7px; border-radius: 99px; background: rgb(255 255 255 / .6); font-size: 11px; color: var(--dim); }
.row--topic .row__acts + .row__count, .row--topic:hover .row__count { }
.row__acts { flex: none; display: flex; gap: 1px; opacity: 0; transition: opacity .15s; }
.row:hover .row__acts, .row:focus-within .row__acts, .row.is-current .row__acts { opacity: 1; }
.row__act { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--ink-2); cursor: pointer; }
.row__act .ico { width: 15px; height: 15px; }
.row__act:hover { background: rgb(255 255 255 / .9); color: var(--emerald); }
.row__act--danger:hover { color: var(--danger); }
.row__input { flex: 1; min-width: 0; height: 30px; margin: 2px 0; padding: 0 8px; border: 1px solid var(--emerald); border-radius: 8px; background: #fff; font-size: 14px; outline: none; box-shadow: 0 0 0 3px rgb(95 240 180 / .3); }
.row[draggable="true"] { cursor: grab; }
.row.is-dragging { opacity: .4; }
.row[data-drop="before"] { box-shadow: inset 0 2px 0 var(--emerald); }
.row[data-drop="after"] { box-shadow: inset 0 -2px 0 var(--emerald); }
.row[data-drop="inside"] { background: rgb(95 240 180 / .35); box-shadow: inset 0 0 0 1.5px var(--emerald); }

/* ---------- The page ---------- */
.stage { min-height: 0; overflow: auto; outline: none; scrollbar-width: thin; }
.stage__inner { max-width: 860px; margin: 0 auto; padding: clamp(22px, 4vw, 52px) clamp(18px, 4.5vw, 64px) 90px; }
.eyebrow { margin: 0 0 8px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--emerald); }
.lede { max-width: 58ch; margin: 12px 0 22px; font-size: 16.5px; color: var(--ink-2); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: 12.5px/1.5 var(--mono); color: var(--dim); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--emerald); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 14px 20px; margin: 12px 0 6px; }
.page-title { margin: 0; flex: 1 1 320px; min-width: 0; font-size: clamp(30px, 3.6vw, 44px); line-height: 1.08; font-weight: 750; letter-spacing: -.035em; overflow-wrap: anywhere; }
.title-input { flex: 1 1 320px; min-width: 0; padding: 0 0 4px; border: 0; border-bottom: 2px dashed rgb(15 157 99 / .45); background: transparent; color: var(--ink);
  font-size: clamp(30px, 3.6vw, 44px); line-height: 1.08; font-weight: 750; letter-spacing: -.035em; outline: none; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.page-actions--row { margin: 14px 0 26px; }
.page-meta { margin: 0 0 22px; font-size: 12px; color: var(--dim); }
.status { font: 12px/1 var(--mono); color: var(--dim); }

/* The formatting toolbar, while editing. */
.toolbar { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: 3px; margin: 0 0 14px; padding: 6px; border-radius: 14px; }
.tool { min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: 650 13px/1 var(--sans); cursor: pointer; }
.tool:hover { background: rgb(255 255 255 / .9); }
.tool[aria-pressed="true"] { background: var(--ink); color: #fff; }
.tool--b { font-weight: 850; } .tool--i { font-style: italic; font-family: var(--serif); } .tool--u { text-decoration: underline; } .tool--s { text-decoration: line-through; }
.tool--mark { background: linear-gradient(transparent 58%, rgb(255 210 80 / .85) 58%); }
.tool--mark[aria-pressed="true"] { background: rgb(255 210 80); color: var(--ink); }

/* The text: read like a page, edited on a lighter sheet. */
.doc-host { border-radius: 16px; transition: background .25s, box-shadow .25s, padding .25s; }
.doc-host.is-editable { padding: 18px 22px; background: rgb(255 255 255 / .72); box-shadow: inset 0 0 0 1px var(--line), 0 0 0 4px rgb(95 240 180 / .18); }
.doc { min-height: 60px; outline: none; color: var(--ink); font: 400 17px/1.72 var(--serif); overflow-wrap: break-word; }
.doc-host.is-editable .doc { min-height: 40vh; }
.doc--plain { width: 100%; min-height: 50vh; padding: 0; border: 0; background: transparent; resize: vertical; font: 400 15px/1.6 var(--mono); }
.doc > :first-child { margin-top: 0; }
.doc p { margin: 0 0 .85em; }
.doc h2 { margin: 1.4em 0 .5em; font: 720 23px/1.25 var(--sans); letter-spacing: -.02em; }
.doc h3 { margin: 1.25em 0 .4em; font: 700 18px/1.3 var(--sans); color: var(--deep); }
.doc a { color: var(--emerald); text-underline-offset: 3px; }
.doc mark { background: linear-gradient(transparent 12%, rgb(255 214 77 / .7) 12%); color: inherit; padding: 0 .1em; border-radius: 2px; }
.doc ul, .doc ol { margin: 0 0 .85em; padding-left: 1.4em; }
.doc li > p { margin: 0 0 .25em; }
.doc ul[data-type="taskList"] { list-style: none; padding-left: .1em; }
.doc ul[data-type="taskList"] li { display: flex; gap: 9px; align-items: flex-start; }
.doc ul[data-type="taskList"] li > label { flex: none; margin-top: .35em; }
.doc ul[data-type="taskList"] li > label input { width: 16px; height: 16px; accent-color: var(--emerald); }
.doc ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.doc ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--dim); text-decoration: line-through; }
.doc blockquote { margin: .5em 0 1em; padding: .6em 1em; border-left: 3px solid var(--emerald); border-radius: 0 10px 10px 0; background: rgb(95 240 180 / .12); font-style: italic; }
.doc blockquote p { margin: 0 0 .3em; }
.doc code { padding: .12em .38em; border-radius: 5px; background: rgb(15 110 70 / .08); font: 14px/1.5 var(--mono); }
.doc pre { margin: 0 0 1em; padding: 14px 16px; border-radius: 12px; background: #0f2a1e; color: #d9f7e8; white-space: pre-wrap; }
.doc pre code { padding: 0; background: none; color: inherit; font-size: 13.5px; }
.doc hr { margin: 1.8em 0; border: 0; border-top: 1px dashed var(--line-2); }
.doc p.is-editor-empty:first-child::before { content: attr(data-placeholder); float: left; height: 0; color: var(--dim); font-style: italic; pointer-events: none; }
.doc-empty { margin: 4px 0 0; font-style: italic; }

/* Cards: topics on the home, pages in a topic, pages inside a page. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 22px; }
.cards--small { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-top: 12px; }
.card { display: grid; gap: 6px; align-content: start; min-height: 104px; padding: 16px; border-radius: 16px; color: var(--ink); text-decoration: none; transition: transform .3s var(--ease), box-shadow .3s; }
.cards--small .card { min-height: 0; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 12px 14px; }
.card:hover { transform: translateY(-3px); box-shadow: inset 0 1px 0 rgb(255 255 255 / .85), 0 22px 40px -24px rgb(11 70 45 / .5); }
.card strong { font-size: 15.5px; line-height: 1.3; overflow-wrap: anywhere; }
.card__icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--deep); background: linear-gradient(140deg, rgb(182 239 114 / .6), rgb(95 240 180 / .45)); }
.card__meta { font-size: 11.5px; color: var(--dim); }
.card--add { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 1.5px dashed var(--line-2); background: rgb(255 255 255 / .3); color: var(--ink-2); font-weight: 600; cursor: pointer; }
.card--add:hover { border-color: var(--emerald); color: var(--emerald); background: rgb(255 255 255 / .6); }
.children { margin-top: 44px; }
.children:empty { display: none; }
.children__title { margin: 0; font-size: 11.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.empty { display: grid; justify-items: center; gap: 14px; padding: 60px 20px; text-align: center; }

/* ---------- Small screens: the sidebar slides in ---------- */
@media (max-width: 860px) {
  .side-toggle { display: inline-flex; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 30; top: 82px; bottom: 12px; left: 12px; width: min(330px, calc(100vw - 24px)); transform: translateX(calc(-100% - 24px)); transition: transform .35s var(--ease); }
  body.side-open .side { transform: none; }
  .topbar .btn span { display: none; }
  .topbar .btn:has(span) { width: 38px; padding: 0; }
  .row__acts { opacity: 1; }
}
@media (max-width: 520px) {
  .brand span { display: none; }
  .stage__inner { padding: 20px 16px 80px; }
  .doc { font-size: 16.5px; }
}
