/* note – dark, calm, yellow accents (paleta: webdeck.pl) */
:root {
  --bg: #060709;
  --surface: #0d1015;
  --surface-2: #12151b;
  --surface-3: #191d25;
  --border: #1d2330;
  --border-strong: #2a3140;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --faint: #6b7280;
  --accent: #ffd200;
  --accent-soft: rgba(255, 210, 0, 0.12);
  --accent-ink: #1a1500;
  --danger: #ff5a5f;
  --ok: #2ecc71;

  --space-personal: #ffd200;
  --space-work: #5b9dff;
  --space-school: #2ecc71;

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tabbar-h: 58px;
  --gutter: 16px;
  --kb: 0px; /* on-screen keyboard height, set from JS */
  color-scheme: dark;
}

.c-yellow { --c: #ffd200; } .c-orange { --c: #ff9f43; } .c-red { --c: #ff5a5f; }
.c-pink { --c: #ff6fb5; } .c-purple { --c: #a78bfa; } .c-blue { --c: #5b9dff; }
.c-teal { --c: #2dd4bf; } .c-green { --c: #2ecc71; } .c-gray { --c: #8b93a1; }
.s-personal { --c: var(--space-personal); } .s-work { --c: var(--space-work); } .s-school { --c: var(--space-school); }
.s-quick { --c: #ff9f43; }

*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body.locked { overflow: hidden; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#i-more circle, #i-grip circle, #i-bullets circle { fill: currentColor; stroke: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, textarea, select { font-size: 16px; } /* prevents iOS zoom on focus */
[hidden] { display: none !important; }
::selection { background: rgba(255, 210, 0, 0.35); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Layout ---------- */
.app { min-height: 100dvh; }
.sidebar { display: none; }
.main {
  padding: 0 calc(var(--gutter) + var(--safe-r)) calc(var(--tabbar-h) + var(--safe-b) + 40px) calc(var(--gutter) + var(--safe-l));
  max-width: 820px;
  margin: 0 auto;
}
.detail {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  transform: translate3d(100%, 0, 0);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  visibility: hidden;
}
.detail.open { transform: none; visibility: visible; }
.detail.closing { visibility: visible; }

@media (min-width: 900px) {
  :root { --gutter: 28px; }
  body { overflow: hidden; height: 100dvh; }
  .app { display: grid; grid-template-columns: 270px minmax(0, 1fr); height: 100dvh; }
  .app.with-detail { grid-template-columns: 270px minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    padding: 22px 14px 18px; border-right: 1px solid var(--border);
    background: var(--surface); overflow-y: auto;
  }
  .main { max-width: none; width: 100%; margin: 0; height: 100dvh; overflow-y: auto; padding-bottom: 60px; }
  .main > * { max-width: 860px; margin-left: auto; margin-right: auto; }
  .detail {
    position: relative; inset: auto; transform: none; transition: none; visibility: visible;
    display: none; height: 100dvh; border-left: 1px solid var(--border);
  }
  .app.with-detail .detail { display: flex; flex-direction: column; }
  .detail .editor { flex: 1 0 auto; width: 100%; }
  .app.with-detail .main { display: none; }
  .tabbar { display: none !important; }
}
@media (min-width: 1180px) {
  .app.with-detail { grid-template-columns: 270px minmax(340px, 0.85fr) minmax(0, 1.25fr); }
  .app.with-detail .main { display: block; }
  .app.with-detail .main > * { max-width: 640px; }
}

/* ---------- Sidebar (desktop) ---------- */
.side-brand { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 14px; }
.brand { font-weight: 750; font-size: 22px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 18px rgba(255, 210, 0, 0.5); }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 4px 12px; }
.side-label { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; padding: 14px 10px 6px; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: var(--muted); font-size: 15px; min-height: 38px;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--surface-3); color: var(--text); }
.side-link svg { width: 19px; height: 19px; color: var(--c, var(--muted)); }
.side-link .count { margin-left: auto; font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }
.side-tree { padding-left: 18px; }
.side-tree .side-link { font-size: 14px; min-height: 32px; padding: 6px 10px; }

/* ---------- Page header ---------- */
.page-head {
  position: sticky; top: 0; z-index: 20;
  margin: 0 calc(-1 * (var(--gutter) + var(--safe-r))) 0 calc(-1 * (var(--gutter) + var(--safe-l)));
  padding: calc(var(--safe-t) + 10px) calc(var(--gutter) + var(--safe-r)) 10px calc(var(--gutter) + var(--safe-l));
  background: rgba(6, 7, 9, 0.82);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
}
@media (min-width: 900px) { .page-head { margin: 0 calc(-1 * var(--gutter)); padding: 18px var(--gutter) 12px; max-width: none !important; } }
.head-row { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.head-row .grow { flex: 1; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 2px; color: var(--accent); font-size: 16px; min-width: 0; }
.crumbs a { display: flex; align-items: center; gap: 2px; padding: 6px 4px 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title { font-size: 32px; line-height: 1.12; font-weight: 750; letter-spacing: -0.025em; margin: 6px 0 2px; display: flex; align-items: center; gap: 10px; }
.page-title .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 6px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center;
  color: var(--text); background: transparent; flex: none;
}
.icon-btn:active { background: var(--surface-3); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); } }
.icon-btn.accent { color: var(--accent); }
.icon-btn.filled { background: var(--surface-2); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; font-weight: 600; font-size: 15px;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
  transition: transform 0.12s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn svg { width: 19px; height: 19px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ---------- Home ---------- */
.capture {
  display: flex; align-items: center; gap: 6px; margin: 8px 0 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 6px 6px 6px 16px;
}
.capture:focus-within { border-color: var(--border-strong); }
.capture input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 10px 0; }
.capture input::placeholder { color: var(--faint); }
.capture .icon-btn { width: 42px; height: 42px; }
.capture .send { background: var(--accent); color: var(--accent-ink); border-radius: 12px; }

.smart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.smart {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 92px;
  transition: transform 0.12s, background 0.15s;
}
.smart:active { transform: scale(0.98); background: var(--surface-2); }
.smart-top { display: flex; align-items: center; justify-content: space-between; }
.smart-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); }
.smart-ico svg { width: 19px; height: 19px; }
.smart-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.smart-label { color: var(--muted); font-size: 14px; font-weight: 550; }
.smart.warn .smart-num { color: var(--danger); }

.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 20px; font-weight: 700; letter-spacing: -0.015em; margin: 22px 2px 10px;
}
.section-title .btn { margin-right: -6px; }
.section-title small { font-size: 13px; color: var(--faint); font-weight: 500; }

.spaces { display: grid; gap: 10px; }
.space-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  position: relative; overflow: hidden; transition: transform 0.12s, background 0.15s;
}
.space-card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.space-card:active { transform: scale(0.985); background: var(--surface-2); }
.space-ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.space-name { font-weight: 650; font-size: 17px; }
.space-meta { color: var(--muted); font-size: 13.5px; }
.space-card .chev { margin-left: auto; color: var(--faint); width: 18px; }

