/* Grain — the native app's look (Design/GrainTheme.swift). The iPhone app is dark everywhere: grainBg #0D0C0A,
   grainCard #1F1C17, grainAccent #C99339 (the AccentColor), grainText #F0EAE0, grainMuted #6E6558, a warm centre
   bloom, a top vignette and animated film grain; light serif for writing (New York), monospaced caps for labels,
   ultra-light serif for big numbers. Dark is the default here too; html.paper is the web-only Light appearance (warm
   paper, the same amber). Alerts, dialogs and the NavigationStack sheets follow whichever Grain is showing. */
:root {
  --bg: #0D0C0A; --surface: #161412; --card: #1F1C17; --accent: #C99339; --accent-ink: #C99339; --accent-dim: rgba(201, 147, 57, 0.12);
  --text: #F0EAE0; --text-88: rgba(240, 234, 224, 0.88); --text-60: rgba(240, 234, 224, 0.6); --text-55: rgba(240, 234, 224, 0.55);
  --muted: #6E6558; --muted-40: rgba(110, 101, 88, 0.4); --muted-30: rgba(110, 101, 88, 0.3); --muted-20: rgba(110, 101, 88, 0.2); --muted-12: rgba(110, 101, 88, 0.12);
  --line: rgba(51, 46, 39, 0.5); --rule: rgba(201, 147, 57, 0.28); --on-accent: #0D0C0A;
  --bloom: rgba(51, 36, 15, 0.55); --vignette: rgba(0, 0, 0, 0.25);
  --glass-card: rgba(37, 33, 28, 0.62); --glass-card-tint: rgba(201, 147, 57, 0.04);
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sys: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  /* system surfaces (alerts, dialogs, the NavigationStack sheets) in dark */
  --sys-bg: #1c1c1e; --row: #2c2c2e; --sep: rgba(84, 84, 88, 0.6); --fill: rgba(120, 120, 128, 0.32); --fill2: rgba(118, 118, 128, 0.24);
  --alert: rgba(44, 44, 46, 0.9); --sys-text: #fff; --sys-text2: rgba(235, 235, 245, 0.6); --red: rgb(255, 69, 58); --green: rgb(48, 209, 88);
  --glass: rgba(70, 66, 60, 0.55); --glass-edge: rgba(255, 255, 255, 0.1);
  color-scheme: dark;
}
html.paper {
  --bg: #F3EDE2; --surface: #ECE4D6; --card: #FBF7F0; --accent: #C99339; --accent-ink: #8E5D12; --accent-dim: rgba(201, 147, 57, 0.16);
  --text: #2A231A; --text-88: rgba(42, 35, 26, 0.88); --text-60: rgba(42, 35, 26, 0.6); --text-55: rgba(42, 35, 26, 0.55);
  --muted: #8A7D6A; --muted-40: rgba(138, 125, 106, 0.55); --muted-30: rgba(138, 125, 106, 0.4); --muted-20: rgba(138, 125, 106, 0.28); --muted-12: rgba(138, 125, 106, 0.16);
  --line: rgba(120, 98, 66, 0.2); --rule: rgba(142, 93, 18, 0.3); --on-accent: #1E160A;
  --bloom: rgba(226, 184, 110, 0.32); --vignette: rgba(120, 90, 40, 0.06);
  --glass-card: rgba(255, 252, 246, 0.72); --glass-card-tint: rgba(201, 147, 57, 0.06);
  --sys-bg: #f2f2f7; --row: #fff; --sep: rgba(60, 60, 67, 0.22); --fill: rgba(120, 120, 128, 0.16); --fill2: rgba(118, 118, 128, 0.12);
  --alert: rgba(250, 250, 250, 0.9); --sys-text: #000; --sys-text2: rgba(60, 60, 67, 0.6); --red: rgb(255, 59, 48); --green: rgb(52, 199, 89);
  --glass: rgba(255, 255, 255, 0.7); --glass-edge: rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 17px/1.29 var(--sys); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; letter-spacing: inherit; }
button:disabled { cursor: default; }
html.touch #app button, html.touch #lock button { min-height: 0; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-title:focus, .keypad:focus, textarea:focus-visible { outline: none; }
[hidden] { display: none !important; }
p, h1, h2, h3 { margin: 0; font-weight: inherit; font-size: inherit; }
.sf { display: inline-block; vertical-align: -0.125em; flex: none; overflow: visible; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 0; min-height: 12px; }

