/* =====================================================================
   "Your notes. Your style." redesign layer (loaded last).
   Colours come from the theme studio (src/theme.js), written onto <body>:
   --wall-base background · --card-solid / --card-ink note cards ·
   --head headings · --ink / --text-secondary text · --accent / --accent-ink buttons ·
   --c1..--c3 (+ -ink) bento card colours · --mesh pastel gradient background.
   ===================================================================== */

:root {
  --display: 'Google Sans', 'Sarabun', system-ui, sans-serif;
}

/* ---------- Wallpaper: two soft glows, or a pastel mesh ---------- */
body[data-tint="studio"] .wallpaper .orb-c,
body[data-tint="studio"] .wallpaper .orb-d { opacity: 0; }
body[data-tint="studio"] .wallpaper .orb-a,
body[data-tint="studio"] .wallpaper .orb-b { opacity: .55; filter: blur(80px); }
body[data-tint="studio"][data-theme="dark"] .wallpaper .orb-a,
body[data-tint="studio"][data-theme="dark"] .wallpaper .orb-b { opacity: .34; filter: blur(90px); }
body[data-mesh="true"] .wallpaper { background: var(--mesh); }
body[data-mesh="true"] .wallpaper .orb { opacity: .28 !important; }
body[data-mesh="true"][data-theme="dark"] .wallpaper .orb { opacity: .18 !important; }

/* ---------- Headings use the derived heading colour ---------- */
body[data-tint="studio"] #page-title,
body[data-tint="studio"] .note-card .card-title,
body[data-tint="studio"] .dialog-heading h2,
body[data-tint="studio"] .page-head h2 { color: var(--head); }

/* ---------- Multi-colour (bento) note cards ---------- */
body[data-multi="true"] .note-card:nth-child(3n+1) { --ink: var(--c1-ink); --head: var(--c1-ink); --text-secondary: var(--c1-ink); --muted: var(--c1-ink); background: var(--c1) !important; }
body[data-multi="true"] .note-card:nth-child(3n+2) { --ink: var(--c2-ink); --head: var(--c2-ink); --text-secondary: var(--c2-ink); --muted: var(--c2-ink); background: var(--c2) !important; }
body[data-multi="true"] .note-card:nth-child(3n+3) { --ink: var(--c3-ink); --head: var(--c3-ink); --text-secondary: var(--c3-ink); --muted: var(--c3-ink); background: var(--c3) !important; }
body[data-multi="true"] .note-card .card-preview,
body[data-multi="true"] .note-card .card-footer,
body[data-multi="true"] .note-card .card-date { opacity: .82; }

/* =====================================================================
   Settings: grouped list + pages
   ===================================================================== */
.settings-sheet form { display: block; }
.settings-page[hidden] { display: none !important; }
.settings-page { display: grid; gap: 14px; }
.settings-page .field-label { margin-top: 4px; }
.set-title { font: 700 30px/1.1 var(--display); letter-spacing: -.02em; }
.profile-card { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 22px; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
.profile-card .avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--accent); color: var(--accent-ink); flex: none; }
.profile-card b { display: block; font-size: 16px; }
.profile-card small { display: block; color: var(--text-secondary); font-size: 13px; overflow-wrap: anywhere; }
.profile-card > div { min-width: 0; flex: 1; }
.plan-badge { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 4px 9px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); flex: none; }
.set-group { display: grid; gap: 6px; }
.set-group > small { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); padding: 0 8px; }
.set-rows { border-radius: 20px; overflow: hidden; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
.set-row { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto 12px; gap: 12px; align-items: center; min-height: 52px; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--ink); cursor: pointer; text-decoration: none; }
.set-row:last-child { border-bottom: 0; }
.set-row:hover { background: rgba(127, 127, 127, .07); }
.set-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.set-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); font-size: 14px; font-weight: 700; color: var(--ink); }
.set-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-row em { font-style: normal; font-size: 13px; color: var(--text-secondary); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-row .chev { font-style: normal; color: var(--text-secondary); font-size: 18px; }
.set-row.danger, .set-row.danger .set-ic { color: var(--danger); }
.page-head { display: grid; gap: 6px; }
.page-back { all: unset; cursor: pointer; justify-self: start; color: var(--accent-text, var(--accent)); font-weight: 600; font-size: 15px; padding: 6px 2px; min-height: 32px; }
.page-back:focus-visible { outline: 2px solid var(--accent); border-radius: 8px; }
.page-head h2 { font: 700 26px/1.15 var(--display); margin: 0; letter-spacing: -.02em; }

/* ---------- Theme studio ---------- */
.studio-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.studio-preset { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px 6px 6px; border-radius: 99px; border: 1px solid var(--line); background: rgba(var(--g-rgb), var(--g-alpha-control)); color: var(--ink); font: 600 13px var(--app-font, inherit); cursor: pointer; }
.studio-preset i { width: 26px; height: 26px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.studio-preset.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.studio-pickers { display: grid; gap: 10px; }
.picker { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 12px; align-items: center; cursor: pointer; }
.picker input[type="color"] { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 14px; padding: 3px; background: rgba(var(--g-rgb), var(--g-alpha-control)); cursor: pointer; }
.picker b { display: block; font-size: 14px; }
.picker small { display: block; font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.picker code { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.token-table { overflow-x: auto; border-radius: 16px; border: 1px solid var(--line); }
.token-table table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 420px; }
.token-table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.token-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.token-table tr:last-child td { border-bottom: 0; }
.token-table .role b { display: block; font-weight: 600; font-size: 13px; }
.token-table .role small { color: var(--text-secondary); }
.sw { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sw i { width: 20px; height: 20px; border-radius: 6px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .4); }
.ratio { font-size: 10.5px; font-weight: 700; padding: 2px 5px; border-radius: 6px; }
.ratio.ok { background: rgba(46, 160, 90, .16); color: var(--success); }
.ratio.low { background: rgba(214, 80, 60, .16); color: var(--danger); }

/* Live mini preview at the top of the studio */
.studio-preview { border-radius: 24px; padding: 14px; display: grid; gap: 10px; background: var(--wall-base); border: 1px solid var(--line); position: relative; overflow: hidden; isolation: isolate; }
body[data-mesh="true"] .studio-preview { background: var(--mesh); }
.studio-preview::before { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; background: var(--orb-a); filter: blur(40px); opacity: .45; top: -80px; right: -60px; z-index: -1; }
.sp-head { display: flex; align-items: center; gap: 10px; }
.sp-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.sp-lines { display: grid; gap: 5px; }
.sp-lines i { display: block; height: 7px; width: 90px; border-radius: 4px; background: var(--head); }
.sp-lines i + i { width: 60px; background: var(--text-secondary); opacity: .7; }
.sp-bento { display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; }
.sp-today { border-radius: 18px; background: var(--accent); min-height: 70px; padding: 10px; display: grid; gap: 5px; align-content: start; }
.sp-today small, .sp-today b, .sp-today span { display: block; height: 6px; border-radius: 3px; background: var(--accent-ink); opacity: .55; width: 40%; }
.sp-today b { height: 9px; width: 75%; opacity: .9; }
.sp-today span { margin-top: auto; height: 14px; width: 48%; opacity: 1; border-radius: 99px; }
.sp-tiles { display: grid; gap: 8px; }
.sp-tiles i { border-radius: 14px; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); }
.sp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp-card { height: 46px; border-radius: 14px; background: var(--card-solid); border: 1px solid var(--line); display: block; }
body[data-multi="true"] .sp-c1 { background: var(--c1); }
body[data-multi="true"] .sp-c2 { background: var(--c2); }

/* =====================================================================
   Home
   ===================================================================== */
.glassy, .hello-avatar, .space-pill, .home-header .icon-button, .week-day, .quick-tile, .chip, .note-list,
.hint-card, .empty-card, .starter, .dock, .layout-toggle {
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.6); backdrop-filter: blur(var(--g-blur)) saturate(1.6);
}

/* Header: greeting on the left, space + search on the right */
:root body .home-header { position: relative; z-index: 8; height: auto; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) clamp(16px, 5vw, 74px) 10px; background: transparent !important; border: 0 !important; box-shadow: none !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
.hello { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; min-width: 0; }
.hello:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 14px; }
.hello-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 16px; background: var(--accent) !important; color: var(--accent-ink) !important; flex: none; }
.hello-text { display: grid; min-width: 0; }
.hello-text b { font-size: 16px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hello-text small { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root body .home-header .top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
:root body .home-header .icon-button { width: 40px; height: 40px; min-width: 40px; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--ink);
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
:root body .home-header .icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root body .space-pill { margin: 0; display: inline-flex; align-items: center; gap: 6px; height: 40px; max-width: 42vw; padding: 0 14px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--ink);
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
.space-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-pill i { font-style: normal; font-size: 11px; opacity: .7; }

:root body .content-area { padding-top: 6px; }
.home-hero { display: grid; gap: 12px; margin-bottom: 18px; }
.home-hero[hidden], .section-head[hidden], .chip-row[hidden], .home-hints[hidden], .bento[hidden] { display: none !important; }

/* Week strip (kept short) */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.week-day { all: unset; box-sizing: border-box; cursor: pointer; text-align: center; border-radius: 16px; padding: 5px 0 6px; font-size: 11px; line-height: 1.25; color: var(--text-secondary);
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); min-height: 50px; }
.week-day b { display: block; font-size: 15px; color: var(--ink); line-height: 1.3; }
.week-day .dot { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 1px auto 0; }
.week-day.today { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.week-day.today b { color: var(--accent-ink); }
.week-day.today .dot { background: var(--accent-ink); }
.week-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Bento: "today" card + two shortcuts */
.bento { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; }
.today-card { all: unset; box-sizing: border-box; cursor: pointer; border-radius: 26px; padding: 16px; display: grid; gap: 6px; align-content: start; min-height: 148px;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 12px 26px color-mix(in srgb, var(--accent) 28%, transparent), inset 0 1px 0 rgba(255, 255, 255, .35); }
.today-card small { font-size: 12px; font-weight: 700; opacity: .92; }
.today-card b { font: 700 19px/1.25 var(--display); }
.today-card .today-years { font: 600 13px var(--app-font, inherit); opacity: .92; }
.today-card .pill { justify-self: start; align-self: end; margin-top: auto; background: var(--accent-ink); color: var(--accent-on-ink, var(--accent)); padding: 6px 12px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.today-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.quick-tiles { display: grid; gap: 10px; }
.quick-tile { all: unset; box-sizing: border-box; cursor: pointer; border-radius: 22px; padding: 12px 14px; display: grid; gap: 4px; align-content: center; font-size: 14px; font-weight: 600; color: var(--ink);
  background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
.quick-tile svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--accent-text, var(--accent)); }
.quick-tile:focus-within, .quick-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Search, chips and section head */
:root body .search-row { margin: 0 0 14px; }
:root body .search-row input { font-size: 16px; padding: 12px 16px; border-radius: 18px; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip { all: unset; box-sizing: border-box; cursor: pointer; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--ink);
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); }
.chip em { font-style: normal; opacity: .6; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--ink); color: var(--wall-base); border-color: transparent; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 2px 10px; }
.section-head h2 { margin: 0; font: 700 19px/1.2 var(--display); color: var(--head); letter-spacing: -.01em; }
.section-tools { display: flex; align-items: center; gap: 6px; }
.section-tools small { font-size: 12.5px; color: var(--text-secondary); margin-right: 2px; font-variant-numeric: tabular-nums; }
.layout-toggle { all: unset; box-sizing: border-box; cursor: pointer; width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; color: var(--text-secondary); }
.layout-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.layout-toggle[aria-pressed="true"] { background: rgba(var(--g-rgb), var(--g-alpha-control)); color: var(--ink); border: 1px solid var(--g-edge-soft); }
.layout-toggle[hidden], .select-mini[hidden] { display: none !important; }
.select-mini { font-size: 13px !important; font-weight: 700; color: var(--accent-text, var(--accent)) !important; padding: 6px 4px !important; }
:root body .event-banners { margin-bottom: 14px; }