/* ---------- Lists / rows ---------- */
.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.group + .group { margin-top: 12px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px;
  position: relative; width: 100%; text-align: left;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 1px; background: var(--border); }
.row:active { background: var(--surface-2); }
@media (hover: hover) { .row:hover { background: var(--surface-2); } }
.row-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); flex: none; }
.row-ico svg { width: 18px; height: 18px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { color: var(--faint); font-size: 14px; display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.row-end svg { width: 17px; height: 17px; }
.row .grip { color: var(--faint); cursor: grab; touch-action: none; padding: 6px; margin: -6px -8px -6px 0; }

/* Note cards */
.notes { display: grid; gap: 8px; }
.notes.grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.note-card {
  position: relative; display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 14px 12px 16px; overflow: hidden; transition: transform 0.12s, background 0.15s, border-color 0.15s;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.note-card:active { transform: scale(0.985); background: var(--surface-2); }
@media (hover: hover) { .note-card:hover { border-color: var(--border-strong); } }
.note-card.has-color::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.note-card.done .nc-title { text-decoration: line-through; color: var(--muted); }
.note-card.active { border-color: var(--accent); }
.nc-head { display: flex; align-items: flex-start; gap: 8px; }
.nc-title { font-weight: 620; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nc-title.empty { color: var(--faint); font-weight: 500; }
.nc-icons { display: flex; gap: 4px; color: var(--accent); }
.nc-icons svg { width: 16px; height: 16px; }
.nc-icons .flag { color: #ff9f43; }
.nc-preview { color: var(--muted); font-size: 14px; margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-line; }
.notes.grid .nc-preview { -webkit-line-clamp: 6; }
.notes.grid .note-card { min-height: 128px; }
.nc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--faint); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.chip svg { width: 13px; height: 13px; }
.chip.due-today { background: var(--accent-soft); color: var(--accent); }
.chip.due-over { background: rgba(255, 90, 95, 0.14); color: var(--danger); }
.chip.space { color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.progress { width: 34px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); }
.note-card .grip { position: absolute; right: 6px; bottom: 6px; color: var(--faint); padding: 6px; touch-action: none; cursor: grab; }
.sortable-ghost { opacity: 0.35; }
.sortable-chosen { transform: scale(1.02); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }

/* Toolbar under headers */
.toolbar { display: flex; align-items: center; gap: 6px; margin: 4px 0 14px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  font-size: 14px; color: var(--muted); font-weight: 550; min-height: 34px;
}
.pill svg { width: 16px; height: 16px; }
.pill.on { background: var(--accent-soft); color: var(--accent); border-color: rgba(255, 210, 0, 0.35); }
.pill .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }

.empty {
  text-align: center; color: var(--muted); padding: 46px 20px; border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg); font-size: 15px;
}
.empty svg { width: 34px; height: 34px; color: var(--faint); margin-bottom: 8px; }
.empty .btn { margin-top: 14px; }
.hint { color: var(--faint); font-size: 13px; margin: 8px 2px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 calc(6px + var(--safe-r)) var(--safe-b) calc(6px + var(--safe-l));
  background: rgba(10, 12, 16, 0.86);
  -webkit-backdrop-filter: saturate(170%) blur(20px);
  backdrop-filter: saturate(170%) blur(20px);
  border-top: 1px solid var(--border);
  transition: transform 0.25s;
}
body.kb-open .tabbar, body.detail-open .tabbar { transform: translateY(110%); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--faint); padding-top: 6px; height: 100%; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.tab-fab {
  justify-self: center; width: 58px; height: 58px; border-radius: 50%; margin-top: -22px;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(255, 210, 0, 0.28), 0 0 0 6px var(--bg);
  transition: transform 0.15s;
}
.tab-fab:active { transform: scale(0.92); }
.tab-fab svg { width: 26px; height: 26px; stroke-width: 2; }

.desk-fab {
  display: none; position: fixed; right: 28px; bottom: 28px; z-index: 25;
  width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  place-items: center; box-shadow: 0 10px 30px rgba(255, 210, 0, 0.25);
}
@media (min-width: 900px) { .desk-fab { display: grid; } .app.with-detail ~ .desk-fab { display: none; } }

/* ---------- Editor ---------- */
.editor { max-width: 760px; margin: 0 auto; padding: 0 calc(var(--gutter) + var(--safe-r)) calc(140px + var(--kb)) calc(var(--gutter) + var(--safe-l)); }
.editor-head {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px;
  margin: 0 calc(-1 * (var(--gutter) + var(--safe-r))) 0 calc(-1 * (var(--gutter) + var(--safe-l)));
  padding: calc(var(--safe-t) + 6px) calc(var(--gutter) + var(--safe-r) - 8px) 6px calc(var(--gutter) + var(--safe-l) - 8px);
  background: rgba(6, 7, 9, 0.86);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
@media (min-width: 900px) { .editor-head { padding-top: 14px; } }
.editor-head .back { display: flex; align-items: center; gap: 0; color: var(--accent); font-size: 16px; padding: 8px 8px 8px 2px; min-width: 0; }
.editor-head .back span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.editor-head .grow { flex: 1; }
.save-state { font-size: 12.5px; color: var(--faint); margin-right: 4px; transition: opacity 0.3s; }
.editor-title {
  width: 100%; border: 0; outline: 0; background: none; resize: none; overflow: hidden;
  font-size: 28px; line-height: 1.2; font-weight: 750; letter-spacing: -0.02em; padding: 8px 0 4px; margin: 0;
}
.editor-title::placeholder { color: var(--faint); }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.meta-row .pill { min-height: 32px; padding: 5px 11px; font-size: 13.5px; }
.meta-row .pill.loc { color: var(--c); }

.blocks { display: flex; flex-direction: column; }
.block { display: flex; align-items: flex-start; gap: 10px; position: relative; }
.block textarea {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; resize: none; overflow: hidden;
  padding: 5px 0; margin: 0; line-height: 1.5; font-size: 17px; min-height: 35px;
}
.block textarea::placeholder { color: var(--faint); }
.block.h textarea { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; padding-top: 12px; }
.block.quote { border-left: 3px solid var(--accent); padding-left: 12px; }
.block.quote textarea { color: var(--muted); font-style: italic; }
.block.bullet::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin: 15px 6px 0 8px; flex: none; }
.block.check { align-items: flex-start; }
.block.ind-1 { padding-left: 26px; } .block.ind-2 { padding-left: 52px; } .block.ind-3 { padding-left: 78px; }
.cb {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); margin-top: 6px;
  display: grid; place-items: center; flex: none; transition: background 0.15s, border-color 0.15s, transform 0.12s;
  position: relative;
}
.cb::after { content: ""; position: absolute; inset: -10px; } /* larger tap target */
.cb svg { width: 15px; height: 15px; stroke-width: 3; color: var(--accent-ink); opacity: 0; transform: scale(0.6); transition: 0.15s; }
.cb:active { transform: scale(0.88); }
.block.checked .cb { background: var(--accent); border-color: var(--accent); }
.block.checked .cb svg { opacity: 1; transform: none; }
.block.checked textarea { color: var(--faint); text-decoration: line-through; }

.attachments { display: grid; gap: 8px; margin-top: 18px; }
.audio {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.audio .play { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.audio .play svg { width: 18px; height: 18px; fill: currentColor; }
.audio .bar { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.audio .bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.audio .time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.editor-foot { color: var(--faint); font-size: 12.5px; margin-top: 26px; text-align: center; }

.kbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; align-items: center; gap: 2px; padding: 6px calc(10px + var(--safe-r)) calc(6px + var(--safe-b)) calc(10px + var(--safe-l));
  background: rgba(13, 16, 21, 0.94); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  transform: translate3d(0, calc(-1 * var(--kb)), 0);
  overflow-x: auto; scrollbar-width: none;
}
.kbar::-webkit-scrollbar { display: none; }
body.kb-open .kbar { padding-bottom: 6px; }
.kbar .icon-btn { width: 40px; height: 40px; color: var(--muted); }
.kbar .icon-btn.on { color: var(--accent); }
.kbar .sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 4px; flex: none; }
.kbar .grow { flex: 1; }
@media (min-width: 900px) {
  .kbar { position: sticky; bottom: 16px; left: auto; right: auto; margin: 24px auto 0; width: fit-content; border: 1px solid var(--border); border-radius: 16px; transform: none; padding: 4px 6px; }
}

/* ---------- Sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); opacity: 0; transition: opacity 0.25s; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: calc(92dvh - var(--kb));
  margin-bottom: var(--kb);
  background: var(--surface); border: 1px solid var(--border); border-bottom: 0;
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--safe-b));
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  transform: translate3d(0, 100%, 0); transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), margin-bottom 0.2s;
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
@media (min-width: 700px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 22px; border-bottom: 1px solid var(--border); margin-bottom: 0; transform: translate3d(0, 24px, 0) scale(0.98); opacity: 0; transition: transform 0.22s, opacity 0.22s; padding-bottom: 18px; }
  .sheet-wrap.open .sheet { opacity: 1; }
}
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 0 auto 10px; }
.sheet-title { font-size: 19px; font-weight: 700; margin: 4px 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet .group { background: var(--surface-2); }
.sheet .row + .row::before { background: var(--border-strong); opacity: 0.6; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }
.menu .row { font-size: 16px; }
.menu .row svg { color: var(--muted); }
.menu .row.danger, .menu .row.danger svg { color: var(--danger); }
.menu .row.on svg { color: var(--accent); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 11px 13px; outline: 0; min-height: 46px; -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.5; }
input[type="date"].input, input[type="time"].input, input[type="datetime-local"].input { display: block; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 3px solid transparent; position: relative; }
.swatch.none { background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.swatch.none svg { width: 18px; height: 18px; }
.swatch.on { border-color: var(--text); }
.quick-dates { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg button { padding: 9px 6px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button svg { width: 16px; height: 16px; }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.seg button.on svg { color: var(--c, var(--accent)); }

.tree .row { min-height: 46px; padding-top: 9px; padding-bottom: 9px; }
.tree .row.current { opacity: 0.45; pointer-events: none; }

/* Voice capture */
.voice { text-align: center; padding: 6px 0 4px; }
.mic-big {
  width: 96px; height: 96px; border-radius: 50%; margin: 10px auto 14px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); position: relative; transition: transform 0.15s;
}
.mic-big svg { width: 40px; height: 40px; stroke-width: 2; }
.mic-big:active { transform: scale(0.94); }
.mic-big.rec::before, .mic-big.rec::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid rgba(255, 210, 0, 0.5);
  animation: pulse 1.6s ease-out infinite;
}
.mic-big.rec::after { animation-delay: 0.8s; }
@keyframes pulse { from { transform: scale(0.9); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
.voice-state { color: var(--muted); font-size: 14px; min-height: 20px; font-variant-numeric: tabular-nums; }
.transcript {
  text-align: left; min-height: 120px; max-height: 34dvh; overflow-y: auto; margin: 14px 0 12px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 14px; font-size: 16px; line-height: 1.5;
  width: 100%; outline: 0; resize: none;
}
.transcript .interim { color: var(--faint); }
.toggles { display: grid; gap: 4px; text-align: left; margin-bottom: 4px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 8px 2px; font-size: 15px; }
.toggle .grow { flex: 1; }
.toggle small { display: block; color: var(--faint); font-size: 12.5px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: 0.2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 4px; margin: 4px 0 10px; }
.cal-head .month { font-size: 20px; font-weight: 700; flex: 1; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 8px; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 650; color: var(--faint); padding: 4px 0 6px; text-transform: uppercase; }
.cal-day {
  aspect-ratio: 1 / 1.05; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 7px; font-size: 15px; font-weight: 550; position: relative; font-variant-numeric: tabular-nums;
}
.cal-day.out { color: var(--faint); opacity: 0.5; }
.cal-day.today .num { background: var(--accent); color: var(--accent-ink); }
.cal-day .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.cal-day.sel { background: var(--surface-3); }
.cal-day.weekend:not(.today) .num { color: var(--muted); }
.cal-dots { display: flex; gap: 3px; margin-top: 3px; height: 6px; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.cal-list-title { font-size: 17px; font-weight: 700; margin: 20px 2px 10px; display: flex; align-items: center; justify-content: space-between; }
@media (min-width: 900px) { .cal-day { aspect-ratio: auto; min-height: 74px; } }

/* ---------- Settings ---------- */
.set-block { margin-bottom: 22px; }
.set-block h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 0 4px 8px; font-weight: 650; }
.set-block .group { padding: 4px 0; }
.set-body { padding: 12px 14px; color: var(--muted); font-size: 14.5px; }
.set-body p { margin: 0 0 10px; }
.set-body ol { margin: 0 0 10px; padding-left: 20px; }
.set-body li { margin-bottom: 6px; }
.set-body b { color: var(--text); font-weight: 600; }
.codebox { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 8px 8px 12px; margin: 6px 0 10px; }
.codebox code { flex: 1; min-width: 0; font: 12.5px/1.4 var(--mono); color: var(--text); overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.codebox code::-webkit-scrollbar { display: none; }
pre.code { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px; font: 12px/1.45 var(--mono); color: var(--text); overflow: auto; max-height: 260px; margin: 6px 0 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); display: inline-block; margin-right: 6px; }
.status-dot.ok { background: var(--ok); } .status-dot.warn { background: #ff9f43; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px + var(--kb)); z-index: 200; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px;
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 14px; border-radius: 14px; font-size: 14.5px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease-out;
}
.toast.err { border-color: rgba(255, 90, 95, 0.5); }
.toast button { color: var(--accent); font-weight: 650; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
body.detail-open .toasts { bottom: calc(70px + var(--safe-b) + var(--kb)); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }

.loading { display: grid; place-items: center; padding: 60px 0; color: var(--faint); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* iOS: no link previews / callouts on long-press targets */
a.row, .smart, .space-card, .side-link, .note-card { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.tree .row .ind-pad { display: block; }

/* Dictation preview */
.voice-hint { margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-align: left; }
.mic-big[disabled] { opacity: 0.85; }
.mic-big .spinner { border-color: rgba(26, 21, 0, 0.25); border-top-color: var(--accent-ink); width: 30px; height: 30px; }
.btn .spinner { width: 18px; height: 18px; }
.btn.primary .spinner { border-color: rgba(26, 21, 0, 0.25); border-top-color: var(--accent-ink); }
.draft-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px 0 4px -10px; }
.draft-engine { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.draft-engine svg { width: 15px; height: 15px; }
.draft .editor-title { font-size: 24px; }
.draft .blocks { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 14px; padding: 6px 12px; }
.draft .block textarea { font-size: 16px; }
.draft-tools { display: flex; align-items: center; gap: 2px; margin: 8px 0 2px; }
.draft-tools .icon-btn { color: var(--muted); width: 40px; }
.draft-tools .grow { flex: 1; }

/* Link blocks */
.block.link { align-items: center; padding: 3px 0; }
.link-chip {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px 0 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 12px; color: var(--text);
  -webkit-touch-callout: default; transition: background 0.15s, transform 0.12s;
}
.link-chip:active { transform: scale(0.99); background: var(--surface-3); }
@media (hover: hover) { .link-chip:hover { border-color: var(--accent); } }
.link-chip.loading .link-title { color: var(--faint); }
.link-ico {
  width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--accent); font: 700 12px/1 var(--font);
}
.link-ico svg { width: 15px; height: 15px; }
.link-ico.b-ig { background: linear-gradient(45deg, #f9ce34, #ee2a7b 50%, #6228d7); color: #fff; }
.link-ico.b-yt { background: #ff0033; color: #fff; }
.link-ico.b-tt { background: #000; color: #25f4ee; border: 1px solid #333; }
.link-ico.b-fb { background: #1877f2; color: #fff; font-size: 16px; }
.link-ico.b-x { background: #000; color: #fff; border: 1px solid #333; }
.link-ico.b-li { background: #0a66c2; color: #fff; }
.link-ico.b-sp { background: #1db954; color: #000; }
.link-ico.b-gd { background: #fff; color: #4285f4; }
.link-ico.b-ms { background: #5059c9; color: #fff; }
.link-ico.b-pi { background: #e60023; color: #fff; }
.link-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-site { flex: none; max-width: 38%; font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block.link .link-more { width: 34px; height: 34px; color: var(--faint); }

/* Swipe actions on note cards */
.note-row { position: relative; border-radius: var(--r-md); overflow: hidden; }
.note-row .note-card { z-index: 1; touch-action: pan-y; transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), background 0.15s, border-color 0.15s; }
.swipe-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; padding-left: 24px; }
.note-row:not(.open):not(.swiping) .swipe-actions { visibility: hidden; }
.swipe-btn { width: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 650; color: #fff; }
.swipe-btn svg { width: 22px; height: 22px; }
.swipe-btn.done { background: var(--ok); color: #04210f; }
.swipe-btn.trash { background: var(--danger); }
.note-row.removing { opacity: 0; transform: translateX(-30%); transition: opacity 0.25s, transform 0.25s; }
.brand-ico { width: 30px; height: 30px; border-radius: 8px; display: block; }
.side-brand .brand-ico { width: 26px; height: 26px; border-radius: 7px; }
