/* Anatomy Notebook — school-notebook look. Everything on the "page" sits on a 32px ruled grid. */
:root {
  --desk: #e4dccb;
  --bar: #f4eee0;
  --binder: #efe7d6;
  --paper: #fffdf4;
  --card: #fffaf0;
  --edge: #d3c8b2;
  --line: #cddff2;
  --margin: #ee8b93;
  --hole: #d8cfba;
  --hole-edge: #c4b99f;
  --ink: #232b3a;
  --muted: #6b7384;
  --blue: #2457c5;
  --red: #c23b48;
  --accent: #c4552d;
  --accent-ink: #ffffff;
  --mark: #ffe45e;
  --ok: #2f9e62;
  --warn: #d99a1b;
  --bad: #c9403f;
  --shadow: 0 1px 2px rgba(60, 40, 10, .12), 0 10px 30px rgba(60, 40, 10, .14);
  --font-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-hand: 'Caveat', 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive;
  --font-body: 'Patrick Hand', 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive;
  --fs: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #11141c; --bar: #181c27; --binder: #161a25; --paper: #1d2230; --card: #232a3b; --edge: #2f384c;
    --line: #2b3548; --margin: #8c4752; --hole: #10131b; --hole-edge: #2a3244;
    --ink: #e8e5da; --muted: #98a1b3; --blue: #7aa2ff; --red: #ff8e98; --accent: #e0724a; --mark: #6b5a12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #11141c; --bar: #181c27; --binder: #161a25; --paper: #1d2230; --card: #232a3b; --edge: #2f384c;
  --line: #2b3548; --margin: #8c4752; --hole: #10131b; --hole-edge: #2a3244;
  --ink: #e8e5da; --muted: #98a1b3; --blue: #7aa2ff; --red: #ff8e98; --accent: #e0724a; --mark: #6b5a12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root[data-font="clean"] { --font-body: 'Nunito', system-ui, sans-serif; --fs: 17px; }
:root[data-size="s"] { --fs: 18px; }
:root[data-size="l"] { --fs: 22px; }
:root[data-font="clean"][data-size="s"] { --fs: 15px; }
:root[data-font="clean"][data-size="l"] { --fs: 19px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--desk); color: var(--ink); font-family: var(--font-ui); font-size: 16px;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app { display: flex; height: 100dvh; }

/* ---------- binder (sidebar) ---------- */
#binder { width: 308px; flex: none; background: var(--binder); border-right: 1px solid var(--edge); display: flex; flex-direction: column; z-index: 30; }
.binder-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 8px 16px; }
.brand { flex: 1; font-family: var(--font-hand); font-weight: 700; font-size: 29px; line-height: 1; color: var(--blue); cursor: pointer; }
.brand small { display: block; font-family: var(--font-ui); font-weight: 700; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.tree { flex: 1; overflow: auto; padding: 4px 8px 80px; }
.tree-empty { padding: 20px 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.row { --d: 0; display: flex; align-items: center; gap: 4px; min-height: 38px; padding: 2px 4px 2px calc(4px + var(--d) * 16px); border-radius: 10px; cursor: pointer; position: relative; user-select: none; }
.row:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.row.active { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 700; }
.row .twisty { width: 24px; height: 28px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; padding: 0; }
.row .twisty svg { width: 16px; height: 16px; transition: transform .12s; }
.row .twisty.open svg { transform: rotate(90deg); }
.row .twisty.none { visibility: hidden; }
.row .ico { color: var(--muted); }
.row.course { font-weight: 700; margin-top: 4px; }
.row.course::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--tab, var(--accent)); }
.row.course .ico { color: var(--tab, var(--accent)); }
.row .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.row .star { color: var(--warn); }
.row .star svg { width: 14px; height: 14px; fill: currentColor; }
.row .more { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--muted); display: grid; place-items: center; opacity: 0; }
.row:hover .more, .row.active .more { opacity: 1; }
@media (hover: none) { .row .more { opacity: .7; } }
.binder-foot { padding: 8px 10px; border-top: 1px solid var(--edge); display: flex; align-items: center; gap: 6px; }

