/* ════════════════════════════════════════════════════════════════════════
   study-pages.css — Space: the home that lists your pages, and one page open
   (public/js/study/study-pages.js). Co-Writer's paper and Google-style menus
   are gone; a page is a single clean column on the landing's paper.
   Tokens, the tactile .k-btn and the rise-in come from /css/shared/khio-ui.css,
   so light and dark follow html[data-theme] with nothing to redo here.
   The AI bar, the suggestion card and the Sources panel keep their own rules in
   study-deeptutor.js (they sit inside .cwq-canvas, over the page).
   ════════════════════════════════════════════════════════════════════════ */

.sp-home *, .sp-shell *, #spLayer * { box-sizing: border-box; }
.sp-home button, .sp-shell button, #spLayer button { font-family: inherit; }
.sp-home svg, .sp-shell svg, #spLayer svg { flex: none; }
.sp-home [hidden], #spLayer [hidden] { display: none !important; }

/* ── The home ─────────────────────────────────────────────────────────── */
.sp-home { flex: 1; min-height: 0; overflow-y: auto; background: var(--k-paper); color: var(--k-ink); font-family: var(--k-sans); -webkit-font-smoothing: antialiased; }
.sp-home-in { width: 100%; max-width: 980px; margin: 0 auto; padding: 56px clamp(20px, 4vw, 48px) 96px; animation: k-rise .6s var(--k-ease) both; }
.sp-home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.sp-h1 { margin: 0; font-family: var(--k-display); font-weight: 500; font-size: clamp(42px, 4.2vw, 60px); line-height: 1; letter-spacing: -.028em; }
.sp-sub { margin: 12px 0 0; max-width: 56ch; font-size: 16.5px; line-height: 1.5; color: var(--k-ink-2); }
.sp-eyebrow { margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--k-ink-3); }
.sp-link { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; font: 500 14px var(--k-sans); color: var(--k-blue); cursor: pointer; }
.sp-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* "New page" and the arrow beside it are one button split in two. */
.sp-split { display: flex; gap: 2px; flex: none; }
.sp-split .sp-new { border-radius: 13px 4px 4px 13px; padding: 0 18px 0 16px; }
.sp-split .sp-new-more { border-radius: 4px 13px 13px 4px; padding: 0 11px; }

/* Templates: five small starts in a row. */
.sp-tpls { margin-bottom: 36px; }
.sp-tpl-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.sp-tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 16px 16px; text-align: left; border-radius: 16px; border: 1px solid var(--k-line); background: var(--k-surface); color: var(--k-ink); cursor: pointer; outline: 0;
    transition: transform .3s var(--k-ease), box-shadow .3s var(--k-ease), border-color .2s ease; }
.sp-tpl:hover, .sp-tpl:focus-visible { transform: translateY(-2px); box-shadow: var(--k-shadow); border-color: color-mix(in srgb, var(--k-ink) 18%, var(--k-line)); }
.sp-tpl:focus-visible { box-shadow: 0 0 0 3px rgba(10, 132, 255, .25), var(--k-shadow); }
/* A card is a small drawing of the page the template starts, in its own colour
   (--tpl, set on the card), then its name and what is in it. */
.sp-tpl { padding: 7px 7px 14px; gap: 0; }
.sp-tpl-art { display: flex; flex-direction: column; justify-content: center; gap: 6px; width: 100%; height: 84px; margin-bottom: 12px; padding: 12px 14px; border-radius: 11px; background: color-mix(in srgb, var(--tpl) 9%, var(--k-paper)); overflow: hidden; transition: background .2s ease; }
.sp-tpl:hover .sp-tpl-art, .sp-tpl:focus-visible .sp-tpl-art { background: color-mix(in srgb, var(--tpl) 15%, var(--k-paper)); }
.sp-tp-line { display: block; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--tpl) 26%, transparent); }
.sp-tp-line.is-head { height: 8px; margin-bottom: 2px; background: color-mix(in srgb, var(--tpl) 55%, transparent); }
.sp-tp-row { display: flex; align-items: center; gap: 7px; }
.sp-tp-box { flex: none; width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid color-mix(in srgb, var(--tpl) 60%, transparent); }
.sp-tp-box.is-done { background: var(--tpl); border-color: var(--tpl); }
.sp-tp-row.is-bullet::before { content: ''; flex: none; width: 5px; height: 5px; border-radius: 50%; background: color-mix(in srgb, var(--tpl) 60%, transparent); }
.sp-tp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; height: 100%; }
.sp-tp-days > span { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-height: 0; }
.sp-tp-days i { width: 100%; border-radius: 3px; background: color-mix(in srgb, var(--tpl) 38%, transparent); }
.sp-tp-days em { font: 600 8px/1 var(--k-sans); font-style: normal; color: color-mix(in srgb, var(--tpl) 75%, var(--k-ink-3)); }
.sp-tp-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; height: 100%; }
.sp-tp-cols > span { display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: 6px; background: color-mix(in srgb, var(--tpl) 12%, transparent); }
.sp-tp-cols i, .sp-tp-card { border-radius: 4px; background: var(--k-surface); box-shadow: 0 0 0 1px color-mix(in srgb, var(--tpl) 22%, transparent); }
.sp-tp-cols i { height: 11px; }
.sp-tp-card { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; padding: 7px 8px; border-radius: 7px; }
.sp-tpl-name { display: flex; align-items: center; gap: 8px; padding: 0 9px; }
/* On a phone the drawing is hidden and this line icon stands in for it. */
.sp-tpl-ico { display: none; flex: none; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: color-mix(in srgb, var(--tpl) 14%, transparent); color: var(--tpl); }
.sp-tpl-ico svg { width: 14px; height: 14px; }
.sp-tpl b { font-size: 14.5px; font-weight: 600; }
.sp-tpl small { margin-top: 5px; padding: 0 9px; font-size: 12.5px; line-height: 1.35; color: var(--k-ink-3); }

