/* Web notes — a quiet three-pane layout: sidebar, list, editor. Shared by
   Sebastian Notes and TaskFlow Notes; each app's theme.css sets its colours.
   Flat: solid fills and neutral lines, no gradients or glows. */
:root {
  color-scheme: light;
  --bg: #ffffff; --sidebar: #f6f6f7; --list: #fbfbfc; --hover: #eeeef1; --selected: #e4e9f2;
  --ink: #1d1f23; --muted: #6b7079; --faint: #9a9fa8; --line: #e3e4e8;
  --accent: #2f6fdb; --accent-ink: #ffffff; --danger: #c0392b; --pill: #ececf0;
  --shadow: 0 8px 28px rgba(0, 0, 0, .14);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1c1c1e; --sidebar: #232326; --list: #202023; --hover: #2c2c30; --selected: #34363d;
    --ink: #ececee; --muted: #a2a5ad; --faint: #75787f; --line: #323236;
    --accent: #5b95f5; --accent-ink: #0d1626; --danger: #ff8a7d; --pill: #34343a;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1c1e; --sidebar: #232326; --list: #202023; --hover: #2c2c30; --selected: #34363d;
  --ink: #ececee; --muted: #a2a5ad; --faint: #75787f; --line: #323236;
  --accent: #5b95f5; --accent-ink: #0d1626; --danger: #ff8a7d; --pill: #34343a;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 14px; }
button:hover { background: var(--hover); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:hover { background: var(--accent); opacity: .9; }
.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; }
.link:hover { background: none; text-decoration: underline; }
.icon-button { border: 0; background: none; width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; color: var(--muted); border-radius: 8px; flex: none; }
.icon-button:hover { background: var(--hover); color: var(--ink); }
.install-help { margin: 8px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.text-button { border: 0; background: none; padding: 6px 10px; font-size: 13px; color: var(--muted); }
.text-button:hover { color: var(--ink); }
.error { color: var(--danger) !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font: inherit; font-size: .9em; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

/* Welcome */
.welcome { max-width: 440px; margin: 0 auto; padding: 14vh 24px 40px; text-align: center; }
.welcome-icon { width: 72px; height: 72px; border-radius: 16px; }
.welcome h1 { font-size: 30px; letter-spacing: -.5px; margin: 18px 0 6px; }
.welcome p { color: var(--muted); margin: 0 0 26px; }
.welcome .primary { padding: 11px 26px; }
.welcome .fine { font-size: 12.5px; margin-top: 26px; }
#apple-signin { display: flex; justify-content: center; margin: 12px auto; min-height: 8px; }
#try-demo { display: block; margin: 6px auto 0; }

/* Three panes */
.app { display: grid; grid-template-columns: 220px 320px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; padding: 2px 8px 16px; font-weight: 700; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.brand-sub { font-weight: 400; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 7px; }
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="true"] { background: var(--selected); font-weight: 600; }
.nav-icon { width: 18px; text-align: center; color: var(--muted); flex: none; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-heading { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); margin: 18px 10px 4px; }
.tag-nav { display: grid; gap: 1px; }
.heading-toggle { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; border: 0; background: none; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; border-radius: 4px; }
.heading-toggle:hover { background: none; color: var(--muted); }
.chevron { display: inline-block; transition: transform .15s ease; }
.heading-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }
.all-tags-toggle { color: var(--muted); margin-top: 2px; }
.all-tags-toggle .nav-icon { transition: transform .15s ease; }
.all-tags-toggle[aria-expanded="true"] .nav-icon { transform: rotate(90deg); }
.tag-filter { width: calc(100% - 20px); margin: 4px 10px 6px; border: 1px solid var(--line); background: var(--bg); border-radius: 7px; padding: 5px 9px; font-size: 13px; }
.tag-filter-empty { font-size: 12.5px; color: var(--faint); padding: 4px 14px; }
.search-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.tag-suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 12; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; max-height: 300px; overflow-y: auto; }
.tag-suggest .nav-item[aria-selected="true"] { background: var(--selected); }
.tag-suggest .hint-row { font-size: 12px; color: var(--faint); padding: 6px 10px 4px; }
.tag-nav .nav-item { padding-left: 14px; }
#untagged-item { margin-top: 10px; }
.sidebar-footer { margin-top: auto; padding: 14px 4px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.sync-status { font-size: 12px; color: var(--muted); padding: 0 6px; min-height: 18px; overflow-wrap: anywhere; }
.sidebar-actions { display: flex; align-items: center; gap: 2px; }
.sidebar-actions .text-button { margin-left: auto; }

.list-pane { background: var(--list); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-toolbar { display: flex; align-items: center; gap: 6px; padding: 10px 10px 8px; }
#search { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
#sidebar-toggle { display: none; }
.notice { margin: 0 10px 8px; padding: 8px 10px; border-radius: 8px; background: var(--selected); font-size: 12.5px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 10px 6px 18px; min-height: 26px; }
.list-title { font-size: 12px; color: var(--faint); }
.list-head .text-button { font-size: 12px; padding: 2px 8px; }
.list-title { margin-right: auto; }
.sort-select { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 2px 4px; border-radius: 6px; cursor: pointer; }
.sort-select:hover { background: var(--hover); color: var(--ink); }
.danger { color: var(--danger) !important; }
.danger-button { background: var(--danger); border-color: var(--danger); color: var(--bg); font-weight: 600; }
.danger-button:hover { background: var(--danger); opacity: .9; }
.note-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
.note-card { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 11px 12px; }
.note-card:hover { background: var(--hover); }
.note-card.selected { background: var(--selected); border-radius: 8px; border-bottom-color: transparent; }
.note-card-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-card-title .pin { color: var(--accent); margin-right: 4px; }
.note-card-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.note-card-date { display: block; font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.empty-list { color: var(--faint); font-size: 13px; text-align: center; padding: 30px 10px; }

.editor-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.editor-toolbar { display: flex; align-items: center; gap: 4px; padding: 10px 16px; border-bottom: 1px solid transparent; }
.back { display: none; }
.format-bar { display: flex; align-items: center; gap: 2px; flex: none; }
.format-bar button { border: 0; background: none; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 7px; font-size: 14px; color: var(--muted); }
.format-bar button:hover { background: var(--hover); color: var(--ink); }
.format-bar button[aria-pressed="true"] { background: var(--selected); color: var(--ink); }
.format-bar svg { display: block; }
/* Each formatting button names itself on hover or keyboard focus, with its
   shortcut or typing hint underneath, sooner and clearer than a native title. */
.format-bar button[data-tip] { position: relative; }
@media (hover: hover) {
  .format-bar button[data-tip]:hover::after, .format-bar button[data-tip]:focus-visible::after {
    content: attr(data-tip) "\A" attr(data-keys); white-space: pre; position: absolute; z-index: 30; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    padding: 6px 9px; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.4; text-align: center;
    pointer-events: none; animation: tip-in .12s .35s both; }
  .format-bar button[data-tip]:first-child::after { left: 0; transform: none; text-align: left; }
}
@keyframes tip-in { from { opacity: 0; } to { opacity: 1; } }
.link-form { display: flex; align-items: center; gap: 6px; margin: 0 16px 6px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--sidebar); }
.link-form input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 7px; padding: 6px 9px; font-size: 14px; }
.link-form input.error { border-color: var(--danger); }
.link-form .primary { padding: 6px 12px; font-size: 13px; }
.sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.save-state { flex: 1 1 0; min-width: 0; text-align: right; padding: 0 4px; font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pin-note[aria-pressed="true"] { color: var(--accent); }
.editor-pane:not(.has-note) .format-bar, .editor-pane:not(.has-note) #expand-note, .editor-pane:not(.has-note) #pin-note, .editor-pane:not(.has-note) #trash-note, .editor-pane:not(.has-note) #info-button { visibility: hidden; }
/* A note with the app's formatting keeps its text locked until "Edit Text Here". */
.editor-pane.body-locked .format-bar { visibility: hidden; }
.format-lock { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 10px; padding: 9px 12px; border-radius: 9px; background: var(--sidebar); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.format-lock .link { padding: 2px 0; font-weight: 600; }
/* A note in Trash is read-only: restore it to edit. */
.editor-pane.in-trash .format-bar, .editor-pane.in-trash #pin-note, .editor-pane.in-trash #trash-note { display: none; }
.editor-pane.in-trash .tag-input, .editor-pane.in-trash .tag-pill .remove { display: none; }
#info-button[aria-expanded="true"] { background: var(--selected); color: var(--ink); }
.info-panel { position: absolute; top: 52px; right: 16px; z-index: 15; width: 260px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; }
.info-panel dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.info-panel dt { color: var(--muted); }
.info-panel dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.note-badges { display: flex; flex-wrap: wrap; gap: 6px; }
/* Folder and badges sit in one quiet row above the title. */
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
/* Without folders, an empty row takes no space. */
body:not(.has-folders) .note-meta:has(#note-badges[hidden]) { display: none; }
.folder-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; border-radius: 7px; padding: 2px 8px 2px 6px; background: var(--sidebar); border: 1px solid transparent; }
body:not(.has-folders) .folder-field { display: none; }
.folder-field:focus-within { border-color: var(--line); }
.folder-field input { border: 0; background: none; padding: 2px 0; font-size: 13px; width: 11em; outline: none; color: var(--ink); }
.folder-field input::placeholder { color: var(--faint); }
.folder-field input::-webkit-calendar-picker-indicator { display: none !important; }
.folder-field input:disabled { color: var(--muted); }
.folder-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; line-height: 1.5; color: var(--muted); padding: 0 6px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.folder-chip::before { content: "▱"; font-size: 11px; }
#trash-note:disabled { opacity: .35; cursor: not-allowed; }
/* Checked items, hidden while "hide completed" is on. */
.editor.hide-done .note-body .ql-editor li[data-list="checked"] { display: none; }
.done-hidden { font-size: 12.5px; color: var(--muted); margin: 0 auto 10px; }
.done-hidden .link { padding: 0 2px; }
#hide-done[aria-pressed="true"] { color: var(--accent); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); background: var(--pill); border-radius: 999px; padding: 2px 9px; cursor: default; }
.badge.trash { color: var(--danger); }
.toast button { margin-left: 10px; border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 25; max-width: min(440px, calc(100% - 32px)); background: var(--ink); color: var(--bg); border-radius: 10px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow); text-align: center; }
.remote-change { margin: 0 16px; padding: 8px 12px; border-radius: 8px; background: var(--selected); font-size: 13px; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--faint); text-align: center; padding: 24px; }
.empty img { width: 56px; height: 56px; border-radius: 13px; opacity: .55; filter: grayscale(1); }
.editor { flex: 1; overflow-y: auto; padding: 12px clamp(16px, 4vw, 56px) 40px; display: flex; flex-direction: column; }
.editor > :not(.sr-only) { width: 100%; max-width: 1000px; margin-left: auto; margin-right: auto; }
/* The note text is the whole page here; a focus ring around all of it is noise. */
.note-body .ql-editor:focus-visible { outline: none; }
.note-title { display: block; border: 0; background: none; padding: 0; font-size: 28px; line-height: 1.25; font-weight: 700; letter-spacing: -.3px; outline: none; resize: none; overflow: hidden; }
.note-title::placeholder { color: var(--faint); }
.note-body { flex: 1; margin-top: 8px; }
.note-body .ql-editor { padding: 6px 0 24px; font-size: 16px; line-height: 1.65; min-height: 240px; overflow-wrap: anywhere; }
.note-body .ql-editor.ql-blank::before { left: 0; right: 0; color: var(--faint); font-style: normal; }
.note-body .ql-editor h1, .note-body .ql-editor h2, .note-body .ql-editor h3 { font-size: 1.3em; margin: .6em 0 .2em; }
.note-body .ql-editor blockquote { border-left: 3px solid var(--line); padding-left: 12px; color: var(--muted); }
.note-body .ql-editor a { color: var(--accent); cursor: text; }
body.open-links .note-body .ql-editor a { cursor: pointer; text-decoration: underline; }
@media (hover: none) { .note-body .ql-editor a { cursor: pointer; } }
.note-body .ql-editor li[data-list="checked"] { color: var(--muted); text-decoration: line-through; }
/* Checklist boxes are bold open circles, like the apps' reminders; ticked ones
   fill with the accent colour and a white check. Sized to Quill's 1.5em list
   gutter so indented items still line up. */
.note-body .ql-editor li[data-list="checked"] > .ql-ui, .note-body .ql-editor li[data-list="unchecked"] > .ql-ui { color: transparent; }
.note-body .ql-editor li[data-list="checked"] > .ql-ui::before, .note-body .ql-editor li[data-list="unchecked"] > .ql-ui::before { content: ""; box-sizing: border-box; width: 1.15em; height: 1.15em; margin-left: -1.5em; margin-right: .35em; vertical-align: -.2em; border: 2px solid var(--muted); border-radius: 50%; background: transparent center / 70% no-repeat; transition: border-color .12s, background-color .12s; }
.note-body .ql-container:not(.ql-disabled) li[data-list="unchecked"] > .ql-ui:hover::before { border-color: var(--accent); }
.note-body .ql-editor li[data-list="checked"] > .ql-ui::before { border-color: var(--accent); background-color: var(--accent); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.4l3 3 6-6.6' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px auto; }
.tag-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.tag-pills { display: contents; }
/* Tag colours come from the app's palette (tagColor in core.mjs): a solid dot
   and a light tint behind the name, so the text stays readable in both themes. */
.tag-dot::before, .tag-pill::before, .tag-chip::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--tag, var(--faint)); flex: none; }
.nav-icon.tag-dot { display: inline-flex; align-items: center; justify-content: center; }
.tag-pill { display: inline-flex; align-items: center; gap: 6px; border: 0; background: color-mix(in srgb, var(--tag, var(--faint)) 18%, var(--bg)); border-radius: 999px; padding: 3px 6px 3px 9px; font-size: 13px; }
.tag-pill:hover { background: color-mix(in srgb, var(--tag, var(--faint)) 18%, var(--bg)); }
.note-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; font-size: 11.5px; line-height: 1.5; color: var(--muted); background: color-mix(in srgb, var(--tag, var(--faint)) 16%, transparent); border-radius: 999px; padding: 0 8px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-chip::before { width: 6px; height: 6px; }
.tag-more { font-size: 11.5px; color: var(--faint); }
.tag-pill .remove { border: 0; background: none; padding: 0 4px; color: var(--faint); font-size: 14px; line-height: 1; border-radius: 999px; }
.tag-pill .remove:hover { color: var(--ink); background: none; }
.tag-input { border: 0; background: none; padding: 4px 2px; font-size: 13px; min-width: 120px; flex: 1; outline: none; }
.tag-input::-webkit-calendar-picker-indicator { display: none !important; }

/* Signed out while working */
.reauth { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; width: min(440px, calc(100% - 32px)); background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; text-align: center; }
.reauth p { margin: 0 0 10px; font-size: 13.5px; }
.reauth-button { display: flex; justify-content: center; min-height: 32px; }

/* Tags heading's Edit button and the tag manager */
.heading-action { border: 0; background: none; padding: 0 2px; font: inherit; font-size: 11px; letter-spacing: normal; text-transform: none; font-weight: 500; color: var(--faint); }
.heading-action:hover { background: none; color: var(--accent); }
.dialog-hint { font-size: 13px; color: var(--muted); margin-top: -4px; }
.dialog-status { font-size: 12.5px; color: var(--muted); min-height: 18px; margin: 10px 0 0; }
.tag-manager { display: grid; gap: 4px; max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.tag-row { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.tag-row .tag-dot::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--tag, var(--faint)); }
.tag-row input { flex: 1; min-width: 0; border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 6px; font-size: 14px; }
.tag-row input:hover { border-color: var(--line); }
.tag-row input:focus { border-color: var(--accent); background: var(--bg); outline: none; }
.tag-row .count { white-space: nowrap; }
.tag-row .text-button { font-size: 12px; white-space: nowrap; }

/* Conflict dialog */
dialog { max-width: 760px; width: calc(100% - 32px); background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin-top: 0; font-size: 19px; }
.conflict-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.conflict-columns h3 { font-size: 13px; color: var(--muted); }
.conflict-columns pre { white-space: pre-wrap; overflow: auto; max-height: 240px; background: var(--sidebar); padding: 12px; border-radius: 8px; font: 13px/1.5 ui-monospace, Menlo, monospace; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* Narrow windows: the sidebar slides in; the list and editor take turns. */
@media (max-width: 980px) {
  .app { grid-template-columns: 300px minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow); }
  .app.sidebar-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 10; }
  #sidebar-toggle { display: inline-flex; }
}
@media (max-width: 680px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .editor-pane { display: none; }
  .app.show-editor .list-pane { display: none; }
  .app.show-editor .editor-pane { display: flex; }
  .back { display: inline-flex; font-size: 26px; }
  .editor { padding: 10px 18px 32px; }
  .note-title { font-size: 24px; }
  .editor-toolbar { padding: 8px 8px; gap: 0; }
  .format-bar .sep { display: none; }
  /* On a phone the formatting buttons scroll sideways rather than push the note buttons off the screen. */
  .format-bar { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .format-bar::-webkit-scrollbar { display: none; }
  .format-bar button { flex: none; }
  .format-bar button { min-width: 30px; padding: 0 6px; }
  .editor-toolbar .text-button { padding: 6px 6px; }
  .editor-toolbar .icon-button { width: 30px; }
  .info-panel { right: 8px; top: 48px; }
  .conflict-columns { grid-template-columns: 1fr; }
}

/* Touch screens: finger-sized targets (about 40 points) without changing the mouse layout. */
@media (pointer: coarse) {
  .icon-button { width: 40px; height: 40px; }
  .editor-toolbar .icon-button { width: 40px; }
  .format-bar button { min-width: 40px; min-height: 40px; }
  .nav-item { min-height: 40px; }
  .heading-toggle { min-height: 36px; }
  .heading-action { display: inline-flex; align-items: center; min-height: 36px; padding: 0 10px; font-size: 13px; }
  .text-button { min-height: 36px; }
  .tag-pill { padding-top: 4px; padding-bottom: 4px; }
  .tag-pill .remove { min-width: 28px; min-height: 28px; margin: -4px -4px -4px 0; font-size: 16px; }
}

/* Formatting help: a wide reference in cards, keys drawn as keycaps. */
.help-dialog { max-width: 940px; padding: 0; max-height: min(88vh, 920px); overflow: hidden; }
.help-dialog[open] { display: flex; flex-direction: column; }
.help-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.help-head h2 { flex: 1; margin: 0; }
.help-filter { width: min(260px, 45vw); padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--sidebar); color: var(--ink); font: inherit; font-size: 14px; }
.help-close { flex: none; }
.help-tip { flex: none; margin: 0; padding: 10px 20px 0; font-size: 12.5px; color: var(--muted); min-height: 1.4em; }
.help-tip.miss { color: var(--danger, #d64545); }
.help-sections { overflow: auto; padding: 12px 20px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.help-card { border: 1px solid var(--line); border-radius: 12px; background: var(--sidebar); padding: 4px; }
.help-card:first-child { grid-row: span 2; }
.help-card h3 { margin: 10px 12px 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.help-row { display: grid; grid-template-columns: 22px minmax(0, max-content) minmax(0, 1fr); align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; font-size: 14px; transition: background-color .2s; }
.help-row + .help-row { box-shadow: inset 0 1px var(--line); }
.help-row .help-icon { color: var(--ink); display: flex; }
.help-card.no-icons .help-row { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); }
.help-card.no-icons .help-icon { display: none; }
.help-row .help-label { font-weight: 600; }
.help-row .help-desc { justify-self: end; text-align: right; color: var(--muted); line-height: 1.7; }
.help-row.flash { background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: none; }
.help-keys { display: inline-flex; gap: 3px; vertical-align: baseline; }
.help-desc kbd { display: inline-block; min-width: 1.75em; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--bg); color: var(--ink); font: 600 12px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; text-align: center; }
.help-empty { margin: 0; padding: 0 20px 24px; color: var(--muted); }
@media (max-width: 720px) {
  .help-sections { grid-template-columns: 1fr; }
  .help-card:first-child { grid-row: auto; }
  .help-head { flex-wrap: wrap; }
  .help-filter { order: 3; width: 100%; }
}

/* Expanded: the note takes the whole window; the sidebar and list step aside. */
#expand-note .expand-in, #expand-note[aria-pressed="true"] .expand-out { display: none; }
#expand-note[aria-pressed="true"] .expand-in { display: inline; }
@media (min-width: 681px) {
  .app.expanded { grid-template-columns: minmax(0, 1fr); }
  .app.expanded .sidebar, .app.expanded .list-pane, .app.expanded .scrim { display: none; }
  .app.expanded .editor > :not(.sr-only) { max-width: 1400px; }
}
@media (max-width: 680px) { #expand-note { display: none; } }

/* Tables: a quiet grid like Apple Notes. The ⋯ handles sit on the current
   column's top edge and the current row's left edge. */
.note-body .ql-editor table { border-collapse: collapse; table-layout: fixed; width: 100%; margin: .5em 0; }
.note-body .ql-editor table td { border: 1px solid var(--line); padding: 7px 10px; min-width: 3em; vertical-align: top; line-height: 1.45; overflow-wrap: anywhere; }
.note-body .ql-editor table td:focus-within { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.table-handle { position: fixed; z-index: 30; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--muted); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); cursor: pointer; }
.table-handle.column { width: 30px; height: 16px; transform: translate(-50%, -50%); }
.table-handle.row { width: 16px; height: 30px; transform: translate(-50%, -50%); }
.table-handle:hover, .table-handle[aria-expanded="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.table-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.table-menu { position: fixed; z-index: 40; min-width: 190px; padding: 5px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.table-menu[hidden] { display: none; }
.table-menu button { text-align: left; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.table-menu button:hover, .table-menu button:focus-visible { background: var(--hover); outline: none; }
.table-menu button.danger { color: var(--danger); }
.table-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
@media (hover: none) {
  .table-handle.column { width: 40px; height: 22px; }
  .table-handle.row { width: 22px; height: 40px; }
}

.collection-choice { display: flex; align-items: center; gap: 12px; padding: 12px 4px; cursor: pointer; }
.collection-choice .count { margin-left: auto; }
.collection-choice input { width: 18px; height: 18px; flex: none; }
#collection-membership { max-height: 55vh; overflow: auto; }
#collection-create-dialog { max-width: min(440px, calc(100vw - 32px)); }
#collection-name { display: block; width: 100%; box-sizing: border-box; margin-top: 8px; padding: 10px; font: inherit; }

/* Sebastian only: today's events beside the notes */
.agenda-section { margin-top: 10px; }
.agenda-section .heading-action { text-decoration: none; }
.agenda-group { margin-bottom: 6px; }
.agenda-day { font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 10px 2px; }
.agenda-item { display: grid; grid-template-columns: 54px 3px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; padding: 5px 10px; border: 0; background: none; border-radius: 8px; text-align: left; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; }
.agenda-item:hover { background: var(--hover); }
.agenda-item.past { opacity: .5; }
.agenda-item.now .agenda-time { color: var(--accent); font-weight: 700; }
.agenda-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.agenda-bar { width: 3px; height: 18px; border-radius: 2px; }
.agenda-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-action { font-size: 12px; color: var(--muted); opacity: .7; }
.agenda-item:hover .agenda-action { opacity: 1; }
.agenda-empty { font-size: 12px; color: var(--faint); padding: 2px 10px 6px; }
.note-event { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.note-event-bar { width: 3px; height: 16px; border-radius: 2px; flex: none; }
.note-event strong { color: var(--ink); font-weight: 600; }
.note-event a { color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.note-event a:hover { text-decoration: underline; }
@media (pointer: coarse) { .note-event a { padding: 8px 0; } }