/* ---------- type (GrainFont) ---------- */
.display { font-family: var(--serif); font-weight: 200; line-height: 1.12; color: var(--text); letter-spacing: -0.005em; font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); font-weight: 300; }
.g-label { font-family: var(--mono); font-weight: 500; line-height: 1.25; white-space: nowrap; }
.accent { color: var(--accent-ink); }
.muted { color: var(--muted); }
.italic { font-style: italic; }
.pad { padding-left: calc(28px + var(--sal)); padding-right: calc(28px + var(--sar)); }

/* ---------- GrainBackground ---------- */
#app { position: fixed; inset: 0; overflow: hidden; background: var(--bg); }
.grain-noise, .noise { position: absolute; inset: 0; pointer-events: none; background-image: var(--noise); background-size: 200px 200px; mix-blend-mode: screen; animation: grain-shift 0.48s steps(1) infinite; }
html.paper .grain-noise, html.paper .noise { mix-blend-mode: multiply; }
@keyframes grain-shift { 0% { background-position: 0 0; } 17% { background-position: -61px -137px; } 33% { background-position: -143px -29px; } 50% { background-position: -17px -91px; } 67% { background-position: -109px -173px; } 83% { background-position: -181px -53px; } }
@media (prefers-reduced-motion: reduce) { .grain-noise, .noise { animation: none; } }
.page-bloom, .bloom { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, var(--vignette), transparent 15%), radial-gradient(55vh 55vh at 50% 35%, var(--bloom), transparent 100%); }
#stage { position: absolute; inset: 0; z-index: 1; }
#sheets { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
#sheets > * { pointer-events: auto; }
#overlays { position: absolute; inset: 0; z-index: 40; pointer-events: none; }
#overlays > * { pointer-events: auto; }
#toast { position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 104px); z-index: 50; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
#lock { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
#lock > * { pointer-events: auto; }
html.locked #app { visibility: hidden; }