/* Tabs and search. */
.sp-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.sp-tabs { display: flex; gap: 4px; }
.sp-tab { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: none; color: var(--k-ink-2); font: 500 14.5px var(--k-sans); cursor: pointer; transition: background .2s ease, color .2s ease; }
.sp-tab:hover { background: var(--k-hover); color: var(--k-ink); }
.sp-tab.is-on { background: var(--k-ink); color: var(--k-paper); }
.sp-tab i { font-style: normal; font-size: 12px; font-weight: 600; opacity: .6; }
.sp-search { display: flex; align-items: center; gap: 8px; height: 40px; width: min(320px, 100%); padding: 0 14px; border-radius: 999px; background: var(--k-surface); border: 1px solid var(--k-line); color: var(--k-ink-3); transition: border-color .2s ease, box-shadow .2s ease; }
.sp-search:focus-within { border-color: var(--k-blue); box-shadow: 0 0 0 3px rgba(10, 132, 255, .14); }
.sp-search svg { width: 16px; height: 16px; }
/* study-themes.css dresses every light-theme field as a grey pill with an orange
   focus ring, which would draw a second box inside this one. The pill around it
   is the field. */
#view-deeptutor .sp-search input,
#view-deeptutor .sp-search input:focus { flex: 1; min-width: 0; height: auto; padding: 0; border: 0 !important; border-radius: 0 !important; background: none !important; box-shadow: none !important; outline: 0 !important; color: var(--k-ink) !important; font: 15px var(--k-sans) !important; }

