/* Mi Agenda — paper, two inks and a ribbon. Every ink used for text reaches WCAG AA on paper. */

:root {
  --paper: #F6F1E7;
  --raised: #FBF8F1;
  --ink: #1F1B16;
  --ink2: #6B6358;
  --faint: #766D61;
  --rule: #E3DACB;
  --ribbon: #8C2F2B;
  --on-ribbon: #FBF8F1;
  --blue: #2F4A6D;
  --moss: #4F6B4A;
  --ochre: #7E5F28;
  --plum: #6B4E71;
  --teal: #3F6668;
  --amber: #85591A;
  --clay: #7A4B3A;
  --ribbon-soft: rgba(140, 47, 43, 0.10);
  --ribbon-line: rgba(140, 47, 43, 0.40);
  --blue-soft: rgba(47, 74, 109, 0.10);
  --moss-soft: rgba(79, 107, 74, 0.12);
  --ochre-soft: rgba(126, 95, 40, 0.12);
  --shadow: rgba(140, 47, 43, 0.35);
  --scrim: rgba(31, 27, 22, 0.30);
  --sheet-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);

  --serif: ui-serif, 'New York', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', Roboto, sans-serif;

  --page: 24px;
  --nav-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15130F;
    --raised: #1E1B16;
    --ink: #EDE6D8;
    --ink2: #A69E90;
    --faint: #8A8275;
    --rule: #2C2820;
    --ribbon: #D0675E;
    --on-ribbon: #15130F;
    --blue: #8FA9CC;
    --moss: #9DB892;
    --ochre: #D2B06F;
    --plum: #B79BC0;
    --teal: #8DBDBF;
    --amber: #E0B866;
    --clay: #D39B85;
    --ribbon-soft: rgba(208, 103, 94, 0.16);
    --ribbon-line: rgba(208, 103, 94, 0.45);
    --blue-soft: rgba(143, 169, 204, 0.14);
    --moss-soft: rgba(157, 184, 146, 0.14);
    --ochre-soft: rgba(210, 176, 111, 0.14);
    --shadow: rgba(0, 0, 0, 0.5);
    --scrim: rgba(0, 0, 0, 0.45);
    --sheet-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #15130F;
  --raised: #1E1B16;
  --ink: #EDE6D8;
  --ink2: #A69E90;
  --faint: #8A8275;
  --rule: #2C2820;
  --ribbon: #D0675E;
  --on-ribbon: #15130F;
  --blue: #8FA9CC;
  --moss: #9DB892;
  --ochre: #D2B06F;
  --plum: #B79BC0;
  --teal: #8DBDBF;
  --amber: #E0B866;
  --clay: #D39B85;
  --ribbon-soft: rgba(208, 103, 94, 0.16);
  --ribbon-line: rgba(208, 103, 94, 0.45);
  --blue-soft: rgba(143, 169, 204, 0.14);
  --moss-soft: rgba(157, 184, 146, 0.14);
  --ochre-soft: rgba(210, 176, 111, 0.14);
  --shadow: rgba(0, 0, 0, 0.5);
  --scrim: rgba(0, 0, 0, 0.45);
  --sheet-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html {
  /* On iPhone this follows the system text size (Dynamic Type). */
  font: -apple-system-body;
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

@supports not (font: -apple-system-body) {
  html { font-size: 17px; }
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--ribbon); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

svg.icon { width: 1.12em; height: 1.12em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Paper grain: almost imperceptible, generated once. Off with Reduce Transparency. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
@media (prefers-reduced-transparency: reduce) { body::before { display: none; } }

/* ── Type ─────────────────────────────────────────────────────────────── */

.folio {
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink);
}
.display { font-family: var(--serif); font-size: 2rem; line-height: 1.12; font-weight: 400; margin: 2px 0 0; letter-spacing: -0.01em; }
.chapter { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; line-height: 1.25; margin: 0; }
.entry { font-family: var(--serif); font-size: 1.12rem; line-height: 1.25; }
.meta { font-family: var(--sans); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.caption { font-family: var(--sans); font-size: 0.76rem; color: var(--ink2); }
.body-serif { font-family: var(--serif); font-size: 1rem; line-height: 1.45; }
.faint { color: var(--faint); }
.muted { color: var(--ink2); }
.ribbon-ink { color: var(--ribbon); }
.italic { font-style: italic; }

/* ── App frame ───────────────────────────────────────────────────────── */

#app { position: relative; z-index: 1; }

.screen {
  position: fixed;
  inset: 0 0 calc(var(--nav-h) + var(--safe-bottom)) 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-top: var(--safe-top);
}
.screen-inner { max-width: 640px; margin: 0 auto; position: relative; padding-bottom: 40px; }

.page-header { padding: 6px var(--page) 0; position: relative; }
.page-header .bar { display: flex; align-items: center; min-height: 44px; gap: 4px; }
.page-header .bar .folio { color: var(--ribbon); }
.page-header .spacer { flex: 1; }
.page-header .subtitle { margin-top: 2px; }

.ribbon-mark {
  position: absolute;
  right: var(--page);
  top: calc(-1 * var(--safe-top) - 8px);
  width: 14px;
  height: calc(52px + var(--safe-top));
  background: var(--ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
  border: 0;
  padding: 0;
  transition: transform .25s var(--ease);
}
.ribbon-mark:active { transform: translateY(4px); }
.has-ribbon .bar { margin-right: 26px; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--ink2);
  border-radius: 22px;
}
.icon-btn svg.icon { width: 21px; height: 21px; }
.icon-btn:active { background: var(--ribbon-soft); }
.text-btn {
  min-height: 44px;
  padding: 0 8px;
  background: transparent;
  border: 0;
  font-weight: 600;
  font-size: 1rem;
  color: var(--ribbon);
}
.text-btn.quiet { color: var(--ink2); font-size: 0.82rem; }

.chapter-heading { display: flex; align-items: center; gap: 8px; padding: 22px var(--page) 6px; }
.chapter-heading .dash { width: 16px; height: 1px; background: var(--ribbon); }
.chapter-heading .count { margin-left: auto; font-size: 0.76rem; color: var(--faint); }
.chapter-heading.tint-ribbon .folio { color: var(--ribbon); }
.chapter-heading.tint-moss .folio { color: var(--moss); }
.chapter-heading.tint-moss .dash { background: var(--moss); }
.chapter-heading button.folio { background: none; border: 0; padding: 0; min-height: 32px; display: inline-flex; align-items: center; gap: 6px; }

.page-footer { text-align: center; padding: 18px 0 12px; font-family: var(--serif); font-size: 0.76rem; color: var(--faint); }

.rule { height: 0.5px; background: var(--rule); margin: 0 var(--page); }
@media (min-resolution: 2dppx) { .rule { height: 0.5px; } }

/* ── Bottom bar ──────────────────────────────────────────────────────── */

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 4px 8px var(--safe-bottom);
  background: var(--raised);
  border-top: 0.5px solid var(--rule);
  display: flex;
  align-items: stretch;
}
.bottom-bar .tabs { display: flex; width: 100%; max-width: 640px; margin: 0 auto; }
.tab {
  flex: 1 1 0;
  background: transparent;
  border: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 500;
  min-height: 54px;
}
.tab svg.icon { width: 22px; height: 22px; stroke-width: 1.6; }
.tab .underline { width: 16px; height: 2px; border-radius: 1px; background: transparent; margin-top: 1px; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tab[aria-current="page"] svg.icon { stroke-width: 2; }
.tab[aria-current="page"] .underline { background: var(--ribbon); }
.tab .badge {
  position: absolute;
  margin: -18px 0 0 28px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--ribbon);
  color: var(--on-ribbon);
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 16px;
}
.tab { position: relative; }

.mic-slot { flex: 1 1 0; position: relative; display: flex; justify-content: center; }
.mic-button {
  position: absolute;
  top: -30px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--raised);
  border: 0.5px solid var(--rule);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.mic-button .disc {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--ribbon);
  box-shadow: 0 4px 10px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-ribbon);
  transition: transform .18s var(--ease);
}
.mic-button .disc svg.icon { width: 28px; height: 28px; stroke-width: 2.2; }
.mic-button:active .disc { transform: scale(0.94); }