/* ---------- the paged TabView + floating capsule tab bar ---------- */
.main { position: absolute; inset: 0; }
.detail { position: absolute; inset: 0; }
.sidebar { display: none; }
.pager { position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.pager::-webkit-scrollbar { display: none; }
.page { position: relative; flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: flex; flex-direction: column; overflow: hidden; }
.page-scroll { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.page-scroll::-webkit-scrollbar { display: none; }
.page-content { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 680px; margin: 0 auto; }
.tabbar { position: absolute; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); width: min(calc(100% - 32px), 420px); z-index: 5; display: flex; padding: 14px 32px; border-radius: 999px;
  background: var(--card); box-shadow: inset 0 0 0 0.5px var(--line), 0 8px 40px rgba(0, 0, 0, 0.4); }
html.paper .tabbar { box-shadow: inset 0 0 0 0.5px var(--line), 0 8px 34px rgba(90, 64, 24, 0.16); }
.tab-btn { flex: 1 1 0; display: grid; place-items: center; padding: 4px 0; color: var(--muted); font-size: 18px; transition: color 0.25s; }
.tab-btn .sf path, .tab-btn .sf circle { stroke-width: 1.25; }
.tab-btn.on { color: var(--accent); }
.tab-btn.on .sf path, .tab-btn.on .sf circle { stroke-width: 2; }
html.onboarding-open .tabbar { display: none; }

/* iPad / desktop: NavigationSplitView(.balanced) */
html.wide .main { display: grid; grid-template-columns: minmax(280px, 320px) 1fr; }
html.wide .detail { position: relative; inset: auto; }
html.wide .sidebar { position: relative; display: flex; flex-direction: column; padding: calc(var(--sat) + 52px) 12px 24px calc(12px + var(--sal)); background: var(--surface); box-shadow: inset -0.5px 0 0 var(--line); overflow-y: auto; }
html.wide .tabbar { display: none; }
html.wide .pager { overflow: hidden; scroll-snap-type: none; display: block; }
html.wide .page { width: 100%; }
.side-title { position: relative; font: 700 34px/1.2 var(--sys); letter-spacing: 0.01em; padding: 0 12px 14px; color: var(--text); }
.side-list { position: relative; display: flex; flex-direction: column; gap: 2px; }
.side-row { display: flex; align-items: center; gap: 14px; padding: 11px 12px; border-radius: 12px; font-size: 17px; color: var(--accent-ink); }
.side-row .sf { font-size: 20px; width: 24px; }
.side-row:hover { background: var(--accent-dim); }
.side-row.on { background: var(--accent-dim); }

/* ---------- GrainDivider, FilmCounterBadge, GrainDot ---------- */
.g-divider { height: 0.5px; background: var(--rule); flex: none; }
.g-divider.labeled { height: auto; background: none; display: flex; align-items: center; gap: 12px; }
.gd-line { flex: 1 1 auto; height: 0.5px; background: var(--rule); }
.film-counter { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; background: var(--card); box-shadow: inset 0 0 0 0.5px var(--line); }
.fc-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.g-dot { position: relative; display: inline-block; width: var(--s); height: var(--s); border-radius: 50%; background: var(--muted-20); flex: none; }
.g-dot.filled { background: var(--accent); }
.g-dot.today::after { content: ""; position: absolute; left: 50%; top: 50%; width: calc(var(--s) + 4px); height: calc(var(--s) + 4px); margin: calc(var(--s) / -2 - 2px); border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--accent); }
.primary-btn { display: flex; align-items: center; justify-content: center; width: 100%; padding: 16px 20px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-family: var(--mono); font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; transition: transform 0.15s var(--ease), filter 0.15s; }
.primary-btn:active:not(:disabled) { transform: scale(0.98); filter: brightness(0.94); }
.close-btn { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--card); color: var(--muted); font-size: 14px; }
.close-btn .sf path { stroke-width: 1.3; }
.plain-icon { width: 44px; height: 44px; display: grid; place-items: center; color: var(--muted); font-size: 16px; }
.outline-capsule { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px 16px; border-radius: 999px; color: var(--accent-ink); box-shadow: inset 0 0 0 0.5px rgba(201, 147, 57, 0.4); font-size: 13px; }
.outline-capsule:active { background: var(--accent-dim); }
.ghost-capsule { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px; color: var(--accent-ink); box-shadow: inset 0 0 0 0.5px rgba(201, 147, 57, 0.45); font: 500 10px var(--mono); letter-spacing: 1.5px; text-transform: uppercase; }
.ghost-capsule .sf { font-size: 13px; }
.mini-capsule { padding: 8px 12px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: 500 10px var(--mono); letter-spacing: 1px; flex: none; }
.text-btn { padding: 6px 10px; }
.text-accent { color: var(--accent-ink); font-family: var(--mono); font-weight: 500; padding: 4px 0 4px 10px; }
.g-card { background: var(--card); border-radius: 18px; }
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(13, 12, 10, 0.25); border-top-color: var(--on-accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* glass toolbar items (iOS 26) */
.glass { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; min-width: 44px; padding: 0 16px; border-radius: 22px; font-size: 17px; color: var(--sys-text);
  background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.8); backdrop-filter: blur(16px) saturate(1.8); box-shadow: 0 0 0 0.5px var(--glass-edge), 0 4px 16px rgba(0, 0, 0, 0.1); transition: transform 0.15s var(--ease), opacity 0.15s; white-space: nowrap; }
.glass-icon { padding: 0; width: 44px; }
.glass .sf { font-size: 20px; }
.glass-bold { font-weight: 600; }
.glass-prominent { background: var(--accent); color: var(--on-accent); font-weight: 600; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); }
.glass:active:not(:disabled) { transform: scale(0.94); }
.glass:disabled { opacity: 0.35; }
.glass-prominent:disabled { background: var(--fill); color: var(--sys-text2); opacity: 1; }
/* the muted app-grid button: the way back to the Yuzool store */
.glass-subtle { width: 34px; height: 34px; min-width: 0; color: var(--muted); background: rgba(240, 234, 224, 0.05); box-shadow: inset 0 0 0 0.5px rgba(240, 234, 224, 0.1); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4); }
html.paper .glass-subtle { background: rgba(42, 35, 26, 0.04); box-shadow: inset 0 0 0 0.5px rgba(42, 35, 26, 0.1); }
.glass-subtle .sf { font-size: 16px; }
.glass-subtle .sf rect { stroke-width: 1.4; }
.glass-subtle:hover { color: var(--text-60); }