/* The list. A hairline between rows, inset to the icon, that steps aside for a hover. */
.sp-listhead { display: flex; justify-content: space-between; padding: 0 0 8px 64px; border-bottom: 1px solid var(--k-line); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--k-ink-3); }
.sp-listhead span:last-child { margin-right: 84px; }
.sp-list { list-style: none; margin: 4px 0 0; padding: 0; }
.sp-row { position: relative; display: flex; align-items: center; gap: 4px; border-radius: 14px; transition: background .15s ease; }
.sp-row + .sp-row::before { content: ''; position: absolute; top: 0; left: 14px; right: 14px; height: 1px; background: var(--k-line); transition: opacity .15s ease; }
.sp-row:hover, .sp-row:focus-within { background: var(--k-hover); }
.sp-row:hover::before, .sp-row:focus-within::before, .sp-row:hover + .sp-row::before, .sp-row:focus-within + .sp-row::before { opacity: 0; }
.sp-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 12px 8px 12px 14px; border-radius: 14px; cursor: pointer; outline: 0; }
.sp-row-main:focus-visible { box-shadow: 0 0 0 3px rgba(10, 132, 255, .25); }
.sp-ico { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--k-hover); font-size: 20px; line-height: 1; }
.sp-row:hover .sp-ico { background: color-mix(in srgb, var(--k-ink) 8%, transparent); }
.sp-ico.is-blank { color: var(--k-ink-3); }
.sp-ico svg { width: 18px; height: 18px; }
.sp-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sp-row-title { font-size: 15.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-row-title.is-untitled { color: var(--k-ink-3); font-weight: 500; }
.sp-row-snip { font-size: 13.5px; color: var(--k-ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-row-when { flex: none; width: 110px; text-align: right; font-size: 13.5px; color: var(--k-ink-3); }
.sp-row-star, .sp-row-more { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--k-ink-2); cursor: pointer; opacity: 0; transition: opacity .15s ease, background .15s ease, color .15s ease; }
.sp-row-star svg, .sp-row-more svg { width: 16px; height: 16px; }
.sp-row:hover .sp-row-star, .sp-row:hover .sp-row-more, .sp-row:focus-within .sp-row-star, .sp-row:focus-within .sp-row-more, .sp-row-star.is-on { opacity: 1; }
.sp-row-star:hover, .sp-row-more:hover { background: var(--k-hover); color: var(--k-ink); }
.sp-row-star.is-on { color: #e0a82e; }
.sp-row-star.is-on svg { fill: currentColor; }
#view-deeptutor .sp-rename, #view-deeptutor .sp-rename:focus { width: 100%; height: 30px; padding: 0 8px; margin: -5px 0; border: 1px solid var(--k-blue) !important; border-radius: 8px !important; background: var(--k-surface) !important; box-shadow: 0 0 0 3px rgba(10, 132, 255, .14) !important; outline: 0 !important; color: var(--k-ink) !important; font: 600 15.5px var(--k-sans) !important; }
.sp-note { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px 0; text-align: center; color: var(--k-ink-3); font-size: 15px; }
.sp-note b { color: var(--k-ink); font-weight: 600; font-size: 16px; }

/* Pages inside pages: a caret on a page that has some, its pages indented under
   it once opened, and in a flat list (a search, Favorites) where a page lives. */
.sp-row { margin-left: calc(var(--depth, 0) * 28px); }
.sp-row-caret { flex: none; width: 24px; height: 24px; margin: 0 -8px 0 4px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; color: var(--k-ink-3); cursor: pointer; transition: background .15s ease, color .15s ease; }
.sp-row-caret svg { width: 16px; height: 16px; transition: transform .2s var(--k-ease); }
.sp-row-caret.is-open svg { transform: rotate(90deg); }
button.sp-row-caret:hover { background: color-mix(in srgb, var(--k-ink) 8%, transparent); color: var(--k-ink); }
.sp-home.is-nested .sp-listhead { padding-left: 88px; }
.sp-row-in { color: var(--k-ink-2); font-weight: 500; }

/* First visit: the page, drawn small. */
.sp-first { display: none; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 40px; align-items: center; margin-bottom: 36px; padding: 44px 48px; border-radius: 30px; background: var(--k-surface); border: 1px solid var(--k-line); box-shadow: var(--k-shadow); overflow: hidden; }
.sp-home.is-first .sp-first { display: grid; }
.sp-home.is-first .sp-tools, .sp-home.is-first .sp-listhead, .sp-home.is-first .sp-list, .sp-home.is-first .sp-note { display: none; }
.sp-first h2 { margin: 0; font-family: var(--k-display); font-weight: 500; font-size: clamp(32px, 3vw, 44px); line-height: 1.02; letter-spacing: -.025em; }
.sp-first-points { list-style: none; margin: 22px 0 26px; padding: 0; display: grid; gap: 11px; }
.sp-first-points li { display: flex; align-items: center; gap: 12px; font-size: 15.5px; color: var(--k-ink-2); }
.sp-first-points svg { width: 30px; height: 30px; padding: 7px; border-radius: 10px; background: var(--k-hover); color: var(--k-ink); }
.sp-first-cta { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; }
.sp-first-art { display: flex; justify-content: center; }
.sp-mock { width: min(300px, 100%); padding: 22px 22px 14px; border-radius: 18px; background: var(--k-paper); border: 1px solid var(--k-line); box-shadow: 0 2px 4px rgba(0, 0, 0, .04), 0 24px 60px rgba(17, 17, 20, .12); transform: rotate(-2deg); animation: sp-float 7s ease-in-out infinite; }
.sp-mock-ico { font-size: 34px; line-height: 1; }
.sp-mock-title { margin: 10px 0 16px; font-family: var(--k-display); font-weight: 500; font-size: 30px; line-height: 1; letter-spacing: -.02em; }
.sp-mock-h { display: block; width: 38%; height: 9px; margin-bottom: 14px; border-radius: 5px; background: color-mix(in srgb, var(--k-ink) 78%, transparent); }
.sp-mock-todo { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sp-mock-todo span { flex: none; width: 17px; height: 17px; border-radius: 5px; border: 1.6px solid color-mix(in srgb, var(--k-ink) 36%, transparent); background: var(--k-surface); }
.sp-mock-todo i { flex: 1; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--k-ink) 12%, transparent); }
.sp-mock-todo:nth-of-type(odd) i { max-width: 82%; }
.sp-mock-todo.is-done span { background: var(--k-ink); border-color: var(--k-ink); }
.sp-mock-todo.is-done span::after { content: ''; display: block; width: 4px; height: 8px; margin: 1.5px 0 0 5.5px; border: solid var(--k-paper); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.sp-mock-todo.is-done i { background: color-mix(in srgb, var(--k-ink) 7%, transparent); }
@keyframes sp-float { 50% { transform: rotate(-1deg) translateY(-6px); } }

@media (max-width: 1100px) {
    .sp-tpl-row { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .sp-first { grid-template-columns: 1fr; padding: 32px; }
    .sp-first-art { display: none; }
}
@media (max-width: 720px) {
    .sp-home-head, .sp-tools { flex-direction: column; align-items: stretch; }
    .sp-split { align-self: flex-start; }
    .sp-row-snip, .sp-listhead { display: none; }
    .sp-row-when { width: auto; }
    .sp-row-star, .sp-row-more { opacity: 1; }
}

/* ── Floating things: menus, the icon picker, "/" menu, selection bar ──── */
/* One layer on <body>. It is an id so the app's !important field rules lose. */
#spLayer { position: fixed; inset: 0; z-index: 10060; pointer-events: none; font-family: var(--k-sans); color: var(--k-ink); -webkit-font-smoothing: antialiased; }
#spLayer > * { pointer-events: auto; }
#spLayer .sp-pop { position: fixed; }
#spLayer .sp-menu, #spLayer .sp-emoji, #spLayer .sp-imgcard, #spLayer .sp-slash { border-radius: 14px; background: var(--k-surface); border: 1px solid var(--k-line); box-shadow: var(--k-shadow); }
#spLayer .sp-menu, #spLayer .sp-emoji, #spLayer .sp-imgcard { animation: k-rise .22s var(--k-ease) both; }

#spLayer .sp-menu { min-width: 220px; padding: 6px; outline: 0; }
#spLayer .sp-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: var(--k-ink); font: 500 14px var(--k-sans); text-align: left; cursor: pointer; }
#spLayer .sp-menu-item:hover, #spLayer .sp-menu-item:focus-visible { background: var(--k-hover); outline: 0; }
#spLayer .sp-menu-item svg { width: 16px; height: 16px; color: var(--k-ink-2); }
#spLayer .sp-menu-item.is-danger, #spLayer .sp-menu-item.is-danger svg { color: var(--k-bad); }
#spLayer .sp-menu-emoji { flex: none; width: 16px; text-align: center; font-size: 15px; line-height: 1; }
#spLayer .sp-menu-label { padding: 8px 10px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--k-ink-3); }
#spLayer .sp-menu-sep { height: 1px; margin: 6px 4px; background: var(--k-line); }

#spLayer .sp-emoji { width: 328px; padding: 10px; }
#spLayer .sp-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
#spLayer .sp-emoji-btn { aspect-ratio: 1; display: grid; place-items: center; border: 0; border-radius: 9px; background: none; font-size: 22px; line-height: 1; cursor: pointer; transition: background .12s ease, transform .12s ease; }
#spLayer .sp-emoji-btn:hover, #spLayer .sp-emoji-btn:focus-visible { background: var(--k-hover); transform: scale(1.12); outline: 0; }
#spLayer .sp-emoji-btn.is-on { background: color-mix(in srgb, var(--k-blue) 14%, transparent); }
#spLayer .sp-emoji-remove { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 8px; padding: 9px 10px; border: 0; border-top: 1px solid var(--k-line); border-radius: 0 0 9px 9px; background: none; color: var(--k-ink-2); font: 500 13.5px var(--k-sans); cursor: pointer; }
#spLayer .sp-emoji-remove:hover { color: var(--k-ink); }
#spLayer .sp-emoji-remove svg { width: 15px; height: 15px; }

/* The "/" menu. */
#spLayer .sp-slash { position: fixed; width: 288px; max-height: 340px; overflow-y: auto; padding: 6px; animation: k-rise .18s var(--k-ease) both; }
#spLayer .sp-slash-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 7px 8px; border: 0; border-radius: 10px; background: none; color: var(--k-ink); text-align: left; cursor: pointer; }
#spLayer .sp-slash-item.is-active { background: var(--k-hover); }
#spLayer .sp-slash-ico { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: var(--k-paper); border: 1px solid var(--k-line); color: var(--k-ink-2); }
#spLayer .sp-slash-ico svg { width: 18px; height: 18px; }
#spLayer .sp-slash-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#spLayer .sp-slash-text b { font-size: 14.5px; font-weight: 600; }
#spLayer .sp-slash-text small { font-size: 12.5px; color: var(--k-ink-3); }
#spLayer .sp-slash-empty { padding: 14px 12px; font-size: 14px; color: var(--k-ink-3); }

/* The bar over selected text: ink on paper, flipping in dark mode. */
#spLayer .sp-bubble { position: fixed; display: flex; align-items: center; padding: 4px; border-radius: 12px; background: var(--k-ink); color: var(--k-paper); box-shadow: 0 8px 28px rgba(0, 0, 0, .22); animation: k-rise .16s var(--k-ease) both; }
#spLayer .sp-bubble-main { display: flex; align-items: center; gap: 2px; }
#spLayer .sp-bubble-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: inherit; cursor: pointer; transition: background .12s ease; }
#spLayer .sp-bubble-btn svg { width: 16px; height: 16px; }
#spLayer .sp-bubble-btn:hover { background: color-mix(in srgb, var(--k-paper) 16%, transparent); }
#spLayer .sp-bubble-btn.is-on { background: color-mix(in srgb, var(--k-paper) 26%, transparent); }
#spLayer .sp-bubble-sep { width: 1px; height: 18px; margin: 0 4px; background: color-mix(in srgb, var(--k-paper) 28%, transparent); }
/* Ask Khio: the chat beside the page, with the selected words attached. */
#spLayer .sp-bubble-ask { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 9px; border: 0; border-radius: 8px; background: none; color: inherit; font: 600 13.5px var(--k-sans); white-space: nowrap; cursor: pointer; transition: background .12s ease; }
#spLayer .sp-bubble-ask svg { width: 15px; height: 15px; }
#spLayer .sp-bubble-ask:hover { background: color-mix(in srgb, var(--k-paper) 16%, transparent); }
#spLayer .sp-bubble-link { display: none; align-items: center; gap: 4px; }
#spLayer .sp-bubble.is-link .sp-bubble-main { display: none; }
#spLayer .sp-bubble.is-link .sp-bubble-link { display: flex; }
#spLayer .sp-bubble-link input { width: 230px; height: 32px; padding: 0 10px; border: 0 !important; border-radius: 8px !important; background: color-mix(in srgb, var(--k-paper) 14%, transparent) !important; box-shadow: none !important; outline: 0 !important; color: var(--k-paper) !important; font: 14px var(--k-sans) !important; }
#spLayer .sp-bubble-link input::placeholder { color: color-mix(in srgb, var(--k-paper) 55%, transparent) !important; }
#spLayer .sp-bubble-apply { height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--k-paper); color: var(--k-ink); font: 600 13.5px var(--k-sans); cursor: pointer; }
#spLayer .sp-bubble-unlink { display: none; width: 32px; height: 32px; place-items: center; border: 0; border-radius: 8px; background: none; color: inherit; cursor: pointer; }
#spLayer .sp-bubble-unlink svg { width: 16px; height: 16px; }
#spLayer .sp-bubble.has-link .sp-bubble-unlink { display: grid; }

/* Image: upload or a link. */
#spLayer .sp-imgcard { width: 300px; padding: 12px; }
#spLayer .sp-imgcard-up { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 40px; border: 1px dashed color-mix(in srgb, var(--k-ink) 28%, transparent); border-radius: 11px; background: none; color: var(--k-ink); font: 500 14px var(--k-sans); cursor: pointer; }
#spLayer .sp-imgcard-up:hover { border-color: var(--k-blue); background: color-mix(in srgb, var(--k-blue) 6%, transparent); }
#spLayer .sp-imgcard-up svg { width: 16px; height: 16px; }
#spLayer .sp-imgcard-or { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 12px; color: var(--k-ink-3); }
#spLayer .sp-imgcard-or::before, #spLayer .sp-imgcard-or::after { content: ''; flex: 1; height: 1px; background: var(--k-line); }
#spLayer .sp-imgcard-link { display: flex; gap: 6px; }
#spLayer .sp-imgcard-link input { flex: 1; min-width: 0; height: 36px; padding: 0 11px; border: 1px solid var(--k-line) !important; border-radius: 10px !important; background: var(--k-paper) !important; box-shadow: none !important; outline: 0 !important; color: var(--k-ink) !important; font: 14px var(--k-sans) !important; }
#spLayer .sp-imgcard-link input:focus { border-color: var(--k-blue) !important; box-shadow: 0 0 0 3px rgba(10, 132, 255, .14) !important; }
#spLayer .sp-imgcard-add { height: 36px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--k-ink); color: var(--k-paper); font: 600 13.5px var(--k-sans); cursor: pointer; }

/* Find a page: "Link to page" and "Move to". */
#spLayer .sp-picker { width: 340px; padding: 8px; border-radius: 14px; background: var(--k-surface); border: 1px solid var(--k-line); box-shadow: var(--k-shadow); animation: k-rise .2s var(--k-ease) both; }
#spLayer .sp-picker-label { padding: 2px 6px 8px; font-size: 13px; font-weight: 500; color: var(--k-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#spLayer .sp-picker-find { display: flex; align-items: center; gap: 8px; height: 38px; margin-bottom: 6px; padding: 0 11px; border-radius: 10px; background: var(--k-hover); color: var(--k-ink-3); }
#spLayer .sp-picker-find svg { width: 15px; height: 15px; }
#spLayer .sp-picker-find input { flex: 1; min-width: 0; height: auto; padding: 0; border: 0 !important; border-radius: 0 !important; background: none !important; box-shadow: none !important; outline: 0 !important; color: var(--k-ink) !important; font: 14.5px var(--k-sans) !important; }
#spLayer .sp-picker-list { max-height: 300px; overflow-y: auto; }
#spLayer .sp-picker-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: 9px; background: none; color: var(--k-ink); text-align: left; cursor: pointer; }
#spLayer .sp-picker-item:hover, #spLayer .sp-picker-item.is-active { background: var(--k-hover); }
#spLayer .sp-picker-ico { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--k-paper); border: 1px solid var(--k-line); color: var(--k-ink-2); font-size: 16px; line-height: 1; }
#spLayer .sp-picker-ico svg { width: 16px; height: 16px; }
#spLayer .sp-picker-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#spLayer .sp-picker-text b, #spLayer .sp-picker-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#spLayer .sp-picker-text b { font-size: 14px; font-weight: 600; }
#spLayer .sp-picker-text small { font-size: 12px; color: var(--k-ink-3); }
#spLayer .sp-picker-empty { padding: 14px 10px; font-size: 14px; color: var(--k-ink-3); }

/* ── A page ───────────────────────────────────────────────────────────── */
.sp-shell { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; background: var(--k-paper); color: var(--k-ink); font-family: var(--k-sans); -webkit-font-smoothing: antialiased; }

.sp-bar { flex: none; position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 54px; padding: 0 16px; border-bottom: 1px solid var(--k-line);
    background: color-mix(in srgb, var(--k-paper) 88%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5); }
.sp-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14.5px; }
.sp-crumb-back { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px 0 8px; border: 0; border-radius: 10px; background: none; color: var(--k-ink-2); font: 500 14.5px var(--k-sans); cursor: pointer; }
.sp-crumb-back:hover { background: var(--k-hover); color: var(--k-ink); }
.sp-crumb-back svg { width: 17px; height: 17px; }
.sp-crumb-sep { color: var(--k-ink-3); }
.sp-crumb-page { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 500; }
.sp-crumb-ico { flex: none; font-size: 16px; line-height: 1; }
.sp-crumb-ico:empty { display: none; }
.sp-crumb-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The pages above this one, between "Space" and the page. */
.sp-trail { display: contents; }
.sp-crumb { flex: 0 1 auto; min-width: 0; max-width: 200px; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--k-ink-2); font: 500 14.5px var(--k-sans); cursor: pointer; }
.sp-crumb:hover { background: var(--k-hover); color: var(--k-ink); }
.sp-crumb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-bar-right { flex: none; display: flex; align-items: center; gap: 6px; }
.sp-saved { min-width: 56px; padding-right: 6px; text-align: right; font-size: 13px; color: var(--k-ink-3); }
.sp-bar-btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border: 0; border-radius: 10px; background: none; color: var(--k-ink-2); font: 500 14px var(--k-sans); cursor: pointer; }
.sp-bar-btn:hover { background: var(--k-hover); color: var(--k-ink); }
.sp-bar-btn.is-icon { width: 34px; padding: 0; justify-content: center; }
.sp-bar-btn svg { width: 16px; height: 16px; }
.sp-bar-count { opacity: .7; }

/* The page scrolls; the AI bar and the Sources panel float over it. */
.sp-scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; container: sp / inline-size; background: var(--k-paper); scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--k-ink) 22%, transparent) transparent; }
.sp-doc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 720px) minmax(0, 1fr); min-height: 100%; padding: 0 24px; animation: k-rise .5s var(--k-ease) both; }
.sp-col { grid-column: 2; min-width: 0; padding: 64px 0 240px; }

