@font-face{font-family:"Chakra Petch";font-weight:500;font-display:swap;src:url(fonts/ChakraPetch-normal-500-latin.woff2) format("woff2")}
@font-face{font-family:"Chakra Petch";font-weight:600;font-display:swap;src:url(fonts/ChakraPetch-normal-600-latin.woff2) format("woff2")}
@font-face{font-family:"Chakra Petch";font-weight:700;font-display:swap;src:url(fonts/ChakraPetch-normal-700-latin.woff2) format("woff2")}
@font-face{font-family:Literata;font-weight:400 700;font-display:swap;src:url(fonts/Literata-normal-400_700-latin.woff2) format("woff2")}
@font-face{font-family:Literata;font-weight:400 700;font-display:swap;src:url(fonts/Literata-normal-400_700-greek.woff2) format("woff2");unicode-range:U+0370-03FF}
@font-face{font-family:Literata;font-style:italic;font-weight:400 700;font-display:swap;src:url(fonts/Literata-italic-400_700-latin.woff2) format("woff2")}

/* Paper and Dark share their ground with the splash screens. */
:root{
  --bg:#f6f3ec;--surface:#fffcf5;--ink:#231b12;--muted:#665947;--line:#d9cdb8;
  --accent:#4a1a6e;--accent-text:#7d3c98;--on-accent:#fff;--amber:#cc8800;--amber-soft:#fff6dc;--danger:#c62828;
  --ui:"Chakra Petch",system-ui,sans-serif;--read:Literata,Georgia,serif;
  --bar:64px;--safe-b:env(safe-area-inset-bottom,0px);
  --yellow:#f7df5e;--green:#a5dd8b;--blue:#9cb9fb;--pink:#f3a2b4;--purple:#c3b0f8;--mark:100%;
  color-scheme:light;
}
[data-theme=light]{--bg:#fff;--surface:#f7f6f3;--ink:#16181d;--muted:#5b6069;--line:#dcdde0}
[data-theme=sage]{--bg:#e5ecdd;--surface:#f0f5ea;--ink:#1b271c;--muted:#4d5d4b;--line:#bfcdb5;--accent-text:#74338f;--danger:#b42318}
[data-theme=dark]{--bg:#101010;--surface:#1c1a18;--ink:#e4ddd0;--muted:#a79c8c;--line:#38332d;--accent:#b84a1c;--accent-text:#f0915f;--amber:#e0a030;--amber-soft:#33270f;--danger:#ff8a7a;--mark:38%;color-scheme:dark}
[data-theme=black]{--bg:#000;--surface:#121110;--ink:#d6cfc2;--muted:#9b9081;--line:#2d2925;--accent:#b84a1c;--accent-text:#f0915f;--amber:#e0a030;--amber-soft:#2b210c;--danger:#ff8a7a;--mark:38%;color-scheme:dark}

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;background:var(--bg)}
body{margin:0;background:var(--bg);color:var(--ink);font:500 16px/1.5 var(--ui);-webkit-tap-highlight-color:transparent;overflow-x:clip}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer;touch-action:manipulation}
a{color:inherit;text-decoration:none}
h1,h2,h3,p{margin:0}
svg{display:block}
[hidden]{display:none!important}
:focus-visible{outline:3px solid var(--amber);outline-offset:2px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.icon{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:square}
.iconbtn{display:grid;place-items:center;min-width:44px;height:44px;border-radius:8px;flex:none}
.iconbtn:active,.row:active{background:color-mix(in srgb,var(--ink) 8%,transparent)}
@media(hover:hover){.iconbtn:hover,.row:hover{background:color-mix(in srgb,var(--ink) 6%,transparent)}}

/* Bottom bar */
.tabs{position:fixed;z-index:20;inset:auto 0 0;display:flex;justify-content:center;background:var(--surface);border-top:1px solid var(--line);padding-bottom:var(--safe-b)}
.tabs a{flex:1;max-width:220px;height:var(--bar);display:flex;align-items:center;justify-content:center;gap:12px;color:var(--muted);font-weight:600;box-shadow:inset 0 3px transparent}
.tabs a[aria-current]{color:var(--accent-text);box-shadow:inset 0 3px var(--accent)}

/* Home and index */
.screen{max-width:1080px;margin:0 auto;padding:max(12px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) calc(var(--bar) + var(--safe-b) + 32px) max(16px,env(safe-area-inset-left))}
.brand{display:flex;align-items:center;gap:12px;font-weight:700;font-size:20px;letter-spacing:.04em;height:56px}
.brand img{width:40px;height:40px;border-radius:9px}
.brand button{margin-left:auto}
.home{display:grid;gap:16px}
.panel{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:20px 16px}
.panel h2,.screen>h1{font-weight:700;font-size:20px;line-height:1.3}
.screen>h1{font-size:32px;margin:20px 0 16px}
/* vw sizes fit the longest case, "Wednesday, 30 September 2026", on one line. */
.screen>.date{font:italic 500 clamp(18px,6vw,44px)/1.2 var(--read);margin:12px 0 20px;white-space:nowrap}
.streak{display:grid;grid-template-columns:1fr auto;gap:clamp(10px,3.4vw,24px);--ok:#23895a;--miss:#cf4a45;--fire:#f2a33c}
:root:is([data-theme=dark],[data-theme=black]) .streak{--ok:#4cc38a;--miss:#e8746c}
.streak svg path:first-child{fill:var(--fire)}
.streak svg path:last-child{fill:#fff3dc}
.streak p{color:var(--muted);font-size:clamp(12px,3.7vw,15px);line-height:1.4;white-space:nowrap}
.run{min-width:0;container-type:inline-size}
.run h2{display:flex;align-items:center;gap:.3em;font-size:clamp(16px,9.6cqi,30px);white-space:nowrap}
.run h2 svg{height:1.2em}
.week{list-style:none;display:grid;grid-template-columns:repeat(7,1fr);margin:12px 0 8px;padding:0;text-align:center}
.week li{position:relative;--c:var(--line)}
.week i{position:relative;z-index:1;display:grid;place-items:center;width:86%;max-width:40px;aspect-ratio:1;margin:0 auto 4px;border-radius:50%;background:var(--surface);border:clamp(2px,1.1cqi,4px) solid var(--c)}
.week b{font-weight:600;font-size:14px;color:var(--muted)}
.week svg{width:68%;height:68%}
.week .icon{stroke:var(--ok);stroke-width:3.4}
.week .on{--c:var(--ok)}
.week .today.on{--c:var(--fire)}
.week .today b{color:var(--ink);font-weight:700}
/* A missed day is a broken ring, so it reads without colour. */
.week .missed{--c:color-mix(in srgb,var(--miss) 22%,var(--surface))}
.week .missed i::after{content:"";position:absolute;inset:calc(-1*clamp(2px,1.1cqi,4px));border:inherit;border-color:var(--miss) var(--miss) var(--miss) transparent;border-radius:50%;rotate:30deg}
/* Link to the day before: a line, or a band when both days were opened. */
.week li+li::before{content:"";position:absolute;right:50%;width:100%;top:calc(min(43cqi/7,20px) - 1px);height:2px;background:var(--line)}
.week .on+.on::before{top:0;height:min(86cqi/7,40px);background:color-mix(in srgb,var(--ok) 18%,var(--surface))}
.best{display:grid;justify-items:center;align-content:center;gap:6px;border-left:1px solid var(--line);padding-left:clamp(10px,3.4vw,24px)}
.best>div{position:relative;width:clamp(58px,19vw,104px)}
.best svg path:last-child{fill:#ffc56b;transform:scale(1.22);transform-origin:50% 100%}
.best strong{position:absolute;inset:38% 0 0;text-align:center;color:#2a1505;font-size:clamp(17px,5.6vw,30px);line-height:1;font-weight:700}
.best small{display:block;font-size:12px;font-weight:700}
.best p{font-weight:600;line-height:1.2;text-align:center;white-space:normal;width:min-content}
.rows{list-style:none;margin:0;padding:0}
.rows li{display:flex;align-items:center;border-top:1px solid var(--line)}
.rows li:first-child{border-top:0}
.row{flex:1;min-width:0;display:flex;align-items:center;gap:16px;padding:12px 8px;min-height:68px;border-radius:8px}
.row>span{min-width:0}
.row strong{display:block;font-weight:600;font-size:18px;line-height:1.3}
.row small{display:block;font-size:14px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.num{width:32px;flex:none;font-weight:700;font-size:20px;color:var(--accent-text);font-variant-numeric:tabular-nums}
.recent{margin:8px -8px 0}
.empty{color:var(--muted);margin:8px 0 16px}
.btn{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:0 20px;border-radius:8px;background:var(--accent);color:var(--on-accent);font-weight:600}
.btn.quiet{background:none;color:var(--ink);box-shadow:inset 0 0 0 1px var(--line)}
.save{font-size:14px;color:var(--muted);font-variant-numeric:tabular-nums}
.save.done{color:var(--accent-text)}
@media(min-width:860px){
  .home{grid-template-columns:1fr 1fr;align-items:start;gap:24px}
  .home>div{display:grid;gap:16px}
  .index{columns:2;column-gap:48px}
  .index li{break-inside:avoid}
}
@media(max-width:859px){.home>div{display:grid;gap:16px}}

/* Reader */
.top{position:sticky;top:0;z-index:15;background:var(--bg);border-bottom:1px solid var(--line);padding:env(safe-area-inset-top) max(8px,env(safe-area-inset-right)) 0 max(8px,env(safe-area-inset-left))}
.top>div{display:flex;align-items:center;max-width:860px;margin:0 auto;height:60px}
.where{flex:1;min-width:0;padding:0 8px;line-height:1.25}
.where strong,.where small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.where strong{font-weight:600}
.where small{font-size:14px;color:var(--muted)}
#book{max-width:760px;margin:0 auto;padding:8px max(16px,env(safe-area-inset-right)) calc(96px + var(--safe-b)) max(16px,env(safe-area-inset-left));font:400 18px/1.62 var(--read);overflow-wrap:break-word;-webkit-user-select:text;user-select:text}
#book .page{padding:20px 0 28px;border-top:1px solid var(--line)}
#book .page:first-child{border-top:0}
#book .pn{font:500 14px/1.5 var(--ui);color:var(--muted);margin-bottom:8px}
#book :is(h1,h2,h3){font-family:var(--ui);line-height:1.25;text-wrap:balance;scroll-margin-top:calc(76px + env(safe-area-inset-top))}
#book h1{font-size:26px;font-weight:700;background:var(--accent);color:var(--on-accent);padding:16px;border-radius:8px;margin:12px 0 20px}
#book h1 :is(.q,.red,.pyt){color:inherit;background:none}
#book h2{font-size:22px;font-weight:700;border-bottom:2px solid var(--accent);padding-bottom:6px;margin:28px 0 12px}
#book h3{font-size:18px;font-weight:600;color:var(--accent-text);margin:22px 0 8px}
#book p{margin:0 0 12px}
#book :is(ul,ol){padding-left:1.35em;margin:0 0 14px}
#book li{margin:3px 0}
#book li::marker{color:var(--accent-text)}
#book .t{overflow-x:auto;margin:14px 0;-webkit-overflow-scrolling:touch}
#book table{border-collapse:collapse;min-width:60%;font-size:16px;line-height:1.5}
#book :is(th,td){border:1px solid var(--line);padding:8px 12px;text-align:left;vertical-align:top;min-width:96px;overflow-wrap:normal}
#book th{background:var(--surface);font-family:var(--ui);font-weight:600}
#book .box{background:var(--amber-soft);border-radius:8px;padding:12px 16px;margin:16px 0}
#book .box>:last-child{margin-bottom:0}
#book .mnemonic{background:var(--surface);border:1px dashed var(--accent)}
#book .pyt{font:600 16px/1.5 var(--ui);background:var(--amber-soft);padding:2px 6px;border-radius:4px}
#book .q{color:var(--accent-text);font-weight:700}
#book .red{color:var(--danger)}
#book figure{margin:20px 0;text-align:center}
#book img{max-width:100%;height:auto;background:#fff;border-radius:6px}
:is([data-theme=dark],[data-theme=black]) #book img{filter:brightness(.86)}
#book figcaption{font-size:15px;font-style:italic;color:var(--muted);margin-top:6px}

/* The original notes' look, in the light themes only. */
:root:not([data-theme=dark],[data-theme=black]) #book{
  h2{background:var(--accent);color:var(--on-accent);border:0;border-radius:6px;padding:8px 14px;text-align:center}
  h2 :is(.q,.red,.pyt){color:inherit;background:none}
  th{background:#f1e2f5;color:#43186b}
  :is(th,td){border-color:#cbbfd6}
  .box{background:#fff8e6;box-shadow:inset 0 0 0 1px #e5b94c}
  .mnemonic{background:#f5e8fa;border:0;box-shadow:none;border-left:4px solid #8e44ad;border-radius:0 8px 8px 0}
  .pyt{color:#7a5c00}
  figcaption{color:var(--accent-text)}
}

/* Marks */
#book mark{--c:transparent;background:color-mix(in srgb,var(--c) var(--mark),transparent);color:inherit;cursor:pointer;border-radius:2px;-webkit-box-decoration-break:clone;box-decoration-break:clone}
:root:not([data-theme=dark],[data-theme=black]) #book mark:not([data-c=underline]),:root:not([data-theme=dark],[data-theme=black]) #book mark:not([data-c=underline]) *{color:#1d1710}
mark[data-c=yellow]{--c:var(--yellow)!important}mark[data-c=green]{--c:var(--green)!important}mark[data-c=blue]{--c:var(--blue)!important}mark[data-c=pink]{--c:var(--pink)!important}mark[data-c=purple]{--c:var(--purple)!important}
#book mark[data-c=underline]{text-decoration:underline 2px currentColor;text-underline-offset:3px}
/* Drawn in CSS so it never changes the text that saved positions count through. */
#book mark.noted::after{content:"";display:inline-block;width:.72em;height:.72em;margin-left:.2em;border-radius:2px 2px 2px 0;background:var(--accent)}

/* The hold menu keeps the dark Apple Notes look in every theme. */
.menu{position:absolute;z-index:30;width:212px;background:#2a2826;color:#eeebe6;border-radius:12px;padding:6px 0;box-shadow:0 0 0 1px #46423e,0 12px 32px rgb(0 0 0/.35);font:400 17px/1.3 system-ui,sans-serif;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.menu button{display:flex;align-items:center;gap:14px;width:100%;min-height:44px;padding:0 18px;text-align:left}
.menu button:active,.menu button[aria-pressed=true]{background:#46423e}
@media(hover:hover){.menu button:hover{background:#3b3835}}
.menu button:focus-visible{outline-offset:-3px}
.menu i{width:18px;height:18px;border-radius:50%;flex:none;font-style:normal;text-decoration:underline;text-underline-offset:3px;text-align:center;line-height:17px}
.menu .icon{width:18px;height:18px}
.menu hr{border:0;border-top:1px solid #4d4945;margin:6px 18px}
.menu p{padding:8px 18px;max-height:120px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;font-size:16px;border-bottom:1px solid #4d4945;margin-bottom:6px}

/* Sheets */
dialog{border:0;padding:0;margin:auto auto 0;width:100%;max-width:520px;max-height:82dvh;background:var(--surface);color:var(--ink);border-radius:16px 16px 0 0;padding-bottom:var(--safe-b);overflow:hidden}
dialog[open]{display:flex;flex-direction:column}
dialog::backdrop{background:rgb(0 0 0/.45)}
.sheet-head{display:flex;align-items:center;padding:8px 8px 8px 20px;border-bottom:1px solid var(--line);flex:none}
.sheet-head h2{flex:1;font-size:20px;font-weight:700}
#toc .list{overflow-y:auto;overscroll-behavior:contain;padding:8px}
#toc .list button{display:flex;gap:16px;width:100%;min-height:44px;align-items:center;padding:8px 12px;text-align:left;border-radius:8px;line-height:1.3;overflow-wrap:anywhere}
#toc .list button>span:first-child{flex:1;min-width:0}
#toc .list span:last-child{color:var(--muted);font-size:14px;font-variant-numeric:tabular-nums}
#toc .ch{font-weight:700;color:var(--accent-text)}
#toc [aria-current]{background:color-mix(in srgb,var(--accent) 14%,transparent)}
.swatches{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;padding:20px 16px 24px;border:0;margin:0;min-width:0}
.swatches label{display:grid;justify-items:center;gap:8px;cursor:pointer;font-size:14px}
.swatches span{width:52px;height:64px;border-radius:10px;display:grid;place-items:center;font:500 22px var(--read);box-shadow:inset 0 0 0 1px rgb(128 128 128/.5)}
.swatches input:checked+span{outline:3px solid var(--accent);outline-offset:3px}
.swatches input:focus-visible+span{outline:3px solid var(--amber);outline-offset:3px}
#note form{padding:16px 20px 20px;display:grid;gap:16px}
#note blockquote{margin:0;font:italic 400 16px/1.5 var(--read);color:var(--muted);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
#note textarea{width:100%;min-height:132px;resize:vertical;font:400 18px/1.5 var(--read);color:inherit;background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:12px}
#note .acts{display:flex;justify-content:flex-end;gap:12px}
.toast{position:fixed;z-index:60;left:50%;bottom:calc(var(--bar) + var(--safe-b) + 16px);transform:translateX(-50%);width:max-content;max-width:calc(100% - 32px);background:var(--ink);color:var(--bg);padding:12px 18px;border-radius:8px}
@media(min-width:700px){dialog{margin:auto;border-radius:16px}}
@media(prefers-reduced-motion:no-preference){
  dialog[open]{animation:rise .2s ease-out}
  .menu{animation:pop .12s ease-out}
  @keyframes rise{from{transform:translateY(24px);opacity:0}}
  @keyframes pop{from{transform:scale(.96);opacity:0}}
}