/* ================================================================ Today */
.today-header { position: relative; flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: calc(var(--sat) + 16px); width: 100%; max-width: 680px; margin: 0 auto; }
.th-date { display: flex; flex-direction: column; gap: 4px; padding-top: 10px; min-width: 0; }
.th-date .display { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-side { display: flex; flex-direction: column; align-items: flex-end; gap: 14px; flex: none; }
.th-buttons { display: flex; align-items: center; gap: 4px; margin-right: -10px; }
.streak-badge { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.streak-n { font-size: 26px; color: var(--accent); line-height: 1; }
.today-content { gap: 52px; padding-top: 36px; padding-bottom: calc(140px + var(--sab)); }
.entry-section { display: flex; flex-direction: column; gap: 16px; }
.editor-wrap { position: relative; }
.entry-editor { display: block; width: 100%; min-height: 130px; padding: 8px 0 8px 0; margin: 0; border: 0; outline: none; resize: none; overflow: hidden; background: transparent; color: var(--text); caret-color: var(--accent); font: 300 23px/1.32 var(--serif); }
.entry-editor::selection { background: rgba(201, 147, 57, 0.35); }
.entry-placeholder { position: absolute; left: 0; top: 0; right: 0; padding: 8px 0 0 5px; color: var(--muted); font: 300 23px/1.32 var(--serif); pointer-events: none; }
.entry-meta { display: flex; align-items: center; min-height: 16px; }
.saved-ind { display: inline-flex; align-items: center; gap: 5px; }
.saved-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.saved-ind.draft .saved-dot { background: transparent; box-shadow: inset 0 0 0 1px var(--accent); }
.remaining { font-variant-numeric: tabular-nums; transition: color 0.3s; }
.lock-note { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--accent-dim); }
.lock-note p { font: 300 15px/1.35 var(--serif); color: var(--text-88); }
.on-this-day { display: flex; flex-direction: column; gap: 24px; }
.past-card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; border-radius: 18px;
  background: linear-gradient(var(--glass-card-tint), var(--glass-card-tint)), var(--glass-card); -webkit-backdrop-filter: blur(24px) saturate(1.5); backdrop-filter: blur(24px) saturate(1.5); box-shadow: inset 0 0 0 0.5px rgba(201, 147, 57, 0.1); }
.pc-head { display: flex; align-items: baseline; justify-content: space-between; }
.pc-text { font-size: 18px; line-height: calc(18px * 1.2 + 5px); color: var(--text-88); white-space: pre-wrap; overflow-wrap: anywhere; }
.pc-share { display: flex; justify-content: flex-end; }
.share-moment { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-ink); opacity: 0.75; padding: 4px 0; }
.share-moment .sf { font-size: 11px; }
.share-moment:hover { opacity: 1; }

