/* Phone (narrower than 700px, or a phone on its side): no spiral, no page
   edges, no tabs. Edge-to-edge paper, a slim header, a bottom bar, and the
   whole week on one screen. Everything here is keyed on data-phone="1", so
   tablets and the desk keep the book exactly as it is. */

#phead, #pbar { display: none; }

:root[data-phone="1"] {
  --wash: rgb(184 150 62 / .10);
  /* the grid's face: sturdy and narrow. Avenir Next Condensed ships on every iPhone
     and Mac (a system font: nothing to download); elsewhere the system face, condensed */
  --pf: "Avenir Next Condensed", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --pf-stretch: 87.5%;
  --pf-weight: 600;
  --ent-fs: 12px;
  --tint-ent: 10%;
  --tint-bar: 12%;
}
@media (prefers-color-scheme: dark) { :root[data-phone="1"]:not([data-appearance="light"]) { --wash: rgb(212 178 90 / .07); } }
:root[data-phone="1"][data-appearance="dark"] { --wash: rgb(212 178 90 / .07); }

:root[data-phone="1"] body, :root[data-phone="1"] #desk { background: var(--page); }
:root[data-phone="1"] #tabs, :root[data-phone="1"] #ribbon, :root[data-phone="1"] .corner { display: none !important; }

/* ---------------- header ---------------- */
:root[data-phone="1"] #phead {
  display: flex; align-items: center; gap: 2px;
  position: fixed; z-index: 6; top: 0; left: 0; right: 0;
  height: calc(var(--sat, 0px) + var(--hh, 50px));
  padding: var(--sat, 0px) calc(var(--sar, 0px) + 4px) 0 calc(var(--sal, 0px) + 10px);
  background: var(--page); border-bottom: 1px solid var(--rule);
}
.ph-title { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; min-width: 0; min-height: 44px; padding: 0 6px 0 4px; border-radius: 8px; text-align: left; }
.ph-tl { display: flex; align-items: center; gap: 4px; font-family: var(--font-book); font-size: 20px; line-height: 1.1; color: var(--print-strong); white-space: nowrap; }
.ph-tl::after { content: ""; width: 7px; height: 7px; margin-left: 4px; border-right: 1.4px solid var(--print); border-bottom: 1.4px solid var(--print); transform: translateY(-3px) rotate(45deg); flex: none; }
.ph-t { overflow: hidden; text-overflow: ellipsis; }
.ph-doodle { flex: none; display: flex; align-items: center; max-height: 30px; overflow: hidden; }
.ph-sub { font-family: var(--font-sans); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--print); margin-top: 2px; }
.ph-grow { flex: 1; }
.ph-today { min-height: 44px; padding: 0 12px; font-family: var(--font-sans); font-size: 13px; letter-spacing: .04em; color: var(--print-strong); }
.ph-today::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin-right: 6px; vertical-align: 1px; }
.ph-gear { width: 44px; height: 44px; display: grid; place-items: center; color: var(--print); border-radius: 50%; }
.ph-gear svg { width: 21px; height: 21px; }
.ph-title:focus-visible, .ph-today:focus-visible, .ph-gear:focus-visible, .pb:focus-visible { outline: 2px solid var(--print-strong); outline-offset: -2px; }
:root[data-phone="1"][data-view="cover"] #phead, :root[data-phone="1"][data-view="title"] #phead, :root[data-phone="1"][data-view="lock"] #phead,
:root[data-phone="1"][data-view="cover"] #pbar, :root[data-phone="1"][data-view="title"] #pbar, :root[data-phone="1"][data-view="lock"] #pbar { display: none; }

/* ---------------- bottom bar ---------------- */
:root[data-phone="1"] #pbar {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0;
  height: calc(var(--sab, 0px) + var(--bh, 54px));
  padding: 0 var(--sar, 0px) var(--sab, 0px) var(--sal, 0px);
  background: var(--page); border-top: 1px solid var(--rule);
}
.pb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 44px; color: var(--print); font-family: var(--font-sans); font-size: 10.5px; letter-spacing: .06em; }
.pb-i { width: 23px; height: 23px; }
.pb.on { color: var(--gold-text); }
.pb.on .pb-l { font-weight: 500; }
@media (max-height: 499px) {
  .pb { flex-direction: row; gap: 6px; font-size: 12px; }
  .pb-i { width: 20px; height: 20px; }
}

