/* ---------- components/notepad/notepad.css ---------- */
/* ===== notepad ===== */
#npWrap{--lg:32px;position:relative;flex:none;display:flex;align-items:center;order:4}
@media (max-width:420px){#npWrap{--lg:30px}}
#npBtn{position:relative;width:var(--lg,30px);height:var(--lg,30px);padding:0;display:block;border-radius:9px;background:transparent;color:#fff;border:0;perspective:220px;box-shadow:0 1px 2px rgba(0,0,0,.12);transition:box-shadow .15s,transform .1s}
#npBtn .npcard{position:absolute;inset:0;transform-style:preserve-3d}
#npBtn .npf{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;border-radius:9px;backface-visibility:hidden;-webkit-backface-visibility:hidden}
#npBtn .npf1{background:#D4A017;color:#3b2a00}   /* gold fill, dark lines */
#npBtn .npf2{background:var(--err);transform:rotateY(180deg)}   /* the back side: the red count of notes due today or overdue */
#npBtn .npnum{font-size:calc(var(--lg,30px) * .52);font-weight:700;line-height:1}
#npBtn .npnum.many{font-size:calc(var(--lg,30px) * .42)}
#npBtn svg{width:calc(var(--lg,30px) - 10px);height:calc(var(--lg,30px) - 10px);display:block}
#npBtn svg path{stroke-dasharray:1;stroke-dashoffset:0}
@keyframes npDraw{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}
#npBtn:hover svg path,#npBtn:active svg path,#npBtn:focus-visible svg path{animation:npDraw .55s ease-out both}   /* the three lines draw themselves one by one */
#npBtn:hover svg path:nth-child(2),#npBtn:active svg path:nth-child(2),#npBtn:focus-visible svg path:nth-child(2){animation-delay:.12s}
#npBtn:hover svg path:nth-child(3),#npBtn:active svg path:nth-child(3),#npBtn:focus-visible svg path:nth-child(3){animation-delay:.24s}
@keyframes npFlip{0%,38%{transform:rotateY(0)}50%,88%{transform:rotateY(180deg)}100%{transform:rotateY(360deg)}}
#npBtn.due .npcard{animation:npFlip 4s ease-in-out 3}   /* flips icon, number, icon three times when something is due, then rests (the red dot below stays) */
#npBtn.due[aria-expanded="true"] .npcard{animation:none}   /* still while the notepad is open */
@media (prefers-reduced-motion:reduce){#npBtn.due .npcard{animation:none;transform:rotateY(180deg)}#npBtn:hover svg path,#npBtn:active svg path,#npBtn:focus-visible svg path{animation:none}}
#npBtn:hover,#npBtn[aria-expanded="true"]{box-shadow:0 0 0 3px rgba(212,160,23,.30)}
@keyframes npGlow{0%,100%{box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 55%,transparent)}50%{box-shadow:0 0 0 7px color-mix(in srgb,var(--accent) 0%,transparent)}}
#npBtn.glow{animation:npGlow 1.8s ease-out 3}
@media (prefers-reduced-motion:reduce){#npBtn.glow{animation:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 35%,transparent)}}
#npBtn:active{transform:scale(.94)}
#npBtn:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
#npPop{display:none;position:fixed;left:8px;top:60px;width:min(390px,calc(100vw - 16px));max-height:min(85vh,720px);overflow:auto;background:var(--card);border:1px solid var(--line);border-radius:18px;box-shadow:0 18px 40px -12px rgba(0,0,0,.45);padding:12px;z-index:60}
#npPop.on{display:block}
#npPop button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
#npPop .nph{display:flex;align-items:center;gap:8px;min-width:0;padding:0 2px 6px;font-weight:700;font-size:15px}
#npPop .nph .npcr{margin-left:auto;padding:0;gap:6px;flex-wrap:nowrap}
#npPop .nph button.npback{position:relative;flex:none;display:block;box-sizing:border-box;width:28px;height:28px;min-width:0;min-height:0;margin:0;padding:0;border:0;border-radius:50%;background:transparent;box-shadow:none;color:var(--text);-webkit-appearance:none;appearance:none}
#npPop .nph button.npback:hover{background:var(--bg)}
#npPop .nph button.npback::before,#npPop .nph button.npback::after{content:none}
#npPop .npback span{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;transition:transform .35s cubic-bezier(.4,0,.2,1),opacity .25s}
#npPop .npback svg{width:18px;height:18px;display:block}
#npPop .npi2{opacity:0;transform:rotate(-90deg) scale(.5)}
#npPop.editing .npi1{opacity:0;transform:rotate(90deg) scale(.5)}
#npPop.editing .npi2{opacity:1;transform:none}
#npPop .npcr{display:flex;flex-wrap:nowrap;gap:2px;min-width:0;padding:0 2px 6px}
#npPop .npc{display:inline-flex;align-items:center;gap:4px;flex:1 1 auto;min-width:0;padding:3px;white-space:nowrap;color:var(--text);border:0;border-bottom:2px solid transparent;border-radius:0;background:none;font-size:13px;font-weight:500;line-height:1.3}   /* a filter tab: the tag word, its note count, and a line under the chosen one */
#npPop .npl{display:flex;flex-direction:column;gap:0}
#npPop .npe{padding:22px 10px;text-align:center;font-size:13px;color:var(--mute);background:var(--bg);border:1px dashed var(--line);border-radius:12px}
#npPop .npd{flex:none;display:flex;align-items:center;justify-content:flex-start;width:46px;height:auto;border-radius:0;background:none;color:var(--mute);font-size:10.5px;font-weight:700;line-height:1;text-align:left;text-transform:none}   /* a tag is a small coloured word (the colours are below) */
#npPop .npdh{display:flex;align-items:center;justify-content:center;box-sizing:content-box;width:46px;height:20px;padding:4px;margin:-4px;cursor:pointer}
#npPop .npdt{flex:none;padding:2px 9px;border-radius:99px;background:color-mix(in srgb,var(--mute) 14%,transparent);color:var(--mute);font-size:12px;font-weight:600;line-height:1.4;white-space:nowrap}
#npPop .npdt.due{background:color-mix(in srgb,var(--err) 16%,transparent);color:var(--err);font-weight:700}
#npPop .npdw{position:relative;align-self:flex-start;margin:0 8px 8px}
#npPop .npdate{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;border:0;padding:0;margin:0;box-sizing:border-box}
#npPop .npdate::-webkit-calendar-picker-indicator{position:absolute;inset:0;width:100%;height:100%;cursor:pointer}
#npPop .npdb{pointer-events:none;display:flex;align-items:center;justify-content:center;gap:6px;box-sizing:border-box;min-width:var(--npb,25px);height:var(--npb,25px);padding:0 10px;border:1px solid var(--line);border-radius:10px;background:var(--card);color:var(--text);font-size:13px;font-weight:600}
#npPop .npdi svg{display:block}
#npPop .npx{display:flex;flex:none;color:var(--mute);padding:8px;margin:-8px;cursor:pointer}
#npPop .npx svg{width:14px;height:14px;display:block}
#npPop .npx.arm{color:var(--err)}
#npPop .npx.arm svg{width:16px;height:16px}
#npPop .npcs{display:flex;gap:6px;padding:0 12px 10px}
#npPop .nprh{display:flex;align-items:center;gap:10px;width:100%;padding:10px 4px;background:none;color:var(--text);text-align:left;border-radius:0}
#npPop .nprt{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;font-weight:600;font-size:15px;line-height:1.3;overflow-wrap:anywhere}
#npPop .npf{position:relative;display:flex;flex-direction:column;background:var(--bg);border:1px solid var(--accent);border-radius:12px}
#npPop .npfi{display:block;width:100%;min-width:0;box-sizing:border-box;border:1px solid var(--line);background:var(--card);color:var(--text);border-radius:10px;padding:8px 11px;font:inherit;font-size:16px;resize:vertical;transition:border-color .15s,box-shadow .15s}
#npPop .npfi::placeholder{color:var(--mute);opacity:.6}
#npPop .npfi:focus{outline:0;border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 18%,transparent)}
#npPop textarea.npfi{border:0;background:transparent;padding:12px;border-radius:12px;min-height:240px;height:45vh;max-height:60vh}
#npPop textarea.npfi:focus{box-shadow:none}
/* sums typed in a note (answers under the note box) and the Receipt print button */
#npPop .npcalc{margin:0 8px 8px;padding:6px 8px;background:var(--card);border:1px solid var(--line);border-radius:10px;font-size:13px}
#npPop .npcalc[hidden]{display:none}
#npPop .npcl{display:flex;justify-content:space-between;gap:10px;padding:4px 0;border-bottom:1px solid var(--line)}
#npPop .npcx{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--mute)}
#npPop .npca{flex:none;font-weight:700;color:var(--accent);white-space:nowrap}
#npPop .npct{display:flex;justify-content:space-between;gap:10px;margin-top:6px;padding:6px 8px;border-radius:8px;background:color-mix(in srgb,var(--accent) 16%,transparent);color:var(--accent);font-weight:700}
#npPop .npfr{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
#npPop .npprint{flex:none;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:var(--npb,25px);height:var(--npb,25px);margin:0 0 8px;padding:0;border-radius:10px;background:var(--accent);color:#fff;border:1px solid var(--accent)}   /* icon only, next to the date button */
#npPop .npprint[hidden]{display:none}
#npPop .npprint svg{width:14px;height:14px;display:block}
#npPop .npct[hidden]{display:none}
#npPop .npfr .npct{flex:1;min-width:0;box-sizing:border-box;height:var(--npb,25px);margin:0 8px 8px 4px;padding-top:0;padding-bottom:0;align-items:center}   /* total: fills the rest of the bottom row */
#npPop .npprint:active{transform:scale(.96)}
body.locked #npWrap{display:none !important}

/* ===== phone (560px or less): the notepad becomes a full page under the header. Sizes match the Home screen; no Back button (the phone's own Back button and the notepad icon both close it). The round button on the right is + (new note), and turns into a tick (done) while a note is open ===== */
.npbar{display:none}
@media (max-width:560px){
  #npPop{left:0;right:0;top:120px;bottom:0;width:auto;max-height:none;border:0;border-radius:0;box-shadow:none;padding:0 0 28px;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}   /* top is set by the script to just under the header */
  #npPop .npbar{display:flex;align-items:center;gap:8px;position:sticky;top:0;z-index:4;box-sizing:border-box;height:44px;padding:0 14px;background:var(--card)}
  #npPop .npnew{flex:none;display:flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;border-radius:9px;background:var(--accent);color:#fff;border:1px solid var(--accent);box-shadow:0 1px 2px rgba(0,0,0,.12)}
  #npPop .npnew svg{width:20px;height:20px;display:block}
  #npPop .npnew:active{transform:scale(.94)}
  #npPop .npt{flex:1;font-size:16px;font-weight:700}
  #npPop .nph button.npback{display:none}   /* the top bar has its own + / tick button */
  #npPop .nph{position:sticky;top:44px;z-index:3;background:var(--card);padding:2px 14px 8px}
  #npPop .nph .npcr{margin-left:0;flex:1;gap:6px;padding:0}
  #npPop .npc{justify-content:center;min-height:34px}
  #npPop .npl{padding:2px 14px 0}
  #npPop .npe{padding:28px 14px;font-size:13px}
  #npPop .nprh{min-height:46px;gap:12px}
  #npPop .nprt{font-size:15.5px}
  #npPop .npdh{height:20px;padding:10px;margin:-10px}
  #npPop .npx{padding:12px;margin:-12px}
  #npPop .npx svg{width:16px;height:16px}
  #npPop .npx.arm svg{width:18px;height:18px}
  #npPop .npcs{flex-wrap:wrap;gap:6px;padding:0 12px 10px}
  #npPop textarea.npfi{min-height:34vh;height:40vh;font-size:16px;padding:12px}
  #npPop .npdw{margin:0 10px 10px}
}
/* sum answers shown on the same line, inside the note box */
#npPop .npbox{position:relative}
#npPop .npghost{position:absolute;left:0;top:0;box-sizing:border-box;border:0;overflow:hidden;white-space:pre-wrap;overflow-wrap:break-word;color:transparent;pointer-events:none}
#npPop .npgr{display:inline-block;width:0;white-space:nowrap;margin-left:.6em;color:var(--accent);font-weight:700}

/* computer: the popup has a fixed size, the same as the reminders list (set in notepad.js, place()); the open note box is sized to fit inside it */
@media (min-width:561px){#npPop{box-sizing:border-box}#npPop textarea.npfi{height:150px;min-height:100px;max-height:none}}   /* border-box so the popup is exactly its set height, padding and border included */

/* receipt note: you write freely; every line is a row with its amount at the right in green, the total sits under the box */
#npPop .npbox.rc{border-radius:12px;overflow:hidden;background:var(--rcbg,var(--card))}
#npPop .npbox.rc textarea.npfi{white-space:pre;overflow-wrap:normal;overflow-x:auto;line-height:34px;padding:0 104px 0 12px;border-radius:0;background:repeating-linear-gradient(to bottom,transparent 0,transparent 33px,var(--line) 33px,var(--line) 34px);background-attachment:local}
#npPop .npbox.rc textarea.npfi::-webkit-scrollbar:horizontal{height:0}
#npPop .npbox.rc .rcl{height:34px;line-height:34px;text-align:right;white-space:nowrap;color:var(--accent);font-weight:700}
#npPop .npbox.rc .rcl span{display:inline-block;vertical-align:top;height:33px;line-height:33px;padding:0 12px 0 10px;background:var(--rcbg,var(--card))}   /* hides a long line that slides under the amount */
@media (min-width:561px){#npPop .npbox.rc textarea.npfi{height:136px;min-height:136px}}   /* four rows */

/* tiny scroll line (4px, no arrows) */
#npPop::-webkit-scrollbar,#npPop ::-webkit-scrollbar{width:4px;height:4px}
#npPop::-webkit-scrollbar-track,#npPop ::-webkit-scrollbar-track{background:transparent}
#npPop::-webkit-scrollbar-thumb,#npPop ::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--mute) 55%,transparent);border-radius:4px}
#npPop::-webkit-scrollbar-button,#npPop ::-webkit-scrollbar-button{display:none;width:0;height:0}
#npPop::-webkit-scrollbar-corner,#npPop ::-webkit-scrollbar-corner{background:transparent}
@supports not selector(::-webkit-scrollbar){#npPop,#npPop textarea{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--mute) 55%,transparent) transparent}}

/* open note = the whole popup: no outer padding, no second frame; the back/tags row sits inside the note at the top (like the date row at the bottom) and the writing area fills everything between */
#npPop.editing{--rcbg:var(--bg);background:var(--bg);padding:0;overflow:hidden}
#npPop.editing .npl{display:flex;flex-direction:column;gap:0;padding:0;height:100%}
#npPop.editing .npf{flex:1;min-height:0;border:0;border-radius:0;background:transparent}
#npPop.editing .npf .nph{position:static;padding:8px 10px 2px;background:transparent}
#npPop.editing .npf .npbox{flex:1;min-height:0;display:flex;flex-direction:column}
#npPop.editing .npf .npbox textarea.npfi{flex:1;height:auto;min-height:0;max-height:none;resize:none;overflow-y:auto}
#npPop.editing .npf .npbox.rc{border-radius:0}
#npPop.editing .npf .npcalc{margin:0 8px 6px}
#npPop.editing .npf .npdw{margin:0 6px 6px}
#npPop.editing .npf .npprint{margin:0 0 6px}
#npPop.editing .npf .npfr .npct{margin:0 8px 6px 6px}
@media (max-width:560px){
  #npPop.editing{overflow:auto;padding:0 0 28px}
  #npPop.editing .npl{height:auto;min-height:calc(100% - 44px)}
  #npPop.editing .npf .nph{padding:6px 14px 2px}
  #npPop.editing .npf .npbox textarea.npfi{min-height:44vh}
}


/* ===== tags are small coloured words; the top row only filters (it never needs a side scroll); notes are plain rows ===== */
#npPop .npd.none::before{content:"\2013"}
#npPop .npd.urgent{color:var(--err)}
#npPop .npd.shop{color:#5b9df0}
#npPop .npd.home{color:var(--accent)}
#npPop .npd.work{color:#a56cf0}
#npPop .npd.receipt{color:#d4537e}
#npPop .npc .npd{width:auto;height:auto;justify-content:center;font-size:12px}
#npPop .npc:hover{border-color:transparent;border-bottom-color:var(--line)}
#npPop .npc.on{background:none;border-color:transparent;border-bottom-color:var(--accent)}
#npPop.editing .npc{pointer-events:none}
#npPop.editing .npc:not(.on){opacity:.3}
#npPop.editing .npc[data-f="all"]{display:none}
#npPop .npr{background:none;border:0;border-bottom:1px solid var(--line);border-radius:0}
#npPop .npr:last-child{border-bottom:0}


/* ===== filter tabs with counts, tag pills, previews, date chips, date button, empty state ===== */
/* filter chips: readable words with a note count */
#npPop .npn{font-size:10.5px;font-weight:600;line-height:1;color:var(--mute);font-variant-numeric:tabular-nums}
#npPop .npn:empty{display:none}
#npPop .npc.on .npn{color:var(--text)}
#npPop.editing .npn{display:none}
/* rows: tag as a soft pill, title with a one-line preview, date as a chip */
#npPop .nprh .npdh{width:auto;min-width:62px;justify-content:flex-start}
#npPop .nprh .npd{width:auto;padding:3px 9px;border-radius:99px;font-size:11px;line-height:1.2;background:color-mix(in srgb,currentColor 15%,transparent)}
#npPop .nprh .npd.none{background:none;padding:3px 0}
#npPop .nprtt{display:block}
#npPop .nprb{display:block;font-size:12.5px;font-weight:400;line-height:1.3;color:var(--mute);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#npPop .npr{transition:background .15s}
@media (hover:hover){#npPop .npr:hover{background:color-mix(in srgb,var(--mute) 8%,transparent)}}
/* open note: the date button looks like a button (green when a date is set); bottom row buttons are 32px high */
#npPop .npfr{--npb:32px}
#npPop .npdw:hover .npdb{border-color:var(--mute)}
#npPop .npdb.set{background:color-mix(in srgb,var(--accent) 14%,var(--card));border-color:color-mix(in srgb,var(--accent) 45%,var(--line));color:var(--accent)}
#npPop .npdb .npdi,#npPop .npdb .npdi svg{width:15px;height:15px}
/* empty state: soft icon and a hint */
#npPop .npe{display:flex;flex-direction:column;align-items:center;gap:6px;line-height:1.4}
#npPop .npe::before{content:"";width:40px;height:40px;margin-bottom:4px;background:color-mix(in srgb,var(--mute) 55%,transparent);-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='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='3' width='16' height='18' rx='2'/%3E%3Cpath d='M8 8h8M8 12h8M8 16h5'/%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='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='3' width='16' height='18' rx='2'/%3E%3Cpath d='M8 8h8M8 12h8M8 16h5'/%3E%3C/svg%3E") center/contain no-repeat}
#npPop .npe small{font-size:12px;color:var(--mute)}


/* ===== header button dot, pinned tabs, keyboard focus ===== */
/* red dot on the header button while something is due (the flip only runs three times) */
#npBtn.due::after{content:"";position:absolute;top:-3px;right:-3px;width:9px;height:9px;border-radius:50%;background:var(--err);border:2px solid var(--bg);box-sizing:content-box;pointer-events:none}
@media (prefers-reduced-motion:reduce){#npBtn.due::after{display:none}}
/* computer: the tag chips stay pinned while the list scrolls (top -12px = the popup's padding, as in the reminders list) */
@media (min-width:561px){#npPop .nph{position:sticky;top:-12px;z-index:3;background:var(--card);padding:4px 2px 6px}}
/* tag dot and delete cross can be reached with Tab */
#npPop .npdh:focus-visible,#npPop .npx:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:6px}