:root body .note-management { margin: 0 0 12px; }

/* Compact note cards */
:root body .note-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
:root body .note-card { border-radius: 22px; padding: 14px; min-height: 0; gap: 4px;
  background-color: var(--card-solid); border: 1px solid var(--g-edge-soft); box-shadow: inset 0 1px 0 var(--g-edge-soft), 0 6px 18px rgba(0, 0, 0, .06); color: var(--card-ink, var(--ink)); }
:root body .note-card:nth-child(n) { background-color: color-mix(in srgb, var(--card-solid) 88%, transparent); }
:root body .note-card .card-top { min-height: 0; }
:root body .note-card .card-date { font-size: 11px; color: var(--text-secondary); letter-spacing: 0; }
:root body .note-card .card-title { font: 700 16px/1.3 var(--note-title-font, var(--display)); margin: 6px 0 2px; color: var(--head); }
:root body .note-card .card-preview { font-size: 13px; line-height: 1.55; -webkit-line-clamp: 3; color: var(--text-secondary); }
:root body .note-card .card-image { height: 84px; margin-top: 8px; border-radius: 14px; order: -1; }
:root body .note-card .card-footer { padding-top: 10px; font-size: 11px; color: var(--text-secondary); }
:root body .note-card .card-tools { opacity: 0; transition: opacity .15s; }
:root body .note-card:hover .card-tools, :root body .note-card:focus-within .card-tools,
:root body .selection-mode .note-card .card-tools, :root body .trash-mode .note-card .card-tools { opacity: 1; }
@media (hover: none) { :root body .note-grid:not(.selection-mode):not(.trash-mode) .note-card .card-tools { display: none; } }

/* Dense list for many notes */
.note-grid.list-layout { display: block; }
.group-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); margin: 14px 6px 6px; }
.group-label:first-child { margin-top: 0; }
.note-list { border-radius: 22px; overflow: hidden; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
:root body .note-card.note-row { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 14px; min-height: 58px;
  border-radius: 0; border: 0; border-bottom: 1px solid var(--line); background: transparent !important; box-shadow: none; transform: none; }
:root body .note-card.note-row:last-child { border-bottom: 0; }
:root body .note-card.note-row:hover { background: rgba(127, 127, 127, .06) !important; box-shadow: none; transform: none; }
.note-row .row-dot { width: 9px; height: 9px; border-radius: 50%; }
.note-row .row-text { min-width: 0; display: grid; }
:root body .note-row .card-title { font: 600 15px/1.35 var(--app-font, inherit); margin: 0; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-row .row-text span { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-row small { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.note-row .card-select { display: none; }
.selection-mode .note-row { grid-template-columns: 9px minmax(0, 1fr) auto 32px; }
.selection-mode .note-row .card-select { display: grid; }
/* Rows sit on one shared glass panel, so they keep the page's text colours even with multi-colour cards on
   (the bento rule would give them ink meant for a light tile, unreadable on a dark panel). */
.note-list { --row-ink: var(--ink); --row-ink2: var(--text-secondary); }
:root body .note-list .note-card.note-row { --ink: var(--row-ink); --head: var(--row-ink); --text-secondary: var(--row-ink2); --muted: var(--row-ink2); }
:root body .note-list .note-card.note-row .card-title, :root body .note-list .note-row .row-text span, :root body .note-list .note-row small { opacity: 1; }
.show-more { display: block; margin: 14px auto 0; }
.show-more[hidden] { display: none !important; }

/* Hints that fill the space when there are only a few notes */
.home-hints { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.hint-card { all: unset; box-sizing: border-box; cursor: pointer; border-radius: 20px; padding: 12px 14px; font-size: 12.5px; color: var(--text-secondary); border: 1.5px dashed color-mix(in srgb, var(--ink) 24%, transparent); }
.hint-card b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
.hint-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Empty state */
:root body .empty-state { padding: 0; text-align: center; }
:root body .empty-state.visible { display: grid; gap: 12px; }
.empty-card { border-radius: 28px; padding: 22px 18px; display: grid; gap: 8px; justify-items: center; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
:root body .empty-state .empty-art { width: 96px; height: 96px; margin: 0 0 6px; border-radius: 38% 62% 55% 45% / 45% 40% 60% 55%; background: var(--accent) !important; color: var(--accent-ink); transform: none; box-shadow: inset -10px -12px 0 rgba(0, 0, 0, .12); font-size: 38px; border: 0; }
:root body .empty-state h2 { font: 700 21px/1.2 var(--display); color: var(--head); margin: 0; }
:root body .empty-state p { margin: 0; font-size: 13.5px; color: var(--text-secondary); }
.starters { display: grid; gap: 8px; }
.starter { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: center; text-align: left; min-height: 52px; padding: 10px 14px; border-radius: 20px;
  font-size: 14.5px; font-weight: 600; color: var(--ink); background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
.starter i { font-style: normal; width: 32px; height: 32px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); }
.starter.primary-starter { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.starter.primary-starter i { background: rgba(255, 255, 255, .25); }
.starter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.starter.hidden, :root body .empty-state.trash-empty .starters { display: none !important; }
:root body .empty-state.trash-empty .empty-art { border-radius: 30px; background: rgba(var(--g-rgb), var(--g-alpha-control)) !important; color: var(--text-secondary); box-shadow: none; }

/* Collections sheet: trash row */
.trash-row { margin-top: 8px; }
.trash-row svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* =====================================================================
   Phone: floating glass dock with a raised + in the middle
   ===================================================================== */
@media (max-width: 760px) {
  :root body .home-header { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .top-wide-action, :root body .home-header #share-space { display: none !important; }
  :root body .content-area { padding: 4px max(16px, env(safe-area-inset-right)) calc(120px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  :root body .note-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  :root body .note-grid.list-layout { display: block; }
  :root body .note-card { padding: 12px; border-radius: 20px; }
  :root body .note-card .card-title { font-size: 15px; }
  :root body .note-card .card-preview { font-size: 12.5px; }
  :root body .note-card .card-image { height: 64px; }
  :root body .welcome-row { margin-bottom: 14px; }
  :root body .welcome-row #new-note-top { display: none; }
  :root body .mobile-nav.dock { position: fixed; top: auto; left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 20; height: 66px; min-height: 66px; padding: 0 10px; border-radius: 34px; display: flex; align-items: center; justify-content: space-around; gap: 0; overflow: visible;
    background: rgba(var(--g-rgb), var(--g-alpha-strong)) !important; border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow-lift); }
  :root body .dock .mobile-nav-item { width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 24px; border: 0 !important; background: transparent !important; box-shadow: none !important; color: var(--text-secondary); flex-direction: column; gap: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
  :root body .dock .mobile-nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }
  :root body .dock .mobile-nav-item span, :root body .dock .mobile-nav-item i { display: none; }
  :root body .dock .mobile-nav-item.active { color: var(--ink); background: color-mix(in srgb, var(--ink) 10%, transparent) !important; }
  :root body .dock .mobile-new-note { width: 60px; height: 60px; border-radius: 30px; margin-top: -28px; background: var(--accent) !important; color: var(--accent-ink) !important;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .5) !important; }
  :root body .dock .mobile-new-note svg { width: 28px; height: 28px; stroke-width: 2; }
  :root body .dock .mobile-new-note.hidden { display: flex !important; visibility: hidden; }
  :root body .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (min-width: 761px) {
  :root body .mobile-nav.dock { display: none; }
  /* The week strip that used to sit beside the cards is gone (Kô, 1 Dec), so the cards take the whole width
     (iPad: they used to fill only the left half). */
  .home-hero { grid-template-columns: minmax(0, 1fr); }
  .bento { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}
@media (max-width: 380px) {
  .hello-text small { display: none; }
  .space-pill { max-width: 36vw; }
  .today-card { min-height: 132px; padding: 14px; }
  .today-card b { font-size: 17px; }
}

/* Dock: five equal slots, one shape for every item, one active style (soft or pill from Settings) */
@media (max-width: 760px) {
  :root body .mobile-nav.dock { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); justify-items: center; padding: 0 6px; }
  :root body .dock .mobile-nav-item { width: 48px; height: 48px; border-radius: 50% !important; outline: none; position: relative; transition: background-color .15s ease, color .15s ease; transform: none !important; }
  :root body .dock .mobile-nav-item:hover { transform: none; }
  :root body .dock .mobile-nav-item.active { background: color-mix(in srgb, var(--ink) 9%, transparent) !important; color: var(--ink); }
  :root body .dock .mobile-nav-item.active::after { content: ""; position: absolute; bottom: 4px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); }
  :root body[data-nav="pill"] .dock .mobile-nav-item.active { background: var(--accent) !important; color: var(--accent-ink); }
  :root body[data-nav="pill"] .dock .mobile-nav-item.active::after { background: var(--accent-ink); }
  :root body .dock .mobile-nav-item:focus-visible { box-shadow: 0 0 0 2px var(--accent) !important; }
  :root body .dock .mobile-new-note { width: 60px; height: 60px; }
  :root body .dock .mobile-new-note::after { display: none; }
}

/* =====================================================================
   Editor: writing first
   ===================================================================== */
:root body .editor-toolbar { display: flex; align-items: center; gap: 8px; border-bottom: 0 !important; background: transparent !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
:root body #close-editor { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px; border-radius: 99px; font-size: 14px; font-weight: 600; color: var(--ink);
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }
:root body #close-editor svg { width: 18px; height: 18px; }
:root body .editor-toolbar .save-status { display: inline-flex !important; align-items: center; gap: 6px; margin: 0 auto; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
:root body .editor-toolbar .save-status:not(:empty)::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
:root body .editor-toolbar .save-status[data-state="editor.saving"]::before, :root body .editor-toolbar .save-status[data-state="editor.uploading"]::before { background: var(--accent); }
:root body .editor-toolbar .save-status[data-state="editor.saveFailed"]::before { background: var(--danger); }
:root body .editor-actions { display: flex; align-items: center; gap: 8px; }
.presence { display: flex; }
.presence .avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--accent); color: var(--accent-ink); border: 2px solid var(--wall-base); }
.presence .avatar + .avatar { margin-left: -9px; background: var(--c2, var(--accent-soft)); color: var(--c2-ink, var(--ink)); }
.presence .avatar.more { background: rgba(var(--g-rgb), var(--g-alpha-strong)); color: var(--ink); }
:root body .more-button { width: 40px; height: 40px; min-width: 40px; border-radius: 50%; display: grid; place-items: center; padding: 0; font-size: 20px; line-height: 1; color: var(--ink);
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow); }

/* Meta chips: collection · date · who can see */
:root body .editor-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
:root body .editor-meta input, :root body .editor-meta select, :root body .editor-meta .visibility-toggle {
  height: 34px; min-height: 34px; padding: 0 12px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--ink); width: auto; max-width: 100%;
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); box-shadow: none; }
:root body .editor-meta select { padding-right: 26px; }

/* Title and body */
:root body #note-content { font-size: var(--note-font-size, 17px); line-height: 1.75; }
:root body #note-content h1 { font-family: var(--note-title-font, var(--display)); font-weight: 700; letter-spacing: -.02em; color: var(--head); }

/* Format capsule */
.fmt-aa, .fmt-image, .fmt-menu { display: none; }
.fmt-panel { display: contents; }
.comment-pill { display: none; }
.editor-menu .set-rows { margin-top: 2px; }
.editor-menu .set-row[hidden] { display: none; }
.editor-menu label.set-row { cursor: pointer; }

@media (max-width: 760px) {
  :root body .editor-toolbar { height: auto; min-height: 60px; padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); position: sticky; top: 0; z-index: 5; }
  :root body .editor-toolbar .attach-top-button, :root body .editor-toolbar #delete-note, :root body .editor-toolbar #done-editor { display: none !important; }
  :root body .editor-meta #note-lock { display: none; }
  :root body .editor-body { padding: 0 max(18px, env(safe-area-inset-right)) calc(150px + var(--kb, 0px)) max(18px, env(safe-area-inset-left)); }
  :root body .editor-main { padding-top: 4px; }
  :root body #note-content h1 { font-size: 30px; line-height: 1.15; }

  :root body .format-sidebar { position: fixed; top: auto !important; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom) + var(--kb, 0px)); transform: translateX(-50%); z-index: 6;
    width: auto; max-width: calc(100vw - 24px); padding: 0 !important; border: 0; background: transparent !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; box-shadow: none; }
  :root body .format-toolbar { display: flex !important; flex-wrap: nowrap; align-items: center; gap: 4px; padding: 6px; border-radius: 99px; grid-template-columns: none;
    background: rgba(var(--g-rgb), var(--g-alpha-strong)) !important; border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow-lift);
    -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.7); backdrop-filter: blur(var(--g-blur)) saturate(1.7); position: relative; }
  :root body .format-toolbar > button, :root body .format-toolbar > label { width: 42px; height: 42px; min-width: 42px; min-height: 42px; padding: 0; border-radius: 50%; display: grid; place-items: center;
    font-size: 16px; font-weight: 700; color: var(--ink); background: transparent; border: 0; box-shadow: none; }
  :root body .format-toolbar > button.active { background: color-mix(in srgb, var(--ink) 12%, transparent); }
  .fmt-aa, .fmt-image, .fmt-menu { display: grid !important; }
  :root body .fmt-aa { background: var(--accent) !important; color: var(--accent-ink) !important; font-family: var(--display); }
  .fmt-image svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .fmt-panel { display: none; }
  .panel-open .fmt-panel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); padding: 8px; border-radius: 22px;
    background: rgba(var(--g-rgb), var(--g-alpha-strong)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow-lift);
    -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.7); backdrop-filter: blur(var(--g-blur)) saturate(1.7); }
  .panel-open .fmt-panel > button { width: 40px; height: 40px; border-radius: 12px; }
  .panel-open .fmt-panel select { flex: 1 1 110px; height: 40px; font-size: 16px; border-radius: 12px; }
  .panel-open .fmt-panel .toolbar-divider { display: none; }
  .comment-pill:not([hidden]) { display: inline-flex; position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(86px + env(safe-area-inset-bottom) + var(--kb, 0px)); z-index: 6;
    align-items: center; height: 36px; padding: 0 14px; border-radius: 99px; font: 600 13px var(--app-font, inherit); color: var(--ink); cursor: pointer;
    background: rgba(var(--g-rgb), var(--g-alpha-strong)); border: 1px solid var(--g-edge-soft); box-shadow: var(--g-shadow);
    -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.6); backdrop-filter: blur(var(--g-blur)) saturate(1.6); }
  .editor-dialog:has(.panel-open) .comment-pill { display: none; }
}
:root body .editor-meta > * { flex: 0 0 auto; }
:root body .editor-meta input[type="date"] { width: 148px; }
:root body .editor-meta select { width: auto; max-width: 60vw; }