/* ---------------- the stage: full screen between the two ---------------- */
:root[data-phone="1"] #stage {
  position: fixed; transform: none; perspective: none; overflow: hidden;
  left: var(--sal, 0px); right: var(--sar, 0px); width: auto; height: auto;
  top: calc(var(--sat, 0px) + var(--hh, 50px)); bottom: calc(var(--sab, 0px) + var(--bh, 54px));
}
:root[data-phone="1"][data-view="cover"] #stage, :root[data-phone="1"][data-view="title"] #stage, :root[data-phone="1"][data-view="lock"] #stage { top: 0; bottom: 0; left: 0; right: 0; }
:root[data-phone="1"] .page {
  width: 100%; height: 100%; border-radius: 0; box-shadow: none; background: var(--page);
  padding: 1.1em calc(.9em + 2px) 88px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
}
:root[data-phone="1"] .page::-webkit-scrollbar { display: none; }
:root[data-phone="1"] .page.title { padding: calc(var(--sat, 0px) + 2em) 2em calc(var(--sab, 0px) + 2em); }
:root[data-phone="1"] .gear { top: calc(var(--sat, 0px) + .5em); right: .6em; }
:root[data-phone="1"] .cover { left: 0; width: 100%; height: 100%; border-radius: 0; box-shadow: none; }
:root[data-phone="1"] .cover .spiral-edge { display: none; }
:root[data-phone="1"] .cover-face { padding-bottom: calc(var(--sab, 0px) + 2.4em); }
:root[data-phone="1"] .page.lists, :root[data-phone="1"] .page.goals, :root[data-phone="1"] .page.mnotes,
:root[data-phone="1"] .page.notes-index, :root[data-phone="1"] .page.note-page { padding-top: 1.3em; }
:root[data-phone="1"] .page.today-page { padding: 0; }
:root[data-phone="1"] #shelf { left: calc(var(--sal, 0px) + 12px); bottom: calc(var(--sab, 0px) + var(--bh, 54px) + 8px); }
:root[data-phone="1"] #sync:not([data-state="offline"]) { opacity: 0; }
:root[data-phone="1"] .toast { bottom: calc(var(--sab, 0px) + var(--bh, 54px) + 12px); }

/* ---------------- the week ---------------- */
:root[data-phone="1"] .page.pw-page { padding: 0 0 92px; }
.pw-days {
  position: sticky; top: 0; z-index: 4;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--page); border-bottom: 1px solid var(--rule-strong);
}
.pw-day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 46px; padding: 4px 0 3px; font-family: var(--font-sans); color: var(--print); }
.pw-day + .pw-day { box-shadow: inset 1px 0 0 var(--rule-soft); }
.pw-dn { font-size: 10px; letter-spacing: .1em; line-height: 1.2; }
.pw-dd { font-size: 17px; font-weight: 400; line-height: 1; }
.pw-dd .n { display: inline-grid; place-items: center; min-width: 25px; height: 25px; border-radius: 50%; }
.pw-day.today { background: var(--wash); color: var(--print-strong); }
.pw-day.today .pw-dn { font-weight: 500; }
.pw-day.today .n { box-shadow: 0 0 0 1.5px var(--gold); font-weight: 500; }
.pw-day:focus-visible { outline: 2px solid var(--print-strong); outline-offset: -2px; }

.pw-row { --rowmin: 34px; border-bottom: 1px solid var(--rule); }
.pw-row.pw-me { --rowmin: 50px; }
.pw-row.pw-printed { --rowmin: 30px; border-bottom: 0; }
.pw-band { display: flex; align-items: flex-end; height: 19px; padding: 0 6px; }
.pw-lab { white-space: nowrap; }
.pw-lab.ink { font-family: var(--font-hand); font-size: 15px; line-height: 17px; color: var(--pen); }
:root[data-handwriting="off"] .pw-lab.ink { font-family: var(--font-serif); font-weight: 600; font-size: 14px; }
.pw-caps { font-family: var(--font-sans); font-size: 10px; line-height: 15px; letter-spacing: .14em; color: var(--print); }

.pw-grid {
  position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  padding-bottom: 2px;
}
.pw-col { pointer-events: none; z-index: 0; margin-bottom: -2px; }
.pw-col + .pw-col { box-shadow: inset 1px 0 0 var(--rule-soft); }
.pw-col.today { background: var(--wash); }
.pw-cell { position: relative; z-index: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 2px 1px 3px 2px; cursor: pointer; }