.sp-head { margin-bottom: 14px; }
.sp-icon-btn { display: flex; align-items: center; height: 84px; margin: 0 0 2px -8px; padding: 0 8px; border: 0; border-radius: 16px; background: none; color: var(--k-ink-3); cursor: pointer; transition: background .15s ease; }
.sp-icon-btn:hover { background: var(--k-hover); }
.sp-icon-glyph { font-size: 60px; line-height: 1; }
.sp-icon-glyph:empty { display: none; }
.sp-icon-add { display: none; align-items: center; gap: 7px; font: 500 14px var(--k-sans); opacity: 0; transition: opacity .15s ease; }
.sp-icon-add svg { width: 16px; height: 16px; }
.sp-icon-btn:not(.has-icon) { height: 34px; margin-bottom: 8px; border-radius: 10px; }
.sp-icon-btn:not(.has-icon) .sp-icon-add { display: inline-flex; }
.sp-head:hover .sp-icon-add, .sp-icon-btn:focus-visible .sp-icon-add { opacity: 1; }
.sp-icon-btn:focus-visible { outline: 2px solid var(--k-blue); outline-offset: 2px; }

/* The title is a field; the global field rules need an id to lose to. */
#view-deeptutor .sp-title, #view-deeptutor .sp-title:hover, #view-deeptutor .sp-title:focus { display: block; width: 100%; margin: 0; padding: 4px 0; border: 0 !important; border-radius: 0 !important; background: none !important; box-shadow: none !important; outline: 0 !important; resize: none; overflow: hidden;
    color: var(--k-ink) !important; font-family: var(--k-display) !important; font-weight: 500 !important; font-size: clamp(38px, 3.6vw, 48px) !important; line-height: 1.08; letter-spacing: -.025em; }