/* ================================================================ Memories */
.memories-content { gap: 34px; padding-top: calc(var(--sat) + 28px); padding-bottom: calc(130px + var(--sab)); }
.mem-header { display: flex; flex-direction: column; gap: 8px; }
.mem-title { line-height: 45px; }
.mem-section { display: flex; flex-direction: column; gap: 16px; }
.mem-section.tight { gap: 14px; }
.memory-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.mc-text { font-size: 19px; line-height: calc(19px * 1.2 + 4px); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.lb-row { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; }
.lb-key { width: 58px; flex: none; padding-top: 3px; }
.lb-text { font-size: 15px; line-height: 1.32; color: var(--text); overflow-wrap: anywhere; }
.lb-text.muted { color: var(--muted); }
.year-block { display: flex; flex-direction: column; gap: 12px; }
.yb-head { display: flex; align-items: baseline; justify-content: space-between; }
.year-strip { display: flex; align-items: center; gap: 5px; padding: 14px; }
.ys-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ys-bar { width: 100%; border-radius: 3px; background: var(--muted-12); }
.ys-bar.on { background: rgba(201, 147, 57, var(--o)); }
.recap-row { display: flex; gap: 12px; }
.recap-card { flex: 1 1 0; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
.rc-icon { font-size: 18px; }
.empty-card { padding: 18px; }
.threads-head { display: flex; align-items: center; gap: 8px; }
.threads-head .g-divider { flex: 1 1 auto; }
.thread-row, .export-row { display: flex; align-items: center; gap: 14px; padding: 16px; width: 100%; text-align: left; transition: transform 0.15s var(--ease), background 0.2s; }
.thread-row:active, .export-row:active { transform: scale(0.985); }
.tr-icon { font-size: 18px; display: grid; }
.tr-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tr-title { font-size: 18px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-chev { font-size: 15px; display: grid; }
.export-row.busy { opacity: 0.6; pointer-events: none; }

/* ================================================================ Calendar */
.calendar-content { padding-top: calc(var(--sat) + 16px); padding-bottom: calc(100px + var(--sab)); }
.month-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 28px; }
.mh-text { display: flex; flex-direction: column; gap: 4px; }
.mh-chevrons { display: flex; gap: 4px; }
.chev { padding: 8px; color: var(--muted); font-size: 14px; display: grid; border-radius: 50%; transition: opacity 0.2s; }
.chev:disabled { opacity: 0.2; }
.stats-row { display: flex; align-items: center; padding-bottom: 32px; }
.stat-cell { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.stat-sep { width: 0.5px; height: 32px; flex: none; }
.calendar-content > .g-divider { margin-bottom: 24px; }
.dow-row { display: grid; grid-template-columns: repeat(7, 1fr); justify-items: center; margin-bottom: 14px; }
.day-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 14px; }
.day-cell { display: flex; flex-direction: column; align-items: center; gap: 5px; min-height: 32px; padding: 2px 0; }
.day-cell .day-n { font-variant-numeric: tabular-nums; color: var(--muted-40); }
.day-cell.today .day-n { color: var(--accent-ink); }
.day-cell.filled .day-n { color: var(--text-60); }
.day-cell.future .day-n { color: var(--muted-20); }
.day-cell:not(:disabled):active { transform: scale(0.9); }

/* ================================================================ sheets */
.sheet-wrap { position: absolute; inset: 0; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
html.paper .sheet-backdrop { background: rgba(40, 28, 10, 0.25); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; top: calc(var(--sat) + 10px); display: flex; flex-direction: column; border-radius: 38px 38px 0 0; overflow: hidden; background: var(--bg); color: var(--text); box-shadow: 0 -2px 30px rgba(0, 0, 0, 0.35); }
.sheet-bg { position: absolute; inset: 0; pointer-events: none; }
.sheet-grabber { position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: currentColor; opacity: 0.25; z-index: 5; }
.sheet-body { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: none; padding-bottom: var(--sab); }
.sheet-body::-webkit-scrollbar { display: none; }
.sheet-content { min-height: 100%; display: flex; flex-direction: column; }
@media (min-width: 700px) and (min-height: 600px) {
  .sheet { top: 50% !important; left: 50%; right: auto; bottom: auto; width: min(560px, calc(100% - 48px)); height: min(820px, calc(100% - 64px)); translate: -50% -50%; border-radius: 32px; }
  .sheet-grabber { display: none; }
}
/* NavigationStack sheets (New Memory Thread, a thread): iOS chrome */
.nav-sheet { background: var(--sys-bg); color: var(--sys-text); }
.navbar { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center; gap: 8px; min-height: 60px; padding: 12px 16px 6px; flex: none; }
.nav-title { grid-column: 2; font: 600 17px/22px var(--sys); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-leading { grid-column: 1; display: flex; gap: 8px; justify-self: start; }
.nav-trailing { grid-column: 3; display: flex; gap: 8px; justify-self: end; }
.large-title { font: 700 34px/41px var(--sys); letter-spacing: 0.01em; padding: 0 20px 6px; overflow-wrap: anywhere; }
.form-col { max-width: 640px; width: 100%; margin: 0 auto; padding: 0 16px 28px; }
.group { margin-top: 18px; }
.group-header { padding: 0 20px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--sys-text2); }
.group-rows { background: var(--row); border-radius: 26px; overflow: hidden; }
.row { position: relative; display: flex; align-items: center; width: 100%; min-height: 52px; padding: 12px 20px; gap: 12px; text-align: left; color: var(--sys-text); }
.group-rows > .row + .row::before { content: ""; position: absolute; left: 20px; right: 0; top: 0; border-top: 0.5px solid var(--sep); }
.form-field { width: 100%; border: 0; outline: none; background: transparent; font-size: 17px; color: var(--sys-text); caret-color: var(--accent); }
.form-field::placeholder { color: var(--sys-text2); opacity: 0.6; }
.thread-entry { align-items: flex-start; }
.thread-entry:active { background: var(--fill2); }
.te-check { color: var(--accent); font-size: 22px; display: grid; padding-top: 1px; }
.te-check .sf path, .te-check .sf circle { stroke-width: 1.4; }
.te-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.te-sentence { color: var(--text); font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.sys-muted { color: var(--muted); }
.muted-row { color: var(--sys-text2); }
.group-rows > .thread-entry + .thread-entry::before { left: 54px; }

/* ---------- Settings (Grain's own sheet) ---------- */
.set-top { position: relative; flex: none; display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 16px; padding-bottom: 32px; }
.set-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--muted); opacity: 0.35; }
.set-titlebar { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.set-body { position: relative; padding-bottom: 60px; }
.set-scroll-col { display: flex; flex-direction: column; gap: 28px; max-width: 560px; margin: 0 auto; }
.set-section { display: flex; flex-direction: column; }
.set-title { padding: 0 4px 10px; }
.set-card { background: var(--card); border-radius: 18px; box-shadow: inset 0 0 0 0.5px var(--line); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; text-align: left; color: var(--text); }
.set-row.tappable:active { background: var(--accent-dim); }
.sr-icon { width: 22px; flex: none; display: grid; place-items: center; font-size: 17px; }
.sr-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sr-title { font: 300 15px/1.3 var(--sys); }
.sr-text .g-label { white-space: normal; }
.sr-chev { font-size: 12px; display: grid; }
.set-sep { padding: 0 16px; }
.set-foot { padding: 0 16px 14px; font: 400 11px/1.45 var(--mono); color: var(--muted); }
.version-row { padding: 14px 16px; }
.wheel-wrap { padding: 4px 8px 8px; }
.seg { display: flex; gap: 2px; margin: 12px; padding: 2px; border-radius: 999px; background: var(--muted-12); }
.seg-btn { flex: 1 1 0; padding: 8px 4px; border-radius: 999px; text-align: center; font: 500 11px var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--muted); transition: background 0.25s, color 0.25s; }
.seg-btn.on { background: var(--accent); color: var(--on-accent); }
.seg + .set-foot { padding-top: 0; }

/* Toggle (.tint(Color.grainAccent)) */
.switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 63px; height: 28px; margin: 0; border-radius: 14px; background: var(--fill); cursor: pointer; transition: background 0.25s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 37px; height: 24px; border-radius: 12px; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16); transition: transform 0.3s var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(22px); }