/* =====================================================================
   Space & sharing sheet
   ===================================================================== */
.space-sheet .dialog-heading h2 { font: 700 24px/1.15 var(--display); }
.space-sub { display: block; margin-top: 2px; font-size: 13px; color: var(--text-secondary); }
:root body .space-sheet .member-list { gap: 0; border-radius: 20px; overflow: hidden; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); }
:root body .space-sheet .member-list li { padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
:root body .space-sheet .member-list li:last-child { border-bottom: 0; }
:root body .space-sheet .member-list .avatar { width: 36px; height: 36px; background: var(--c2, var(--accent-soft)); color: var(--c2-ink, var(--ink)); }
:root body .space-sheet .member-list li:first-child .avatar { background: var(--accent); color: var(--accent-ink); }
:root body .space-sheet .member-list b { font-size: 14.5px; }
:root body .space-sheet .member-list small { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc { font-style: normal; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.acc.owner { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
:root body .space-sheet .member-access { height: 34px; min-height: 34px; padding: 0 26px 0 12px; border-radius: 99px; font-size: 13px; font-weight: 600; width: auto; }
.space-invite-block { display: grid; gap: 8px; margin-top: 6px; }
.space-invite-block[hidden] { display: none; }
.access3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.access3 button { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 2px; justify-items: center; text-align: center; padding: 10px 4px; border-radius: 16px; font-size: 12.5px; color: var(--ink);
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--g-edge-soft); }
.access3 button span { font-size: 18px; }
.access3 button b { font-weight: 600; }
.access3 button.selected { border: 2px solid var(--accent); background: var(--accent-soft); padding: 9px 3px; }
.access3 button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.space-invite-block .primary-button { margin-top: 2px; border-radius: 99px; min-height: 46px; font-weight: 700; }
.btn-leave { all: unset; box-sizing: border-box; cursor: pointer; display: block; width: 100%; text-align: center; margin-top: 16px; padding: 12px; border-radius: 99px; font-size: 14px; font-weight: 700; color: var(--danger); border: 1px solid var(--line); }
.btn-leave[hidden] { display: none; }
.btn-leave:focus-visible { outline: 2px solid var(--danger); outline-offset: 2px; }

/* Sidebar footer (wide screens): avatar · name and email · settings · sign out, never squeezed */
:root body .sidebar-bottom { display: grid; grid-template-columns: 38px minmax(0, 1fr) 36px 36px; gap: 8px; align-items: center; padding: 14px 2px 0; }
:root body .sidebar-bottom #user-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
:root body .sidebar-bottom > div { min-width: 0; }
:root body .sidebar-bottom strong { display: block; font-size: 14px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root body .sidebar-bottom small { display: block; font-size: 11.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
:root body .sidebar-bottom .settings-trigger { width: 36px; height: 36px; min-width: 36px; margin: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; }
:root body .sidebar-bottom .settings-trigger svg { width: 18px; height: 18px; }
/* Settings already lives in the sidebar on wide screens and in the dock on phones */
.top-wide-action { display: none !important; }
/* Sign out moved into Settings → Account & data, which leaves room for the name and email */
:root body .sidebar-bottom { grid-template-columns: 38px minmax(0, 1fr) 36px; cursor: pointer; border-radius: 16px; }
:root body .sidebar-bottom #logout { display: none; }

/* =====================================================================
   Touch comfort
   ===================================================================== */
/* Focus rings only when moving with the keyboard */
html:not(.kbd) :focus-visible { outline: none !important; }
html:not(.kbd) .dock .mobile-nav-item:focus-visible { box-shadow: none !important; }
/* No lift-on-hover on touch screens (iOS keeps :hover after a tap, so things looked pressed) */
@media (hover: none) {
  :root body .note-card:hover, .mobile-nav-item:hover, .icon-button:hover, .settings-trigger:hover, .theme-options button:hover, .password-toggle:hover,
  .primary-button:hover, .secondary-button:hover, .text-button:hover, .share-button:hover, .calendar-step:hover, .space-option:hover { transform: none !important; }
  :root body .note-card:hover { box-shadow: inset 0 1px 0 var(--g-edge-soft), 0 6px 18px rgba(0, 0, 0, .06); }
}
/* A light press effect instead, only while the finger is down */
.set-row:active, .starter:active, .quick-tile:active, .chip:active, .week-day:active, .today-card:active, .hint-card:active, :root body .note-card:active { filter: brightness(.96); }

/* Settings pages: back and close stay at the top while scrolling */
.page-bar { position: sticky; top: -18px; z-index: 2; display: flex; align-items: center; justify-content: space-between; margin: -18px -18px 0; padding: 12px 14px 8px;
  background: rgba(var(--g-rgb), var(--g-alpha-strong)); -webkit-backdrop-filter: blur(var(--g-blur)) saturate(1.6); backdrop-filter: blur(var(--g-blur)) saturate(1.6); border-radius: 26px 26px 0 0; }
.page-bar .page-close { width: 38px; height: 38px; }
.picker { cursor: default; }
@media (min-width: 761px) { .page-bar { top: -24px; margin: -24px -24px 0; padding: 14px 18px 8px; } }
.settings-page .page-head { display: contents; }
@media (max-width: 760px) {
  .token-table table { min-width: 0; }
  .token-table .sw code { display: none; }
  .token-table td, .token-table th { padding: 8px; }
}
.page-bar { background: var(--wall-base); box-shadow: 0 1px 0 var(--line); }

/* Phones: the glow behind the glass stays put. Its slow drift made every glass layer repaint
   all the time, which delayed taps (measured: tap → sheet 318 ms moving vs 171 ms still). */
@media (hover: none) {
  .wallpaper .orb { animation: none !important; will-change: auto; }
}
/* Taps fire straight away (no waiting to see whether it is a double-tap zoom) */
html, button, a, label, input, select, textarea, [role="button"] { touch-action: manipulation; }

/* Keyboard open: the editor is exactly the free space above the keyboard, so the capsule
   belongs at the bottom of that space. */
@media (max-width: 760px) {
  html.keyboard-open body .format-sidebar { bottom: calc(10px + var(--kb, 0px) + var(--kb-fix, 0px)) !important; }
  html.keyboard-open body .comment-pill { display: none !important; }
  html.keyboard-open body .editor-body { padding-bottom: calc(110px + var(--kb-room, var(--kb, 0px))); }
}

/* Sheets keep their own scrolling (no chaining to the page behind) */
dialog { overscroll-behavior: contain; }
/* Phones: note cards and lists skip the second blur. The wallpaper behind them is already a soft
   blur and no longer moves, so they look the same, but scrolling no longer re-blurs every card. */
@media (hover: none) {
  :root body .note-card, :root body .note-list, :root body .home-header .icon-button, :root body .space-pill, .hello-avatar, .week-day, .quick-tile, .chip, .starter, .empty-card, .set-rows, .profile-card {
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  }
}

/* =====================================================================
   Phone speed and steadiness (round 3)
   ===================================================================== */
@media (hover: none) {
  /* The editor covers the whole screen, so blurring what is behind it was pure cost. */
  :root body .editor-dialog::backdrop { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: rgba(0, 0, 0, .2); }
  /* Sheets dim the page instead of re-blurring the whole screen; the sheet itself stays glass. */
  :root body .small-dialog::backdrop { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: rgba(20, 16, 28, .32); }
  :root body[data-theme="dark"] .small-dialog::backdrop { background: rgba(0, 0, 0, .5); }
}
/* The note screen itself never slides around; only the writing area scrolls, without bouncing the page. */
:root body .editor-dialog { overscroll-behavior: none; }
@media (max-width: 760px) {
  :root body .editor-dialog { overflow: hidden; }
  :root body .editor-form { height: 100%; overflow: hidden; }
  :root body .editor-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; min-height: 0; }
}

/* Phones: the note screen covers everything, so instead of blurring the whole page through glass on
   every open and close (heavy on iPhone), it paints the same soft glows itself. Looks the same. */
@media (max-width: 760px) {
  :root body .editor-dialog {
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
    background:
      radial-gradient(48% 30% at 30% 28%, color-mix(in srgb, var(--orb-a) 80%, transparent), transparent 75%),
      radial-gradient(60% 34% at 100% 6%, color-mix(in srgb, var(--orb-b) 70%, transparent), transparent 75%),
      radial-gradient(55% 30% at 35% 100%, color-mix(in srgb, var(--orb-a) 35%, transparent), transparent 75%),
      var(--wall-base) !important;
  }
  :root body[data-theme="dark"] .editor-dialog {
    background:
      radial-gradient(48% 30% at 30% 28%, color-mix(in srgb, var(--orb-a) 42%, transparent), transparent 75%),
      radial-gradient(60% 34% at 100% 6%, color-mix(in srgb, var(--orb-b) 40%, transparent), transparent 75%),
      radial-gradient(55% 30% at 35% 100%, color-mix(in srgb, var(--orb-a) 22%, transparent), transparent 75%),
      var(--wall-base) !important;
  }
  body[data-mesh="true"] .editor-dialog { background: var(--mesh) !important; }
}

/* Until the first real render, keep the page content out of sight (no flash of the old layout). */
body.booting .main-panel, body.booting .sidebar, body.booting .mobile-nav { visibility: hidden; }

/* =====================================================================
   Phones: Settings and Categories open as full screens under the dock
   ===================================================================== */
@media (max-width: 760px) {
  :root body dialog.as-page {
    position: fixed; inset: 0; z-index: 15; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0;
    border: 0 !important; border-radius: 0 !important; box-shadow: none !important; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: calc(18px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) calc(118px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important; animation: none !important; transform: none !important; color: var(--ink);
    background:
      radial-gradient(48% 30% at 30% 28%, color-mix(in srgb, var(--orb-a) 80%, transparent), transparent 75%),
      radial-gradient(60% 34% at 100% 6%, color-mix(in srgb, var(--orb-b) 70%, transparent), transparent 75%),
      radial-gradient(55% 30% at 35% 100%, color-mix(in srgb, var(--orb-a) 35%, transparent), transparent 75%),
      var(--wall-base) !important;
  }
  :root body[data-theme="dark"] dialog.as-page {
    background:
      radial-gradient(48% 30% at 30% 28%, color-mix(in srgb, var(--orb-a) 42%, transparent), transparent 75%),
      radial-gradient(60% 34% at 100% 6%, color-mix(in srgb, var(--orb-b) 40%, transparent), transparent 75%),
      radial-gradient(55% 30% at 35% 100%, color-mix(in srgb, var(--orb-a) 22%, transparent), transparent 75%),
      var(--wall-base) !important;
  }
  body[data-mesh="true"] dialog.as-page { background: var(--mesh) !important; }
  dialog.as-page > form { max-width: 560px; margin: 0 auto; }
  /* The dock is how you leave a full screen, so the floating × on the main page goes away. */
  dialog.as-page .settings-page[data-page="root"] .dialog-heading .icon-button,
  dialog.as-page.folder-dialog .dialog-heading .icon-button,
  dialog.as-page .page-close { display: none; }
  dialog.as-page .set-title, dialog.as-page.folder-dialog h2 { font: 700 34px/1.1 var(--display); letter-spacing: -.02em; }
  dialog.as-page .page-bar { top: calc(-18px - env(safe-area-inset-top)); margin: calc(-18px - env(safe-area-inset-top)) -18px 0; padding: calc(12px + env(safe-area-inset-top)) 18px 8px; border-radius: 0; }
  /* Which full screen is showing is marked on the dock, like Notes and Calendar. */
  body[data-page-open] .dock .mobile-nav-item.active:not(.mobile-new-note) { color: var(--text-secondary); background: transparent !important; }
  body[data-page-open="settings"] .dock #mobile-settings, body[data-page-open="folder"] .dock #mobile-folder { color: var(--ink); background: color-mix(in srgb, var(--ink) 10%, transparent) !important; }
}

/* Saved themes: same chip as a preset, with a small remove button */
.saved-themes:empty { display: none; }
.saved-theme { position: relative; display: inline-flex; }
.saved-theme .studio-preset { padding-right: 34px; }
.saved-theme.selected .studio-preset { outline: 2px solid var(--accent); outline-offset: 1px; }
.saved-theme-remove { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); font-size: 15px; line-height: 1; cursor: pointer; }
.studio-save { justify-self: start; }

/* User guide */
.guide { display: grid; gap: 10px; }
.guide-section { border-radius: 18px; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); overflow: hidden; }
.guide-section summary { list-style: none; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 700; color: var(--ink); min-height: 52px; }
.guide-section summary::-webkit-details-marker { display: none; }
.guide-section summary .chev { font-style: normal; color: var(--text-secondary); transition: transform .15s ease; }
.guide-section[open] summary .chev { transform: rotate(90deg); }
.guide-ic { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); font-size: 16px; font-weight: 700; color: var(--ink); }
.guide-body { padding: 0 16px 14px; color: var(--ink); font-size: 14.5px; line-height: 1.6; }
.guide-body p { margin: 0 0 8px; color: var(--text-secondary); }
.guide-body ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.guide-tips { margin: 10px 0 0; padding: 10px 12px 10px 28px; border-radius: 14px; background: var(--accent-soft); display: grid; gap: 4px; font-size: 13.5px; }
.guide-body [data-guide-slot] { margin-top: 12px; display: grid; gap: 10px; }
.guide-page > .guide-tray { display: none; }
@media (max-width: 760px) {
  body[data-page-open] .dock .mobile-nav-item.active::after { display: none; }
  body[data-page-open="settings"] .dock #mobile-settings::after, body[data-page-open="folder"] .dock #mobile-folder::after { content: ""; display: block; position: absolute; bottom: 4px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); }
}

/* Phones: the background glows are drawn as soft gradients instead of blurred circles. A live
   blur(70–90px) on four screen-sized layers is the single most expensive thing for an iPhone to
   redraw, and it looked the same. Buttons inside an already-blurred bar no longer blur again. */
@media (hover: none) {
  :root body .wallpaper .orb { filter: none !important; transform: scale(1.45); will-change: auto; border-radius: 0; }
  :root body .wallpaper .orb-a { background: radial-gradient(closest-side, var(--orb-a), color-mix(in srgb, var(--orb-a) 55%, transparent) 50%, transparent); }
  :root body .wallpaper .orb-b { background: radial-gradient(closest-side, var(--orb-b), color-mix(in srgb, var(--orb-b) 55%, transparent) 50%, transparent); }
  :root body .wallpaper .orb-c { background: radial-gradient(closest-side, var(--orb-c), color-mix(in srgb, var(--orb-c) 55%, transparent) 50%, transparent); }
  :root body .wallpaper .orb-d { background: radial-gradient(closest-side, var(--orb-d), color-mix(in srgb, var(--orb-d) 55%, transparent) 50%, transparent); }
  :root body .format-toolbar button, :root body .format-toolbar label, :root body .fmt-panel button, :root body .fmt-panel select,
  :root body .editor-dialog .text-button, :root body .editor-dialog .icon-button, :root body .editor-meta input, :root body .editor-meta select, :root body .editor-meta button {
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}

/* Pinned strip on the home screen */
.pinned-strip { margin: 4px 0 14px; }
.pinned-strip .section-head { margin-bottom: 8px; }
.pinned-strip h2 { font: 700 18px/1.2 var(--display); margin: 0; color: var(--head); }
.pinned-row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; scrollbar-width: none; }
.pinned-row::-webkit-scrollbar { display: none; }
.pin-tile { all: unset; box-sizing: border-box; flex: 0 0 auto; width: 168px; min-height: 92px; padding: 12px; border-radius: 20px; cursor: pointer; scroll-snap-align: start;
  display: grid; grid-template-rows: auto auto 1fr; gap: 4px; background: color-mix(in srgb, var(--card-solid) 88%, transparent); border: 1px solid var(--g-edge-soft); color: var(--ink); }
.pin-tile b { font: 700 14.5px/1.3 var(--display); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--head); }
.pin-tile small { font-size: 12px; line-height: 1.4; color: var(--text-secondary); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pin-tile .pin-ic { font-size: 18px; line-height: 1; }
.pin-note .pin-ic { width: 10px; height: 10px; border-radius: 50%; margin: 4px 0; }
.pin-event { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.pin-tile:active { filter: brightness(.96); }
.card-pin { font-style: normal; font-size: .85em; }
@media (min-width: 761px) { .pin-tile { width: 200px; } }

/* Profile: tappable card, picture avatars everywhere, profile page */
button.profile-card { width: 100%; box-sizing: border-box; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.profile-card .chev { font-style: normal; color: var(--text-secondary); }
.avatar { overflow: hidden; }
.avatar.has-photo { padding: 0 !important; background: transparent !important; }
.avatar > img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.profile-photo { display: flex; align-items: center; gap: 18px; }
.avatar-xl { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; flex: none; font: 700 38px/1 var(--display); background: var(--accent); color: var(--accent-ink); box-shadow: var(--g-shadow); }
.profile-photo-actions { display: grid; gap: 8px; justify-items: start; }
.profile-photo-actions label { cursor: pointer; }
.profile-page #profile-save { justify-self: stretch; }

/* Calendar: everything added, with a jump-to-day button on each row */
.all-events-head h3 em { font-style: normal; color: var(--text-secondary); font-weight: 600; }
.event-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.event-filter[hidden] { display: none; }
.event-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; border-radius: 18px; }
.event-item .event-row { min-width: 0; }
.event-item.on-selected { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.event-item.is-past { opacity: .7; }
.go-day { all: unset; box-sizing: border-box; cursor: pointer; display: grid; justify-items: center; gap: 2px; min-width: 56px; padding: 6px; border-radius: 14px; color: var(--accent-text, var(--accent)); font-size: 10.5px; font-weight: 700; text-align: center; }
.go-day svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.go-day:active { background: var(--accent-soft); }
body[data-theme="light"] .go-day { color: var(--head); }

/* Checklists in notes (editor and anywhere note HTML is shown) */
ul.checklist { list-style: none; padding-left: 2px; }
ul.checklist > li { position: relative; padding-left: 32px; min-height: 26px; }
ul.checklist > li::before { content: ""; position: absolute; left: 0; top: .15em; width: 21px; height: 21px; box-sizing: border-box; border-radius: 7px; border: 2px solid var(--accent); background: transparent; cursor: pointer; }
ul.checklist > li[data-checked="true"]::before { background: var(--accent); }
ul.checklist > li[data-checked="true"]::after { content: ""; position: absolute; left: 7px; top: calc(.15em + 3px); width: 5px; height: 10px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); pointer-events: none; }
ul.checklist > li[data-checked="true"] { color: var(--text-secondary); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.fmt-check svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Pinned tiles take the theme's own colours: events in the accent, notes in the three card tints */
:root body .pin-tile.pin-event { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: none; }
:root body .pin-tile.pin-event b, :root body .pin-tile.pin-event small { color: var(--accent-ink); }
:root body .pin-tile.pin-event small { opacity: .92; }
:root body .pin-tile.pin-note { background: var(--c2); color: var(--c2-ink); border-color: transparent; }
:root body .pin-tile.pin-note:nth-child(3n+1) { background: var(--c3); color: var(--c3-ink); }
:root body .pin-tile.pin-note:nth-child(3n) { background: var(--c1); color: var(--c1-ink); }
:root body .pin-tile.pin-note b, :root body .pin-tile.pin-note small { color: inherit; }
:root body .pin-tile.pin-note small { opacity: .78; }
:root body .pin-tile.pin-note .pin-ic { box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 25%, transparent); }
.home-hints .hint-card[hidden] { display: none; }

/* Packages: locked controls, package cards, upgrade sheet, admin matrix */
.studio-preset.locked { opacity: .62; }
.studio-preset.locked::after { content: "🔒"; font-size: 11px; margin-left: 2px; }
.studio-pickers.locked .picker, .switch-row.locked, #studio-save.locked { opacity: .55; }
.switch-row.locked span::after, #studio-save.locked::after { content: " 🔒"; }
.plan-cards { display: grid; gap: 12px; }
.plan-card { border-radius: 22px; padding: 16px; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); display: grid; gap: 10px; }
.plan-card.mine { box-shadow: inset 0 0 0 2px var(--accent); }
.plan-card header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.plan-card header b { font: 700 18px/1.2 var(--display); color: var(--head); letter-spacing: .02em; }
.plan-price { font: 700 20px/1 var(--display); color: var(--ink); }
.plan-card ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; color: var(--ink); }
.plan-card li.soon { color: var(--text-secondary); }
.plan-card li em { font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--ink); }
.plan-card ul:empty { display: none; }
.plan-current, .plan-upgrade { justify-self: start; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 99px; }
.plan-current { background: var(--accent); color: var(--accent-ink); }
.plan-upgrade { background: var(--accent-soft); color: var(--ink); }
.upsell-copy { margin: 4px 0 16px; color: var(--ink); font-size: 15px; line-height: 1.6; }
.admin-matrix td, .admin-matrix th { text-align: center; }
.admin-matrix td:first-child, .admin-matrix th:first-child { text-align: left; }
.admin-matrix td:first-child b { display: block; font-size: 13.5px; }
.admin-matrix small { font-size: 11px; font-weight: 700; }
.admin-matrix small.is-ready { color: var(--accent-text, var(--accent)); }
body[data-theme="light"] .admin-matrix small.is-ready { color: var(--head); }
.admin-matrix small.is-soon { color: var(--text-secondary); }
.admin-matrix input { width: 20px; height: 20px; accent-color: var(--accent); }
.admin-grant-row { display: flex; gap: 10px; align-items: center; }
.admin-grant-row select { flex: 1; }
.admin-users { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.admin-users li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 16px; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); }
.admin-users li span { display: grid; min-width: 0; }
.admin-users li small { color: var(--text-secondary); font-size: 12px; overflow-wrap: anywhere; }
.admin-users li em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--ink); text-align: right; }
@media (max-width: 760px) { .admin-matrix table { min-width: 0; } .admin-matrix td, .admin-matrix th { padding: 6px 4px; } }
.plan-card li.lead { list-style: none; margin-left: -20px; font-weight: 700; color: var(--text-secondary); }