/* ---------- main column ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 8px; background: var(--bar); border-bottom: 1px solid var(--edge); }
#crumbs { flex: 1; min-width: 0; padding: 0 6px; font-family: var(--font-hand); font-size: 23px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#crumbs a { color: var(--muted); text-decoration: none; cursor: pointer; }
#crumbs a:hover { color: var(--blue); }
#crumbs .sep { color: var(--muted); margin: 0 4px; opacity: .6; }
.iconbtn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--ink); display: grid; place-items: center; flex: none; }
.iconbtn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.iconbtn.on { color: var(--warn); }
.iconbtn.on svg { fill: currentColor; }
#menuBtn { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; border: 1px solid var(--edge); background: var(--card); color: var(--muted); white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok i { background: var(--ok); } .pill.busy i { background: var(--warn); animation: pulse 1s infinite; } .pill.bad i { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }
#scroll { flex: 1; overflow: auto; scroll-behavior: smooth; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px auto 0; max-width: 880px; padding: 6px 8px 6px 14px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 18%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); font-size: 13.5px; line-height: 1.4; }
.banner b { font-weight: 800; }
.banner .btn { height: 32px; padding: 0 12px; font-size: 13px; flex: none; }
@media (max-width: 899px) { .banner { margin: 0; max-width: none; border-radius: 0; border-width: 0 0 1px; } }

/* ---------- the sheet of paper ---------- */
.sheet {
  --ruled: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--line) 31px, var(--line) 32px);
  position: relative; max-width: 880px; margin: 18px auto 140px; padding: 32px 30px 64px 88px; min-height: 70vh;
  background-color: var(--paper);
  background-image: linear-gradient(to right, transparent 66px, var(--margin) 66px, var(--margin) 68px, transparent 68px), var(--ruled);
  border-radius: 6px; box-shadow: var(--shadow);
}
.sheet::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 28px;
  background: radial-gradient(circle at 14px 16px, var(--hole) 0 7px, var(--hole-edge) 7px 8.5px, transparent 9.5px) 0 0 / 28px 96px repeat-y; pointer-events: none; }