.mic-menu {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 64px);
  transform: translateX(-50%);
  z-index: 40;
  min-width: 240px;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  padding: 6px;
  animation: pop .18s var(--ease);
}
.mic-menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  font-size: 1rem;
}
.mic-menu button:active { background: var(--ribbon-soft); }
.mic-menu .emoji { width: 24px; text-align: center; }

@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px) scale(.97); } }

/* ── Rows ────────────────────────────────────────────────────────────── */

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px var(--page);
  min-height: 56px;
  background: var(--paper);
  touch-action: pan-y;
}
.row-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  color: inherit;
}
.row > .row-main:last-child { margin-right: calc(var(--page) - 10px); }
.sheet .row, .sheet .swipe { background: var(--raised); }
.row .time { width: 52px; flex-shrink: 0; padding-top: 3px; color: var(--ink2); }
.row.shows-day .time { width: 96px; }
.row .glyph { width: 20px; flex-shrink: 0; padding-top: 3px; }
.row .glyph svg.icon { width: 17px; height: 17px; }
.row .texts { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .title { overflow-wrap: anywhere; }
.row .detail { font-size: 0.76rem; color: var(--ink2); display: flex; gap: 4px; align-items: center; }
.row .detail svg.icon { width: 12px; height: 12px; }
.row.is-done .title { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--faint); }
.row.is-past .title { color: var(--faint); }
.row.is-overdue .time, .row.is-overdue .detail { color: var(--ribbon); }