/* DatePicker(.wheel) */
.wheel { position: relative; display: flex; justify-content: center; height: 170px; -webkit-mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent); mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent); user-select: none; -webkit-user-select: none; }
.wheel-band { position: absolute; left: 4px; right: 4px; top: 68px; height: 34px; border-radius: 9px; background: var(--muted-20); pointer-events: none; }
.wheel-col { position: relative; height: 170px; width: 64px; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain; }
.wheel-col::-webkit-scrollbar { display: none; }
.wheel-col:focus-visible { outline: none; }
.wheel-col:focus-visible .wheel-item.on { color: var(--accent-ink); }
.wheel-pad { height: 68px; }
.wheel-item { height: 34px; display: grid; place-items: center; scroll-snap-align: center; font: 400 21px var(--sys); font-variant-numeric: tabular-nums; color: var(--text-55); }
.wheel-item.on { color: var(--text); }

/* ---------- the entry (EntryDetailSheet) ---------- */
.es-col { position: relative; flex: 1 1 auto; display: flex; flex-direction: column; gap: 28px; padding: calc(28px + 8px) 28px calc(28px + var(--sab)); max-width: 560px; width: 100%; margin: 0 auto; }
.es-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.es-head > div { display: flex; flex-direction: column; gap: 4px; }
.es-text { font-size: 22px; line-height: calc(22px * 1.2 + 7px); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.es-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- the paywall ---------- */
.pw-col { position: relative; flex: 1 1 auto; display: flex; flex-direction: column; align-items: stretch; max-width: 520px; width: 100%; margin: 0 auto; padding-bottom: calc(24px + var(--sab)); }
.pw-close { display: flex; justify-content: flex-end; padding-top: 20px; margin-right: -8px; }
.pw-head { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; padding-bottom: 48px; }
.pw-head > p, .pw-head .pw-small { margin-top: -12px; }
.pw-small { white-space: normal; padding: 0 24px; }
.pw-badge { width: 88px; height: 88px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-size: 40px; color: var(--accent); }
.pw-badge .sf circle { stroke-width: 1; }
.pw-features { display: flex; flex-direction: column; gap: 20px; padding-bottom: 48px; }
.pw-feature { display: flex; align-items: center; gap: 16px; }
.pw-ficon { width: 24px; display: grid; place-items: center; font-size: 18px; }
.pw-ftext { font: 300 15px var(--sys); color: var(--text); }
.pw-col > .g-divider { margin-bottom: 36px; }
.pw-buy { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.pw-price { display: flex; align-items: baseline; gap: 0; }
.pw-cta { padding: 18px 20px; }
.pw-owned { display: flex; align-items: center; gap: 8px; padding: 16px; color: var(--accent-ink); }
.pw-note { font: 400 10px/1.5 var(--mono); color: var(--muted); text-align: center; max-width: 360px; opacity: 0.85; }

/* ---------- onboarding ---------- */
.onboarding { position: absolute; inset: 0; }
.ob-store { position: absolute; top: calc(var(--sat) + 14px); left: calc(16px + var(--sal)); z-index: 3; }
.ob-col { position: relative; height: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; padding-top: var(--sat); padding-bottom: calc(48px + var(--sab)); }
.ob-stage { position: relative; }
.ob-page { display: flex; flex-direction: column; gap: 32px; }
.ob-title-block { display: flex; flex-direction: column; gap: 8px; }
.ob-tag { font-size: 28px; line-height: calc(28px * 1.2 + 8px); color: var(--text); }
.ob-sub { font-size: 16px; line-height: calc(16px * 1.2 + 4px); }
.ob-h2 { font-size: 30px; line-height: calc(30px * 1.2 + 6px); color: var(--text); }
.concept-list { display: flex; flex-direction: column; gap: 20px; }
.concept-row { display: flex; align-items: flex-start; gap: 14px; }
.cr-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-30); margin-top: 7px; flex: none; }
.accent-row .cr-dot { background: var(--accent); }
.cr-text { display: flex; flex-direction: column; gap: 3px; }
.cr-text p { font-size: 16px; line-height: calc(16px * 1.2 + 3px); color: var(--text-55); }
.accent-row .cr-text p { font-size: 18px; line-height: calc(18px * 1.2 + 3px); color: var(--text); }
#ob-page-2 { gap: 28px; }
.ob-first-head { display: flex; flex-direction: column; gap: 8px; }
.ob-editor-wrap .entry-editor, .ob-editor-wrap .entry-placeholder { font-size: 21px; }
.ob-editor-wrap .entry-placeholder { padding-left: 0; }
.ob-editor { height: 120px; min-height: 120px; overflow-y: auto; }
.ob-indicator { display: flex; justify-content: center; gap: 6px; }
.ob-indicator i { width: 6px; height: 6px; border-radius: 3px; background: var(--muted-30); transition: width 0.3s cubic-bezier(0.34, 1.32, 0.5, 1), background 0.3s; }
.ob-indicator i.on { width: 18px; background: var(--accent); }