#view-deeptutor .sp-title::placeholder { color: var(--k-ink-3) !important; opacity: 1; }
.sp-origin { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; color: var(--k-ink-3); font: 500 13.5px/1.3 var(--k-sans); }
.sp-origin svg { width: 15px; height: 15px; }

/* The editor: Quill's snow stylesheet is the base, restyled to the page.
   study-notes.css restyles EVERY .ql-editor with !important (padding, headings,
   lists, links, quotes) for the notes view, so what differs here carries !important
   too and wins on the id. */
#view-deeptutor .sp-editor { margin-top: 6px; }
#view-deeptutor .sp-editor .ql-container.ql-snow { border: 0; height: auto; background: none; font-family: var(--k-sans); font-size: 17px; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) { min-height: 45vh; padding: 0 !important; overflow: visible; color: var(--k-ink); font-size: 17px !important; line-height: 1.7 !important; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) > * { margin: 0 0 .5em !important; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) > :first-child { margin-top: 0 !important; }
#view-deeptutor .sp-editor .ql-editor.ql-blank::before { left: 0; right: 0; color: var(--k-ink-3); font-style: normal; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) h1 { margin: 1.5em 0 .3em !important; font: 500 36px/1.12 var(--k-display) !important; letter-spacing: -.02em !important; scroll-margin-top: 24px; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) h1:not([class*="ql-align"]) { text-align: left !important; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) h2 { margin: 1.4em 0 .3em !important; font: 500 28px/1.16 var(--k-display) !important; letter-spacing: -.015em !important; scroll-margin-top: 24px; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) h3 { margin: 1.2em 0 .2em !important; font: 600 19px/1.3 var(--k-sans) !important; letter-spacing: 0 !important; scroll-margin-top: 24px; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) > :first-child:is(h1, h2, h3) { margin-top: 0 !important; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) strong { color: inherit !important; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) a { color: var(--k-blue) !important; text-decoration: underline !important; text-decoration-thickness: 1px !important; text-underline-offset: 3px !important; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) blockquote { margin: .6em 0 !important; padding: 2px 0 2px 18px !important; border: 0 !important; border-left: 3px solid color-mix(in srgb, var(--k-ink) 22%, transparent) !important; border-radius: 0 !important; background: none !important; color: var(--k-ink-2); font-family: var(--k-display); font-size: 21px; line-height: 1.45; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) code { padding: 2px 5px; border-radius: 6px; background: var(--k-hover); color: var(--k-ink); font: .88em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) pre, #view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) pre.ql-syntax { margin: .6em 0; padding: 14px 16px; border: 1px solid var(--k-line); border-radius: 12px; background: var(--k-hover); color: var(--k-ink); font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) hr { height: 0; margin: 1.6em 0 !important; border: 0 !important; border-top: 1px solid var(--k-line) !important; }
/* Photos never stand taller than most of the screen. One inside a list item (a
   trip stop's photo) stays small, so a day of them still reads as a list.
   object-fit keeps an image that carries its own width from being squashed. */
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) img { display: block; max-width: 100%; max-height: min(80vh, 720px); height: auto; object-fit: contain; margin: 8px 0; border: 0; border-radius: 12px; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) :is(li, .sp-li) img { max-height: 260px; }
#view-deeptutor .sp-editor .ql-editor ul, #view-deeptutor .sp-editor .ql-editor ol { padding-left: 0 !important; }
#view-deeptutor .sp-editor .ql-editor li { margin: 0 !important; line-height: inherit !important; }
#view-deeptutor .sp-editor .ql-editor li::before { color: var(--k-ink-3); }