.ink-check {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 0;
}
.ink-check span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.4px solid var(--faint);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.ink-check svg.icon { width: 13px; height: 13px; stroke-width: 3; color: var(--paper); opacity: 0; }
.ink-check.on span { background: var(--moss); border-color: var(--moss); }
.ink-check.on svg.icon { opacity: 1; }
.ink-check:active span { transform: scale(0.88); }

/* Swipe actions */
.swipe { position: relative; overflow: hidden; }
.swipe-actions { position: absolute; inset: 0; display: flex; justify-content: space-between; }
.swipe-actions .side { display: flex; height: 100%; }
.swipe-actions button {
  border: 0;
  min-width: 78px;
  color: #FBF8F1;
  font-size: 0.76rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.swipe-actions .act-tomorrow { background: #7E5F28; }
.swipe-actions .act-hour { background: #2F4A6D; }
.swipe-actions .act-delete { background: #8C2F2B; }
.swipe .row { transition: transform .22s var(--ease); will-change: transform; }
.swipe.dragging .row { transition: none; }

.now-marker { display: flex; align-items: center; gap: 8px; padding: 2px var(--page); }
.now-marker .meta { color: var(--ribbon); font-weight: 600; }
.now-marker .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ribbon); }
.now-marker .line { flex: 1; height: 1px; background: var(--ribbon); opacity: 0.6; }

.empty-page { text-align: center; padding: 28px var(--page) 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-page svg.icon { width: 28px; height: 28px; color: var(--faint); stroke-width: 1.4; margin-bottom: 4px; }
.empty-page .chapter { font-weight: 400; font-style: italic; }
.empty-page p { margin: 0; color: var(--ink2); max-width: 300px; }
.empty-line { padding: 4px var(--page) 8px; font-family: var(--serif); font-style: italic; color: var(--faint); }

/* Kind and category tints */
.k-reminder { color: var(--ribbon); }
.k-event { color: var(--blue); }
.k-task { color: var(--moss); }
.k-note { color: var(--ochre); }
.c-work { color: var(--blue); }
.c-personal { color: var(--moss); }
.c-finance { color: var(--ochre); }
.c-shopping { color: var(--plum); }
.c-study { color: var(--teal); }
.c-ideas { color: var(--amber); }
.c-people { color: var(--clay); }
.c-other { color: var(--ink2); }
.category-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 0.76rem; }
.category-tag svg.icon { width: 14px; height: 14px; }

/* ── Cards, chips, buttons ───────────────────────────────────────────── */

.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card.accent { border-color: var(--ribbon-line); }
.card + .card { margin-top: 12px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: 8px var(--page); scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  background: var(--raised);
  border: 1px solid var(--rule);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink);
}
.chip[aria-pressed="true"] { background: var(--ribbon); border-color: var(--ribbon); color: var(--on-ribbon); }
.chip:active { transform: scale(0.97); }

.btn {
  flex: 1 1 0;
  min-height: 50px;
  border-radius: 14px;
  padding: 0 16px;
  background: var(--ribbon);
  color: var(--on-ribbon);
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .15s, transform .15s var(--ease);
}
.btn.secondary { background: var(--raised); color: var(--ink); border-color: var(--rule); }
.btn.danger { background: transparent; color: var(--ribbon); border-color: var(--ribbon-line); }
.btn:disabled { opacity: 0.45; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-row { display: flex; gap: 12px; }

.banner {
  margin: 12px var(--page) 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--raised);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.banner.alert { border-color: var(--ribbon-line); background: var(--ribbon-soft); }
.banner .head { display: flex; align-items: center; gap: 8px; }
.banner .head .folio { color: var(--ribbon); }
.banner .close { margin-left: auto; margin-right: -10px; }
.banner p { margin: 0; }
.alert-item { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; border-top: 0.5px solid var(--rule); }
.alert-item:first-of-type { border-top: 0; }
.alert-item .chips { gap: 6px; }
.alert-item .texts { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.alert-item .chip { min-height: 36px; padding: 0 12px; font-size: 0.8rem; }

/* ── Sheets ──────────────────────────────────────────────────────────── */

.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 30; animation: fade .25s ease; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  max-height: calc(100dvh - var(--safe-top) - 10px);
  margin: 0 auto;
  max-width: 640px;
  background: var(--raised);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--sheet-shadow);
  display: flex;
  flex-direction: column;
  animation: rise .35s var(--ease);
  padding-bottom: var(--safe-bottom);
}
.sheet.large { top: calc(var(--safe-top) + 10px); }
.sheet.closing { animation: sink .22s ease forwards; }
.scrim.closing { animation: fade .22s ease reverse forwards; }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--rule); margin: 8px auto 0; flex-shrink: 0; }
.sheet .sheet-bar { display: flex; align-items: center; padding: 4px 12px 0 var(--page); min-height: 48px; flex-shrink: 0; }
.sheet .sheet-bar .folio { color: var(--ribbon); }
.sheet .sheet-bar .spacer { flex: 1; }
.sheet .sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 8px var(--page) 20px; flex: 1; }
.sheet .sheet-footer { display: flex; gap: 12px; padding: 12px var(--page); border-top: 0.5px solid var(--rule); background: var(--raised); flex-shrink: 0; }