/* ---------- the passcode ---------- */
.lock-screen { position: absolute; inset: 0; background: var(--bg); color: var(--text); display: flex; align-items: center; justify-content: center; overflow-y: auto; }
.lock-screen::before { content: ""; position: absolute; inset: 0; background-image: var(--noise); background-size: 200px 200px; mix-blend-mode: screen; opacity: 1; pointer-events: none; }
html.paper .lock-screen::before { mix-blend-mode: multiply; }
.lock-col { position: relative; display: flex; flex-direction: column; align-items: center; gap: 26px; padding: calc(var(--sat) + 24px) 24px calc(var(--sab) + 24px); }
.lock-logo { font-size: 40px; }
.keypad { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.kp-title { font-size: 22px; color: var(--text); }
.kp-sub { white-space: normal; text-align: center; min-height: 13px; }
.kp-dots { display: flex; gap: 18px; padding: 10px 0 18px; }
.kp-grid { display: grid; grid-template-columns: repeat(3, 76px); gap: 18px 24px; }
.kp-key { width: 76px; height: 76px; border-radius: 50%; background: var(--card); box-shadow: inset 0 0 0 0.5px var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; transition: background 0.12s, transform 0.12s; -webkit-user-select: none; user-select: none; }
.kp-key:active { background: var(--accent-dim); transform: scale(0.95); }
.kp-digit { font: 200 32px/1 var(--serif); color: var(--text); }
.kp-letters { font: 500 8px var(--mono); letter-spacing: 2px; color: var(--muted); margin-top: 3px; padding-left: 2px; }
.kp-del { background: none; box-shadow: none; color: var(--muted); font-size: 24px; }
.kp-forgot { margin-top: 6px; }
.pc-col { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 48px 24px calc(48px + var(--sab)); }

/* ---------- toast, alert, confirmation dialog, banner ---------- */
.toast { display: flex; align-items: center; gap: 10px; max-width: 520px; padding: 12px 18px; border-radius: 999px; color: var(--text); background: var(--card); box-shadow: inset 0 0 0 0.5px var(--line), 0 10px 30px rgba(0, 0, 0, 0.35); font-size: 15px; font-weight: 400; opacity: 0; transform: translateY(14px); transition: opacity 0.25s, transform 0.35s var(--ease); pointer-events: auto; }
.toast.on { opacity: 1; transform: none; }
.toast .sf { color: var(--accent); font-size: 18px; }
.alert-wrap { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.4); padding: 24px; }
.alert { width: 300px; max-width: 100%; border-radius: 30px; background: var(--alert); color: var(--sys-text); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); padding: 22px 18px 16px; }
.alert-title { font-weight: 600; font-size: 17px; }
.alert-message { font-size: 15px; line-height: 20px; margin-top: 6px; }
.alert-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.alert-buttons.two { flex-direction: row; }
.alert-btn { flex: 1; min-height: 48px; border-radius: 24px; background: var(--fill2); font-size: 17px; font-weight: 500; text-align: center; color: var(--sys-text); }
.alert-btn:not(.cancel):not(.destructive) { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.alert-btn.destructive { color: var(--red); }
.alert-buttons:not(.two) .alert-btn.cancel:only-child { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.alert-btn:active { opacity: 0.7; }
.asheet-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.asheet-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); }
.asheet { position: relative; width: 100%; max-width: 440px; padding: 0 8px calc(var(--sab) + 8px); display: flex; flex-direction: column; gap: 8px; }
.asheet-group { border-radius: 26px; overflow: hidden; background: var(--alert); color: var(--sys-text); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8); }
.asheet-head { padding: 14px 18px 12px; text-align: center; border-bottom: 0.5px solid var(--sep); }
.asheet-title { font-size: 13px; font-weight: 600; color: var(--sys-text2); }
.asheet-msg { font-size: 13px; line-height: 17px; margin-top: 3px; color: var(--sys-text2); }
.asheet-btn { display: block; width: 100%; min-height: 56px; text-align: center; font-size: 19px; color: var(--accent-ink); }
html:not(.paper) .asheet-btn { color: var(--accent); }
.asheet-group .asheet-btn + .asheet-btn { border-top: 0.5px solid var(--sep); }
.asheet-btn.destructive { color: var(--red) !important; }
.asheet-btn:active { background: var(--fill2); }
.asheet-cancel { border-radius: 26px; background: var(--alert); font-weight: 600; -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8); }
@media (min-width: 700px) { .asheet-wrap { justify-content: center; } }
.nbanner { position: absolute; top: calc(var(--sat) + 8px); left: 50%; width: min(400px, calc(100% - 16px)); margin-left: max(-200px, calc(-50% + 8px)); display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 24px; text-align: left; color: var(--sys-text);
  background: var(--alert); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), 0 0 0 0.5px var(--glass-edge); z-index: 60; }
.nb-icon { width: 38px; height: 38px; border-radius: 9px; flex: none; }
.nb-icon-fallback { display: grid; place-items: center; background: #2a2018; color: var(--accent); font: 400 22px var(--serif); }
.nb-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.nb-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--sys-text2); letter-spacing: 0.3px; }
.nb-title { font-size: 15px; font-weight: 600; margin-top: 1px; }
.nb-body { font-size: 15px; line-height: 1.25; }

@media (max-width: 360px) { .pad { padding-left: calc(20px + var(--sal)); padding-right: calc(20px + var(--sar)); } .kp-grid { grid-template-columns: repeat(3, 68px); gap: 14px 20px; } .kp-key { width: 68px; height: 68px; } }
@media (prefers-reduced-motion: reduce) { .ob-indicator i, .switch::after, .tab-btn { transition: none; } }
