/* Space Note on phones. Colours follow its icon: cream and gold on
   white paper. The editor rules follow the Mac's
   (../style.css, .spacenote-editor), so a note looks the same everywhere. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --group-bg: #f7eecb; /* the cream page behind the list's boxes */
  --box: #fffbee; /* the lighter cream of a group's box */
  --glass: rgba(255, 255, 255, 0.22); /* the floating + : frosted glass */
  --glass-sheen: linear-gradient(145deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.05) 60%);
  --glass-edge: rgba(255, 255, 255, 0.75);
  --glass-shine: rgba(255, 255, 255, 0.9);
  --bar: #fffaea;
  --fg: #1d1d1f;
  --fg-dim: #6b6350;
  --line: rgba(74, 56, 0, 0.14);
  --chip: rgba(74, 56, 0, 0.06);
  --press: rgba(74, 56, 0, 0.1);
  --accent: #806400; /* the icon's gold, dark enough to read as text */
  --on-accent: #ffffff;
  --mark: #ffe28a; /* a search match: the cream, deep enough to show on a box */
  --on-mark: #1d1d1f;
  --danger: #c40013;
  --vv-top: 0px;
  --vv-height: 100%;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --scale: 1; /* Settings → Display size (app.js) */
  font: 17px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1b17;
    --group-bg: #0f0e0b;
    --box: #211e18;
    --glass: rgba(98, 90, 70, 0.3);
    --glass-sheen: linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.02) 60%);
    --glass-edge: rgba(255, 255, 255, 0.18);
    --glass-shine: rgba(255, 255, 255, 0.22);
    --bar: #26231c;
    --fg: #f7f4ec;
    --fg-dim: #a39c8b;
    --line: rgba(255, 255, 255, 0.12);
    --chip: rgba(255, 255, 255, 0.08);
    --press: rgba(255, 255, 255, 0.12);
    --accent: #e8bd45;
    --on-accent: #1d1b17;
    --mark: #ffe28a;
  --on-mark: #1d1d1f;
  --danger: #ff6961;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* The app fills the visible part of the screen: above the keyboard on iPhone (app.js sets the
   two variables from visualViewport), and the resized page on Android. */
/* Display size zooms the page; a zoomed page's lengths are multiplied too, so #app's place is
   divided back to stay on the visible part of the screen. */
body { zoom: var(--scale); }
#app { position: fixed; left: 0; right: 0; top: calc(var(--vv-top) / var(--scale)); height: calc(var(--vv-height) / var(--scale)); overflow: hidden; }
.screen { position: absolute; inset: 0; background: var(--bg); min-height: 0; display: flex; flex-direction: column; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.screen.center { align-items: center; justify-content: center; text-align: center; padding: 24px 24px calc(24px + var(--safe-bottom)); gap: 12px; overflow-y: auto; }
.screen.center h1 { font-size: 1.35em; margin: 4px 0; }
.big-icon { width: 72px; height: 72px; border-radius: 16px; }
.dim { color: var(--fg-dim); font-size: 0.88em; max-width: 34em; }
.steps { text-align: left; margin: 4px 0; padding-left: 1.4em; }
.steps li { margin: 6px 0; }
.glyph { color: var(--accent); }

.bar-top { flex: none; display: flex; align-items: center; gap: 2px; padding: calc(6px + env(safe-area-inset-top, 0px)) 6px 6px; border-bottom: 1px solid var(--line); background: var(--bar); }
.bar-top .title { flex: 1; min-width: 0; margin: 0; font-size: 1em; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { flex: none; min-width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--accent); font-size: 1.5em; line-height: 1; }
.icon:active { background: var(--press); }

.banner { flex: none; margin: 0; padding: 8px 14px; font-size: 0.85em; background: var(--chip); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner button { border: 0; background: none; color: var(--accent); padding: 4px 0; font-size: 1em; }
.banner button.danger { color: var(--danger); }

/* ---------- The note ---------- */
.editor-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.editor { padding: 14px 18px 0; }
.editor-tail { min-height: 40vh; }
.editor .tiptap { outline: none; min-height: 3em; overflow-wrap: anywhere; }
.editor .tiptap h1 { font-size: 1.35em; margin: 0.2em 0 0.4em; }
.editor .tiptap h2 { font-size: 1.12em; margin: 0.5em 0 0.3em; }
.editor .tiptap hr { border: 0; border-top: 1px solid var(--line); margin: 0.8em 0; }
.editor .tiptap hr.ProseMirror-selectednode { border-top-color: var(--accent); }
.editor .tiptap p { margin: 0 0 0.35em; }
.editor .tiptap ul, .editor .tiptap ol { margin: 0 0 0.35em; padding-left: 1.4em; }
.editor .tiptap a { color: var(--accent); }
.editor .tiptap p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--fg-dim); float: left; height: 0; pointer-events: none; }
.editor ul[data-type="taskList"] { list-style: none; padding-left: 0.2em; }
.editor ul[data-type="taskList"] li { display: flex; gap: 0.5em; align-items: baseline; }
.editor ul[data-type="taskList"] li > label { flex: none; }
.editor ul[data-type="taskList"] li > label input { width: 1.05em; height: 1.05em; margin: 0; accent-color: var(--accent); }
.editor ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.editor ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--fg-dim); text-decoration: line-through; }