@keyframes rise { from { transform: translateY(100%); } }
@keyframes sink { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* Capture */
.capture-center { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 22px var(--page) 8px; text-align: center; }
.capture-center h2 { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.45rem; }
.live-transcript { font-family: var(--serif); font-size: 1.12rem; line-height: 1.4; min-height: 3em; max-height: 170px; overflow-y: auto; }
.live-transcript .volatile { color: var(--ink2); }
.live-transcript .placeholder { color: var(--faint); }
.wave { height: 60px; display: flex; align-items: center; gap: 6px; }
.wave span { width: 6px; border-radius: 3px; background: var(--ribbon); height: 12px; transition: height .12s ease; animation: breathe 1.1s ease-in-out infinite; }
.wave span:nth-child(2) { animation-delay: .12s; }
.wave span:nth-child(3) { animation-delay: .24s; }
.wave span:nth-child(4) { animation-delay: .36s; }
.wave span:nth-child(5) { animation-delay: .48s; }
.wave span:nth-child(6) { animation-delay: .6s; }
.wave span:nth-child(7) { animation-delay: .72s; }
.wave.hot span { animation-duration: .55s; }
@keyframes breathe { 0%, 100% { height: 12px; opacity: .6; } 50% { height: 46px; opacity: 1; } }
.dots { display: flex; gap: 8px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--ribbon); animation: blink 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

.type-box {
  width: 100%;
  min-height: 120px;
  resize: none;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.35;
  outline: none;
}
.type-box:focus { border-color: var(--ribbon-line); }
.hint { font-size: 0.76rem; color: var(--ink2); display: flex; gap: 8px; align-items: flex-start; }
.hint svg.icon { margin-top: 1px; color: var(--faint); }

.review-head { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.review-head .saved { color: var(--moss); }
.kind-button, .category-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  background: none;
  border: 0;
  padding: 0;
}
.kind-button svg.chev { width: 12px; height: 12px; color: var(--faint); stroke-width: 2.4; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .title-input {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.2;
  padding: 0;
  outline: none;
  resize: none;
  overflow: hidden;
}
.when-line { display: flex; align-items: center; gap: 8px; min-height: 40px; background: none; border: 0; padding: 0; width: 100%; text-align: left; }
.when-line svg.icon { color: var(--ribbon); }
.when-line .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.when-line .value.empty { color: var(--faint); }
.when-line .edit { margin-left: auto; color: var(--faint); width: 14px; height: 14px; }
.detail-line { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--ink2); }
.detail-line svg.icon { width: 15px; height: 15px; color: var(--faint); }
.tags-line { font-size: 0.76rem; color: var(--faint); }
.transcript-quote { display: flex; align-items: baseline; gap: 6px; background: none; border: 0; padding: 4px 0; text-align: left; font-family: var(--serif); font-style: italic; font-size: 0.86rem; color: var(--ink2); line-height: 1.4; }
.transcript-quote svg.icon { width: 12px; height: 12px; color: var(--faint); flex-shrink: 0; }

.date-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border-radius: 12px; background: var(--raised); border: 1px solid var(--rule); }
.date-editor label { display: flex; flex-direction: column; gap: 4px; font-size: 0.72rem; color: var(--ink2); }
.date-editor .full { grid-column: 1 / -1; }