/* Templates row in an empty note */
.template-row { display: grid; gap: 8px; margin: 4px 0 6px; }
.template-row[hidden] { display: none; }
.template-row small { font-size: 12px; font-weight: 700; color: var(--text-secondary); letter-spacing: .02em; }
.template-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.template-chips::-webkit-scrollbar { display: none; }
.template-chip { position: relative; display: inline-flex; flex: none; }
.template-chip > button:first-child { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 99px; font-size: 13.5px; font-weight: 600; color: var(--ink);
  background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--line); white-space: nowrap; }
.template-chip i { font-style: normal; }
.template-chip.locked > button:first-child { opacity: .6; }
.template-chip.locked > button:first-child::after { content: "🔒"; font-size: 11px; }
.template-chip .template-remove { all: unset; cursor: pointer; width: 22px; height: 22px; margin-left: -8px; align-self: center; display: grid; place-items: center; border-radius: 50%; font-size: 14px; color: var(--ink); background: color-mix(in srgb, var(--ink) 10%, transparent); }
.template-chip:has(.template-remove) > button:first-child { padding-right: 14px; }

/* The page a note is drawn on for export (off screen) */
.export-page .export-meta { font-size: 13px; letter-spacing: .04em; opacity: .65; margin-bottom: 6px; }
.export-page .export-body:not(.export-template) h1 { font: 700 34px/1.25 var(--note-title-font, var(--display)); margin: 0 0 18px; color: inherit; }
.export-page .export-body:not(.export-template) p { margin: 0 0 10px; }
.export-page .export-template .ln-chrome { display: none; }   /* the editor's top bar leaves an empty 48 px band in a picture */
.export-page .export-template .c1-head { margin-top: 36px; }
.export-page .export-template .c-tape-corner { top: -6px; }   /* the tape moves up with the removed band, still just above the title */
.export-page .export-body:not(.export-template) img { max-width: 100%; border-radius: 14px; display: block; margin: 10px 0; }
.export-page .export-body:not(.export-template) ul, .export-page .export-body:not(.export-template) ol { margin: 0 0 12px; }
.export-page .export-foot { margin-top: 36px; font-size: 12px; opacity: .5; letter-spacing: .06em; }