.format-bar { flex: none; display: flex; gap: 2px; padding: 4px 6px calc(4px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--bar); }
.format-bar button { flex: 1; min-width: 0; height: 40px; border: 0; border-radius: 8px; background: none; font-size: 1em; }
.format-bar button.on { background: var(--press); color: var(--accent); }
.format-bar button.done { color: var(--fg-dim); }
.format-bar button:disabled { opacity: 0.35; }
/* With the keyboard up there's no home bar inset to keep clear. */
body.keyboard .format-bar { padding-bottom: 4px; }

/* ---------- The list ---------- */
.search-wrap { flex: none; padding: 8px 12px; }
#search { width: 100%; font: inherit; font-size: 16px; padding: 8px 12px; border: 0; border-radius: 10px; background: var(--chip); color: var(--fg); outline: none; -webkit-appearance: none; appearance: none; }
.rows { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 0; list-style: none; overscroll-behavior: contain; }
.rows li > button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.rows li > button:active { background: var(--press); }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: flex; gap: 10px; font-size: 0.85em; color: var(--fg-dim); min-width: 0; }
.row-date { flex: none; }
.row-snippet { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows mark { background: var(--mark); color: var(--on-mark); border-radius: 3px; }
.rows .empty { padding: 24px 16px; color: var(--fg-dim); text-align: center; }

/* The list: rounded boxes on a grey ground, each group's name above its box on the left. */
#list { background: var(--group-bg); }
#list .search-wrap, #list .list-foot { background: var(--group-bg); }
#list #search { background: var(--box); }
#rows { padding: 0 16px 16px; }
#rows .section { margin-top: 14px; }
#rows .section:first-child { margin-top: 4px; }
#rows .section-title { margin: 0 0 6px 4px; font-size: 1.05em; font-weight: 700; color: var(--fg); }
#rows .section-toggle { display: flex; align-items: center; gap: 7px; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; }
#rows .section-toggle .chevron { flex: none; width: 10px; height: 10px; color: var(--fg-dim); }
#rows .section-toggle .chevron svg { display: block; }
#rows .section-toggle .count { color: var(--fg-dim); font-weight: 400; }
#rows .section-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }
#rows .box { margin: 0; padding: 0; list-style: none; background: var(--box); border-radius: 12px; overflow: hidden; }
#rows .box > li > button { padding: 10px 14px; }
#rows .box > li:last-child > button { border-bottom: 0; }
/* Swiping a row left uncovers Pin and Delete behind it. */
#rows .box > li.swipe { position: relative; }
#rows .box > li.swipe > button { position: relative; z-index: 1; background: var(--box); touch-action: pan-y; -webkit-user-select: none; user-select: none; }
#rows .box > li.swipe > button:active { background: linear-gradient(var(--press), var(--press)), var(--box); }
.row-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.row-actions button { width: 74px; border: 0; padding: 0; font-size: 0.85em; font-weight: 600; color: #ffffff; background: var(--danger); }
.row-actions button.pin { background: var(--accent); color: var(--on-accent); }
#rows .deleted-section .box > li > button { display: flex; justify-content: space-between; color: var(--fg-dim); }

/* Sliding between the list and a note. */
.screen.sliding { z-index: 3; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15); }
.screen.behind { z-index: 1; pointer-events: none; }
.list-foot { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 12px calc(6px + var(--safe-bottom)); }
.list-foot:empty, .list-foot:not(:has(:not([hidden]))) { padding: 0 0 var(--safe-bottom); }
.status { border: 0; background: none; color: var(--fg-dim); font-size: 0.8em; padding: 4px; }
.status.alert { color: var(--danger); }

/* ---------- Wide screens: the list beside the note ----------
   An unfolded phone, a tablet or a computer (app.js turns on body.split from 600px wide) keeps
   the list as a sidebar on the left. The sidebar button in the note's bar slides it away
   (body.side-off) and back; with no note open the right side shows a short hint. */
:root { --side-w: clamp(260px, 36vw, 340px); --sel: rgba(128, 100, 0, 0.14); }
@media (prefers-color-scheme: dark) { :root { --sel: rgba(232, 189, 69, 0.2); } }
.icon svg { display: block; margin: auto; }
#side-toggle, .note-empty { display: none; }
body.split #app { display: flex; }
body.split #list, body.split #note { position: relative; inset: auto; }
body.split #list { order: -1; flex: none; width: var(--side-w); padding-right: 0; border-right: 1px solid var(--line); transition: margin-left 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
body.split.side-off #list { margin-left: calc(-1 * var(--side-w)); }
body.split #note { flex: 1; min-width: 0; padding-left: 0; }
body.split #to-list { display: none; }
body.split #side-toggle { display: block; }
body.split #rows .box > li > button[aria-current="true"] { background: linear-gradient(var(--sel), var(--sel)), var(--box); }
body.pane-empty #note > :is(.banner, .editor-scroll, .format-bar) { display: none; }
body.pane-empty #note .bar-top > * { visibility: hidden; }
body.pane-empty .note-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px 24px 96px; text-align: center; }
body.pane-empty .note-empty .big-icon { opacity: 0.55; }
@media (prefers-reduced-motion: reduce) { body.split #list { transition: none; } }

/* ---------- Pairing ---------- */
.pair-form { width: min(100%, 28em); display: flex; flex-direction: column; gap: 10px; }
#pair-code { width: 100%; font: 15px ui-monospace, "SF Mono", Menlo, monospace; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--chip); color: var(--fg); resize: none; }
.primary { border: 0; border-radius: 12px; padding: 12px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.primary:disabled { opacity: 0.6; }
.link { border: 0; background: none; color: var(--accent); padding: 6px; }
.error { margin: 0; color: var(--danger); font-size: 0.88em; }

/* ---------- Menus, confirms and messages ---------- */
.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.3); display: flex; align-items: flex-end; justify-content: center; padding: 8px 8px calc(8px + var(--safe-bottom)); }
.sheet-panel { width: min(100%, 32em); background: var(--bg); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.sheet-panel p { margin: 0; padding: 14px 16px 6px; font-size: 0.9em; color: var(--fg-dim); text-align: center; }
.sheet-panel button { border: 0; border-top: 1px solid var(--line); background: none; padding: 14px; font-size: 1em; color: var(--accent); }
.sheet-panel p + button, .sheet-panel button:first-child { border-top: 0; }
.sheet-panel p + button { border-top: 1px solid var(--line); }
.sheet-panel button.danger { color: var(--danger); }
.sheet-panel button.cancel { font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: calc(70px + var(--safe-bottom)); transform: translateX(-50%); z-index: 20; padding: 8px 14px; border-radius: 10px; background: var(--fg); color: var(--bg); font-size: 0.85em; white-space: nowrap; }

/* ---------- Devices and names ---------- */
.field-label { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 0.85em; color: var(--fg-dim); }
.field-label input { font: inherit; font-size: 16px; color: var(--fg); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--chip); }
.icon-spacer { flex: none; width: 44px; }
.device-row { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.device-row > div { flex: 1; min-width: 0; }
.device-row .row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-row .row-snippet { white-space: normal; }
.device-row button { border: 0; background: none; color: var(--danger); padding: 6px; font-size: 0.9em; }
.rename-form { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 12px 16px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); }

