/* ==========================================================================
   Stickora — styles
   Themes are driven by data-* attributes on <html> set from user prefs.
   ========================================================================== */

:root {
  --accent: #7c5cff;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --scale: 1;
  --font-ui: 'Inter', system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --gap: 18px;
  --sidebar-w: 272px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --bg: #f6f5fb;
  --bg-2: #eeecf7;
  --surface: #ffffff;
  --surface-2: #f8f7fc;
  --text: #1d1b2c;
  --muted: #6b6880;
  --border: #e4e1ef;
  --shadow: 0 1px 2px rgba(20, 16, 50, .06), 0 8px 24px rgba(20, 16, 50, .08);
  --shadow-lg: 0 24px 60px rgba(20, 16, 50, .22);
  --pattern: rgba(60, 50, 120, .10);
  --danger: #e5484d;
  --success: #16a34a;
  --warning: #d97706;
  color-scheme: light;
}

html[data-theme="midnight"] {
  --bg: #0f1020; --bg-2: #15172b; --surface: #1b1d34; --surface-2: #222542;
  --text: #ecebff; --muted: #9a98bd; --border: #2c2f50;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --pattern: rgba(170, 160, 255, .09); color-scheme: dark;
}
html[data-theme="sepia"] {
  --bg: #f4ecdf; --bg-2: #ebe0cd; --surface: #fffaf1; --surface-2: #f8f0e2;
  --text: #3b2f22; --muted: #85725c; --border: #e3d5be; --pattern: rgba(120, 85, 40, .12);
}
html[data-theme="forest"] {
  --bg: #0f1a15; --bg-2: #13221b; --surface: #182a21; --surface-2: #1e3429;
  --text: #e3f4ea; --muted: #8fb5a0; --border: #27443556;
  --shadow: 0 10px 30px rgba(0, 0, 0, .4); --pattern: rgba(140, 230, 180, .08); color-scheme: dark;
}
html[data-theme="ocean"] {
  --bg: #eaf4fb; --bg-2: #dcebf6; --surface: #ffffff; --surface-2: #f2f8fc;
  --text: #0d2a3f; --muted: #557489; --border: #cfe2ef; --pattern: rgba(20, 110, 170, .12);
}
html[data-theme="sakura"] {
  --bg: #fdf1f4; --bg-2: #f9e3ea; --surface: #fffafb; --surface-2: #fdf3f6;
  --text: #3d1d29; --muted: #8e6475; --border: #f2d4de; --pattern: rgba(220, 90, 140, .12);
}
html[data-theme="arctic"] {
  --bg: #2e3440; --bg-2: #353c4a; --surface: #3b4252; --surface-2: #434c5e;
  --text: #eceff4; --muted: #a8b1c2; --border: #4c566a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .3); --pattern: rgba(136, 192, 208, .1); color-scheme: dark;
}