/* Edit history */
.history-list { display: grid; gap: 8px; max-height: 55vh; overflow-y: auto; }
.history-list[hidden], .history-preview[hidden] { display: none; }
.history-row { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 2px; padding: 12px 14px; border-radius: 16px; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); color: var(--ink); }
.history-row b { font-size: 14px; }
.history-row span { font-size: 13px; color: var(--text-secondary); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-row small { font-size: 11.5px; color: var(--text-secondary); }
.history-preview { display: grid; gap: 10px; }
.history-preview .link-button { justify-self: start; }
.history-body { max-height: 45vh; overflow-y: auto; padding: 12px 14px; border-radius: 16px; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); pointer-events: none; }
.history-body h1 { font-size: 22px; margin: 0 0 8px; }

/* =====================================================================
   Template blocks (notes, previews, history, export): cute / luxe / planner, coloured by the theme
   ===================================================================== */
.tpl-kicker { font-size: .7em; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--text-secondary); margin: 0 0 .35em; }
.tpl-h { font: 700 1.12em/1.3 var(--note-title-font, var(--display)); margin: 1.1em 0 .45em; color: var(--head); letter-spacing: -.01em; }
.tpl-card { margin: .7em 0; padding: .85em 1em .7em; border-radius: 18px; background: color-mix(in srgb, var(--accent) 13%, transparent); }
.tpl-card.tpl-tone-2 { background: color-mix(in srgb, var(--c2, var(--accent)) 30%, transparent); }
.tpl-card.tpl-tone-3 { background: color-mix(in srgb, var(--c3, var(--accent)) 34%, transparent); }
.tpl-card > :last-child, .tpl-cell > :last-child { margin-bottom: 0; }
.tpl-card ul, .tpl-card ol, .tpl-cell ul, .tpl-cell ol { margin: .2em 0 .1em; }
.tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6em; margin: .7em 0; }
.tpl-grid.tpl-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tpl-cell { min-width: 0; min-height: 3.4em; padding: .6em .75em; border-radius: 14px; border: 1px solid color-mix(in srgb, currentColor 14%, transparent); background: color-mix(in srgb, var(--card-solid, #fff) 55%, transparent); }
.tpl-cell p { margin: 0 0 .2em; }
.tpl-chip { display: inline-block; margin: 0 .3em .35em 0; padding: .14em .75em; border-radius: 99px; font-size: .86em; background: color-mix(in srgb, var(--accent) 16%, transparent); }
.tpl-sticker { font-size: 2.6em; line-height: 1.1; margin: .1em 0; }
.tpl-center { text-align: center; }
.tpl-muted { color: var(--text-secondary); }
.tpl-quote { margin: .8em 0; padding: .2em 0 .2em .9em; border-left: 3px solid var(--accent); font-style: italic; color: var(--text-secondary); }
hr.tpl-rule { border: 0; height: 1px; margin: 1em 0; background: currentColor; opacity: .18; }
hr.tpl-rule.tpl-dots { height: auto; background: none; opacity: .45; text-align: center; overflow: visible; }
hr.tpl-rule.tpl-dots::before { content: "·  ·  ·"; letter-spacing: .4em; font-size: 1.1em; }
/* Cute: rounder, softer, pastel */
.tpl-cute.tpl-card { border-radius: 24px; padding: .95em 1.1em .8em; }
.tpl-cute .tpl-cell, .tpl-grid.tpl-cute .tpl-cell { border-radius: 20px; border-style: dashed; border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--c2, var(--accent)) 14%, transparent); }
.tpl-kicker.tpl-cute, .tpl-cute .tpl-kicker { letter-spacing: .04em; text-transform: none; font-size: .78em; color: var(--head); }
.tpl-cute .tpl-chip { background: color-mix(in srgb, var(--c1, var(--accent)) 38%, transparent); }
.tpl-quote.tpl-cute { border-left: 0; text-align: center; font-style: normal; padding: .5em 1em; border-radius: 99px; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tpl-quote.tpl-cute::before { content: "♡ "; } .tpl-quote.tpl-cute::after { content: " ♡"; }
/* Luxe: serif headings, hairlines, calm space */
h1.tpl-luxe, .tpl-h.tpl-luxe { font-family: 'Noto Serif Thai', 'Cormorant Garamond', 'DM Serif Display', Georgia, serif !important; font-weight: 600; letter-spacing: .005em; }
h1.tpl-luxe { font-size: 1.85em; }
.tpl-kicker.tpl-luxe { letter-spacing: .3em; font-weight: 700; font-size: .66em; }
.tpl-grid.tpl-luxe .tpl-cell { border-radius: 0; border-width: 0 0 0 1px; border-color: color-mix(in srgb, currentColor 25%, transparent); background: none; padding: .2em .8em; }
.tpl-grid.tpl-luxe .tpl-kicker { letter-spacing: .2em; }
.tpl-quote.tpl-luxe { border-left-width: 1px; font-family: 'Noto Serif Thai', 'Cormorant Garamond', Georgia, serif; font-size: 1.05em; }
.tpl-luxe .tpl-chip { background: none; border: 1px solid color-mix(in srgb, currentColor 30%, transparent); letter-spacing: .2em; }
/* Planner: tidy boxes with headers */
.tpl-grid.tpl-plan .tpl-cell { border-radius: 12px; padding: 0 .7em .5em; border-color: color-mix(in srgb, currentColor 18%, transparent); background: color-mix(in srgb, var(--card-solid, #fff) 70%, transparent); }
.tpl-grid.tpl-plan .tpl-cell > .tpl-kicker:first-child { margin: 0 -.7em .4em; padding: .45em .7em; border-radius: 11px 11px 0 0; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); letter-spacing: .06em; }
.tpl-plan.tpl-card { border-radius: 14px; border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.tpl-plan .tpl-chip { min-width: 1.6em; text-align: center; }
@media (max-width: 430px) { .tpl-grid.tpl-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4em; } .tpl-grid.tpl-grid-3 .tpl-cell { padding-left: .5em; padding-right: .5em; } }

/* Template gallery */
.template-gallery .tpl-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
.template-gallery .tpl-tabs button { all: unset; cursor: pointer; flex: none; padding: 8px 14px; border-radius: 99px; font-size: 13.5px; font-weight: 700; color: var(--ink); background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--line); }
.template-gallery .tpl-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tpl-gallery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tpl-thumb { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 6px; }
.tpl-thumb-frame { display: block; position: relative; height: 210px; overflow: hidden; border-radius: 18px; background: var(--card-solid); border: 1px solid var(--g-edge-soft); box-shadow: 0 6px 18px rgba(0, 0, 0, .08); color: var(--card-ink); }
.tpl-thumb-page { display: block; width: 360px; padding: 22px 22px 0; transform: scale(.44); transform-origin: top left; font-size: 17px; line-height: 1.6; pointer-events: none; }
.tpl-thumb-page h1 { font: 700 30px/1.15 var(--note-title-font, var(--display)); margin: 0 0 10px; color: var(--head); }
.tpl-thumb-frame::after { content: ""; position: absolute; inset: auto 0 0; height: 46px; background: linear-gradient(transparent, var(--card-solid)); }
.tpl-thumb b { font-size: 13.5px; color: var(--ink); display: flex; gap: 6px; align-items: center; }
.tpl-thumb .tpl-lock { margin-left: auto; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); }
.tpl-detail { display: grid; gap: 12px; }
.tpl-detail[hidden], .tpl-gallery-grid[hidden] { display: none; }
.tpl-detail-page { max-height: 56vh; overflow-y: auto; padding: 18px 18px 6px; border-radius: 20px; background: var(--card-solid); color: var(--card-ink); border: 1px solid var(--g-edge-soft); font-size: 16px; line-height: 1.65; pointer-events: none; }
.tpl-detail-page h1 { font: 700 26px/1.2 var(--note-title-font, var(--display)); margin: 0 0 10px; color: var(--head); }
.tpl-detail .link-button { justify-self: start; }
.template-chip.gallery-chip > button:first-child { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* Export choices + themed export pages */
.export-rows .set-label { display: grid; gap: 1px; }
.export-rows .set-label small { font-size: 12px; color: var(--text-secondary); font-weight: 400; }
.export-lock { font-style: normal; font-size: 11px; font-weight: 800; white-space: nowrap; }
.export-page.export-themed .export-meta { font-weight: 700; letter-spacing: .06em; }
.export-page .export-brand { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: 12px; letter-spacing: .12em; color: rgba(255, 255, 255, .85); }
.export-page.export-story .export-body:not(.export-template) h1, .export-page.export-square .export-body:not(.export-template) h1 { font-size: 26px; }

/* Countdown cards (PLUS) */
.countdown-row { display: flex; gap: 10px; overflow-x: auto; margin: 4px 0 14px; padding-bottom: 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
.countdown-row::-webkit-scrollbar { display: none; }
.countdown-row[hidden] { display: none; }
.countdown-card { all: unset; box-sizing: border-box; cursor: pointer; scroll-snap-align: start; flex: 0 0 auto; width: min(78vw, 300px); padding: 16px 18px 14px; border-radius: 24px; display: grid; gap: 4px;
  color: var(--accent-ink); background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 82%, var(--c2, var(--accent)))); }
.countdown-row .countdown-card:only-child { width: 100%; }
.cd-top { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; min-width: 0; }
.cd-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-ic { font-size: 20px; }
.cd-count { display: flex; align-items: baseline; gap: 8px; }
.cd-num { font: 800 54px/1 var(--display); letter-spacing: -.03em; }
.cd-num.cd-today { font-size: 34px; }
.cd-unit { font-size: 16px; font-weight: 700; opacity: .92; }
.cd-meta { font-size: 13px; opacity: .92; }
.cd-bar { display: block; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--accent-ink) 18%, transparent); overflow: hidden; margin-top: 6px; }
.cd-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent-ink); opacity: .55; }