/* Checklists: a real box, ticked with a click. Quill toggles on the box (its
   ::before); the pointer rules below are Quill's own and must stay. */
#view-deeptutor .sp-editor .ql-editor ul[data-checked] > li { --ind: 0; position: relative; padding-left: calc(32px + var(--ind) * 3em); }
#view-deeptutor .sp-editor .ql-editor ul[data-checked] > li.ql-indent-1 { --ind: 1; }
#view-deeptutor .sp-editor .ql-editor ul[data-checked] > li.ql-indent-2 { --ind: 2; }
#view-deeptutor .sp-editor .ql-editor ul[data-checked] > li.ql-indent-3 { --ind: 3; }
#view-deeptutor .sp-editor .ql-editor ul[data-checked] > li.ql-indent-4 { --ind: 4; }
#view-deeptutor .sp-editor .ql-editor ul[data-checked] + ul[data-checked] { margin-top: -.5em !important; }
#view-deeptutor .sp-editor .ql-editor ul[data-checked] > li::before { content: '' !important; position: absolute; left: calc(2px + var(--ind) * 3em); top: calc((1.7em - 19px) / 2); width: 19px; height: 19px; margin: 0; padding: 0; border-radius: 6px;
    border: 1.6px solid color-mix(in srgb, var(--k-ink) 38%, transparent); background: var(--k-surface); cursor: pointer; pointer-events: all; transition: background .15s ease, border-color .15s ease; }