.crumb-line { height: 32px; line-height: 32px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-line a { cursor: pointer; } .crumb-line a:hover { color: var(--blue); }
.title-input { display: block; width: 100%; height: 64px; line-height: 64px; margin: 0; padding: 0; border: 0; background: none; outline: none; resize: none; overflow: hidden; font-family: var(--font-hand); font-weight: 700; font-size: 46px; color: var(--blue); word-break: break-word; }
.title-input::placeholder { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.meta-line { height: 32px; line-height: 32px; font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; align-items: center; white-space: nowrap; overflow: hidden; }
.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; background: var(--card); height: 28px; }
.seg button { border: 0; background: none; padding: 0 12px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--blue); color: #fff; }
.seg button + button { border-left: 1px solid var(--edge); }

/* writing toolbar (sits above the page, never inside the ruled area) */
.toolbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 2px; overflow-x: auto; padding: 6px 8px; background: var(--bar); border-bottom: 1px solid var(--edge); scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar .tb { flex: none; min-width: 38px; height: 38px; padding: 0 8px; border: 0; border-radius: 9px; background: none; font-weight: 800; font-size: 15px; display: grid; place-items: center; }
.toolbar .tb:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.toolbar .tb.hi span { background: var(--mark); padding: 0 5px; border-radius: 3px; color: #222; }
.toolbar .gap { width: 1px; margin: 6px 4px; background: var(--edge); flex: none; }

/* ---------- read mode text ---------- */
.md { font-family: var(--font-body); font-size: var(--fs); line-height: 32px; word-wrap: break-word; overflow-wrap: anywhere; }
.md > * { margin-top: 0; }
.md p { margin: 0 0 32px; }
.md h1, .md h2, .md h3, .md h4 { margin: 0; font-family: var(--font-hand); font-weight: 700; }
.md h1 { font-size: 42px; line-height: 64px; color: var(--blue); }
.md h2 { font-size: 33px; line-height: 32px; margin-top: 32px; color: var(--red); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--red) 45%, transparent); text-underline-offset: 5px; text-decoration-thickness: 2px; }
.md h3 { font-size: 28px; line-height: 32px; color: var(--blue); }
.md h4 { font-size: 24px; line-height: 32px; color: var(--ink); }
.md h1 + p, .md h2 + p, .md h3 + p { margin-top: 0; }
.md ul, .md ol { margin: 0 0 32px; padding-left: 30px; }
.md li ul, .md li ol { margin: 0; }
.md li { line-height: 32px; }
.md li::marker { color: var(--red); }
.md li.task { list-style: none; margin-left: -26px; }
.md li.task > input { width: 19px; height: 19px; margin: 0 9px 0 0; vertical-align: -3px; accent-color: var(--blue); }
.md li.task.done > span { opacity: .55; text-decoration: line-through; }
.md mark { background: linear-gradient(transparent 14%, var(--mark) 14%, var(--mark) 90%, transparent 90%); color: inherit; padding: 0 2px; border-radius: 2px; }
.md a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.md a.wikilink { text-decoration: none; border-bottom: 2px dotted var(--blue); }
.md code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .8em; background: color-mix(in srgb, var(--ink) 9%, transparent); padding: 1px 5px; border-radius: 5px; }
.md hr { border: 0; border-top: 2px dashed var(--muted); margin: 15px 0; opacity: .55; }
.md blockquote { margin: 0 0 32px; padding: 6px 14px; border-left: 4px solid var(--margin); background: color-mix(in srgb, var(--margin) 8%, transparent); border-radius: 0 10px 10px 0; font-style: italic; }
.md blockquote > :last-child { margin-bottom: 0; }
.md pre { margin: 0 0 32px; padding: 12px 14px; background: color-mix(in srgb, var(--ink) 8%, var(--paper)); border-radius: 10px; overflow: auto; }
.md pre code { background: none; padding: 0; font-size: 14px; line-height: 22px; display: block; }
.md .table-wrap { margin: 0 0 32px; overflow-x: auto; border-radius: 10px; border: 1.5px solid color-mix(in srgb, var(--ink) 28%, transparent); background: var(--paper); }
.md table { border-collapse: collapse; width: 100%; font-size: .9em; line-height: 24px; }
.md th, .md td { padding: 6px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid color-mix(in srgb, var(--ink) 15%, transparent); }
.md th { background: color-mix(in srgb, var(--blue) 14%, var(--paper)); font-family: var(--font-hand); font-size: 1.25em; font-weight: 700; white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
.md figure { margin: 0 0 32px; text-align: center; position: relative; }
.md figure img { display: block; margin: 0 auto; max-width: 100%; max-height: 70vh; padding: 8px; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .22); border-radius: 3px; cursor: zoom-in; }
.md figure::before { content: ""; position: absolute; top: -7px; left: 50%; width: 76px; height: 20px; margin-left: -38px; background: color-mix(in srgb, var(--mark) 70%, transparent); transform: rotate(-2deg); z-index: 1; }
.md figcaption { font-family: var(--font-hand); font-size: 22px; line-height: 28px; margin-top: 8px; color: var(--muted); }
.md p img { max-width: 100%; vertical-align: middle; border-radius: 4px; }
.md img[data-pending] { min-height: 80px; min-width: 120px; background: color-mix(in srgb, var(--ink) 8%, transparent); }