.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kind-choice {
  min-height: 92px;
  border-radius: 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
}
.kind-choice .emoji { font-size: 1.7rem; }
.kind-choice.first { background: var(--ribbon-soft); border-color: var(--ribbon-line); }

/* ── Forms (detail, settings) ────────────────────────────────────────── */

.form-section { margin-top: 18px; }
.form-section > .folio { display: block; padding: 0 4px 8px; color: var(--ink2); }
.form-group { background: var(--paper); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; }
.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 6px 14px;
  border-top: 0.5px solid var(--rule);
}
.form-row:first-child { border-top: 0; }
.form-row > .label { flex: 1; min-width: 0; }
.form-row > .label small { display: block; color: var(--ink2); font-size: 0.74rem; margin-top: 2px; }
.form-row.stack { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 14px; }
.form-row.action { background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; color: var(--ribbon); font-weight: 600; }
.form-row.action.danger { color: var(--ribbon); }
.form-row.action:active { background: var(--ribbon-soft); }
.form-row svg.icon { color: var(--faint); }

.field, select.field, textarea.field {
  border: 0;
  background: transparent;
  text-align: right;
  font-size: 1rem;
  padding: 6px 0;
  min-height: 38px;
  outline: none;
  max-width: 60%;
}
select.field { appearance: none; -webkit-appearance: none; color: var(--ribbon); font-weight: 500; text-align-last: right; padding-right: 2px; }
textarea.field, input.field.wide { text-align: left; max-width: none; width: 100%; resize: vertical; }
textarea.field { min-height: 80px; font-family: var(--serif); line-height: 1.4; }
input[type="date"].field, input[type="time"].field, input[type="datetime-local"].field { color: var(--ink); font-variant-numeric: tabular-nums; }
.date-editor input, .date-editor select { width: 100%; min-height: 40px; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); padding: 0 8px; }

.big-title-input {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 1.6rem;
  line-height: 1.2;
  padding: 4px 0;
  outline: none;
  resize: none;
}

/* iOS-style switch */
.switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 16px; background: var(--rule); transition: background .2s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.switch input:checked ~ .track { background: var(--ribbon); }
.switch input:checked ~ .knob { transform: translateX(20px); }
.switch input:focus-visible ~ .track { outline: 2px solid var(--ribbon); outline-offset: 2px; }

.alert-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px; border-radius: 17px; background: var(--raised); border: 1px solid var(--rule); font-size: 0.8rem; }
.alert-chip button { border: 0; background: none; padding: 0; color: var(--faint); display: inline-flex; }

/* ── Agenda ──────────────────────────────────────────────────────────── */

.mode-tabs { display: flex; gap: 20px; padding: 4px var(--page) 0; border-bottom: 0.5px solid var(--rule); }
.mode-tabs.sticky { position: sticky; top: 0; z-index: 4; background: var(--paper); }
.mode-tabs.sticky ~ .pager-bar { position: sticky; top: 45px; z-index: 4; background: var(--paper); border-bottom: 0.5px solid var(--rule); }
.mode-tabs button { min-height: 44px; padding: 0; background: none; border: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; font-size: 0.9rem; color: var(--faint); }
.mode-tabs button::after { content: ''; height: 2px; border-radius: 1px; background: transparent; }
.mode-tabs button[aria-current="true"] { color: var(--ink); font-weight: 600; }
.mode-tabs button[aria-current="true"]::after { background: var(--ribbon); }

.day-chapter {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px var(--page) 8px;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-bottom: 0.5px solid var(--rule);
}
.day-chapter .folio { color: var(--ink2); }
.day-chapter.today .folio, .day-chapter.overdue .folio { color: var(--ribbon); }
.day-chapter .chapter { font-size: 1.08rem; font-weight: 600; }