/* Scrollbars: a small glass capsule that stays inside rounded cards (no square gutter, no arrows) */
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-track { background: transparent; margin: 22px 0; }
::-webkit-scrollbar-track:horizontal { margin: 0 22px; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { border: 3px solid transparent; background-clip: padding-box; border-radius: 99px;
  background-color: color-mix(in srgb, var(--ink, #333) 24%, rgba(255, 255, 255, .45)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55); }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--ink, #333) 38%, rgba(255, 255, 255, .4)); }
@supports not selector(::-webkit-scrollbar) { * { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink, #333) 30%, transparent) transparent; } }
.small-dialog, .settings-sheet, dialog { scrollbar-gutter: auto; }

/* Calendar panel: rounded all round, nothing cut off at the top */
:root body .calendar-view { border-radius: 30px; overflow: visible; }
:root body .calendar-heading { padding-top: 8px; }

/* Space sheet opened from Settings: a way back */
.space-back { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; margin: -4px 0 8px; font-weight: 700; color: var(--accent-text, var(--accent)); }
body[data-theme="light"] .space-back { color: var(--head); }
.space-back[hidden] { display: none; }
.studio-style-note { margin-top: -6px; }

/* Calendar panel: breathing room inside the glass */
:root body .calendar-view { padding: 16px 20px 22px; box-sizing: border-box; }
:root body .calendar-view .calendar-layout { gap: 18px; }
/* When the calendar has little room beside the sidebar (iPad portrait), the day panel goes under the month
   instead of squeezing it into thin columns. */
:root body .calendar-view { container-type: inline-size; }
@container (max-width: 760px) {
  :root body .calendar-view .calendar-layout { grid-template-columns: minmax(0, 1fr); }
  :root body .calendar-view .calendar-day { position: static; }
}

/* ⋯ menu: the pin row shows when the note is pinned */
#menu-pin.is-on { background: var(--accent-soft); }
#menu-pin.is-on em { font-style: normal; font-size: 12px; font-weight: 800; color: var(--ink); }

/* Computer: the formatting panel beside the note is a proper glass card */
@media (min-width: 761px) {
  :root body .editor-dialog .format-sidebar { border: 1px solid var(--g-edge-soft) !important; border-radius: 24px; padding: 14px !important; margin-top: 4px;
    background: rgba(var(--g-rgb), var(--g-alpha-card)) !important; box-shadow: var(--g-shadow); }
  :root body .editor-dialog .format-toolbar { display: grid !important; grid-template-columns: repeat(4, 40px); gap: 8px; justify-content: start; }
  :root body .editor-dialog .format-toolbar > button, :root body .editor-dialog .format-toolbar > label { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; }
  :root body .editor-dialog .format-toolbar .fmt-aa, :root body .editor-dialog .format-toolbar .fmt-menu { display: none !important; }
  :root body .editor-dialog .fmt-panel { grid-column: 1 / -1; display: grid !important; grid-template-columns: repeat(4, 40px); gap: 8px; padding-top: 10px; margin-top: 2px; border-top: 1px solid var(--line); }
  :root body .editor-dialog .fmt-panel .toolbar-divider { display: none; }
  :root body .editor-dialog .fmt-panel select { grid-column: 1 / -1; width: 100%; max-width: none !important; height: 40px; border-radius: 14px; }
  :root body .editor-dialog .fmt-panel button { width: 40px; height: 40px; border-radius: 14px; }
  /* The font button shows the font's name: full width, not squeezed to a 40px square (Kô 2 Dec: an empty box on the computer). */
  :root body .editor-dialog .fmt-panel .font-pick { width: 100%; height: 44px; }
  :root body .editor-dialog .text-color-control { grid-column: span 2; width: auto !important; height: 40px; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
  :root body .editor-dialog .format-sidebar::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--text-secondary); margin: 0 0 10px; }
}

/* Light mode: a fine edge in the theme's text colour, so white and pastel cards never melt into a pale
   background or the coloured glow behind the glass (dark mode cards already stand out by brightness). */
:root body[data-theme="light"] .note-card,
:root body[data-theme="light"] .pin-tile,
:root body[data-theme="light"] .quick-tile { border: 1px solid color-mix(in srgb, var(--ink) 13%, transparent) !important; }
:root body[data-theme="light"] .note-card { box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 8%, transparent), 0 6px 18px color-mix(in srgb, var(--ink) 7%, transparent); }

/* PLUS templates in the editor: the template is the page, so the rich-text tools step aside */
:root body .editor-dialog.is-template .format-sidebar,
:root body .editor-dialog.is-template #note-lock,
:root body .editor-dialog.is-template #note-date,
:root body .editor-dialog.is-template .template-row { display: none !important; }
:root body .editor-dialog.is-template .editor-body { grid-template-columns: minmax(0, 1fr); }
:root body .editor-dialog.is-template .editor-main { max-width: 560px; }
#template-view.ln-tpl { min-height: 0; border-radius: 22px; overflow: hidden; margin: 4px 0 18px; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 26px rgba(0,0,0,.08); }
#template-view .ln-chrome { visibility: hidden; }          /* the app has its own top bar; the space stays (the design is laid out below it, e.g. C1 tape) */
@media (max-width: 760px) { #template-view.ln-tpl { margin: 0 -15px 16px; border-radius: 0; box-shadow: none; } }
/* sheet for dates, money, times */
.tpl-fields { display: grid; gap: 12px; margin: 4px 0 8px; }
.tpl-field { display: grid; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.tpl-field input, .tpl-field select { width: 100%; min-height: 44px; font-size: 16px; color: var(--ink); }
.tpl-date { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; min-height: 44px; box-sizing: border-box; font-size: 16px; color: var(--ink); overflow: hidden; }
.tpl-date-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-date::after { content: ""; flex: none; width: 18px; height: 18px; opacity: .55; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3.5' y='5' width='17' height='15' rx='3'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3.5' y='5' width='17' height='15' rx='3'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E") center / contain no-repeat; }
.tpl-field .tpl-date-input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; -webkit-appearance: none; appearance: none; cursor: pointer; }
.tpl-check { display: flex; align-items: center; gap: 10px; color: var(--ink); min-height: 44px; }
.tpl-check input { width: 22px; height: 22px; accent-color: var(--accent); }
.tpl-sheet .primary-button { width: 100%; min-height: 46px; margin-top: 6px; }
/* undo after removing something from a template */
.undo-toast { position: fixed; z-index: 120; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 14px;
  padding: 10px 10px 10px 16px; border-radius: 16px; background: #1f1d24; color: #fff; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.undo-toast[hidden] { display: none; }
.undo-toast button { all: unset; cursor: pointer; padding: 8px 14px; min-height: 28px; border-radius: 10px; font-weight: 800; color: #1f1d24; background: #fff; }

/* Gallery: the PLUS set, live previews of the real templates (scaled down), with a "sample" badge */
.tpl-group-title { grid-column: 1 / -1; margin: 10px 2px 0; font-size: 13px; font-weight: 800; letter-spacing: .02em; color: var(--text-secondary); }
.tpl-thumb-plus .tpl-thumb-frame { position: relative; display: block; height: 220px; overflow: hidden; border-radius: 16px; background: var(--tpl-paper); }
.tpl-thumb-live { position: absolute; top: 0; left: 0; width: 390px; transform-origin: 0 0; transform: scale(var(--thumb-scale, .4)); pointer-events: none; }
.tpl-thumb-live .ln-tpl, .tpl-detail-live .ln-tpl { min-height: 0; }
.tpl-thumb-live .ln-chrome, .tpl-detail-live .ln-chrome { visibility: hidden; }
.tpl-sample-badge { position: absolute; top: 10px; right: 10px; z-index: 2; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 800; background: rgba(0,0,0,.62); color: #fff; }
.tpl-thumb-live .tpl-sample-badge { transform: scale(2.5); transform-origin: 100% 0; }
.tpl-thumb-plus b small { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-top: 2px; }
.tpl-detail-live { position: relative; border-radius: 20px; overflow: hidden; border: 1px solid var(--line); pointer-events: none; }
.tpl-thumb-plus .tpl-thumb-frame { padding: 0 !important; }
.tpl-thumb-plus .tpl-thumb-live { --thumb-scale: .38; }
.tpl-thumb-plus b { display: grid !important; gap: 2px; justify-items: start; text-align: left; line-height: 1.3; }
.tpl-thumb-plus b .tpl-lock { margin: 4px 0 0; }

/* Glass clarity (Settings → Mode and glass) also sets how see-through the note cards are. The default (70 %)
   looks as before (≈ 85 % solid); 100 % is clearly glassy, 0 % fully solid. */
:root body { --surface-a: calc(1 - .75 * var(--glass-t, .7) * var(--glass-t, .7)); }   /* 0 % solid · 70 % ≈ .63 · 100 % ≈ .25 (Kô: clear glass) */
:root body .note-card:nth-child(n) { background-color: color-mix(in srgb, var(--card-solid) calc(var(--surface-a) * 100%), transparent); }
:root body .quick-tile { background: color-mix(in srgb, var(--card-solid) calc(var(--surface-a) * 100%), transparent); }

@media (max-width: 760px) {
  /* Phones draw no blur (speed): the dock is nearly solid so what scrolls behind it never shows through. */
  :root body .mobile-nav.dock { background: color-mix(in srgb, var(--card-solid) 94%, transparent) !important; }
  /* "Solid pill" menus: the open screen's button is filled on every screen, not only on Notes. */
  body[data-nav="pill"][data-page-open="settings"] .dock #mobile-settings,
  body[data-nav="pill"][data-page-open="folder"] .dock #mobile-folder { background: var(--accent) !important; color: var(--accent-ink) !important; }
  body[data-nav="pill"][data-page-open] .dock .mobile-nav-item.active:not(.mobile-new-note)::after { display: none; }
}

/* Countdowns: the nearest one large, the others as small tiles underneath (no sideways scrolling) */
.countdown-row.has-more { display: grid; grid-template-columns: minmax(0, 1fr); overflow: visible; scroll-snap-type: none; }
.countdown-row .countdown-card { width: 100%; }
.countdown-minis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.countdown-mini { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 8px; row-gap: 2px; align-items: center;
  min-height: 64px; padding: 10px 12px; border-radius: 20px; background: color-mix(in srgb, var(--card-solid) calc(var(--surface-a, .85) * 100%), transparent); border: 1px solid var(--g-edge-soft); color: var(--ink); }
.countdown-mini .cd-ic { grid-row: 1 / span 2; font-size: 22px; }
.countdown-mini .cd-mini-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.countdown-mini b { font: 800 20px/1.1 var(--display); color: var(--ink); }
.countdown-mini b small { font: 700 12px var(--app-font, inherit); color: var(--text-secondary); }
.countdown-mini:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.countdown-more { grid-template-columns: 1fr; justify-items: center; text-align: center; }
.countdown-more b { color: var(--accent-text, var(--accent)); }
.countdown-more span { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
:root body[data-theme="light"] .countdown-mini { border-color: color-mix(in srgb, var(--ink) 13%, transparent); }
/* Multi-colour cards follow glass clarity too in light mode, more gently (their text colour is matched to the solid
   tint; in dark mode the dark page behind would pull dark text below 4.5:1, so they stay solid there). */
:root body { --tint-a: calc(1 - .45 * var(--glass-t, .7) * var(--glass-t, .7)); }      /* light-mode colour cards: 70 % ≈ .78 · 100 % ≈ .55 */
:root body[data-theme="dark"] { --tint-a: 1; }   /* dark: colour cards stay solid — the dark page showing through pulls their dark text (and its softer secondary lines) below 4.5:1 */
body[data-multi="true"] .note-card:not(.note-row):nth-child(3n+1) { background: color-mix(in srgb, var(--c1) calc(var(--tint-a) * 100%), transparent) !important; }
body[data-multi="true"] .note-card:not(.note-row):nth-child(3n+2) { background: color-mix(in srgb, var(--c2) calc(var(--tint-a) * 100%), transparent) !important; }
body[data-multi="true"] .note-card:not(.note-row):nth-child(3n+3) { background: color-mix(in srgb, var(--c3) calc(var(--tint-a) * 100%), transparent) !important; }

/* Countdown card in the theme's partner colour (accent turned round the colour wheel) (the "today" card next to it keeps the main colour), so the two
   big cards on Home are not the same block of colour. Text uses the ink matched to that colour (≥ 6:1). */
:root body .countdown-card { background: linear-gradient(140deg, var(--accent2, var(--accent)), color-mix(in srgb, var(--accent2, var(--accent)) 82%, var(--accent))); color: var(--accent2-ink, var(--accent-ink)); }
:root body .countdown-card .cd-bar { background: color-mix(in srgb, currentColor 18%, transparent); }
:root body .countdown-card .cd-bar i { background: currentColor; }
/* the small countdown tiles get a soft wash of the theme colour */
:root body .countdown-mini { background: color-mix(in srgb, var(--accent) 14%, var(--card-solid)); }

/* Phones: the area under the iPhone status bar is painted in the theme's own background, fading out below it,
   so content scrolled up melts into the theme colour instead of iOS's grey; the greeting sits a little lower,
   clear of that band. */
@media (max-width: 760px) {
  body::before { content: ""; position: fixed; z-index: 12; left: 0; right: 0; top: 0; pointer-events: none;
    height: calc(env(safe-area-inset-top) + 18px);
    background: linear-gradient(to bottom, var(--wall-base) 0, var(--wall-base) env(safe-area-inset-top), color-mix(in srgb, var(--wall-base) 0%, transparent) 100%); }
  :root body .home-header { padding-top: calc(env(safe-area-inset-top) + 16px); }
}

/* Settings → "update the app" (test tools) and its switch in Admin */
.admin-tools { all: unset; cursor: pointer; flex: none; padding: 6px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; color: var(--text-secondary); border: 1px solid var(--line); }
.admin-tools.is-on { color: var(--accent-ink); background: var(--accent); border-color: transparent; }
.admin-tools:disabled { cursor: default; opacity: .7; }
/* Gallery tabs on a computer: a mouse cannot swipe sideways, so the tabs wrap onto a second line instead (Kô, 1 Dec). */
@media (hover: hover) and (pointer: fine) { .template-gallery .tpl-tabs { flex-wrap: wrap; overflow: visible; } }
/* The picture button of the format panel belongs to the phone capsule; on a computer "เพิ่มรูปภาพ" sits in the top bar,
   and a later rule for format labels showed this one as an unstyled black block (Kô, 1 Dec). */
@media (min-width: 761px) { :root body .format-toolbar .fmt-image { display: none !important; } }
.fmt-image svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Theme studio: a typeable colour code and the colour really in use (Kô, 1 Dec). */
.picker .hex-input { width: 92px; height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(var(--g-rgb), var(--g-alpha-control)); color: var(--ink);
  font: 500 13px ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: lowercase; cursor: text; }
.picker .hex-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.picker .hex-input.bad { border-color: var(--danger); }
.studio-actual { display: flex !important; align-items: center; gap: 6px; margin-top: 3px; }
.studio-actual i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); flex: none; }
.studio-actual code { font-size: 11.5px; }

.scroll-diag { margin: 10px 4px 0; font-size: 12px; color: var(--text-secondary); }
.scroll-diag summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
.scroll-diag pre { white-space: pre-wrap; word-break: break-all; font: 11px/1.45 ui-monospace, Menlo, monospace; background: rgba(var(--g-rgb), var(--g-alpha-control)); padding: 10px; border-radius: 12px; user-select: text; -webkit-user-select: text; }

/* Colours the app adds: partner (countdown card) and the multi-colour card tints */
.studio-extra { display: grid; gap: 8px; margin: 12px 0 4px; padding: 12px 14px; border-radius: 16px; background: rgba(var(--g-rgb), var(--g-alpha-control)); border: 1px solid var(--line); }
.studio-extra > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13.5px; color: var(--ink); }
.studio-extra b { min-width: 92px; }
.studio-extra i { width: 18px; height: 18px; border-radius: 6px; border: 1px solid var(--line); flex: none; }
.studio-extra code { font-size: 12px; color: var(--text-secondary); }
.studio-extra small { flex-basis: 100%; font-size: 12px; color: var(--text-secondary); line-height: 1.4; }

/* The message bubble is a popover so it shows above an open note (top layer); undo the browser's popover box. */
:root body .toast[popover] { inset: auto auto 24px 50%; margin: 0; overflow: visible; height: auto; width: auto; color: #fff; }
:root body[data-theme="dark"] .toast[popover] { color: #fff; }
@media (max-width: 760px) { :root body .toast[popover] { bottom: calc(96px + env(safe-area-inset-bottom)); } }

/* Where the A4 pages of the PDF end: faint dashed lines in the note */
:root body .editor-main { position: relative; }
.page-guides { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.page-guide { position: absolute; left: -6px; right: -6px; height: 0; border-top: 1.5px dashed color-mix(in srgb, var(--ink) 22%, transparent); }
.page-guide span { position: absolute; right: 0; top: -9px; padding: 0 6px; font-size: 10.5px; line-height: 16px; border-radius: 8px; color: var(--text-secondary, #888);
  background: var(--card-solid, #fff); opacity: .9; }
/* The finished file on a phone: share button, the picture (press and hold to save), open the file */
.export-result { display: grid; gap: 8px; justify-items: center; text-align: center; }
.export-result .export-save { width: 100%; }
.export-preview { max-width: 100%; max-height: 42vh; border-radius: 12px; border: 1px solid var(--line); -webkit-touch-callout: default; user-select: auto; }
.export-result small { font-size: 12px; color: var(--text-secondary); }
.export-open { font-size: 13.5px; color: var(--ink); text-decoration: underline; }

/* Export like Canva: the pages to pick from */
.export-pages { display: grid; gap: 12px; }
.export-pages-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--text-secondary); }
.export-pages-head .text-button { color: var(--ink); font-size: 13.5px; padding: 6px 2px; }
.export-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; max-height: 46vh; overflow-y: auto; padding: 4px; }
.kind-pdf .export-thumbs, .kind-pdf-theme .export-thumbs { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.export-thumb { position: relative; padding: 0; border: 2px solid transparent; border-radius: 12px; background: none; cursor: pointer; opacity: .45; transition: opacity .15s, border-color .15s; }
.export-thumb.is-on { opacity: 1; border-color: var(--accent); }
.export-thumb img { display: block; width: 100%; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,.12); background: #fff; }
.export-thumb b { position: absolute; left: 6px; bottom: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; font-size: 12px; line-height: 22px; background: rgba(0,0,0,.55); color: #fff; }
.export-thumb i { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; font-style: normal; font-size: 14px; line-height: 22px; text-align: center;
  border: 2px solid #fff; background: rgba(0,0,0,.25); color: transparent; }
.export-thumb.is-on i { background: var(--accent); color: var(--accent-ink, #fff); }
.export-pages-actions { display: flex; gap: 8px; }
.export-pages-actions .primary-button { flex: 1; }
.export-previews { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; }
.export-previews .export-preview { max-height: 38vh; flex: none; }

/* Admin: account search under the email box */
.admin-suggest { display: grid; gap: 4px; margin: 6px 0 4px; padding: 6px; border-radius: 16px; background: rgba(var(--g-rgb), var(--g-alpha-card)); border: 1px solid var(--g-edge-soft); }
.admin-suggest button { display: grid; text-align: left; gap: 2px; padding: 8px 10px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; cursor: pointer; }
.admin-suggest button:hover, .admin-suggest button:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.admin-suggest button small, .admin-suggest .more { font-size: 12px; color: var(--text-secondary); overflow-wrap: anywhere; }
.admin-suggest .more { padding: 4px 10px; }
.admin-users li { cursor: pointer; }
.admin-users li[hidden] { display: none; }
/* App version at the bottom of Settings */
.app-version { text-align: center; font-size: 12px; color: var(--text-secondary); margin: 18px 0 4px; }
.app-version.is-behind { color: var(--accent); font-weight: 600; }

/* Export "like a screenshot": the note's own app styles at phone width (Kô, 2 Dec) */
:root body .export-page.export-screen #note-content { min-height: 0; padding: 0; margin: 0; max-width: none; }
:root body .export-page.export-screen #note-content h1 { font-size: 30px; line-height: 1.15; }
:root body .export-page.export-screen #note-content img { max-width: 100%; }

/* Template photo: choose which part shows in its frame (Kô, 2 Dec) */
.photo-pos { width: min(420px, calc(100vw - 32px)); }
.photo-pos .photo-pos-hint { margin: 4px 0 12px; color: var(--text-secondary); font-size: 14px; }
.photo-pos .photo-pos-frame { position: relative; width: 100%; max-height: 60vh; margin: 0 auto; overflow: hidden; border-radius: 14px; touch-action: none; cursor: grab; background: rgba(0,0,0,.06); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.photo-pos .photo-pos-frame:active { cursor: grabbing; }
.photo-pos .photo-pos-frame img { width: 100%; height: 100%; display: block; object-fit: cover; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.photo-pos .photo-pos-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.photo-pos .photo-pos-actions span { flex: 1; }

/* The font picker in the Aa panel (Kô, 2 Dec — like Canva): each font written in itself with a sample. */
:root body .fmt-panel select.font-native { display: none !important; }
:root body .fmt-panel .font-pick { grid-column: 1 / -1; flex: 1 1 100%; width: 100%; height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px 0 14px; border-radius: 14px; font-size: 17px; color: var(--ink); text-align: left; }
:root body .fmt-panel .font-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root body .fmt-panel .font-pick svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .6; }
:root body .fmt-panel .font-list { grid-column: 1 / -1; flex: 1 1 100%; width: 100%; max-height: min(300px, 42vh); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: grid; gap: 4px; padding: 6px; border-radius: 16px; background: var(--card-solid, #fff); box-shadow: inset 0 0 0 1px var(--g-edge-soft, rgba(0,0,0,.08)); }
:root body .fmt-panel .font-list[hidden] { display: none; }
:root body .fmt-panel .font-group { margin: 6px 8px 2px; font: 600 12px/1.4 var(--app-font, system-ui), sans-serif; color: var(--text-secondary); letter-spacing: .02em; }
:root body .fmt-panel .font-row { width: 100% !important; height: auto !important; min-height: 48px; display: grid !important; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px !important; text-align: left; color: var(--ink); background: transparent; border: 0; }
:root body .fmt-panel .font-row.is-current { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent); }
:root body .fmt-panel .font-row-name { font-size: 19px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root body .fmt-panel .font-row-sample { font-size: 15px; opacity: .62; white-space: nowrap; }
:root body .fmt-panel .font-row-lock { font-size: 13px; }

/* The note's date chip shows the date in the app's language; the iOS date box sits on top, invisible (Kô, 2 Dec). */
:root body .editor-meta .note-date-chip { position: relative; display: inline-flex; flex: none; }
:root body .editor-meta .note-date-chip #note-date { color: transparent !important; -webkit-text-fill-color: transparent; }
:root body .editor-meta .note-date-chip #note-date::-webkit-calendar-picker-indicator { opacity: 0; }
:root body .editor-meta .note-date-chip #note-date::-webkit-datetime-edit { opacity: 0; }
:root body .editor-meta .note-date-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 0 12px; pointer-events: none; font: inherit; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; }
:root body .editor-dialog.is-template .note-date-chip { display: none !important; }

/* The italic button read as "/" — a serif I reads as italic at a glance (Kô, 2 Dec). The Aa panel keeps its glass. */
:root body .format-toolbar [data-format="italic"] i { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 19px; }

/* Kô (2 Dec, iPhone — like Apple Notes): the Aa panel was three tall rows that covered the writing, with unused space at
   the sides. On phones it is one slim row across the screen (underline, strike, font, size, colour); still glass. */
@media (max-width: 760px) {
  :root body .panel-open .fmt-panel { left: 50%; right: auto; transform: translateX(-50%); width: calc(100vw - 16px); flex-wrap: wrap; gap: 6px; padding: 6px; border-radius: 18px; }
  :root body .panel-open .fmt-panel > button { width: 40px; height: 40px; flex: none; }
  :root body .panel-open .fmt-panel .font-pick { grid-column: auto; flex: 1 1 96px; width: auto; min-width: 0; height: 40px; padding: 0 8px 0 10px; font-size: 16px; }
  :root body .panel-open .fmt-panel select#inline-size { flex: 0 0 74px; width: 74px; min-width: 0; padding-left: 8px; padding-right: 2px; }
  :root body .panel-open .fmt-panel .text-color-control { flex: none; }
  :root body .panel-open .fmt-panel .font-list { flex: 1 1 100%; order: 9; }
}

/* One list button (bullets → checklist → plain); the old checklist button stays hidden. */
:root body #fmt-check[hidden] { display: none !important; }
#fmt-list svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Kô (2 Dec): every menu is ONE line. The font list is a sideways strip of fonts (each written in itself) that takes
   the place of the row while it is open — it never grows upward over the writing. */
@media (max-width: 760px) {
  :root body .panel-open .fmt-panel:has(.font-list:not([hidden])) > :not(.font-pick):not(.font-list) { display: none !important; }
  :root body .panel-open .fmt-panel .font-list { display: flex; flex-wrap: nowrap; gap: 6px; flex: 1 1 0; min-width: 0; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 0; border-radius: 0; background: transparent; box-shadow: none; order: 0; }
  :root body .panel-open .fmt-panel .font-list::-webkit-scrollbar { display: none; }
  :root body .panel-open .fmt-panel .font-group { display: none; }
  :root body .panel-open .fmt-panel .font-row { flex: none; width: auto !important; min-height: 40px; display: flex !important; align-items: center; gap: 6px; padding: 0 12px; background: color-mix(in srgb, var(--card-solid, #fff) 70%, transparent); }
  :root body .panel-open .fmt-panel .font-row-sample { display: none; }
  :root body .panel-open .fmt-panel .font-row-name { font-size: 17px; }
  :root body .panel-open .fmt-panel:has(.font-list:not([hidden])) .font-pick { flex: none; width: 40px; padding: 0; justify-content: center; }
  :root body .panel-open .fmt-panel:has(.font-list:not([hidden])) .font-pick span { display: none; }
}

/* Kô (2 Dec, iPhone): ONE bar. Underline, strike, font, size, colour sit in the same glass bar as B, I, list and photo;
   the bar scrolls sideways if it is wider than the phone. The Aa button is no longer needed. */
@media (max-width: 760px) {
  :root body #fmt-aa { display: none !important; }
  :root body .format-toolbar { max-width: calc(100vw - 16px); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 6px 8px; }
  :root body .format-toolbar::-webkit-scrollbar { display: none; }
  :root body .format-toolbar .fmt-panel { display: contents !important; }
  :root body .format-toolbar .fmt-panel .toolbar-divider, :root body .format-toolbar .fmt-menu { display: none !important; }
  :root body .format-toolbar > *, :root body .format-toolbar .fmt-panel > * { flex: none; }
  :root body .format-toolbar [data-format="bold"] { order: 1; }
  :root body .format-toolbar [data-format="italic"] { order: 2; }
  :root body .format-toolbar [data-format="underline"] { order: 3; }
  :root body .format-toolbar [data-format="strikeThrough"] { order: 4; }
  :root body .format-toolbar #fmt-list { order: 5; }
  :root body .format-toolbar .font-pick { order: 6; flex: none; width: 128px; }
  :root body .format-toolbar select#inline-size { order: 7; }
  :root body .format-toolbar .text-color-control { order: 8; }
  :root body .format-toolbar .fmt-image { order: 9; }
  :root body .format-toolbar:has(.font-list:not([hidden])) { width: calc(100vw - 16px); }
  :root body .format-toolbar:has(.font-list:not([hidden])) > :not(.fmt-panel) { display: none !important; }
  :root body .format-toolbar .fmt-panel .font-list { order: 7; flex: 1 1 0; }
}
@media (max-width: 760px) {
  :root body .format-toolbar .fmt-panel .font-list { display: flex; flex-wrap: nowrap; gap: 6px; min-width: 0; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 0; border-radius: 0; background: transparent; box-shadow: none; }
  :root body .format-toolbar .fmt-panel .font-list[hidden] { display: none; }
  :root body .format-toolbar .fmt-panel .font-list::-webkit-scrollbar { display: none; }
  :root body .format-toolbar .fmt-panel .font-group, :root body .format-toolbar .fmt-panel .font-row-sample { display: none; }
  :root body .format-toolbar .fmt-panel .font-row { flex: none; width: auto !important; min-height: 40px; display: flex !important; align-items: center; gap: 6px; padding: 0 12px; background: color-mix(in srgb, var(--card-solid, #fff) 70%, transparent); }
  :root body .format-toolbar .fmt-panel .font-row-name { font-size: 17px; }
  :root body .format-toolbar:has(.font-list:not([hidden])) .font-pick { width: 40px; padding: 0; justify-content: center; }
  :root body .format-toolbar:has(.font-list:not([hidden])) .font-pick span { display: none; }
}
@media (max-width: 760px) {
  :root body .format-toolbar:has(.font-list:not([hidden])) .fmt-panel > :not(.font-pick):not(.font-list) { display: none !important; }
}

/* Kô (2 Dec): choosing colours was confusing — long explanations and a second "in use" colour under each one. A row is
   now just: the colour, its name, its code. The colours the app adds by itself are folded under "Advanced". */
.studio-pickers .picker small { display: none !important; }
.studio-advanced { margin: 10px 0 4px; }
.studio-advanced > summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); padding: 6px 2px; }

.studio-extra .partner-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.studio-extra .partner-row input[type="color"] { width: 40px; height: 40px; border: 0; padding: 0; border-radius: 12px; background: none; }
.studio-extra .partner-row .secondary-button { min-height: 36px; padding: 0 12px; }