html[data-radius="sharp"] { --radius: 4px; --radius-sm: 3px; }
html[data-radius="soft"] { --radius: 9px; --radius-sm: 6px; }
html[data-density="compact"] { --gap: 12px; }
html[data-density="roomy"] { --gap: 26px; }
html[data-animations="false"] *, html[data-animations="false"] *::before { transition: none !important; animation: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { font-size: calc(15px * var(--scale)); }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- backgrounds ---------- */
.board-bg { background-color: var(--bg); }
html[data-bg="dots"] .board-bg { background-image: radial-gradient(var(--pattern) 1.4px, transparent 1.4px); background-size: 22px 22px; }
html[data-bg="grid"] .board-bg {
  background-image: linear-gradient(var(--pattern) 1px, transparent 1px), linear-gradient(90deg, var(--pattern) 1px, transparent 1px);
  background-size: 28px 28px;
}
html[data-bg="cork"] .board-bg {
  background-color: color-mix(in srgb, #c89f6a 55%, var(--bg));
  background-image: radial-gradient(rgba(90, 55, 20, .25) 1px, transparent 1.5px), radial-gradient(rgba(255, 240, 210, .25) 1px, transparent 1.5px);
  background-size: 9px 9px, 13px 13px; background-position: 0 0, 4px 6px;
}
html[data-bg="gradient"] .board-bg {
  background: radial-gradient(circle at 10% 10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 40%),
    radial-gradient(circle at 90% 30%, color-mix(in srgb, #ff7ab6 20%, transparent), transparent 40%),
    radial-gradient(circle at 40% 100%, color-mix(in srgb, #3bd1c4 18%, transparent), transparent 45%), var(--bg);
  background-attachment: local;
}
html[data-bg="waves"] .board-bg {
  background-image: repeating-radial-gradient(circle at 0 0, transparent 0, var(--bg) 22px), repeating-linear-gradient(var(--pattern), var(--pattern));
}
html[data-bg="linen"] .board-bg {
  background-image: repeating-linear-gradient(45deg, var(--pattern) 0 1px, transparent 1px 6px), repeating-linear-gradient(-45deg, var(--pattern) 0 1px, transparent 1px 6px);
}

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; font-size: .92rem;
  transition: transform .15s var(--ease), background .15s, border-color .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: .84rem; }
.btn.icon { padding: 8px; width: 36px; height: 36px; }
.btn.icon.sm { width: 30px; height: 30px; padding: 4px; }

.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 80px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: .82rem; color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .86rem; font-weight: 600;
  transition: all .15s var(--ease); user-select: none;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip .count { font-size: .75rem; opacity: .75; }

.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border); cursor: pointer; transition: .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { border: 0; background: transparent; padding: 5px 10px; border-radius: 7px; cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.segmented button.active.edit { background: var(--accent); color: var(--accent-ink); }
.segmented button.active.ro { background: color-mix(in srgb, #0ea5e9 85%, #000); color: #fff; }

.avatar {
  --c: var(--accent); width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; background: var(--c); color: #fff; font-weight: 700; font-size: .72rem;
  border: 2px solid var(--surface); letter-spacing: .02em;
}
.avatar.lg { width: 42px; height: 42px; font-size: .95rem; }
.avatar.xs { width: 22px; height: 22px; font-size: .58rem; border-width: 1.5px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.badge.admin { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #b45309; }
.badge.off { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge.ro { background: color-mix(in srgb, #0ea5e9 16%, transparent); color: #0284c7; }

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg);
}
.login-art {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #ff7ab6));
  color: #fff;
}
.login-art h1 { font-size: 3rem; margin: 0; letter-spacing: -.03em; line-height: 1.05; }
.login-art p { font-size: 1.1rem; opacity: .9; max-width: 420px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: #ffd54f; display: grid; place-items: center; transform: rotate(-6deg); box-shadow: 0 6px 18px rgba(0,0,0,.18); font-size: 1.1rem; }
.floaters { position: absolute; inset: 0; pointer-events: none; }
.floater {
  position: absolute; width: 150px; padding: 16px; border-radius: 6px; color: #3b2f22; font-family: 'Caveat', cursive; font-size: 1.35rem;
  box-shadow: 0 18px 30px rgba(0,0,0,.18); animation: float 7s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translateY(0) rotate(var(--r)); } 50% { transform: translateY(-14px) rotate(calc(var(--r) * -1)); } }
.login-panel { display: grid; place-items: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login-card h2 { margin: 0; font-size: 1.7rem; letter-spacing: -.02em; }
.error-text { color: var(--danger); font-size: .88rem; min-height: 1.2em; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }
html[data-sidebar="right"] .app { grid-template-columns: 1fr var(--sidebar-w); }
html[data-sidebar="right"] .sidebar { order: 2; border-right: 0; border-left: 1px solid var(--border); }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 18px 14px; gap: 6px; overflow-y: auto; z-index: 30;
}
.sidebar .brand { padding: 4px 8px 16px; color: var(--text); }
.sidebar .brand-mark { color: #3b2f22; }
.nav-section { font-size: .72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 6px; display: flex; align-items: center; justify-content: space-between; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--text);
  border: 0; background: transparent; width: 100%; text-align: left; font-weight: 500; transition: background .15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-item .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: .95rem; }
.nav-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: .75rem; color: var(--muted); background: var(--surface-2); padding: 1px 7px; border-radius: 99px; }
.sidebar-foot .menu { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.me-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; }
.me-card:hover { background: var(--surface-2); }
.me-card .who { flex: 1; min-width: 0; }
.me-card .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-card .who small { color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(10px); z-index: 10;
}
.search { position: relative; flex: 1; max-width: 460px; }
.search input { padding-left: 36px; background: var(--surface-2); }
.search::before { content: '⌕'; position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 1.15rem; }
.menu-toggle { display: none; }
.view { flex: 1; overflow-y: auto; padding: 26px 28px 60px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.live-dot.on { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent); }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .title { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 240px; }
.page-head h1 { margin: 0; font-size: 1.75rem; letter-spacing: -.025em; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.cat-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; flex: none; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

/* ---------- dropdown ---------- */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 6px; border-radius: 12px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: pop .14s var(--ease);
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button small { display: block; color: var(--muted); font-size: .76rem; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- home ---------- */
.hero {
  border-radius: calc(var(--radius) + 6px); padding: 26px 28px; margin-bottom: 24px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(120deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #ff7ab6));
  box-shadow: 0 14px 40px color-mix(in srgb, var(--accent) 30%, transparent);
}
.hero h1 { margin: 0 0 4px; font-size: 1.8rem; letter-spacing: -.02em; }
.hero p { margin: 0; opacity: .9; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 20px; }
.stat { background: rgba(255,255,255,.16); border-radius: 14px; padding: 12px 14px; backdrop-filter: blur(4px); }
.stat b { display: block; font-size: 1.6rem; }
.stat span { font-size: .85rem; opacity: .9; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title h2 { margin: 0; font-size: 1.15rem; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .18s; position: relative; overflow: hidden;
}
.cat-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--c); }
.cat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.cat-card h3 { margin: 10px 0 2px; font-size: 1.05rem; }
.cat-card p { margin: 0 0 12px; color: var(--muted); font-size: .88rem; min-height: 1.3em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty {
  text-align: center; padding: 50px 20px; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.empty .big { font-size: 2.6rem; }
.empty h3 { color: var(--text); margin: 8px 0 4px; }

/* ---------- note board ---------- */
.board { --col: 270px; }
/* Masonry: renderBoard() deals the cards into flex columns. CSS multi-column is not used because
   Chrome fails to paint backdrop-filter ("glass") notes inside it, leaving only the first card visible. */
.board.layout-masonry { display: flex; align-items: flex-start; gap: var(--gap); }
.masonry-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.board-section + .board-section { margin-top: var(--gap); }
.board.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--col), 1fr)); gap: var(--gap); align-items: start; }
.board.layout-list { display: flex; flex-direction: column; gap: 12px; max-width: 820px; }
.board-group-title { column-span: all; grid-column: 1 / -1; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 0 10px; }

.note-card, .note-surface {
  --note-bg: #fff59d; --note-fg: #2b2616; --note-font: 'Patrick Hand', cursive; --note-size: 16px;
  position: relative; background: var(--note-bg); color: var(--note-fg); font-family: var(--note-font); font-size: var(--note-size);
  border-radius: 4px 4px 4px 18px;
}
.note-card {
  padding: 16px 16px 12px; cursor: pointer; display: inline-block; width: 100%;
  box-shadow: 0 1px 1px rgba(0,0,0,.08), 0 10px 22px -8px rgba(0,0,0,.28);
  transition: transform .22s var(--ease), box-shadow .22s;
}
.board.animate .note-card { animation: noteIn .35s var(--ease) both; }
@keyframes noteIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.note-card.tilt { transform: rotate(var(--tilt, 0deg)); }
.note-card:hover { transform: rotate(0) translateY(-4px) scale(1.015); box-shadow: 0 2px 2px rgba(0,0,0,.08), 0 22px 36px -12px rgba(0,0,0,.35); z-index: 2; }
.note-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.note-card .n-head { display: flex; align-items: center; gap: 6px; font-family: var(--font-ui); font-size: .72rem; font-weight: 700; opacity: .72; margin-bottom: 6px; }
.note-card .n-head .spacer { flex: 1; }
.note-card h3 { margin: 0 0 6px; font-size: 1.25em; line-height: 1.15; word-break: break-word; }
.note-card .n-body { word-break: break-word; max-height: 340px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 85%, transparent); mask-image: linear-gradient(#000 85%, transparent); }
.note-card .n-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-family: var(--font-ui); font-size: .72rem; opacity: .75; }
.note-card .avatar { border-color: color-mix(in srgb, var(--note-bg) 80%, #fff); }
.note-card .n-tag { padding: 2px 7px; border-radius: 99px; background: rgba(0,0,0,.08); }
.board.layout-list .note-card { border-radius: var(--radius); }
.board.layout-list .note-card.tilt { transform: none; }
.title-bold h3, .title-bold .title-input { font-weight: 700; }
.title-italic h3, .title-italic .title-input { font-style: italic; }
.note-rich p, .note-rich div { margin: 0 0 .35em; }
.note-rich ul, .note-rich ol { margin: .2em 0 .5em; padding-left: 1.3em; }
.note-rich blockquote { margin: .4em 0; padding-left: .7em; border-left: 3px solid currentColor; opacity: .85; }
.note-rich h3, .note-rich h4 { margin: .3em 0; }
.note-rich mark { background: rgba(255, 230, 0, .6); color: inherit; }

/* note themes */
[data-note-theme="classic"]::after {
  content: ''; position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; border-radius: 0 0 0 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--note-bg) 70%, #000) 0 50%, transparent 50%); opacity: .25;
}
[data-note-theme="tape"] { border-radius: 2px; }
[data-note-theme="tape"]::before {
  content: ''; position: absolute; top: -11px; left: 50%; width: 92px; height: 24px; transform: translateX(-50%) rotate(-3deg);
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 6px, rgba(255,255,255,.3) 6px 12px);
  box-shadow: 0 1px 3px rgba(0,0,0,.12); backdrop-filter: blur(1px);
}
[data-note-theme="lined"] {
  background-image: linear-gradient(90deg, transparent 26px, rgba(220, 60, 60, .35) 26px 27.5px, transparent 27.5px),
    repeating-linear-gradient(transparent 0 calc(1.6em - 1px), color-mix(in srgb, var(--note-fg) 18%, transparent) calc(1.6em - 1px) 1.6em);
  padding-left: 38px !important; line-height: 1.6em; border-radius: 3px;
}
[data-note-theme="grid"] {
  background-image: linear-gradient(color-mix(in srgb, var(--note-fg) 10%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--note-fg) 10%, transparent) 1px, transparent 1px);
  background-size: 18px 18px; border-radius: 6px;
}
[data-note-theme="glass"] {
  background: color-mix(in srgb, var(--note-bg) 55%, transparent) !important; backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--note-bg) 70%, #fff); border-radius: 18px;
}
[data-note-theme="neon"] {
  background: #12121c !important; color: color-mix(in srgb, var(--note-bg) 75%, #fff) !important; border-radius: 14px;
  border: 1.5px solid var(--note-bg); box-shadow: 0 0 0 1px color-mix(in srgb, var(--note-bg) 40%, transparent), 0 0 22px color-mix(in srgb, var(--note-bg) 45%, transparent) !important;
}
[data-note-theme="neon"] h3, [data-note-theme="neon"] .title-input { text-shadow: 0 0 10px color-mix(in srgb, var(--note-bg) 70%, transparent); }
[data-note-theme="gradient"] {
  background: linear-gradient(145deg, var(--note-bg), color-mix(in srgb, var(--note-bg) 55%, #ff8fc7) 60%, color-mix(in srgb, var(--note-bg) 55%, #7cc8ff)) !important;
  border-radius: 20px;
}
[data-note-theme="minimal"] {
  background: var(--surface) !important; color: var(--text) !important; border-radius: var(--radius);
  border: 1px solid var(--border); border-top: 6px solid var(--note-bg);
}

/* item previews in cards */
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.items li { display: flex; align-items: flex-start; gap: 8px; }
.items li.done .txt { text-decoration: line-through; opacity: .55; }
.mark { flex: none; width: 1.1em; text-align: center; opacity: .8; }
.tick {
  flex: none; width: 1.05em; height: 1.05em; margin-top: .18em; border-radius: 4px; border: 2px solid currentColor; opacity: .75;
  display: grid; place-items: center; font-size: .7em; cursor: pointer; background: transparent; padding: 0; color: inherit; line-height: 1;
}
.tick.on { background: currentColor; }
.tick.on::after { content: '✓'; color: var(--note-bg); font-weight: 900; }
[data-note-theme="neon"] .tick.on::after, [data-note-theme="minimal"] .tick.on::after { color: var(--surface); }
.tick:disabled { cursor: default; }
.progress { height: 7px; border-radius: 99px; background: rgba(0,0,0,.1); overflow: hidden; margin: 6px 0 8px; }
.progress > i { display: block; height: 100%; background: currentColor; opacity: .65; border-radius: inherit; transition: width .4s var(--ease); }
.pill { font-family: var(--font-ui); font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: rgba(0,0,0,.1); white-space: nowrap; }
.pill.high { background: #ef444433; color: #b91c1c; }
.pill.medium { background: #f59e0b33; color: #b45309; }
.pill.low { background: #22c55e2e; color: #15803d; }
[data-note-theme="neon"] .pill { color: inherit; }
.evt { display: flex; gap: 10px; align-items: center; }
.evt .day { flex: none; width: 42px; text-align: center; border-radius: 8px; background: rgba(0,0,0,.08); padding: 3px 0; font-family: var(--font-ui); line-height: 1.05; }
.evt .day b { display: block; font-size: 1.05rem; }
.evt .day small { font-size: .62rem; text-transform: uppercase; font-weight: 700; opacity: .7; }
.task-cols-mini { display: flex; gap: 6px; font-family: var(--font-ui); font-size: .72rem; margin-bottom: 6px; }
.task-cols-mini span { padding: 2px 8px; border-radius: 99px; background: rgba(0,0,0,.08); font-weight: 700; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(14, 12, 30, .45); backdrop-filter: blur(4px); animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  animation: rise .25s var(--ease);
}
.modal.wide { max-width: 760px; }
.modal.xl { max-width: 1120px; height: min(820px, calc(100vh - 40px)); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 12px; }
.modal-head h2 { margin: 0; font-size: 1.2rem; flex: 1; }
.modal-body { padding: 6px 22px 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--border); }

.pick-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--accent-soft); }
.pick-row .who { flex: 1; min-width: 0; }
.pick-row .who small { display: block; color: var(--muted); font-size: .76rem; }
.pick-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0;
  transition: transform .15s var(--ease);
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); position: relative; overflow: hidden; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-grid button { width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent; background: var(--surface-2); cursor: pointer; font-size: 1.15rem; }
.emoji-grid button.active { border-color: var(--accent); background: var(--accent-soft); }
.style-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.style-pick label { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: 12px; border: 1.5px solid var(--border); cursor: pointer; font-size: .85rem; font-weight: 600; text-align: center; }
.style-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.style-pick input { display: none; }
.style-pick .e { font-size: 1.5rem; }

/* ---------- note editor ---------- */
.editor { display: grid; grid-template-columns: 1fr 330px; flex: 1; min-height: 0; }
.editor-stage { padding: 26px; overflow-y: auto; min-height: 0; }
.note-surface { padding: 22px 24px 26px; min-height: 100%; box-shadow: 0 2px 2px rgba(0,0,0,.06), 0 20px 40px -18px rgba(0,0,0,.35); border-radius: 6px 6px 6px 26px; }
.title-input { width: 100%; border: 0; background: transparent; font-size: 1.6em; outline: none; font-family: inherit; color: inherit; padding: 0 0 8px; }
.title-input::placeholder { color: currentColor; opacity: .4; }
.rich {
  min-height: 260px; outline: none; line-height: 1.55; word-break: break-word;
}
.rich:empty::before { content: attr(data-placeholder); opacity: .4; }
.fmt-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; padding: 5px; border-radius: 10px; background: rgba(0,0,0,.07); font-family: var(--font-ui); width: fit-content; }
.fmt-bar button { border: 0; background: transparent; min-width: 30px; height: 30px; border-radius: 7px; cursor: pointer; font-size: .9rem; color: inherit; }
.fmt-bar button:hover { background: rgba(0,0,0,.1); }
.fmt-bar .sep { width: 1px; background: currentColor; opacity: .2; margin: 4px 3px; }
.add-row { display: flex; gap: 6px; margin: 4px 0 14px; flex-wrap: wrap; font-family: var(--font-ui); font-size: .92rem; }
.add-row .input, .add-row .select { background: rgba(255,255,255,.55); border-color: rgba(0,0,0,.12); color: #222; flex: 1; min-width: 120px; }
[data-note-theme="neon"] .add-row .input, [data-note-theme="neon"] .add-row .select,
[data-note-theme="neon"] .item-row .item-text { background: rgba(255,255,255,.06); color: inherit; border-color: rgba(255,255,255,.18); }
.add-row .input.grow { flex: 3; }
.add-row .select, .add-row input[type="date"], .add-row input[type="time"] { flex: 0 1 auto; width: auto; min-width: 0; }
.item-list { display: flex; flex-direction: column; gap: 4px; list-style: none; margin: 0; padding: 0; }
.item-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; transition: background .15s; }
.item-row:hover { background: rgba(0,0,0,.05); }
.item-row.dragging { opacity: .4; }
.item-row.drop-target { box-shadow: inset 0 2px 0 currentColor; }
.item-row .item-text { flex: 1; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 4px 6px; font-family: inherit; font-size: inherit; color: inherit; outline: none; min-width: 0; }
.item-row .item-text:focus { background: rgba(255,255,255,.5); border-color: rgba(0,0,0,.15); }
.item-row.done .item-text { text-decoration: line-through; opacity: .55; }
.item-row .handle { cursor: grab; opacity: .35; font-family: var(--font-ui); user-select: none; }
.item-row .x { opacity: 0; border: 0; background: transparent; cursor: pointer; color: inherit; font-size: 1rem; border-radius: 6px; width: 26px; height: 26px; }
.item-row:hover .x, .item-row:focus-within .x { opacity: .6; }
.item-row .x:hover { opacity: 1; background: rgba(0,0,0,.1); }
.item-meta { font-family: var(--font-ui); font-size: .72rem; opacity: .6; white-space: nowrap; }
.tiny-select, .tiny-date { font-family: var(--font-ui); font-size: .76rem; padding: 3px 5px; border-radius: 6px; border: 1px solid rgba(0,0,0,.12); background: rgba(255,255,255,.5); color: #222; }

.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; font-family: var(--font-ui); font-size: .9rem; }
.kcol { background: rgba(0,0,0,.06); border-radius: 12px; padding: 10px; min-height: 140px; display: flex; flex-direction: column; gap: 8px; }
.kcol.over { outline: 2px dashed currentColor; outline-offset: -4px; }
.kcol h4 { margin: 0 0 2px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; display: flex; justify-content: space-between; opacity: .75; }
.kcard { background: rgba(255,255,255,.75); color: #1f1d2b; border-radius: 10px; padding: 9px 10px; box-shadow: 0 1px 3px rgba(0,0,0,.12); cursor: grab; display: flex; flex-direction: column; gap: 6px; }
.kcard .item-text { border: 0; background: transparent; outline: none; font: inherit; color: inherit; width: 100%; font-weight: 600; }
.kcard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kcard.overdue { box-shadow: inset 3px 0 0 var(--danger), 0 1px 3px rgba(0,0,0,.12); }

.cal { font-family: var(--font-ui); }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal-head h4 { margin: 0; flex: 1; font-size: 1.05rem; }
.cal-nav { border: 0; background: rgba(0,0,0,.08); color: inherit; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { font-size: .7rem; font-weight: 800; text-align: center; opacity: .55; padding: 4px 0; text-transform: uppercase; }
.cal-day {
  height: clamp(42px, 5.2vw, 58px); border-radius: 9px; border: 0; background: rgba(255,255,255,.35); color: inherit; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 5px; font-size: .85rem; font-weight: 600;
}
[data-note-theme="neon"] .cal-day { background: rgba(255,255,255,.05); }
.cal-day.other { opacity: .35; }
.cal-day.today { box-shadow: inset 0 0 0 2px currentColor; }
.cal-day.sel { background: currentColor; }
.cal-day.sel span { color: var(--note-bg); }
[data-note-theme="minimal"] .cal-day.sel span, [data-note-theme="neon"] .cal-day.sel span { color: var(--surface); }
.cal-day .dots { display: flex; gap: 2px; margin-top: auto; margin-bottom: 5px; }
.cal-day .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--dot, currentColor); opacity: .8; }
.cal-day.sel .dots i { background: var(--note-bg); }
.cal-events { margin-top: 14px; }

.bucket-ring { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; font-family: var(--font-ui); }
.ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; background: conic-gradient(currentColor calc(var(--p) * 1%), rgba(0,0,0,.1) 0); display: grid; place-items: center; }
.ring::after { content: attr(data-label); width: 50px; height: 50px; border-radius: 50%; background: var(--note-bg); display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
[data-note-theme="neon"] .ring::after { background: #12121c; }
[data-note-theme="minimal"] .ring::after { background: var(--surface); }
.bucket-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.35); margin-bottom: 6px; }
.bucket-item.done { background: rgba(255,255,255,.18); }
.bucket-item .em { font-size: 1.4rem; }
.bucket-item .item-text { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 2px 6px; font: inherit; color: inherit; outline: none; }
.bucket-item .item-text:focus { background: rgba(255,255,255,.5); border-color: rgba(0,0,0,.15); }
.bucket-item.done .item-text { text-decoration: line-through; opacity: .6; }
.achieve { border: 1.5px solid currentColor; background: transparent; color: inherit; border-radius: 99px; padding: 3px 10px; font-family: var(--font-ui); font-size: .72rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.achieve.on { background: currentColor; }
.achieve.on span { color: var(--note-bg); }

.editor-side { border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-radius: 0 0 calc(var(--radius) + 4px) 0; }
.tabs { display: flex; gap: 4px; padding: 10px 12px 0; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; padding: 9px 12px; cursor: pointer; font-weight: 700; font-size: .86rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.theme-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-pick button {
  --note-bg: #ffe082; height: 52px; border: 2px solid transparent; cursor: pointer; font-size: .68rem; font-weight: 700; padding: 0; color: #333; position: relative; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px; background: var(--note-bg);
  font-family: var(--font-ui);
}
.theme-pick button.active { outline: 3px solid var(--accent); outline-offset: 2px; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.history li { display: flex; gap: 10px; font-size: .86rem; }
.history time { display: block; color: var(--muted); font-size: .75rem; }
.share-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.share-row .who { flex: 1; min-width: 0; font-size: .9rem; }
.share-row .who small { display: block; color: var(--muted); font-size: .74rem; }
.access-opt { display: flex; gap: 10px; padding: 12px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; }
.access-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.access-opt input { accent-color: var(--accent); margin-top: 3px; }
.access-opt b { display: block; }
.access-opt small { color: var(--muted); }
.readonly-banner { font-family: var(--font-ui); font-size: .82rem; padding: 8px 12px; border-radius: 10px; background: rgba(0,0,0,.08); margin-bottom: 14px; display: flex; gap: 8px; align-items: center; }

/* ---------- customizer drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(14,12,30,.3); z-index: 90; animation: fade .2s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100vw); background: var(--surface); z-index: 91;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .28s var(--ease); border-left: 1px solid var(--border);
}
@keyframes slide { from { transform: translateX(100%); } }
.drawer .modal-body { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.theme-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-card { border: 2px solid var(--border); border-radius: 12px; padding: 0; cursor: pointer; overflow: hidden; background: none; text-align: left; }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-card .pv { height: 44px; display: flex; gap: 3px; padding: 6px; }
.theme-card .pv i { flex: 1; border-radius: 4px; }
.theme-card span { display: block; padding: 4px 6px 6px; font-size: .72rem; font-weight: 700; color: var(--text); background: var(--surface); }
.bg-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bg-cards button { height: 48px; border-radius: 10px; border: 2px solid var(--border); cursor: pointer; font-size: .7rem; font-weight: 700; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px; background-color: var(--bg); color: var(--muted); }
.bg-cards button.active { border-color: var(--accent); }
.font-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.font-pick button { padding: 10px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface-2); cursor: pointer; text-align: left; }
.font-pick button.active { border-color: var(--accent); background: var(--accent-soft); }
.font-pick button b { display: block; font-size: 1.1rem; }
.font-pick button small { color: var(--muted); font-family: var(--font-ui); }
input[type="range"] { accent-color: var(--accent); width: 100%; }

/* ---------- admin ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell small { display: block; color: var(--muted); }
.perm-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.group-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; border-top: 4px solid var(--c); }
.group-card h3 { margin: 0; font-size: 1.05rem; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.admin-stats .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.admin-stats .card b { font-size: 1.8rem; display: block; }
.admin-stats .card span { color: var(--muted); font-size: .86rem; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bars .bar { display: grid; grid-template-columns: 130px 1fr 40px; gap: 10px; align-items: center; font-size: .88rem; }
.bars .bar i { height: 10px; border-radius: 99px; background: var(--accent); display: block; }

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; }
.toast { background: #1d1b2c; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .9rem; animation: rise .25s var(--ease); display: flex; gap: 8px; align-items: center; }
.toast.error { background: var(--danger); }
.toast.success::before { content: '✓'; font-weight: 900; color: #4ade80; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .editor { grid-template-columns: 1fr; overflow-y: auto; }
  .editor-stage { overflow: visible; }
  .editor-side { border-left: 0; border-top: 1px solid var(--border); }
  .modal.xl { height: calc(100vh - 20px); }
  .kanban { grid-template-columns: 1fr; }
}
/* ---------- phone-only controls (hidden on larger screens) ---------- */
.top-title, .search-toggle, .search-cancel, .fab, .tabbar, .nav-scrim, .editor-back, .editor-opts, .side-head, .side-scrim { display: none; }
.cat-label { font-weight: 500; font-size: .9rem; margin-left: 8px; }
.head-actions { display: flex; align-items: center; gap: 8px; }

/* sheet contents: account menu, category picker, note-style picker */
.sheet-list { display: flex; flex-direction: column; gap: 2px; padding-bottom: 22px; }
.sheet-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 11px 10px; border: 0; background: transparent; border-radius: 12px;
  cursor: pointer; text-align: left; font-size: 1rem; font-weight: 600; color: var(--text);
}
.sheet-item:hover, .sheet-item:active { background: var(--surface-2); }
.sheet-item .si { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); font-size: 1.2rem; flex: none; }
.sheet-item .grow { flex: 1; min-width: 0; }
.sheet-item small { display: block; color: var(--muted); font-weight: 500; font-size: .8rem; }
.sheet-item .chev { color: var(--muted); font-size: 1.4rem; line-height: 1; }
.sheet-item.danger { color: var(--danger); }
.me-row { display: flex; align-items: center; gap: 12px; padding: 4px 10px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.me-row small { display: block; color: var(--muted); }
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 22px; }
.style-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border-radius: 16px; border: 1.5px solid var(--border);
  background: var(--surface-2); cursor: pointer; text-align: left; color: var(--text); transition: transform .12s var(--ease), border-color .12s;
}
.style-tile:hover, .style-tile:active { border-color: var(--accent); }
.style-tile:active { transform: scale(.97); }
.style-tile .e { font-size: 1.8rem; line-height: 1.1; }
.style-tile small { color: var(--muted); font-size: .76rem; }

/* ---------- phone layout: app-style navigation, bottom sheets, full-screen editor ---------- */
@media (max-width: 820px) {
  :root { --tabbar-h: 62px; }
  body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
  .hide-sm, .hide-phone { display: none !important; }

  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 220px; padding: 28px; gap: 24px; }
  .floaters { display: none; }
  .login-art h1 { font-size: 2.1rem; }

  /* top app bar: screen title, search, live, customize */
  .app, html[data-sidebar="right"] .app { grid-template-columns: 1fr; }
  .topbar { padding: 8px 8px 8px 12px; gap: 2px; min-height: 58px; }
  .menu-toggle, .search, .topbar .spacer { display: none; }
  .top-title { display: block; flex: 1; min-width: 0; font-weight: 800; font-size: 1.2rem; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search-toggle { display: inline-flex; font-size: 1.35rem; }
  .live-wrap { padding: 0 8px; }
  .customize-btn { border: 0; background: transparent; padding: 8px; font-size: 1.15rem; }
  .topbar.searching .top-title, .topbar.searching .search-toggle, .topbar.searching .live-wrap, .topbar.searching .customize-btn { display: none; }
  .topbar.searching .search { display: block; flex: 1; max-width: none; }
  .topbar.searching .search input { font-size: 16px; }
  .topbar.searching .search-cancel { display: inline-flex; }
  .view { padding: 14px 12px calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom)); }

  /* bottom tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border);
  }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: .7rem; font-weight: 700; cursor: pointer; padding: 0; }
  .tab .ti { height: 28px; min-width: 56px; display: grid; place-items: center; border-radius: 99px; font-size: 1.2rem; line-height: 1; filter: grayscale(.7); opacity: .75; transition: background .2s, opacity .2s; }
  .tab.active { color: var(--accent); }
  .tab.active .ti { background: var(--accent-soft); filter: none; opacity: 1; }
  .tab .avatar { width: 24px; height: 24px; font-size: .55rem; }

  /* floating "+" button */
  .fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 41;
    width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 2rem; cursor: pointer;
    box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 45%, transparent); transition: transform .15s var(--ease);
  }
  .fab:active { transform: scale(.92); }
  .fab[hidden], body.kb-open .fab, body.kb-open .tabbar { display: none; }

  /* boards drawer (the sidebar) */
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 84vw); transform: translateX(-105%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); z-index: 60; }
  html[data-sidebar="right"] .sidebar { inset: 0 0 0 auto; transform: translateX(105%); }
  body.nav-open .sidebar { transform: none !important; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(14, 12, 30, .4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .nav-item { padding: 11px 10px; font-size: 1rem; }
  .nav-item .ico { width: 36px; height: 36px; font-size: 1.15rem; border-radius: 10px; }

  /* page header: the title lives in the app bar, keep only the summary and actions */
  .page-head { margin-bottom: 12px; gap: 10px; align-items: center; flex-wrap: nowrap; }
  .page-head .title { min-width: 0; }
  .page-head .cat-icon, .page-head h1 { display: none; }
  .page-head p { font-size: .88rem; margin: 0; }
  .head-actions { gap: 6px; flex: none; }
  .head-actions .btn { height: 40px; padding: 6px 10px; }

  /* filters: one swipeable row instead of several wrapped rows */
  .toolbar { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 14px; padding: 2px 12px 4px; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar .chip { flex: none; padding: 8px 14px; }
  .toolbar .spacer { display: none; }
  .toolbar .select { flex: none; width: auto !important; padding: 8px 10px; border-radius: 999px; font-size: .84rem; }

  /* board cards */
  .board { --col: 300px; }
  .note-card { padding: 14px 14px 10px; }
  .note-card.tilt, .note-card:hover { transform: none; }
  .note-card:active { transform: scale(.985); }
  .note-card .n-body { max-height: 240px; }
  .items li { padding: 2px 0; }
  .tick { width: 1.3em; height: 1.3em; }

  /* home: compact hero, swipeable stats and categories */
  .hero { padding: 18px; margin-bottom: 16px; border-radius: 20px; }
  .hero h1 { font-size: 1.35rem; }
  .hero p { font-size: .9rem; }
  .stats { display: flex; overflow-x: auto; gap: 8px; margin: 14px -18px 0; padding: 0 18px 2px; scrollbar-width: none; }
  .stats::-webkit-scrollbar { display: none; }
  .stat { flex: none; min-width: 116px; padding: 10px 12px; }
  .stat b { font-size: 1.3rem; }
  .stat span { font-size: .76rem; }
  .section-title { margin: 18px 0 10px; }
  .cat-grid { display: flex; overflow-x: auto; gap: 10px; margin: 0 -12px; padding: 2px 12px 6px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .cat-grid::-webkit-scrollbar { display: none; }
  .cat-card { flex: none; width: 72%; max-width: 280px; scroll-snap-align: start; }
  .cat-card:hover { transform: none; }
  .cat-card:active { transform: scale(.98); }

  /* dialogs become bottom sheets (drag the header down to close) */
  .modal-backdrop { padding: 0; place-items: end stretch; grid-template-columns: minmax(0, 1fr); }
  .modal { max-width: none !important; min-width: 0; max-height: 90vh; border-radius: 22px 22px 0 0; border-bottom: 0; animation: sheet-up .28s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
  .modal:not(.xl) > .modal-head { padding: 24px 16px 10px; position: relative; touch-action: none; }
  .modal:not(.xl) > .modal-head::before { content: ''; position: absolute; top: 9px; left: 50%; width: 40px; height: 5px; border-radius: 99px; background: var(--border); transform: translateX(-50%); }
  .modal-head h2 { font-size: 1.1rem; }
  .modal-body { padding: 4px 16px 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; padding: 12px; }
  @keyframes sheet-up { from { transform: translateY(100%); } }

  /* note editor: a full-screen page with a back arrow; options open as a sheet */
  .modal.xl { height: 100%; max-height: 100%; border-radius: 0; border: 0; padding-bottom: 0; animation: page-in .22s var(--ease); }
  @keyframes page-in { from { transform: translateX(24%); opacity: 0; } }
  .modal.xl > .modal-head { padding: 6px 6px 6px 4px; gap: 2px; border-bottom: 1px solid var(--border); }
  .modal.xl > .modal-head h2 { font-size: 1rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .modal.xl .cat-label { display: block; margin: 0; font-size: .74rem; overflow: hidden; text-overflow: ellipsis; }
  .modal.xl .modal-head .btn.icon { width: 42px; height: 42px; font-size: 1.1rem; }
  .editor-back { display: inline-flex; font-size: 1.4rem !important; }
  .editor-opts { display: inline-flex; }
  .editor-close { display: none !important; }
  .editor { display: block; flex: 1; min-height: 0; overflow-y: auto; }
  .editor-stage { padding: 12px 10px 40px; overflow: visible; }
  .note-surface { padding: 16px 16px 22px; min-height: calc(100vh - 150px); border-radius: 6px 6px 6px 20px; }
  .title-input { font-size: 1.45em; }
  .editor-side {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 120; max-height: 80vh; border: 0; border-radius: 22px 22px 0 0;
    box-shadow: var(--shadow-lg); transform: translateY(105%); transition: transform .28s var(--ease); padding-bottom: env(safe-area-inset-bottom);
  }
  .editor.side-open .editor-side { transform: none; }
  .side-scrim { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(14, 12, 30, .35); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .editor.side-open .side-scrim { opacity: 1; pointer-events: auto; }
  .side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 0 18px; font-size: 1.05rem; }
  .tabs { padding: 6px 12px 0; }
  .tabs button { flex: 1; padding: 11px 6px; }

  /* editing controls sized for fingers */
  .fmt-bar { position: sticky; top: 0; z-index: 2; width: auto; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -4px 12px; }
  .fmt-bar::-webkit-scrollbar { display: none; }
  .fmt-bar button { min-width: 40px; height: 40px; flex: none; font-size: 1rem; }
  .add-row { gap: 8px; }
  .add-row .input.grow { flex: 1 1 100%; }
  .add-row .input, .add-row .select { min-height: 44px; font-size: 16px; }
  .add-row .btn { min-height: 44px; flex: 1 0 auto; }
  .item-row { padding: 6px 4px; min-height: 46px; }
  .item-row .x { opacity: .55; width: 38px; height: 38px; }
  .item-row .handle { display: none; }
  .tiny-select, .tiny-date { min-height: 36px; font-size: .82rem; padding: 4px 6px; }
  .kanban { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 -16px; padding: 0 16px 8px; scrollbar-width: none; }
  .kanban::-webkit-scrollbar { display: none; }
  .kcol { flex: none; width: 86%; scroll-snap-align: center; min-height: 220px; }
  .kcard { cursor: default; padding: 11px 12px; }
  /* task card controls: priority | due date, then assignee, then move ◀ ▶ and delete as one even row */
  .kcard .meta { gap: 6px; }
  .kcard .meta .tiny-select:first-child, .kcard .meta .tiny-date { flex: 1 1 40%; min-width: 0; }
  .kcard .meta .tiny-select:nth-child(3) { flex: 1 1 100%; }
  .kcard .meta .spacer { display: none; }
  .kcard .meta .x { flex: 1; height: 36px; opacity: .8 !important; border: 1px solid rgba(0, 0, 0, .12); border-radius: 9px; }
  .cal-day { height: 46px; }
  .cal-nav { width: 40px; height: 40px; }
  /* bucket item: emoji | text | ✕ on the first row, "Mark achieved" under the text */
  .bucket-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 8px; row-gap: 6px; align-items: center; }
  .bucket-item .achieve { grid-column: 2; grid-row: 2; justify-self: start; }
  .bucket-item > .x { grid-column: 3; grid-row: 1; width: 38px; height: 38px; border: 0; background: transparent; color: inherit; font-size: 1rem; }
  .achieve { padding: 8px 12px; font-size: .78rem; }

  /* customizer: a tall sheet instead of a side drawer */
  .drawer { top: auto; width: 100vw; height: 88vh; border-radius: 22px 22px 0 0; border-left: 0; animation: sheet-up .28s var(--ease); padding-bottom: env(safe-area-inset-bottom); }

  /* admin tables: each row becomes a card (name + role, then badges, then status and actions) */
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  .table-wrap table, .table-wrap tbody { display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 14px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
  .table-wrap td { display: block; padding: 0; border: 0; }
  .table-wrap td:first-child { flex: 1 1 60%; min-width: 0; }
  .table-wrap td:last-child { margin-left: auto; }
  .table-wrap tr:hover td { background: none; }
  .bars .bar { grid-template-columns: 96px 1fr 32px; }

  .toasts { bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); width: calc(100% - 32px); }
  .toast { width: 100%; justify-content: center; }
  .grid-2 { grid-template-columns: 1fr; }
  .menu button { padding: 12px; }
  .chip { min-height: 38px; }
}
@media (hover: none) {
  .note-card:hover, .cat-card:hover, .swatch:hover { transform: none; }
  .item-row .x { opacity: .55; }
}
