/* Note page as a document (rich.js), page-level loading, jump highlight, the phone half-height chat.
   Uses the theme's colours and easing (theme.css :root), nothing of its own. */

/* ---------- the page ---------- */
.drawer .dr-scroll { cursor: text; }
.dr-blocks.doc { display: block; padding-bottom: 40vh; }   /* room to click below the last line */
.dr-blocks.doc > * + * { margin-top: 6px; }
.dr-blocks.doc > .blk { margin: 12px 0; cursor: default; }
/* pictures sit in the text like in a document: no card, no label; the × shows on hover */
.dr-blocks.doc > .blk:has(> img.pv) { border-color: transparent; padding: 0; box-shadow: none; display: inline-block; max-width: 100%; }
.dr-blocks.doc > .blk:has(> img.pv) > .bk { display: none; }
.dr-blocks.doc > .blk:has(> img.pv) img.pv { max-height: 420px; border-radius: 8px; }
.dr-blocks.doc > .blk:has(> img.pv) .bx { top: 6px; right: 6px; background: rgba(14,23,38,.6); color: #fff; border-radius: 50%; width: 22px; height: 22px; line-height: 20px; padding: 0; }
.dr-blocks.doc > .blk:has(> img.pv):hover img.pv { box-shadow: 0 0 0 2px var(--blue-soft); }
.drawer.docked .dr-scroll { padding: 8px 40px 0; }
.drawer.docked .dr-blocks.doc, .drawer.docked .dr-info, .drawer.docked .rt-bar-in { max-width: 760px; }

.rt { outline: none; font-size: 15px; line-height: 1.75; color: var(--ink); min-height: 1.75em; word-break: break-word; caret-color: var(--blue); }
.rt > :first-child { margin-top: 0; }
.rt p { margin: 0; min-height: 1.75em; }
.rt h1 { font-size: 24px; line-height: 1.4; margin: 18px 0 6px; font-weight: 700; }
.rt h2 { font-size: 20px; line-height: 1.45; margin: 14px 0 4px; font-weight: 700; }
.rt h3 { font-size: 17px; line-height: 1.5; margin: 10px 0 2px; font-weight: 700; }
.rt ul, .rt ol { margin: 2px 0; padding-left: 1.6em; }
.rt li { margin: 1px 0; padding-left: 2px; }
.rt li > ul, .rt li > ol { margin: 0; }
.rt ul[data-ck] { list-style: none; padding-left: 4px; }
.rt ul[data-ck] > li { position: relative; padding-left: 26px; }
.rt ul[data-ck] > li::before { content: ""; position: absolute; left: 2px; top: .42em; width: 14px; height: 14px; border: 1.5px solid #B9C1CC;
                               border-radius: 4px; background: #fff; cursor: pointer; transition: background-color .18s var(--ease), border-color .18s var(--ease); }
.rt ul[data-ck] > li[data-ck="1"]::before { background: var(--blue); border-color: var(--blue);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.2l3 3 6-6.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 12px; background-position: center; background-repeat: no-repeat; }
.rt ul[data-ck] > li[data-ck="1"] { color: var(--pencil); text-decoration: line-through; }
.rt blockquote { margin: 6px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--rule); color: #4B5563; }
.rt code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; padding: 1px 4px; }
.rt pre { background: var(--desk); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; font-size: 13px; }
.rt hr { border: 0; border-top: 1px solid var(--rule); margin: 12px 0; }
.rt [data-in="1"] { padding-left: 2em; } .rt [data-in="2"] { padding-left: 4em; }
.rt [data-in="3"] { padding-left: 6em; } .rt [data-in="4"] { padding-left: 8em; }
.rt mark { border-radius: 3px; padding: 0 1px; color: inherit; }
.rt mark, .rt mark.hl-y { background: #FFF1B8; }
.rt mark.hl-b { background: #DCE6FF; }
.rt mark.hl-g { background: #D5F2E6; }
.rt mark.hl-r { background: #FFE0D9; }
/* the hint lives on the editor (data-ph); the first paragraph shows it, so read it from the parent with a var */
.note-title:empty::before { content: attr(data-ph); color: #B5BDC9; pointer-events: none; }
.rt.blank > p:first-child::before { content: var(--ph, "继续写…"); color: #B5BDC9; pointer-events: none; }
.rt.blank > p:first-child { position: relative; }
.rt.blank > p:first-child::before { position: absolute; left: 0; top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rt.ghost:not(:focus):not(:only-child).blank > p:first-child::before { opacity: 0; transition: opacity .2s; }
.dr-blocks.doc:hover .rt.ghost.blank > p:first-child::before { opacity: 1; }

/* the title of a free note: one line, document-sized, no box */
.note-title { font-size: 26px; line-height: 1.35; font-weight: 700; padding: 10px 0 6px; outline: none; border: 0; min-height: 1.35em;
              word-break: break-word; caret-color: var(--blue); }
.note-title:focus { border: 0; }
.drawer.docked.free .dr-head { border-bottom: 0; padding-bottom: 0; }
.drawer.docked.free .dr-title:empty { display: none; }
.drawer.docked .dr-head { padding-left: 40px; padding-right: 40px; }

/* the toolbar: sticky over the page, quiet until the caret is in the text */
.rt-bar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 6px 16px; border-bottom: 1px solid var(--rule);
          background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); position: relative; z-index: 3; transition: opacity .2s var(--ease); }
.drawer.docked .rt-bar { padding-left: 34px; padding-right: 34px; }
.rt-bar.idle { opacity: .55; }
.rt-bar.idle:hover { opacity: 1; }
.rb { border: 0; background: none; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 6px; cursor: pointer; color: #3C4757; font-size: 14px;
      display: inline-flex; align-items: center; justify-content: center; }
.rb:hover { background: var(--desk); color: var(--ink); }
.rb.on { background: var(--blue-soft); color: var(--blue); }
.rb.b { font-weight: 800; } .rb.i { font-style: italic; font-family: Georgia, serif; } .rb.u { text-decoration: underline; } .rb.s { text-decoration: line-through; }
.rb.li { font-size: 13px; }
.rb-sel { border: 0; background: none; height: 28px; border-radius: 6px; padding: 0 4px; font: inherit; font-size: 13px; color: #3C4757; cursor: pointer; }
.rb-sel:hover { background: var(--desk); }
.rb-sep { width: 1px; height: 16px; background: var(--rule); margin: 0 4px; }
.rb-hl { position: relative; display: inline-flex; }
.rb.hl .hl-a { font-weight: 700; padding: 0 3px; border-radius: 3px; background: linear-gradient(transparent 55%, #FFE58A 55%); }
.rb-menu { position: absolute; top: 32px; left: 0; display: flex; gap: 6px; padding: 8px; background: #fff; border-radius: 10px; z-index: 5;
           box-shadow: 0 0 0 1px var(--rule), 0 10px 28px -10px rgba(14,23,38,.28); animation: popIn .18s var(--ease) both; }
.rb-menu[hidden] { display: none; }
.rb.sw { width: 24px; min-width: 24px; height: 24px; border-radius: 6px; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.rb.sw.hl-y { background: #FFF1B8; } .rb.sw.hl-b { background: #DCE6FF; } .rb.sw.hl-g { background: #D5F2E6; } .rb.sw.hl-r { background: #FFE0D9; }
.rb.sw.none { width: auto; padding: 0 8px; font-size: 12px; color: var(--pencil); background: #fff; }
.rb.sw:hover { transform: scale(1.1); }
/* the schedule's drawer is narrow: the toolbar scrolls sideways instead of wrapping into three rows */
.drawer:not(.docked) .rt-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.drawer:not(.docked) .rt-bar::-webkit-scrollbar { display: none; }

/* a picture / file card that just went in */
.blk.blk-in { animation: blkIn .36s var(--ease) both; }
@keyframes blkIn { from { opacity: 0; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- note list: the one just edited rises to the top ---------- */
.nlist .ni { will-change: auto; }
.nlist .ni.rose { animation: niRose 1.3s var(--ease) both; }
@keyframes niRose { 0% { background: rgba(43,89,255,.16); } 100% { background: transparent; } }
.nlist .ni.on.rose { animation: none; }
.nlist .ni .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nlist > .empty { margin: 18px 8px; line-height: 1.7; font-size: 13px; text-align: left; }
.nlist > .empty .btn { margin-top: 10px; }

/* the 笔记 page before anything is open */
.note-page > .empty, .note-page > .nb-empty { margin: auto; max-width: 360px; text-align: center; color: var(--pencil); line-height: 1.8; font-size: 14px; padding: 40px 24px; }
.nb-empty .ico { width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 14px; background: var(--blue-soft); display: grid; place-items: center; color: var(--blue); font-size: 22px; }
.nb-empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 16px; }
.nb-empty .btn { margin-top: 16px; }

/* ---------- loading: one look everywhere ---------- */
.ld-bar { position: fixed; z-index: 60; left: 0; top: 0; height: 2px; width: 100%; pointer-events: none; opacity: 0; transform-origin: 0 50%;
          background: linear-gradient(90deg, var(--ai-a), var(--ai-b)); transform: scaleX(0); transition: opacity .25s var(--ease); }
.ld-bar.on { opacity: 1; animation: ldGrow 8s cubic-bezier(.1,.7,.2,1) forwards; }
.ld-bar.done { opacity: 0; transform: scaleX(1); animation: none; transition: transform .2s var(--ease), opacity .35s var(--ease) .15s; }
@keyframes ldGrow { 0% { transform: scaleX(0); } 20% { transform: scaleX(.45); } 100% { transform: scaleX(.92); } }
.skel { display: grid; gap: 12px; padding: 16px 0; }
.skel i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #EEF1F5 0%, #F7F8FA 40%, #EEF1F5 80%); background-size: 300% 100%;
          animation: shimmer 1.3s linear infinite; }
.skel i.h { height: 22px; width: 46%; border-radius: 8px; margin-bottom: 6px; }
.skel i:nth-child(3n) { width: 82%; } .skel i:nth-child(3n+1) { width: 94%; } .skel i:nth-child(4n) { width: 64%; }
.skel.list { padding: 8px; gap: 10px; }
.skel.list i { height: 46px; border-radius: 10px; width: 100% !important; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -50% 0; } }
.boot { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--desk); transition: opacity .3s var(--ease), visibility 0s linear .3s; }
.boot.gone { opacity: 0; visibility: hidden; }
.boot .brand { font-size: 26px; display: flex; align-items: center; gap: 12px; }
.boot .dots { display: flex; gap: 5px; justify-content: center; margin-top: 14px; }
.boot .dots i { width: 6px; height: 6px; border-radius: 50%; background: linear-gradient(180deg, var(--ai-a), var(--ai-b)); animation: dot 1s var(--ease) infinite; }
.boot .dots i:nth-child(2) { animation-delay: .15s; } .boot .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
/* opening a note: the bars only show if it takes a moment; then the content fades in where the bars were */
.dr-blocks > .skel { opacity: 0; transition: opacity .15s var(--ease); }
.dr-scroll.loading-shown .dr-blocks > .skel { opacity: 1; }
.dr-scroll.loading .dr-blocks, .dr-scroll.loading .dr-info .recog { opacity: 0; transition: none; }
.dr-blocks, .dr-info .recog { transition: opacity .22s var(--ease); }

/* ---------- jumping to something: it glows where it landed ---------- */
.hl-flash { animation: hlFlash 1.6s var(--ease) both; border-radius: 8px; }
@keyframes hlFlash {
  0% { box-shadow: 0 0 0 0 rgba(43,89,255,.45); background-color: rgba(43,89,255,.18); }
  25% { box-shadow: 0 0 0 6px rgba(43,89,255,0); background-color: rgba(43,89,255,.16); }
  45% { background-color: rgba(43,89,255,.07); }
  65% { background-color: rgba(43,89,255,.15); }
  100% { box-shadow: none; background-color: transparent; }
}
.view.jump-in { animation: jumpIn .32s var(--ease) both; }
@keyframes jumpIn { from { opacity: .4; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .hl-flash, .view.jump-in, .nlist .ni.rose, .blk.blk-in, .skel i, .boot .dots i, .ld-bar.on { animation: none !important; }
  .hl-flash { background-color: rgba(43,89,255,.12); }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .drawer.docked .dr-scroll { padding: 6px 16px 0; }
  .drawer.docked .dr-head { padding: 14px 16px 6px 64px; min-height: 44px; align-items: center; }   /* room for 返回 */
  .drawer.docked .rt-bar { padding-left: 10px; padding-right: 10px; }
  .rt-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rt-bar::-webkit-scrollbar { display: none; }
  .rb { min-width: 34px; height: 34px; }
  .rt { font-size: 16px; }
  .note-title { font-size: 22px; }

  /* the assistant opens as a half-height sheet over the page; drag the handle up (or tap it) for full height */
  body.chat-open.chat-half .assist { top: auto !important; height: min(58dvh, calc(var(--vvh, 100dvh) - 60px)) !important; bottom: var(--kb, 0px);
    border-radius: 18px 18px 0 0; box-shadow: 0 -16px 40px -12px rgba(14,23,38,.28); padding-top: 0; }
  .chat-scrim { position: fixed; inset: 0; z-index: 29; background: rgba(14,23,38,.24); opacity: 0; visibility: hidden;
                transition: opacity .3s var(--ease), visibility 0s linear .3s; }
  body.chat-open .chat-scrim { opacity: 1; visibility: visible; transition: opacity .3s var(--ease); }
  .m-chat-head { position: relative; }
  .chat-grip { position: absolute; left: 50%; top: 5px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: #D3D9E2; border: 0; padding: 0; cursor: grab; }
  .chat-grip::before { content: ""; position: absolute; inset: -12px -30px; }   /* a bigger target for the thumb */
  body.chat-open:not(.chat-half) .chat-grip { display: none; }
  .m-chat-head .m-expand { border: 0; background: none; color: var(--pencil); font-size: 14px; padding: 4px 8px; margin-left: auto; margin-right: 4px; }
  body.chat-open:not(.chat-half) .m-expand { display: none; }
  body.chat-half .assist.dragging { transition: none !important; }
}
@media (min-width: 761px) { .chat-scrim, .chat-grip, .m-expand { display: none !important; } }