.pager-bar { display: flex; align-items: center; min-height: 44px; padding: 0 var(--page); font-size: 0.72rem; font-weight: 500; color: var(--faint); letter-spacing: .06em; }
.pager-bar button { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; min-height: 44px; color: inherit; font: inherit; text-transform: uppercase; }
.pager-bar .center { flex: 1; text-align: center; }
.pager-bar .center .folio.today { color: var(--ribbon); }

.day-page { touch-action: pan-y; }
.day-page.slide-left { animation: slideL .26s var(--ease); }
.day-page.slide-right { animation: slideR .26s var(--ease); }
@keyframes slideL { from { transform: translateX(30%); opacity: 0; } }
@keyframes slideR { from { transform: translateX(-30%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .day-page.slide-left, .day-page.slide-right { animation: fade .15s ease; }
  .sheet, .scrim { animation-duration: .01s; }
  .wave span { animation: none; height: 6px; }
}

.hour-grid { position: relative; margin-top: 8px; }
.hour-line { height: 64px; display: flex; align-items: flex-start; gap: 8px; padding: 0 var(--page) 0 8px; }
.hour-line .label { width: 42px; text-align: right; margin-top: -7px; font-size: 0.66rem; font-variant-numeric: tabular-nums; color: var(--faint); }
.hour-line .line { flex: 1; height: 0.5px; background: var(--rule); }
.block {
  position: absolute;
  box-sizing: border-box;
  padding: 5px 6px 5px 9px;
  border-radius: 8px;
  border: 0;
  border-left: 3px solid currentColor;
  display: flex;
  gap: 6px;
  overflow: hidden;
  text-align: left;
}
.block .t { font-family: var(--serif); font-size: 0.84rem; font-weight: 500; line-height: 1.2; color: var(--ink); }
.block .s { font-size: 0.66rem; font-variant-numeric: tabular-nums; color: var(--ink2); }
.block.k-reminder { background: var(--ribbon-soft); }
.block.k-event { background: var(--blue-soft); }
.block.k-task { background: var(--moss-soft); }
.block.done .t { text-decoration: line-through; color: var(--faint); }
.now-line { position: absolute; left: 54px; right: var(--page); height: 1.2px; background: var(--ribbon); }
.now-line::before { content: ''; position: absolute; left: -4px; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--ribbon); }

.week-day { display: flex; align-items: baseline; gap: 10px; padding: 18px var(--page) 4px; width: 100%; background: none; border: 0; text-align: left; }
.week-day .num { font-family: var(--serif); font-size: 1.25rem; }
.week-day .free { margin-left: auto; font-size: 0.76rem; color: var(--faint); }
.week-day.today .folio { color: var(--ribbon); }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 6px; padding: 0 var(--page); }
.month-grid .initial { text-align: center; font-size: 0.66rem; font-weight: 600; letter-spacing: .1em; color: var(--faint); padding-bottom: 4px; }
.month-cell { background: none; border: 0; padding: 0; min-height: 48px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.month-cell .n { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 1rem; color: var(--ink); }
.month-cell.out .n { color: var(--faint); }
.month-cell.today .n { box-shadow: inset 0 0 0 1px var(--ribbon); }
.month-cell.selected .n { background: var(--ribbon); color: var(--on-ribbon); font-weight: 600; }
.month-cell .marks { display: flex; gap: 3px; height: 4px; }
.month-cell .marks i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }

/* ── Notes ───────────────────────────────────────────────────────────── */

.search-field {
  margin: 12px var(--page) 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--raised);
  border: 1px solid var(--rule);
  color: var(--faint);
}
.search-field input { flex: 1; border: 0; background: transparent; outline: none; font-family: var(--serif); font-size: 1rem; color: var(--ink); min-height: 42px; }
.search-field input::placeholder { color: var(--faint); }
.search-field input::-webkit-search-cancel-button { -webkit-appearance: none; }

