* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  color-scheme: light;
  --app-bg: #f3f3f3; --surface: #ffffff; --text: #202020; --muted: #606060; --faint: #808080;
  --border: #d6d6d6; --hover: rgba(0,0,0,.06); --input-bg: #e8e8e8; --sep: #e5e5e5;
  --shadow: 0 8px 28px rgba(0,0,0,.22); --card-shadow: 0 1px 2px rgba(0,0,0,.08); --folder-line: #dcdcdc;
  --note-bg: #fff7d1; --note-bar: #f5d34f; --note-text: #202020;
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
}
/* dark: follows the phone unless a theme is picked in Settings (data-theme on <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --app-bg: #202020; --surface: #2c2c2c; --text: #f0f0f0; --muted: #b0b0b0; --faint: #8a8a8a;
    --border: #3d3d3d; --hover: rgba(255,255,255,.08); --input-bg: #2c2c2c; --sep: #3d3d3d;
    --shadow: 0 8px 28px rgba(0,0,0,.6); --card-shadow: 0 1px 2px rgba(0,0,0,.4); --folder-line: #3d3d3d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #202020; --surface: #2c2c2c; --text: #f0f0f0; --muted: #b0b0b0; --faint: #8a8a8a;
  --border: #3d3d3d; --hover: rgba(255,255,255,.08); --input-bg: #2c2c2c; --sep: #3d3d3d;
  --shadow: 0 8px 28px rgba(0,0,0,.6); --card-shadow: 0 1px 2px rgba(0,0,0,.4); --folder-line: #3d3d3d;
}

html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, 'Segoe UI Variable Text', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px; color: var(--text); background: var(--app-bg);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* text selection and cursor in dark gray instead of the default blue (same as on the computer).
   iPhone tints its selection with the cursor colour, so caret-color is set too. */
::selection { background: #5c5c5c; color: #ffffff; }
input, textarea, #editor { caret-color: #5c5c5c; }
:root[data-theme="dark"] ::selection { background: #8a8a8a; }
:root[data-theme="dark"] input, :root[data-theme="dark"] textarea, :root[data-theme="dark"] #editor { caret-color: #b0b0b0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) ::selection { background: #8a8a8a; }
  :root:not([data-theme="light"]) input, :root:not([data-theme="light"]) textarea, :root:not([data-theme="light"]) #editor { caret-color: #b0b0b0; }
}

svg.fi { width: 20px; height: 20px; flex: none; fill: currentColor; }
.icon-btn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }
.icon-btn:active { background: var(--hover); }
.icon-btn svg.fi { width: 22px; height: 22px; }