#view-deeptutor .sp-editor .ql-editor ul[data-checked="false"] > li:hover::before { border-color: color-mix(in srgb, var(--k-ink) 62%, transparent); }
#view-deeptutor .sp-editor .ql-editor ul[data-checked="true"] > li::before { background: var(--k-ink); border-color: var(--k-ink); }
#view-deeptutor .sp-editor .ql-editor ul[data-checked="true"] > li::after { content: ''; position: absolute; left: calc(9px + var(--ind) * 3em); top: calc((1.7em - 19px) / 2 + 3px); width: 5px; height: 9px; border: solid var(--k-paper); border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
#view-deeptutor .sp-editor .ql-editor ul[data-checked="true"] > li { color: var(--k-ink-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--k-ink) 30%, transparent); }

/* A link to another page: the page's icon (a page glyph when it has none) and
   its name, on a line of its own. */
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) .sp-pagelink { display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; margin: 0 0 .5em -8px !important; padding: 2px 10px 2px 8px; border-radius: 9px; color: var(--k-ink); font-weight: 500; cursor: pointer; transition: background .15s ease; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) .sp-pagelink:hover { background: var(--k-hover); }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) .sp-pagelink:not(:has(.sp-pagelink-ico))::before { content: ''; flex: none; width: 19px; height: 19px; background: currentColor; opacity: .5;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z'/%3E%3Cpath d='M14 2v4a2 2 0 0 0 2 2h4M10 9H8M16 13H8M16 17H8'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z'/%3E%3Cpath d='M14 2v4a2 2 0 0 0 2 2h4M10 9H8M16 13H8M16 17H8'/%3E%3C/svg%3E") center / contain no-repeat; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) .sp-pagelink-ico { flex: none; font-size: 18px; line-height: 1; }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) .sp-pagelink-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: color-mix(in srgb, var(--k-ink) 24%, transparent); }
#view-deeptutor .sp-editor :is(.ql-editor, .sp-pm) .sp-pagelink.is-missing { color: var(--k-ink-3); }

/* The pages inside this one, at the end of the page. */
.sp-kids { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--k-line); }
.sp-kids-list { list-style: none; margin: 0 0 8px; padding: 0; }
.sp-kid { display: flex; align-items: center; gap: 12px; width: calc(100% + 20px); margin-left: -10px; padding: 8px 10px; border: 0; border-radius: 12px; background: none; color: var(--k-ink); text-align: left; cursor: pointer; transition: background .15s ease; }
.sp-kid:hover { background: var(--k-hover); }
.sp-kid-ico { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--k-hover); font-size: 18px; line-height: 1; }
.sp-kid-ico.is-blank { color: var(--k-ink-3); }
.sp-kid-ico svg { width: 16px; height: 16px; }
.sp-kid-title { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-kid-title.is-untitled { color: var(--k-ink-3); font-weight: 500; }
.sp-kid-inside, .sp-kid-when { flex: none; font-size: 13px; color: var(--k-ink-3); }
.sp-kid-when { min-width: 84px; text-align: right; }
.sp-kids-add svg { width: 15px; height: 15px; }

/* The outline: a dash per heading in the left margin, the headings by name on hover.
   It sits 40px from the text so the block handles (study-page-blocks.css) have the
   strip next to the text to themselves. */
.sp-outline { grid-column: 1; justify-self: end; align-self: start; position: sticky; top: 132px; margin-right: 40px; }
.sp-ol-bars { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; padding: 8px 10px; transition: opacity .15s ease; }
.sp-ol-bar { display: block; height: 2px; border-radius: 2px; background: color-mix(in srgb, var(--k-ink) 22%, transparent); transition: background .2s ease; }
.sp-ol-bar.l1 { width: 22px; }
.sp-ol-bar.l2 { width: 16px; }
.sp-ol-bar.l3 { width: 10px; }
.sp-ol-bar.is-on { background: var(--k-ink); }
.sp-ol-card { display: none; position: absolute; top: 0; right: 0; width: 196px; padding: 6px; border-radius: 14px; background: var(--k-surface); border: 1px solid var(--k-line); box-shadow: var(--k-shadow); }
.sp-outline:hover .sp-ol-card, .sp-outline:focus-within .sp-ol-card { display: block; }
.sp-outline:hover .sp-ol-bars, .sp-outline:focus-within .sp-ol-bars { opacity: 0; }
.sp-ol-item { display: block; width: 100%; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--k-ink-2); font: 500 13.5px var(--k-sans); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.sp-ol-item.l2 { padding-left: 20px; }
.sp-ol-item.l3 { padding-left: 30px; }
.sp-ol-item:hover, .sp-ol-item.is-on { background: var(--k-hover); color: var(--k-ink); }
@container sp (max-width: 1040px) { .sp-outline { display: none; } }

/* Keyboard focus: one blue ring on every control here (the browser's own is orange on this page). */
.sp-tab:focus-visible, .sp-link:focus-visible, .sp-row-star:focus-visible, .sp-row-more:focus-visible, .sp-crumb-back:focus-visible, .sp-bar-btn:focus-visible, .sp-ol-item:focus-visible,
.sp-row-caret:focus-visible, .sp-crumb:focus-visible, .sp-kid:focus-visible, #spLayer .sp-picker-item:focus-visible,
#spLayer .sp-bubble-btn:focus-visible, #spLayer .sp-bubble-ask:focus-visible, #spLayer .sp-bubble-apply:focus-visible, #spLayer .sp-bubble-unlink:focus-visible, #spLayer .sp-imgcard-up:focus-visible, #spLayer .sp-imgcard-add:focus-visible, #spLayer .sp-emoji-remove:focus-visible { outline: 2px solid var(--k-blue); outline-offset: 2px; }

@media (max-width: 1023px) {
    .sp-col { padding-top: 36px; }
    .sp-bar-btn span:not(.sp-bar-count) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .sp-home-in, .sp-doc, #spLayer .sp-menu, #spLayer .sp-emoji, #spLayer .sp-imgcard, #spLayer .sp-slash, #spLayer .sp-bubble, #spLayer .sp-picker, .sp-mock { animation: none; }
}
/* Concurrent saves: recovery actions stay above the page's title. */
.sp-save-conflict { margin: 0 0 24px; padding: 14px 16px; border: 1px solid #c7a36a; border-radius: 8px; background: #fff8eb; color: #574323; font-size: 14px; }
.sp-save-conflict[hidden] { display: none; }
.sp-save-conflict p { margin: 0 0 10px; }
.sp-save-conflict button { border: 1px solid currentColor; border-radius: 5px; padding: 6px 10px; margin: 0 8px 4px 0; background: transparent; color: inherit; cursor: pointer; }
.sp-save-conflict button:disabled { opacity: .6; cursor: wait; }