.note-row { display: flex; gap: 16px; padding: 12px 0; margin: 0 var(--page); border: 0; border-bottom: 0.5px solid var(--rule); background: none; width: calc(100% - 2 * var(--page)); text-align: left; color: inherit; }
.note-row .date { width: 40px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.note-row .date .d { font-family: var(--serif); font-size: 1.4rem; line-height: 1.1; }
.note-row .date .folio { color: var(--faint); letter-spacing: .12em; }
.note-row .texts { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.note-row .head { display: flex; align-items: center; gap: 5px; }
.note-row .head svg.icon { width: 15px; height: 15px; }
.note-row .preview { font-size: 0.78rem; line-height: 1.35; color: var(--ink2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-row .tags { font-size: 0.76rem; color: var(--faint); }

.note-page { padding: 8px var(--page) 30px; display: flex; flex-direction: column; gap: 14px; }
.note-page .top { display: flex; align-items: center; gap: 10px; }
.note-page .top .folio { color: var(--ink2); }
.note-page .top .grow { flex: 1; }
.note-content {
  width: 100%;
  min-height: 240px;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.6;
  outline: none;
  resize: none;
  padding: 0;
}
.note-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note-tags .tag { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 12px; border-radius: 16px; background: var(--raised); border: 1px solid var(--rule); font-size: 0.76rem; color: var(--ink2); }
.note-tags input { width: 110px; border: 0; background: none; outline: none; font-size: 0.76rem; min-height: 32px; }
.note-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.note-images figure { margin: 0; position: relative; }
.note-images img { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; display: block; }
.note-images button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 14px; border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: flex; align-items: center; justify-content: center; }
details.transcript summary { font-size: 0.76rem; color: var(--ink2); cursor: pointer; min-height: 32px; display: flex; align-items: center; }
details.transcript p { font-family: var(--serif); font-style: italic; font-size: 0.86rem; color: var(--ink2); margin: 4px 0 0; white-space: pre-wrap; }

.menu-pop {
  position: fixed;
  z-index: 45;
  min-width: 220px;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  padding: 6px;
  animation: fade .15s ease;
  max-height: 60vh;
  overflow-y: auto;
}
.menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: none; text-align: left; font-size: 0.95rem; }
.menu-pop button:active, .menu-pop button[aria-checked="true"] { background: var(--ribbon-soft); }
.menu-pop button.danger { color: var(--ribbon); }
.menu-pop hr { border: 0; height: 0.5px; background: var(--rule); margin: 4px 8px; }

/* ── Toast ───────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 34px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  min-height: 48px;
  width: max-content;
  max-width: min(calc(100vw - 32px), 460px);
  border-radius: 24px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: toastIn .3s var(--ease);
  font-size: 0.9rem;
}
.toast span { flex: 1; min-width: 0; }
.toast button { flex-shrink: 0; border: 0; background: none; color: var(--paper); font-weight: 700; min-height: 36px; padding: 0 10px; text-decoration: underline; text-underline-offset: 3px; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ── Onboarding ──────────────────────────────────────────────────────── */

.onboarding { position: fixed; inset: 0; z-index: 70; background: var(--paper); display: flex; flex-direction: column; padding: calc(var(--safe-top) + 28px) 28px calc(var(--safe-bottom) + 24px); }
.onboarding .page-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.onboarding .page-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--rule); }
.onboarding .page-dots i.on { width: 18px; background: var(--ribbon); }
.onboarding .content { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; max-width: 520px; margin: 0 auto; width: 100%; }
.onboarding h1 { font-family: var(--serif); font-weight: 400; font-size: 2.2rem; line-height: 1.1; margin: 0; }
.onboarding p { margin: 0; font-family: var(--serif); font-size: 1.1rem; line-height: 1.45; color: var(--ink2); }
.onboarding .examples { display: flex; flex-direction: column; gap: 10px; }
.onboarding .examples div { font-family: var(--serif); font-style: italic; padding: 12px 14px; border-left: 2px solid var(--ribbon); background: var(--raised); border-radius: 0 12px 12px 0; }
.onboarding .steps { display: flex; flex-direction: column; gap: 12px; padding: 0; margin: 0; list-style: none; counter-reset: step; }
.onboarding .steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 1rem; line-height: 1.4; }
.onboarding .steps li::before { counter-increment: step; content: counter(step); flex-shrink: 0; width: 26px; height: 26px; border-radius: 13px; background: var(--ribbon); color: var(--on-ribbon); font-weight: 700; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; }
.onboarding .steps svg.icon { vertical-align: -3px; color: var(--blue); }
.onboarding .mark { width: 72px; height: 72px; border-radius: 18px; }

/* Wider screens: the book stays a book. */
@media (min-width: 700px) {
  :root { --page: 32px; }
  .sheet { border-radius: 28px; bottom: 16px; }
  .sheet.large { top: 24px; bottom: 24px; }
}