/* ---------- Settings ---------- */
.settings-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px calc(16px + var(--safe-bottom)); background: var(--group-bg); }
.setting { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 12px; background: var(--box); }
.setting-head { display: flex; justify-content: space-between; font-weight: 600; }
.setting-head output { color: var(--fg-dim); font-weight: 400; font-variant-numeric: tabular-nums; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input { flex: 1; min-width: 0; accent-color: var(--accent); }
.a-small, .a-big { flex: none; color: var(--fg-dim); font-weight: 600; }
.a-small { font-size: 0.75em; }
.a-big { font-size: 1.3em; }
.setting .dim { margin: 0; }
.setting .link { align-self: flex-start; padding: 6px 0; }

/* ---------- Groups, count, version, the new-note button ---------- */
.note-count { flex: none; margin: 0; padding: 0 20px 2px; font-size: 0.8em; color: var(--fg-dim); }
.app-version { margin: 0; font-size: 0.7em; color: var(--fg-dim); opacity: 0.8; }
.fab {
  position: absolute; right: calc(18px + env(safe-area-inset-right, 0px)); bottom: calc(22px + var(--safe-bottom)); z-index: 2;
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--glass-edge);
  background: var(--glass-sheen), var(--glass); color: var(--accent); font-size: 30px; font-weight: 300; line-height: 1;
  -webkit-backdrop-filter: blur(10px) saturate(180%); backdrop-filter: blur(10px) saturate(180%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), inset 0 1px 0 var(--glass-shine);
  transition: transform 0.12s ease;
}
.fab:active { transform: scale(0.92); }

/* ---------- Christmas (festive.js, 1 December – 6 January) ---------- */
.festive { --snow: rgba(110, 150, 190, 0.55); --holly: #b3261e; }
@media (prefers-color-scheme: dark) { .festive { --snow: rgba(255, 255, 255, 0.6); --holly: #ff8a80; } }
.snow { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.snow span { position: absolute; top: -20px; color: var(--snow); line-height: 1; animation: snowfall linear infinite; will-change: transform; }
@keyframes snowfall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(14px, 52vh, 0) rotate(180deg); }
  100% { transform: translate3d(-6px, 105vh, 0) rotate(360deg); }
}
/* Two layers: the list's on a phone, the whole app's on a wide screen (list and note side by side). */
#app > .snow, body.split #list > .snow { display: none; }
body.split #app > .snow { display: block; }
@media (prefers-reduced-motion: reduce) { .snow, body.split #app > .snow { display: none; } }
.greeting { margin: 0; font-size: 0.8em; font-weight: 600; color: var(--holly); }