.callout { --tone: var(--blue); margin: 0 0 32px; padding: 6px 16px 8px; border-radius: 12px; border: 1.5px solid color-mix(in srgb, var(--tone) 55%, transparent); border-left-width: 6px; background: color-mix(in srgb, var(--tone) 11%, var(--paper)); }
.callout .callout-title { font-family: var(--font-hand); font-weight: 700; font-size: 26px; line-height: 32px; color: var(--tone); }
.callout > :last-child { margin-bottom: 0; }
.callout p, .callout ul, .callout ol { margin-bottom: 8px; }
.callout.key { --tone: #d6890f; } .callout.def { --tone: var(--blue); } .callout.ex { --tone: #2e8b57; } .callout.tip { --tone: #13807f; }
.callout.warn { --tone: #d0462f; } .callout.exam { --tone: #8e3fa0; } .callout.mistake { --tone: #c9403f; } .callout.note { --tone: var(--muted); }

/* conversations */
.chat { display: flex; flex-direction: column; gap: 12px; margin: 0 0 32px; padding: 16px 14px; border-radius: 16px; border: 1.5px dashed color-mix(in srgb, var(--ink) 25%, transparent); background: color-mix(in srgb, var(--ink) 4%, var(--paper)); font-family: var(--font-ui); font-size: 15.5px; }
.chat .turn { max-width: 88%; display: flex; flex-direction: column; align-items: flex-start; }
.chat .turn.right { align-self: flex-end; align-items: flex-end; }
.chat .turn.note-turn { align-self: center; max-width: 100%; color: var(--muted); font-style: italic; }
.chat .who { font-family: var(--font-hand); font-weight: 700; font-size: 20px; line-height: 22px; color: var(--pen); padding: 0 6px; }
.chat .bubble { padding: 8px 13px; border-radius: 16px 16px 16px 4px; border: 1.5px solid color-mix(in srgb, var(--pen) 45%, transparent); background: color-mix(in srgb, var(--pen) 10%, var(--paper)); line-height: 24px; }
.chat .turn.right .bubble { border-radius: 16px 16px 4px 16px; }
.chat .bubble p, .chat .bubble ul, .chat .bubble ol, .chat .bubble pre, .chat .bubble blockquote, .chat .bubble .table-wrap { margin: 0 0 8px; font-family: var(--font-ui); font-size: inherit; line-height: 24px; }
.chat .bubble li { line-height: 24px; }
.chat .bubble > :last-child { margin-bottom: 0; }
.chat .bubble h1, .chat .bubble h2, .chat .bubble h3, .chat .bubble h4 { font-size: 22px; line-height: 28px; margin: 4px 0; color: var(--pen); text-decoration: none; }

/* ---------- editor ---------- */
.editor-wrap { display: grid; gap: 0 24px; }
.editor-wrap.split { grid-template-columns: 1fr 1fr; }
textarea.editor { display: block; width: 100%; height: calc(100dvh - 330px); min-height: 320px; margin: 0; padding: 0; border: 0; outline: none; resize: none; background: none; color: var(--ink);
  font-family: var(--font-body); font-size: var(--fs); line-height: 32px; tab-size: 2; }
.editor-wrap.split .md { height: calc(100dvh - 330px); min-height: 320px; overflow: auto; }

/* ---------- home / folder pages ---------- */
.page { max-width: 880px; margin: 0 auto; padding: 22px 16px 140px; }
.hello { font-family: var(--font-hand); font-weight: 700; font-size: 44px; line-height: 1.05; color: var(--blue); margin: 6px 0 2px; }
.sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.h-sec { display: flex; align-items: center; gap: 8px; margin: 26px 0 10px; font-family: var(--font-hand); font-size: 28px; font-weight: 700; }
.h-sec small { font-family: var(--font-ui); font-size: 12px; color: var(--muted); font-weight: 700; }
.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.cover { --c: var(--accent); position: relative; aspect-ratio: 3 / 4; border-radius: 6px 14px 14px 6px; padding: 14px 8px 12px 20px; color: #fff; cursor: pointer; display: flex; flex-direction: column; justify-content: center; overflow: hidden; box-shadow: var(--shadow);
  background: radial-gradient(circle at 18% 22%, rgba(255, 255, 255, .13) 0 1.5px, transparent 2px) 0 0 / 26px 26px, radial-gradient(circle at 62% 70%, rgba(0, 0, 0, .13) 0 1.5px, transparent 2px) 0 0 / 34px 34px, var(--c); transition: transform .12s; }
.cover:hover { transform: translateY(-3px) rotate(-.6deg); }
.cover::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: rgba(0, 0, 0, .28); }
.cover .lbl { background: #fffdf4; color: #232b3a; border-radius: 6px; padding: 10px 6px; text-align: center; font-family: var(--font-hand); font-weight: 700; font-size: 24px; line-height: 1.05; box-shadow: 0 1px 0 rgba(0, 0, 0, .15); overflow-wrap: break-word; hyphens: auto; }
.cover .cnt { margin-top: 8px; text-align: center; font-size: 12px; font-weight: 700; opacity: .92; }
.cover.add { background: none; box-shadow: none; border: 2.5px dashed var(--edge); color: var(--muted); align-items: center; }
.cover.add::before { display: none; }
.cover.add .lbl { background: none; box-shadow: none; color: var(--muted); }
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--edge); cursor: pointer; }
.item:hover { border-color: var(--blue); }
.item .ico { color: var(--muted); }
.item.folder .ico { color: var(--tab, var(--accent)); }
.item .t { font-weight: 800; font-size: 15.5px; }
.item .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.item .grow { flex: 1; min-width: 0; }
.empty { padding: 26px 18px; text-align: center; color: var(--muted); border: 2px dashed var(--edge); border-radius: 16px; line-height: 1.6; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--edge); background: var(--card); font-weight: 800; font-size: 14px; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

#fab { position: fixed; right: 20px; bottom: 22px; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); z-index: 20; }
#fab svg { width: 28px; height: 28px; stroke-width: 2.6; }