.pw-bar, .pw-ent { color: var(--pen); font-family: var(--pf); font-stretch: var(--pf-stretch); font-weight: var(--pf-weight); }
.pw-bar {
  position: relative; z-index: 2; min-width: 0; display: flex; align-items: center;
  margin: 2px 1px 0 2px; padding: 2px 3px 2px 6px; min-height: 19px; border-radius: 4px;
  background: color-mix(in srgb, var(--pen-fill) var(--tint-bar), var(--page));
  box-shadow: inset 3px 0 0 var(--pen-fill); cursor: pointer;
}
/* a range that runs on past the week continues cleanly to the edge */
.pw-bar:not(.s) { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; box-shadow: none; padding-left: 5px; }
.pw-bar:not(.e) { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.pw-bar:not(.e)::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(to right, transparent, color-mix(in srgb, var(--pen-fill) 35%, var(--page))); }
.pw-bt {
  min-width: 0; width: 100%; font-size: var(--ent-fs); line-height: 1.18;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: normal; word-break: normal; hyphens: manual; -webkit-hyphens: manual;
}
.pw-ent {
  min-width: 0; padding: 2px 1px 2px 4px; border-radius: 3px; cursor: pointer;
  background: color-mix(in srgb, var(--pen-fill) var(--tint-ent), var(--page));
  box-shadow: inset 2px 0 0 var(--pen-fill);
}
.pw-tt {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-size: var(--ent-fs); line-height: 1.18;
  overflow-wrap: normal; word-break: normal; hyphens: manual; -webkit-hyphens: manual;
}
.pw-time { display: none; font-family: var(--font-ui); font-stretch: 100%; font-weight: 400; font-size: 10px; line-height: 1.2; color: var(--print-strong); }
.pw-ent.virt { background: none; box-shadow: none; padding-left: 2px; color: var(--pen); }
.pw-ent.hol { color: var(--print); }
.pw-ent.virt .pw-tt { font-family: var(--font-serif); font-style: italic; font-stretch: 100%; font-weight: 600; font-size: 12px; line-height: 1.1; }
.pw-tt.hy, .pw-bt.hy { hyphens: auto; -webkit-hyphens: auto; }

.pw-foot { padding: 14px 12px 0; display: flex; flex-direction: column; gap: 10px; }
.pw-weekline .write { font-size: 17px; height: 32px; line-height: 32px; border-bottom: 1px solid var(--rule); }
.pw-weekline .write::placeholder { font-size: 14px; color: var(--print); opacity: 1; }
.pw-quote { margin: 0; font-family: var(--font-book); font-size: 12px; line-height: 1.5; color: var(--print); max-width: 30em; }
.pw-quote p { margin: 0; font-style: italic; }
.pw-quote cite { display: block; font-style: normal; margin-top: 2px; }

/* landscape: the same grid, roomier; times come back */
@media (max-height: 499px) {
  :root[data-phone="1"] { --ent-fs: 12.5px; }
  .pw-time { display: block; }
  .pw-day { flex-direction: row; gap: 6px; min-height: 36px; }
  .pw-row { --rowmin: 30px; }
  .pw-row.pw-me { --rowmin: 38px; }
}