.btn { padding: 10px 16px; border-radius: 8px; background: var(--input-bg); border: 1px solid var(--border); font-weight: 600; }
.btn.primary { background: var(--text); color: var(--app-bg); border-color: var(--text); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.btn.danger { background: #e34243; border-color: #e34243; color: #fff; } /* delete / warning actions in red (same as Important) */

.screen { min-height: 100%; }

/* ---------- sign in ---------- */
#login { display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--safe-top)) 20px 24px; }
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { font-size: 30px; margin: 0 0 8px; }
.login-box form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type=email], input[type=password], input[type=text], input[type=url] {
  font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 12px; outline: none;
}
input:focus { border-color: var(--muted); }
.msg { min-height: 18px; margin: 0; font-size: 13px; color: var(--muted); }
.msg.error { color: #e34243; }
.login-box form[hidden] { display: none; }
/* two-step sign-in: the 6-digit code, the QR code to scan and the key to type in by hand */
input.mfa-code { font-size: 22px; letter-spacing: .3em; text-align: center; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; outline: none; }
.mfa-qr { display: block; width: 180px; height: 180px; margin: 6px auto; padding: 8px; background: #fff; border-radius: 10px; }
.mfa-key { font-family: ui-monospace, Menlo, monospace; font-size: 13px; user-select: all; -webkit-user-select: all; word-break: break-all; color: var(--text); }
.sheet .mfa-form { display: flex; flex-direction: column; gap: 10px; padding: 4px 12px 10px; }
.sheet .mfa-form .actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- list ---------- */
#list { display: flex; flex-direction: column; }
.list-head { position: sticky; top: 0; z-index: 5; background: var(--app-bg); padding: calc(10px + var(--safe-top)) 16px 8px; }
.title-row { display: flex; align-items: center; gap: 8px; }
.title-row h1 { font-size: 28px; margin: 0; flex: 1; }
/* logo + name on top, then a bit of air before the tab title */
.app-bar { display: flex; align-items: center; gap: 4px; margin: -6px -8px 10px 0; }
.app-name { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.app-logo { width: 20px; height: 20px; }
.app-logo.dark { display: none; }
:root[data-theme="dark"] .app-logo.light { display: none; }
:root[data-theme="dark"] .app-logo.dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-logo.light { display: none; }
  :root:not([data-theme="light"]) .app-logo.dark { display: block; }
}
/* sync state: cloud icon like on the computer (pulses while syncing, red on a problem) */
.sync-btn.syncing svg { animation: sync-pulse 1s ease-in-out infinite; }
.sync-btn.error, .sync-btn.offline { color: #e34243; }
@keyframes sync-pulse { 50% { opacity: .35; } }
.search { display: flex; flex-direction: row; align-items: center; gap: 8px; background: var(--input-bg); border-radius: 10px; padding: 0 12px; height: 42px; margin-top: 8px; border: 1px solid var(--border); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; }
.search input::-webkit-search-cancel-button { display: none; }
.search svg { color: var(--muted); }
.create-row { display: flex; gap: 8px; margin-top: 10px; }
.create-btn { display: flex; align-items: center; justify-content: center; gap: 6px; height: 42px; padding: 0 16px 0 14px; min-width: 0; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; }
.create-btn:active { background: var(--hover); }
.create-btn svg.fi { width: 18px; height: 18px; }

main#items { padding: 4px 16px calc(88px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; } /* room for the tab bar */
.empty-state { white-space: pre-line; }

/* ---------- tabs: bar at the bottom (phone), rail on the left (iPad) – like Teams ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; padding: 4px 4px calc(4px + var(--safe-bottom));
  background: #e6e6e6; border-top: 1px solid var(--border); /* a shade darker, like the Teams side bar */
}
:root[data-theme="dark"] .tabbar { background: #161616; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabbar { background: #161616; } }
.tab-btn { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 4px; color: var(--muted); border-radius: 8px; }
.tab-btn .ti { display: flex; }
.tab-btn .ti svg.fi { width: 24px; height: 24px; fill: currentColor; }
.tab-btn .tl { font-size: 11px; }
.tab-btn.active { color: #2b2b2b; }
.tab-btn .badge {
  position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box;
  border-radius: 9px; background: #5c5c5c; color: #fff; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.tab-btn .badge.red { background: #e34243; }
:root[data-theme="dark"] .tab-btn.active { color: #f0f0f0; }
:root[data-theme="dark"] .tab-btn .badge:not(.red) { background: #8a8a8a; color: #1f1f1f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tab-btn.active { color: #f0f0f0; }
  :root:not([data-theme="light"]) .tab-btn .badge:not(.red) { background: #8a8a8a; color: #1f1f1f; }
}

/* folder rows are pulled 7 px left so the arrows line up with the note cards; the row highlight sticks out 7 px on both sides
   and the row icons end about 10 px from its right end (same as on the computer) */
.folder { display: flex; flex-direction: column; margin-left: -7px; }
.folder-head { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 0 0 4px; margin-right: -7px; border-radius: 8px; font-weight: 600; }
.folder-head .fbtn:last-child { margin-right: 1px; }
.folder-head:active { background: var(--hover); }
.folder-head .chev { width: 16px; height: 16px; transition: transform .15s; }
.folder.collapsed .chev { transform: rotate(-90deg); }
.folder-head .fname { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-head .count { font-weight: 400; font-size: 13px; color: var(--faint); }
.folder-head .fspacer { flex: 1; }
.folder-head .fbtn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--muted); }
.folder-head .fbtn:active { background: var(--hover); }
.folder-body { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 6px 14px; padding-left: 10px; border-left: 2px solid var(--folder-line); }
.folder.collapsed .folder-body { display: none; }
.folder-empty { font-size: 13px; color: var(--faint); padding: 6px 2px; }

.loose-notes { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Archive ---------- */
.tab-btn.tab-archive { display: none; } /* phone: opened from Settings, the bar keeps its 5 tabs */
.archive-info { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 0 0 4px; }
.archive-info span { flex: 1; min-width: 0; }
.archive-info button { flex: none; min-height: 36px; padding: 0 10px; border-radius: 8px; color: #e34243; font-size: 13px; font-weight: 600; }
.archive-info button:active { background: var(--hover); }

/* ---------- iPad / wide screens ---------- */
@media (min-width: 700px) {
  /* the list doesn't stretch over a huge screen */
  .list-head, main#items { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; }
  .list-head { padding-left: 24px; padding-right: 24px; }
  main#items { padding-left: 24px; padding-right: 24px; }
  .create-btn { font-size: 14px; }
  /* tabs become a rail on the left, like Teams on a computer */
  #list { padding-left: 80px; }
  .tabbar {
    right: auto; top: 0; width: 80px; flex-direction: column; gap: 4px;
    padding: calc(var(--safe-top) + 12px) 6px calc(12px + var(--safe-bottom));
    border-top: 0; border-right: 1px solid var(--border);
  }
  .tab-btn { flex: none; height: 62px; justify-content: center; }
  .tab-btn.tab-archive { display: flex; margin-top: auto; } /* iPad: Archive at the bottom of the rail */
  .tab-btn.active::before { content: ''; position: absolute; left: -6px; top: 16px; bottom: 16px; width: 3px; border-radius: 2px; background: currentColor; }
  main#items { padding-bottom: calc(24px + var(--safe-bottom)); }
  /* notes stay one under another, like on the phone – just a bit more air */
  .notes-grid, .folder-body.notes-grid { gap: 10px; }
  /* the open note: a centred note window, not stretched edge to edge */
  #editor-screen {
    left: 0; right: 0; margin: 0 auto; width: min(680px, calc(100% - 48px));
    top: calc(var(--safe-top) + 56px);
    height: min(760px, calc(100% - var(--safe-top) - var(--safe-bottom) - 112px));
  }
  #editor { font-size: 18px; padding: 18px 22px 28px; }
  /* menus without a button to sit next to: a centred box instead of a full-width sheet */
  .sheet:not(.pop) { left: 50%; right: auto; bottom: 24px; width: min(480px, calc(100% - 48px)); transform: translateX(-50%); border-radius: 14px; padding-bottom: 12px; }
}
/* trackpad / mouse on iPad: hover feedback */
@media (hover: hover) {
  .card:hover { filter: brightness(.97); }
  .folder-head:hover, .icon-btn:hover, .fbtn:hover, .sheet .item:hover, .create-btn:hover { background: var(--hover); }
}

.section-title { display: flex; align-items: center; font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; padding: 10px 2px 0; }
.section-title .ssort { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); padding: 6px 4px; }
.section-title .ssort svg.fi { width: 16px; height: 16px; }

.card { position: relative; border-radius: 8px; border-top: 4px solid; padding: 10px 12px 12px; box-shadow: var(--card-shadow); }

/* pull to refresh – the spinner sits under the sticky header (z-index 5) and slides out below it */
#ptr {
  position: fixed; left: 50%; top: 170px; z-index: 4; width: 38px; height: 38px; margin-left: -19px;
  border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; transform: translateY(-56px); opacity: 0; pointer-events: none;
}
#ptr .ptr-spinner { width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--muted); border-radius: 50%; }
#ptr.ready .ptr-spinner { border-top-color: var(--text); }
#ptr.spin .ptr-spinner { animation: ptr-spin .7s linear infinite; }
#ptr.back, #items.pull-back { transition: transform .22s ease, opacity .22s ease; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* drag & drop (press and hold) */
.card, .folder-head { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.card img { -webkit-touch-callout: none; pointer-events: none; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 50; margin: 0; pointer-events: none; opacity: .95; box-shadow: var(--shadow); border-radius: 8px; }
.folder-head.drag-ghost { background: var(--surface); }
.drag-src { opacity: .35; }
body.dragging, body.dragging * { -webkit-user-select: none !important; user-select: none !important; }
.drop-line { position: fixed; z-index: 49; height: 3px; margin-top: -1.5px; border-radius: 2px; background: var(--muted); pointer-events: none; }
.drop-into { background: var(--hover); box-shadow: inset 0 0 0 2px var(--muted); border-radius: 8px; }
.card:active { filter: brightness(.96); }
.card .meta { display: flex; justify-content: flex-end; font-size: 12px; opacity: .65; height: 16px; }
.card .preview { line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.card .preview.empty { opacity: .5; font-style: italic; }
.card .line { position: relative; }
.card .line.first { font-weight: 600; }
.card .line.bullet, .card .line.check, .card .line.checked { padding-left: 22px; }
.card .line .mark { position: absolute; left: 2px; top: 0; height: 1.4em; display: flex; align-items: center; }
.card .line.bullet .mark::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-left: 4px; }
.card .line.check .mark::before, .card .line.checked .mark::before { content: ''; width: 14px; height: 14px; box-sizing: border-box; border: 1.5px solid currentColor; border-radius: 3px; opacity: .75; }
.card .line.checked .mark::before { background: currentColor; opacity: .8; }
/* the tick: the card colour cut out of the filled box (same as on the computer) */
.card .line.checked .mark::after {
  content: ''; position: absolute; left: 0; top: calc(.7em - 7px); width: 14px; height: 14px;
  background: var(--card-bg, #fff);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.3l2.9 2.9 6.1-6.6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px 11px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.3l2.9 2.9 6.1-6.6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px 11px no-repeat;
}
.card .line.checked { text-decoration: line-through; opacity: .65; }
.card .thumb { display: block; max-width: 140px; max-height: 80px; border-radius: 6px; margin: 3px 0; border: 1px solid rgba(128,128,128,.35); }

.empty-state { text-align: center; color: var(--faint); margin-top: 40px; line-height: 1.6; }

/* ---------- editor ---------- */
/* the note: a sticky-note card floating over the dimmed list */
.ed-backdrop { position: fixed; inset: 0; z-index: 19; background: rgba(0,0,0,.38); animation: fade-in .15s ease-out; }
body.note-open { overflow: hidden; }
#editor-screen {
  display: flex; flex-direction: column; min-height: 0; background: var(--note-bg); color: var(--note-text);
  position: fixed; z-index: 20; left: 12px; right: 12px;
  top: calc(var(--safe-top) + 48px);
  height: min(560px, calc(100% - var(--safe-top) - var(--safe-bottom) - 96px));
  border-radius: 12px; overflow: hidden; box-shadow: 0 14px 44px rgba(0,0,0,.38);
  animation: card-in .16s ease-out;
}
@keyframes card-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.ed-bar { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 14px; background: var(--note-bar); color: var(--bar-text, #202020); flex: none; }
.ed-where { font-size: 14px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
#editor { flex: 1; overflow-y: auto; padding: 14px 16px 24px; outline: none; font-size: 17px; line-height: 1.45; word-break: break-word; -webkit-user-select: text; user-select: text; }
#editor:empty::before { content: 'Take a note…'; opacity: .5; }
#editor ul { margin: 0; padding-left: 24px; }
#editor ol { margin: 0; padding-left: 28px; }
#editor ul.checklist { list-style: none; padding-left: 0; }
#editor ul.checklist li { position: relative; padding-left: 30px; }
#editor ul.checklist li::before { content: ''; position: absolute; left: 2px; top: .18em; width: 18px; height: 18px; border: 1.5px solid currentColor; border-radius: 4px; opacity: .75; box-sizing: border-box; }
#editor ul.checklist li[data-checked="true"]::before { background: currentColor; opacity: .85; }
#editor ul.checklist li[data-checked="true"]::after {
  content: ''; position: absolute; left: 2px; top: .18em; width: 18px; height: 18px; background: var(--note-bg);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.3l2.9 2.9 6.1-6.6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
}
#editor ul.checklist li[data-checked="true"] { text-decoration: line-through; opacity: .6; }
/* important item: red exclamation mark between the box and the text */
#editor ul.checklist li[data-important="true"] {
  padding-left: 48px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2.6v7' stroke='%23e34243' stroke-width='2.8' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='13.2' r='1.7' fill='%23e34243'/%3E%3C/svg%3E") no-repeat 25px .18em / 18px 18px;
}
/* not done on its day (marked at 20:00): red outline, like important notes – the ! is only for "important" */
#editor ul.checklist li[data-missed="true"] { box-shadow: 0 0 0 2px #e34243; border-radius: 5px; padding-right: 8px; margin: 6px 0; }
/* a list with highlighted items is only as wide as its longest item, so the highlights end there */
#editor ul.checklist:has(> li[data-missed="true"]) { width: fit-content; max-width: 100%; min-width: 120px; }
.card .line.missed { box-shadow: 0 0 0 1.5px #e34243; border-radius: 3px; margin: 3px 0 3px 2px; width: fit-content; max-width: 100%; box-sizing: border-box; padding-right: 6px; }
#ed-tools .tool[data-action="important"].active { color: #e34243; }
/* move to another day: Next day + month calendar */
.day-pick { width: 280px; max-width: 100%; }
.day-pick .dp-next { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 8px; font-size: 15px; }
.day-pick .dp-next:active { background: var(--hover); }
.day-pick .dp-next svg.fi { width: 20px; height: 20px; }
.day-pick .dp-sub { margin-left: auto; color: var(--muted); font-size: 13px; }
.day-pick .dp-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 4px; padding-top: 8px; border-top: 1px solid var(--border); font-weight: 600; }
.day-pick .dp-nav { width: 40px; height: 36px; border-radius: 8px; font-size: 22px; line-height: 1; }
.day-pick .dp-nav:active { background: var(--hover); }
.day-pick .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.day-pick .dp-wd { font-size: 11px; color: var(--muted); text-align: center; line-height: 20px; }
.day-pick .dp-day { position: relative; height: 36px; border-radius: 8px; font-size: 15px; }
.day-pick .dp-day:active:not(:disabled) { background: var(--hover); }
.day-pick .dp-day:disabled { opacity: .35; }
.day-pick .dp-day.today { box-shadow: inset 0 0 0 1.5px currentColor; font-weight: 600; }
.day-pick .dp-day.has-note::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: currentColor; opacity: .55; }
/* important note: red ! on the card (top left) and a red button in the note's top bar */
.card .imp-note { position: absolute; top: 5px; left: 10px; display: flex; color: #e34243; }
.card .imp-note svg.fi { width: 16px; height: 16px; }
.icon-btn.ed-imp.on { background: #e34243; color: #ffffff; }
.card.important { box-shadow: 0 0 0 2px #e34243, var(--card-shadow); }                 /* red border */
#editor-screen.important { box-shadow: 0 0 0 2.5px #e34243, 0 14px 44px rgba(0,0,0,.38); }
.card .line .imp { display: inline-block; color: #e34243; font-weight: 800; margin-right: 6px; }
#editor a { color: #7536f0; font-weight: 600; text-decoration: none; }
#editor .att {
  display: inline-block; position: relative; max-width: 100%; padding: 6px 12px 6px 32px; margin: 3px 0; vertical-align: middle;
  border: 1px solid rgba(128,128,128,.45); border-radius: 8px; background: rgba(255,255,255,.4);
  font-size: 15px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: pointer;
}
#editor .att::before {
  content: ''; position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; margin-top: -8px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M4.83 10.48L10.49 4.83C11.66 3.66 13.56 3.66 14.73 4.83C15.9 6 15.9 7.9 14.73 9.07L8.01 15.79C7.42 16.37 6.47 16.37 5.89 15.79C5.3 15.2 5.3 14.25 5.89 13.67L11.9 7.66C12.09 7.46 12.09 7.14 11.9 6.95C11.7 6.75 11.39 6.75 11.19 6.95L5.18 12.96C4.21 13.94 4.21 15.52 5.18 16.5C6.16 17.47 7.74 17.47 8.72 16.5L15.43 9.78C17 8.22 17 5.68 15.43 4.12C13.87 2.56 11.34 2.56 9.78 4.12L4.12 9.78C3.93 9.97 3.93 10.29 4.12 10.48C4.32 10.68 4.63 10.68 4.83 10.48Z'/></svg>") center / 16px 16px no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M4.83 10.48L10.49 4.83C11.66 3.66 13.56 3.66 14.73 4.83C15.9 6 15.9 7.9 14.73 9.07L8.01 15.79C7.42 16.37 6.47 16.37 5.89 15.79C5.3 15.2 5.3 14.25 5.89 13.67L11.9 7.66C12.09 7.46 12.09 7.14 11.9 6.95C11.7 6.75 11.39 6.75 11.19 6.95L5.18 12.96C4.21 13.94 4.21 15.52 5.18 16.5C6.16 17.47 7.74 17.47 8.72 16.5L15.43 9.78C17 8.22 17 5.68 15.43 4.12C13.87 2.56 11.34 2.56 9.78 4.12L4.12 9.78C3.93 9.97 3.93 10.29 4.12 10.48C4.32 10.68 4.63 10.68 4.83 10.48Z'/></svg>") center / 16px 16px no-repeat;
}
#editor .att.loading { opacity: .5; }
:root[data-theme="dark"] #editor .att { background: rgba(255,255,255,.08); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #editor .att { background: rgba(255,255,255,.08); } }
#editor img.shot[data-shot$=".svg"], .card .thumb[src*=".svg?"] { background: #fff; min-width: 40px; min-height: 40px; object-fit: contain; }
.viewer img[src*=".svg?"] { background: #fff; width: 90vw; height: auto; }
#editor img.shot { display: block; max-width: min(100%, 220px); max-height: 160px; margin: 6px 0; border-radius: 8px; border: 1px solid rgba(128,128,128,.35); }
.ed-tools { display: flex; align-items: center; justify-content: space-around; padding: 4px 6px; border-top: 1px solid rgba(128,128,128,.25); flex: none; background: var(--note-bg); }
.tool { width: 42px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--note-text); opacity: .85; }
.tool.active { background: rgba(128,128,128,.25); opacity: 1; }
.link-bubble { position: fixed; z-index: 30; display: inline-flex; gap: 6px; align-items: center; background: #202020; color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 14px; text-decoration: none; box-shadow: var(--shadow); }
.link-bubble svg.fi { width: 16px; height: 16px; }

/* ---------- bottom sheet (menus) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--surface); color: var(--text); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  padding: 8px 12px calc(16px + var(--safe-bottom)); max-height: 80vh; overflow-y: auto;
}
/* pop-up next to the button that opened it */
.sheet-backdrop.light { background: rgba(0,0,0,.12); }
.sheet.pop {
  right: auto; bottom: auto; border-radius: 12px; padding: 4px 6px 6px;
  border: 1px solid var(--border); max-height: 70vh; overscroll-behavior: contain;
  animation: pop-in .12s ease-out;
}
.sheet.pop .item { padding: 11px 8px; font-size: 15px; }
.sheet.pop h3 { margin: 8px 8px 2px; }
@keyframes pop-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.sheet h3 { font-size: 13px; color: var(--faint); font-weight: 600; margin: 10px 8px 4px; text-transform: uppercase; letter-spacing: .04em; }
.sheet .item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 8px; border-radius: 8px; text-align: left; font-size: 16px; }
.sheet .item:active { background: var(--hover); }
.sheet .item.current::after { content: '✓'; margin-left: auto; }
/* info lines in a sheet (sync: account, state) as a bulleted list */
.sheet .menu-info { margin: 2px 0 6px; padding: 0 12px 0 30px; font-size: 14px; color: var(--muted); line-height: 1.7; list-style: disc; }
.sheet .item.danger { color: #e34243; }
.sheet .colors { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 8px; }
.sheet .swatch { height: 52px; border-radius: 10px; border: 1px solid rgba(128,128,128,.3); position: relative; }
/* selected colour: a tick, like on the computer (the custom swatch has its palette, so it gets a ring instead) */
.sheet .swatch.current:not(.custom)::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 14px; height: 8px;
  border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
}
.sheet .swatch.custom.current { box-shadow: inset 0 0 0 2px currentColor; }
.sheet .swatch.custom { display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sheet .swatch.custom.blank { border-color: #000000; }
.sheet .swatch.custom svg.fi { width: 24px; height: 24px; pointer-events: none; }
.sheet .swatch.custom input[type=color] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }
.sheet .form { display: flex; flex-direction: column; gap: 10px; padding: 8px; }
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; padding: 8px; }

/* ---------- image viewer ---------- */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; display: flex; align-items: center; justify-content: center; padding: var(--safe-top) 8px var(--safe-bottom); }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

.sheet .confirm-warn { color: #e34243; font-weight: 600; margin-top: 2px; } /* deleting a folder/month deletes its notes */