/* ---------- dialogs ---------- */
#overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 25, .55); display: grid; place-items: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: 90dvh; overflow: auto; background: var(--paper); color: var(--ink); border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); padding: 18px 18px 16px; animation: rise .16s; }
.modal.wide { width: min(760px, 100%); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.modal h3 { margin: 0 0 4px; font-family: var(--font-hand); font-size: 30px; line-height: 1.1; color: var(--blue); }
.modal p.hint { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.modal input[type=text], .modal input[type=password], .modal textarea, .modal select { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1.5px solid var(--edge); background: var(--card); outline: none; font-size: 16px; }
.modal input:focus, .modal textarea:focus { border-color: var(--blue); }
.modal textarea { min-height: 150px; resize: vertical; line-height: 1.5; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.modal .actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.modal .preview { margin-top: 12px; max-height: 38vh; overflow: auto; border-radius: 12px; }
.modal .preview .chat { margin: 0; }
.modal label.f { display: block; margin: 12px 0 6px; font-size: 12.5px; font-weight: 800; color: var(--muted); }
.sheetlist { display: grid; gap: 2px; margin: 8px -6px 0; }
.sheetlist button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 10px; border: 0; border-radius: 12px; background: none; text-align: left; font-weight: 700; font-size: 15.5px; }
.sheetlist button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.sheetlist button.danger { color: var(--bad); }
.sheetlist button small { display: block; font-weight: 600; font-size: 12.5px; color: var(--muted); }
.sheetlist hr { border: 0; border-top: 1px solid var(--edge); margin: 6px 4px; width: calc(100% - 8px); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatches button.on { border-color: var(--ink); }
.picker { max-height: 46vh; overflow: auto; border: 1.5px solid var(--edge); border-radius: 12px; padding: 6px; background: var(--card); }
.picker .row.disabled { opacity: .35; pointer-events: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 8px 0; }
.kv dt { color: var(--muted); font-weight: 700; } .kv dd { margin: 0; font-weight: 700; word-break: break-word; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0; font-weight: 800; font-size: 14px; }
.err { color: var(--bad); font-size: 13.5px; font-weight: 700; min-height: 20px; margin-top: 8px; }

#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 120; display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 14px; background: #232b3a; color: #fff; font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
#toast button { border: 0; background: none; color: #ffd37a; font-weight: 800; padding: 0; }
#lightbox { position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, .88); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; touch-action: pinch-zoom; background: #fff; }
#lightbox p { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: #fff; font-family: var(--font-hand); font-size: 24px; margin: 0; }

#lock { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: var(--desk); }
#lock .card { width: min(380px, 100%); padding: 26px 22px; border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); text-align: center; }
#lock h2 { margin: 6px 0 4px; font-family: var(--font-hand); font-size: 38px; color: var(--blue); }
#lock p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
#lock input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--edge); background: var(--card); outline: none; font-size: 16px; text-align: center; }
#lock .btn { width: 100%; justify-content: center; margin-top: 12px; height: 46px; }

/* ---------- phones ---------- */
@media (max-width: 899px) {
  #binder { position: fixed; inset: 0 auto 0 0; width: min(86vw, 330px); transform: translateX(-102%); transition: transform .18s; visibility: hidden; }
  body.drawer #binder { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  #scrim { position: fixed; inset: 0; z-index: 25; background: rgba(10, 14, 25, .45); }
  #menuBtn { display: grid; }
  .editor-wrap.split { grid-template-columns: 1fr; }
  .seg .split-btn { display: none; }
}
@media (min-width: 900px) { #scrim { display: none; } }
@media (max-width: 700px) {
  .sheet { margin: 0 0 120px; padding: 24px 14px 56px 48px; border-radius: 0; box-shadow: none; background-image: linear-gradient(to right, transparent 38px, var(--margin) 38px, var(--margin) 40px, transparent 40px), var(--ruled); }
  .sheet::before { display: none; }
  .md h1 { font-size: 36px; } .title-input { font-size: 38px; }
  .chat .turn { max-width: 96%; }
  .page { padding-top: 14px; } .hello { font-size: 38px; }
  .covers { grid-template-columns: repeat(2, 1fr); }
  textarea.editor { height: calc(100dvh - 300px); }
  .pill span { display: none; } .pill { padding: 0 9px; }
  #toast { bottom: 90px; }
}
@media print { #binder, #topbar, .toolbar, #fab, .meta-line .seg { display: none !important; } #scroll { overflow: visible; } .sheet { box-shadow: none; margin: 0; } }