/* ---------------- the day sheet ---------------- */
.pd-scrim { display: block; background: var(--scrim); }
.pd {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  background: var(--page); color: var(--print);
  padding: var(--sat, 0px) var(--sar, 0px) 0 var(--sal, 0px);
  transform: translateY(24px); opacity: 0; transition: transform .22s var(--ease), opacity .18s;
}
.scrim.in .pd { transform: none; opacity: 1; }
.pd-head { flex: none; display: flex; align-items: center; gap: 2px; padding: 6px 4px 8px; border-bottom: 1px solid var(--rule-strong); }
.pd-title { flex: 1; min-width: 0; margin: 0; display: flex; flex-direction: column; align-items: center; font-weight: 400; }
.pd-dow { font-family: var(--font-sans); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--print); }
.pd-today { margin-left: .7em; color: var(--gold-text); }
.pd-date { font-family: var(--font-book); font-size: 25px; line-height: 1.15; color: var(--print-strong); }
.pd-nav, .pd-x { flex: none; width: 44px; height: 44px; font-size: 26px; line-height: 1; color: var(--print); border-radius: 50%; }
.pd-x { font-size: 28px; }
.pd-nav:focus-visible, .pd-x:focus-visible, .pd-write:focus-visible, .pd-ent:focus-visible { outline: 2px solid var(--print-strong); outline-offset: 1px; }
.pd-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px calc(var(--sab, 0px) + 28px); }
.pd-row { padding: 12px 0 6px; border-bottom: 1px solid var(--rule); }
.pd-row:last-child { border-bottom: 0; }
.pd-lab { margin: 0 0 4px; font-weight: 400; }
.pd-lab.ink { font-family: var(--font-hand); font-size: 21px; line-height: 1.1; color: var(--pen); }
.pd-caps { font-family: var(--font-sans); font-size: 11px; letter-spacing: .16em; color: var(--print); }
.pd-ents { display: flex; flex-direction: column; gap: 2px; }
.pd-ent { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; padding: 6px 0 6px 12px; min-height: 44px; justify-content: center; box-shadow: inset 3px 0 0 var(--pen-fill); border-radius: 2px; color: var(--pen); }
.pd-ent.pd-multi { background: color-mix(in srgb, var(--pen-fill) var(--tint-bar, 12%), var(--page)); }
.pd-t { font-family: var(--font-hand); font-size: 22px; line-height: 1.2; overflow-wrap: break-word; max-width: 100%; }
:root[data-handwriting="off"] .pd-t { font-family: var(--font-serif); font-weight: 600; font-size: 20px; }
.pd-meta { font-family: var(--font-ui); font-size: 13px; color: var(--print); margin-top: 1px; }
.pd-note { font-family: var(--font-serif); font-style: italic; font-size: 15px; color: var(--print); margin-top: 2px; }
.pd-ent.virt { box-shadow: none; padding-left: 0; min-height: 0; }
.pd-ent.virt .pd-t { font-family: var(--font-serif); font-style: italic; font-weight: 600; font-size: 18px; }
.pd-ent.hol { color: var(--print); }
.pd-write { display: block; width: 100%; min-height: 44px; text-align: left; padding: 8px 0 4px 12px; border-bottom: 1px dotted var(--rule-strong); color: var(--print); font-family: var(--font-serif); font-style: italic; font-size: 16px; }
.pd-write span::before { content: "+ "; font-style: normal; color: var(--pen); }
.pd-row.focus .pd-lab { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 4px; }

/* ---------------- the jump sheet (header tap) ---------------- */
.pk { display: flex; flex-direction: column; gap: 14px; }
.pk-year { display: flex; align-items: center; justify-content: center; gap: 12px; }
.pk-yb { width: 44px; height: 44px; font-size: 24px; color: var(--print); border-radius: 50%; }
.pk-y { font-size: 20px; letter-spacing: .14em; color: var(--print-strong); }
.pk-months { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.pk-m { min-height: 44px; border-radius: 10px; font-family: var(--font-serif); font-size: 17px; color: var(--print-strong); }
.pk-m.now { color: var(--gold-text); font-weight: 600; }
.pk-m.on { background: var(--rule-soft); }
.pk-cals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.pk-ch { font-family: var(--font-sans); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--print); margin-bottom: 4px; }
.pk-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; font-family: var(--font-sans); font-size: 12px; color: var(--print-strong); }
.pk-h { color: var(--print); font-size: 10px; padding-bottom: 2px; }
.pk-d { min-height: 26px; border-radius: 13px; font-size: 12px; }
.pk-d.wk { background: var(--rule-soft); }
.pk-d.t { color: var(--gold-text); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--gold); }
.pk-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.pk-link { min-height: 44px; font-family: var(--font-serif); font-style: italic; font-size: 16px; color: var(--print-strong); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 4px; }
.pk-quote { margin: 0; font-family: var(--font-book); font-size: 13px; color: var(--print); }
.pk-quote p { margin: 0; font-style: italic; }
.pk-quote cite { display: block; font-style: normal; }
.pk-yb:focus-visible, .pk-m:focus-visible, .pk-d:focus-visible, .pk-link:focus-visible { outline: 2px solid var(--print-strong); outline-offset: 1px; }

/* ---------------- the month ---------------- */
:root[data-phone="1"] .page.pm-page { padding: 0 0 6px; display: flex; flex-direction: column; }
.pm-head, .pm-week { display: grid; grid-template-columns: 20px repeat(7, minmax(0, 1fr)); }
.pm-head { flex: none; font-family: var(--font-sans); font-size: 10px; letter-spacing: .1em; color: var(--print); text-align: center; padding: 6px 0 5px; border-bottom: 1px solid var(--rule-strong); }
.pm-weeks { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.pm-week { position: relative; flex: 1 1 0; border-bottom: 1px solid var(--rule); }   /* never shorter than its content */
.pm-wk { display: flex; align-items: flex-start; justify-content: center; padding-top: 6px; font-family: var(--font-sans); font-size: 9.5px; color: var(--print); border-right: 1px solid var(--rule-soft); }
.pm-wk:focus-visible, .pm-bg:focus-visible, .pm-goals:focus-visible { outline: 2px solid var(--print-strong); outline-offset: -2px; }
.pm-bg { position: relative; z-index: 0; cursor: pointer; }
.pm-bg + .pm-bg, .pm-bg ~ .pm-bg { box-shadow: inset 1px 0 0 var(--rule-soft); }
.pm-bg.out { background: color-mix(in srgb, var(--rule-soft) 40%, transparent); cursor: default; }
.pm-bg.today { background: var(--wash); }
.pm-top { position: relative; z-index: 1; min-width: 0; padding: 3px 2px 1px 4px; pointer-events: none; }
.pm-num { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: -3px; border-radius: 50%; font-family: var(--font-sans); font-size: 13px; color: var(--print-strong); }
.pm-num.today { box-shadow: 0 0 0 1.5px var(--gold); font-weight: 500; }
.pm-hol { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-family: var(--font-serif); font-style: italic; font-weight: 600; font-size: 10px; line-height: 1.1; color: var(--print); overflow-wrap: normal; hyphens: auto; -webkit-hyphens: auto; }
.pm-bar {
  position: relative; z-index: 2; min-width: 0; margin: 1px 1px 1px 2px; padding: 1px 3px 1px 5px; min-height: 15px; border-radius: 3px;
  display: flex; align-items: center; overflow: hidden; cursor: pointer;
  background: color-mix(in srgb, var(--pen-fill) var(--tint-bar), var(--page)); box-shadow: inset 2px 0 0 var(--pen-fill);
  color: var(--pen); font-family: var(--pf); font-stretch: var(--pf-stretch); font-weight: var(--pf-weight); font-size: 10.5px; line-height: 15px;
}
.pm-bar:not(.s) { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; box-shadow: none; }
.pm-bar:not(.e) { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.pm-bt { min-width: 0; width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 13px; overflow-wrap: normal; word-break: normal; }
.pm-bar.bare { padding: 0; }
.pm-bar.bare, :root .pm-bar.bare { background: color-mix(in srgb, var(--pen-fill) 55%, var(--page)); }
.pm-ents { position: relative; z-index: 1; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 1px; padding: 1px 1px 2px 2px; pointer-events: none; }
.pm-ent { flex: none; min-width: 0; white-space: nowrap; overflow: hidden; padding: 0 1px 0 4px; border-radius: 2px; box-shadow: inset 2px 0 0 var(--pen-fill); color: var(--pen); font-family: var(--pf); font-stretch: var(--pf-stretch); font-weight: var(--pf-weight); font-size: 10.5px; line-height: 13px; }
.pm-ent.virt { box-shadow: none; padding-left: 1px; font-family: var(--font-serif); font-style: italic; font-weight: 600; font-stretch: 100%; }
.pm-more { float: right; margin: 4px 1px 0 2px; padding: 0 4px; border-radius: 7px; background: var(--rule-soft); font-family: var(--font-sans); font-size: 10px; line-height: 14px; color: var(--print-strong); }
.pm-ents.dots { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 3px; padding: 2px 2px 2px 4px; }
.pm-ents.dots .pm-ent { width: 7px; height: 7px; padding: 0; border-radius: 50%; background: var(--pen-fill); box-shadow: none; }
.pm-ents.dots .pm-et { display: none; }
.pm-foot { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 8px 12px 0; }
.pm-goals { align-self: flex-start; min-height: 40px; font-family: var(--font-serif); font-style: italic; font-size: 16px; color: var(--print-strong); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 4px; }
.pm-quote { margin: 0; font-family: var(--font-book); font-style: italic; font-size: 12px; color: var(--print); padding-right: 64px; }
