/* =====================================================================
   DOTSPACE — design system
   Light = warm grey hardware panel (orange accent)
   Dark  = pure black, dot-matrix, signal red accent
   ===================================================================== */

@font-face { font-family: 'Doto'; font-weight: 400; font-display: swap; src: url('/fonts/doto/doto-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Doto'; font-weight: 700; font-display: swap; src: url('/fonts/doto/doto-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Doto'; font-weight: 900; font-display: swap; src: url('/fonts/doto/doto-latin-900-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 400; font-display: swap; src: url('/fonts/grotesk/space-grotesk-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-display: swap; src: url('/fonts/grotesk/space-grotesk-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 600; font-display: swap; src: url('/fonts/grotesk/space-grotesk-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 700; font-display: swap; src: url('/fonts/grotesk/space-grotesk-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 400; font-display: swap; src: url('/fonts/mono/space-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 700; font-display: swap; src: url('/fonts/mono/space-mono-latin-700-normal.woff2') format('woff2'); }

:root {
  --f-dot: 'Doto', 'Space Mono', monospace;
  --f-sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'Space Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  /* hardware palette */
  --c-red: #d71921;
  --c-orange: #ff4f00;
  --c-yellow: #ffc400;
  --c-green: #12a150;
  --c-blue: #1d5cff;
  --c-grey: #9a9a95;

  --r-s: 4px;
  --r-m: 8px;
  --r-l: 14px;
  --r-pill: 999px;

  --side-w: 264px;
  --top-h: 52px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* light (default) */
  --bg: #e7e7e3;
  --panel: #f1f1ee;
  --card: #fbfbf9;
  --raised: #ffffff;
  --ink: #111111;
  --ink-2: #3d3d3b;
  --muted: #858581;
  --faint: #b2b2ad;
  --line: #cfcfca;
  --line-2: #dcdcd7;
  --hover: rgba(0, 0, 0, .05);
  --active: rgba(0, 0, 0, .09);
  --dot: rgba(0, 0, 0, .16);
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.22);
  --shadow-l: 0 2px 0 rgba(0,0,0,.04), 0 24px 60px -20px rgba(0,0,0,.35);
  --accent: var(--c-orange);
  --on-accent: #ffffff;
  --sel: rgba(255, 79, 0, .18);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --panel: #0a0a0a;
  --card: #121212;
  --raised: #1a1a1a;
  --ink: #f4f4f4;
  --ink-2: #c4c4c4;
  --muted: #7d7d7d;
  --faint: #4a4a4a;
  --line: #2a2a2a;
  --line-2: #1d1d1d;
  --hover: rgba(255, 255, 255, .06);
  --active: rgba(255, 255, 255, .11);
  --dot: rgba(255, 255, 255, .17);
  --shadow: 0 0 0 1px rgba(255,255,255,.04), 0 10px 30px -12px rgba(0,0,0,.9);
  --shadow-l: 0 0 0 1px rgba(255,255,255,.06), 0 30px 80px -20px rgba(0,0,0,1);
  --accent: var(--c-red);
  --sel: rgba(215, 25, 33, .28);
  color-scheme: dark;
}

:root[data-accent="red"]    { --accent: var(--c-red); --sel: rgba(215,25,33,.22); }
:root[data-accent="orange"] { --accent: var(--c-orange); --sel: rgba(255,79,0,.2); }
:root[data-accent="yellow"] { --accent: var(--c-yellow); --on-accent: #111; --sel: rgba(255,196,0,.28); }
:root[data-accent="green"]  { --accent: var(--c-green); --sel: rgba(18,161,80,.22); }
:root[data-accent="blue"]   { --accent: var(--c-blue); --sel: rgba(29,92,255,.22); }
:root[data-accent="mono"]   { --accent: var(--ink); --on-accent: var(--bg); --sel: rgba(128,128,128,.25); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--f-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
img, video { max-width: 100%; }
::selection { background: var(--sel); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* scrollbars: thin hairline */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border: 3px solid transparent; background-clip: padding-box; border-radius: 10px; }

/* ---------------------------------------------------------------- type */
.dot { font-family: var(--f-dot); font-weight: 700; letter-spacing: .02em; }
.mono { font-family: var(--f-mono); }
.label {
  font: 400 10.5px/1.2 var(--f-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.num { font: 400 10.5px/1 var(--f-mono); color: var(--faint); letter-spacing: .06em; }
.red-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--raised);
  font: 400 11px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
  user-select: none;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--c-red); }
.btn.small { height: 28px; padding: 0 12px; font-size: 10px; }
.btn svg { width: 15px; height: 15px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  color: var(--ink-2);
  transition: background .15s, color .15s;
  flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.input, .textarea, .select {
  width: 100%;
  height: 40px; padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--raised);
  outline: none;
  transition: border-color .15s;
}
.textarea { height: auto; min-height: 90px; padding: 10px 14px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--ink-2); }

.kbd { font: 10px/1 var(--f-mono); padding: 3px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); }

/* ---------------------------------------------------------------- layout */
#app { height: 100%; display: flex; }
.sidebar {
  width: var(--side-w); flex: none;
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 40;
}
.main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; position: relative; }
.view { flex: 1; min-height: 0; overflow: auto; position: relative; }
.view.no-scroll { overflow: hidden; }

.brand {
  display: flex; align-items: center; gap: 10px;
  height: 64px; padding: 0 20px;
  border-bottom: 1px solid var(--line-2);
  text-decoration: none;
}
.brand-word { font: 900 21px/1 var(--f-dot); letter-spacing: .06em; }
.brand .red-dot { width: 9px; height: 9px; animation: blink 2.4s steps(1) infinite; }
@keyframes blink { 0%, 70% { opacity: 1; } 71%, 100% { opacity: .25; } }

.side-search {
  margin: 14px 14px 6px;
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--card);
  color: var(--muted); font: 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
}
.side-search:hover { border-color: var(--ink-2); color: var(--ink-2); }
.side-search .kbd { margin-left: auto; }

.side-scroll { flex: 1; overflow-y: auto; padding: 6px 8px 16px; }
.side-section { margin-top: 18px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 6px; }
.side-head .icon-btn { width: 24px; height: 24px; }
.side-head .icon-btn svg { width: 15px; height: 15px; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px; border-radius: var(--r-m);
  text-decoration: none; color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.nav-link:hover { background: var(--hover); color: var(--ink); }
.nav-link.active { background: var(--active); color: var(--ink); }
.nav-link .num { width: 18px; }
.nav-link .count { margin-left: auto; font: 10px var(--f-mono); color: var(--muted); }

.tree-row {
  display: flex; align-items: center; gap: 4px;
  height: 31px; padding-right: 4px; border-radius: var(--r-s);
  color: var(--ink-2); font-size: 14px;
  cursor: pointer; user-select: none;
  position: relative;
}
.tree-row:hover { background: var(--hover); color: var(--ink); }
.tree-row.active { background: var(--active); color: var(--ink); }
.tree-row.drop-inside { box-shadow: inset 0 0 0 1.5px var(--accent); }
.tree-row.drop-before::before, .tree-row.drop-after::after {
  content: ''; position: absolute; left: 8px; right: 8px; height: 2px; background: var(--accent);
}
.tree-row.drop-before::before { top: -1px; }
.tree-row.drop-after::after { bottom: -1px; }
.tree-caret { width: 20px; height: 20px; display: grid; place-items: center; color: var(--faint); flex: none; border-radius: 4px; }
.tree-caret:hover { background: var(--active); color: var(--ink); }
.tree-caret svg { width: 12px; height: 12px; transition: transform .15s; }
.tree-caret.open svg { transform: rotate(90deg); }
.tree-icon { width: 20px; text-align: center; flex: none; font-size: 13px; color: var(--muted); }
.tree-icon svg { width: 15px; height: 15px; vertical-align: -3px; }
.tree-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-title.untitled { color: var(--muted); }
.tree-actions { display: none; gap: 0; }
.tree-row:hover .tree-actions, .tree-row.menu-open .tree-actions { display: flex; }
.tree-actions .icon-btn { width: 22px; height: 22px; }
.tree-actions .icon-btn svg { width: 14px; height: 14px; }
.tree-empty { padding: 4px 12px; color: var(--faint); font-size: 13px; }

.side-foot { border-top: 1px solid var(--line-2); padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.side-new { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px 6px 8px; }
.side-new .btn { width: 100%; padding: 0 8px; }

/* topbar */
.topbar {
  height: var(--top-h); flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px 0 10px;
  border-bottom: 1px solid var(--line-2);
  background: var(--bg);
  z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; overflow: hidden; }
.crumb { font: 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-decoration: none; white-space: nowrap; padding: 6px 6px; border-radius: 4px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.crumb:hover { background: var(--hover); color: var(--ink); }
.crumb.current { color: var(--ink); }
.crumb-sep { color: var(--faint); font: 11px var(--f-mono); }
.sync { display: flex; align-items: center; gap: 7px; padding: 0 8px; }
.sync .red-dot { width: 7px; height: 7px; background: var(--c-green); }
.sync[data-state="saving"] .red-dot { background: var(--c-yellow); }
.sync[data-state="offline"] .red-dot, .sync[data-state="error"] .red-dot, .sync[data-state="trashed"] .red-dot { background: var(--c-red); animation: blink 1s steps(1) infinite; }
.menu-toggle { display: none; }

/* ---------------------------------------------------------------- mobile bar */
.mobile-bar { display: none; }
.scrim { display: none; }

@media (max-width: 860px) {
  :root { --top-h: 50px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(88vw, 320px);
    transform: translateX(-102%);
    transition: transform .25s var(--ease);
    box-shadow: var(--shadow-l);
  }
  body.side-open .sidebar { transform: none; }
  body.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .menu-toggle { display: inline-grid; }
  .main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .mobile-bar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--panel); border-top: 1px solid var(--line);
    z-index: 30;
  }
  .mobile-bar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font: 9px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; }
  .mobile-bar button.active { color: var(--ink); }
  .mobile-bar button svg { width: 20px; height: 20px; }
  .mobile-bar .plus span { width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; }
  .mobile-bar .plus svg { width: 22px; height: 22px; }
  .crumb { max-width: 130px; }
  .hide-mobile { display: none !important; }
}

/* ---------------------------------------------------------------- generic surfaces */
.wrap { max-width: 1120px; margin: 0 auto; padding: 36px 32px 80px; }
@media (max-width: 860px) { .wrap { padding: 22px 16px 60px; } }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.panel-body { padding: 18px; }

.grid-lines { background-image: linear-gradient(var(--line-2) 1px, transparent 1px), linear-gradient(90deg, var(--line-2) 1px, transparent 1px); background-size: 24px 24px; }
.dot-field { background-image: radial-gradient(var(--dot) 1px, transparent 1.3px); background-size: 16px 16px; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 48px 20px; text-align: center; color: var(--muted);
}
.empty .dot { font-size: 34px; color: var(--faint); }

/* ---------------------------------------------------------------- popovers / menus / modals */
.pop {
  position: fixed; z-index: 200;
  min-width: 200px; max-width: min(340px, calc(100vw - 16px)); max-height: min(420px, calc(100vh - 16px)); overflow: auto;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-l);
  padding: 6px;
  animation: pop-in .12s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 34px; padding: 6px 10px; border-radius: var(--r-m);
  text-align: left; font-size: 14px; color: var(--ink-2);
}
.menu-item:hover, .menu-item.hl { background: var(--hover); color: var(--ink); }
.menu-item .mi-icon { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; flex: none; font: 11px var(--f-mono); color: var(--ink-2); background: var(--card); }
.menu-item .mi-icon svg { width: 15px; height: 15px; }
.menu-item .mi-text { display: flex; flex-direction: column; min-width: 0; }
.menu-item .mi-sub { font-size: 12px; color: var(--muted); }
.menu-item .mi-right { margin-left: auto; font: 10px var(--f-mono); color: var(--faint); }
.menu-item.danger { color: var(--c-red); }
.menu-sep { height: 1px; background: var(--line-2); margin: 5px 4px; }
.menu-label { padding: 8px 10px 4px; }

.modal-back {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(560px, 100%);
  max-height: 80vh; overflow: auto;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-l);
  animation: pop-in .15s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line-2); }
@media (max-width: 860px) {
  .modal-back { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 88vh; width: 100%; padding-bottom: env(safe-area-inset-bottom); }
}

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (max-width: 860px) { .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px;
  background: var(--ink); color: var(--bg);
  border-radius: var(--r-pill);
  font: 11px/1.3 var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
  box-shadow: var(--shadow-l);
  animation: pop-in .18s var(--ease);
  max-width: calc(100vw - 32px);
}
.toast .red-dot { background: var(--accent); }
.toast button { color: var(--accent); font: inherit; letter-spacing: inherit; padding: 4px 8px; border-radius: var(--r-pill); }
.toast button:hover { background: rgba(127,127,127,.2); }
.toast .bar { width: 80px; height: 4px; background: rgba(127,127,127,.35); border-radius: 4px; overflow: hidden; }
.toast .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------------------------------------------------------------- command palette */
.palette { width: min(640px, 100%); }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; height: 60px; border-bottom: 1px solid var(--line-2); }
.palette-input input { flex: 1; border: 0; outline: 0; background: none; font-size: 18px; }
.palette-list { max-height: 55vh; overflow: auto; padding: 6px; }
.palette .snippet { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette .snippet mark { background: var(--sel); color: inherit; border-radius: 2px; }

/* ---------------------------------------------------------------- home */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.hero-title { font: 900 clamp(40px, 7vw, 78px)/.9 var(--f-dot); letter-spacing: .01em; margin: 10px 0 0; text-transform: uppercase; }
.hero-clock { font: 700 clamp(30px, 4.6vw, 52px)/1 var(--f-dot); text-align: right; }
.hero-clock .label { display: block; margin-top: 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tile {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between; gap: 22px;
  min-height: 118px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-l);
  text-align: left; text-decoration: none; color: var(--ink);
  transition: border-color .15s, transform .15s var(--ease);
  overflow: hidden;
}
.tile:hover { border-color: var(--ink-2); transform: translateY(-1px); }
.tile .tile-top { display: flex; justify-content: space-between; align-items: center; }
.tile .tile-title { font: 500 16px/1.25 var(--f-sans); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .tile-glyph { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; }
.tile.dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tile.dark .label { color: var(--faint); }
.tile.dark .tile-glyph { border-color: rgba(127,127,127,.5); }
.tile.accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tile.accent .label { color: inherit; opacity: .75; }
.tile.accent .tile-glyph { border-color: currentColor; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 36px 0 12px; }
.section-title h2 { margin: 0; font: 400 11px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.section-title .rule { flex: 1; height: 1px; background: var(--line); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; background: var(--card); }
.stat { padding: 14px 16px; border-right: 1px solid var(--line-2); }
.stat:last-child { border-right: 0; }
.stat .v { font: 700 30px/1 var(--f-dot); margin-top: 10px; }
@media (max-width: 600px) { .stats { grid-template-columns: repeat(2, 1fr); } .stat:nth-child(2) { border-right: 0; } .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); } }

.item-tile .preview { font-size: 12.5px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------------------------------------------------------------- today */
.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
@media (max-width: 1080px) { .today-grid { grid-template-columns: 1fr; } }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 18px 0 26px; }
.day-cell { text-decoration: none; color: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0 9px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--card);
}
.day-cell:hover { border-color: var(--ink-2); }
.day-cell .d { font: 700 24px/1 var(--f-dot); }
.day-cell .pip { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.day-cell.has .pip { background: var(--muted); }
.day-cell.today { border-color: var(--ink); }
.day-cell.today .pip { background: var(--accent); }
.day-cell.sel { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.day-cell.sel .label { color: var(--faint); }
.today-date { font: 900 clamp(38px, 6vw, 64px)/.95 var(--f-dot); margin: 8px 0 0; text-transform: uppercase; }
.today-doc { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-l); padding: 8px 0 30px; }

.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line-2); }
.task-row:last-child { border-bottom: 0; }
.task-row .t-text { flex: 1; min-width: 0; font-size: 14px; }
.task-row.done .t-text { color: var(--muted); text-decoration: line-through; }
.task-row .t-src { font: 10px var(--f-mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; text-decoration: none; display: block; margin-top: 2px; }
.task-row .t-src:hover { color: var(--accent); }

.check {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; margin: 2px 0 0; flex: none;
  border: 1.5px solid var(--ink-2); border-radius: 5px;
  display: grid; place-items: center; cursor: pointer;
  background: transparent;
  transition: background .12s, border-color .12s;
}
.check::after { content: ''; width: 9px; height: 5px; border: 2px solid var(--on-accent); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check:checked, .check.on { background: var(--accent); border-color: var(--accent); }
.check:checked::after, .check.on::after { opacity: 1; }

.capture { display: flex; gap: 8px; }
.capture .input { border-radius: var(--r-pill); }

/* ---------------------------------------------------------------- settings */
.settings { max-width: 820px; }
.set-row { display: flex; gap: 18px; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.set-row:last-child { border-bottom: 0; }
.set-row .set-info { flex: 1; min-width: 220px; }
.set-row .set-info h3 { margin: 0 0 3px; font-size: 15px; font-weight: 500; }
.set-row .set-info p { margin: 0; font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; background: var(--card); }
.seg button { height: 28px; padding: 0 12px; border-radius: var(--r-pill); font: 10px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--bg); }
.swatches { display: flex; gap: 8px; }
.swatch-btn { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line); }
.swatch-btn.on { box-shadow: 0 0 0 2px var(--ink); }
.qr { width: 180px; height: 180px; padding: 10px; background: #fff; border-radius: var(--r-m); flex: none; }
.qr svg { width: 100%; height: 100%; display: block; }
.code-line { font: 12.5px/1.5 var(--f-mono); background: var(--panel); border: 1px solid var(--line-2); padding: 8px 10px; border-radius: var(--r-s); word-break: break-all; user-select: all; }
.steps { margin: 8px 0 0; padding-left: 20px; font-size: 13.5px; color: var(--ink-2); }
.steps li { margin: 4px 0; }

/* ---------------------------------------------------------------- login */
.login {
  height: 100%; width: 100%; display: grid; place-items: center; padding: 20px;
}
.login-card { width: min(380px, 100%); text-align: center; }
.login-card .brand-word { font-size: 40px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 26px 0 18px; min-height: 14px; }
.pin-dots i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink-2); }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); }
.pin-dots.err i { border-color: var(--c-red); background: var(--c-red); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------------------------------------------------------------- lightbox */
.lightbox { position: fixed; inset: 0; z-index: 250; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; padding: 40px 16px; animation: fade .15s; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lightbox .lb-bar { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.lightbox .icon-btn { color: #fff; background: rgba(255,255,255,.1); }
.lightbox iframe { width: min(1000px, 100%); height: 100%; border: 0; background: #fff; border-radius: 6px; }

/* ---------------------------------------------------------------- shared rich text */
.rt { outline: none; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; min-height: 1.55em; }
.rt a { color: inherit; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1.5px; cursor: pointer; }
.rt code, .inline-code { font: .86em/1 var(--f-mono); background: var(--hover); border: 1px solid var(--line-2); padding: 2px 5px; border-radius: 4px; }
.rt mark { background: rgba(255, 196, 0, .4); color: inherit; padding: 0 2px; border-radius: 2px; }
/* coloured text (e.g. brought over from Milanote) */
.rt span[data-c="red"] { color: var(--c-red); }
.rt span[data-c="orange"] { color: var(--c-orange); }
.rt span[data-c="yellow"] { color: #c99a00; }
.rt span[data-c="green"] { color: var(--c-green); }
.rt span[data-c="blue"] { color: var(--c-blue); }
.rt span[data-c="purple"] { color: #7b4fd6; }
.rt span[data-c="pink"] { color: #e0559b; }
.rt span[data-c="grey"] { color: var(--muted); }
:root[data-theme="dark"] .rt mark { background: rgba(255, 196, 0, .3); }
.rt b, .rt strong { font-weight: 600; }
.rt[data-ph]:empty::before { content: attr(data-ph); color: var(--faint); pointer-events: none; }

.fmt-bar {
  position: fixed; z-index: 180;
  display: flex; align-items: center; gap: 1px; padding: 4px;
  background: var(--ink); color: var(--bg);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-l);
  animation: pop-in .1s var(--ease);
}
.fmt-bar button { height: 30px; min-width: 30px; padding: 0 8px; border-radius: var(--r-pill); font: 13px/1 var(--f-sans); }
.fmt-bar button:hover { background: rgba(127,127,127,.3); }
.fmt-bar .sep { width: 1px; height: 16px; background: rgba(127,127,127,.4); margin: 0 3px; }
.fmt-bar input { height: 30px; width: 220px; border: 0; outline: 0; background: transparent; color: inherit; padding: 0 10px; font-size: 13px; }

/* ---------------------------------------------------------------- link preview (shared by pages + boards) */
.lp {
  display: flex; border: 1px solid var(--line); border-radius: var(--r-m);
  overflow: hidden; text-decoration: none; color: inherit; background: var(--raised);
  transition: border-color .15s;
}
.lp:hover { border-color: var(--ink-2); }
.lp-body { flex: 1; min-width: 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.lp-title { font-weight: 500; font-size: 14.5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lp-desc { font-size: 12.5px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lp-site { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 4px; }
.lp-site img { width: 14px; height: 14px; border-radius: 3px; }
.lp-thumb { width: 34%; max-width: 220px; min-height: 96px; background: var(--panel) center/cover no-repeat; flex: none; border-left: 1px solid var(--line-2); }
.embed {
  position: relative; width: 100%;
  border-radius: var(--r-m); overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}
.embed iframe, .embed video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.embed-poster { position: absolute; inset: 0; background: #111 center/cover no-repeat; display: grid; place-items: center; cursor: pointer; }
.embed-poster::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,.55)); }
.play {
  position: relative; z-index: 1;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  transition: transform .15s var(--ease);
}
.embed-poster:hover .play { transform: scale(1.07); }
.play svg { width: 22px; height: 22px; fill: currentColor; stroke: none; margin-left: 3px; }
.embed-tag { position: absolute; left: 10px; top: 10px; z-index: 1; padding: 4px 8px; border-radius: var(--r-pill); background: rgba(0,0,0,.65); color: #fff; font: 10px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; }
.embed-meta { display: flex; align-items: center; gap: 8px; padding: 8px 2px 0; min-width: 0; }
.embed-meta .t { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.embed-meta a { text-decoration: none; }

.file-chip {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-m); background: var(--raised);
}
.file-chip .ext { width: 42px; height: 48px; border-radius: 6px; background: var(--ink); color: var(--bg); display: grid; place-items: end center; padding-bottom: 7px; font: 700 10px var(--f-mono); letter-spacing: .06em; flex: none; position: relative; }
.file-chip .ext::before { content: ''; position: absolute; top: 0; right: 0; width: 12px; height: 12px; background: linear-gradient(225deg, var(--bg) 50%, rgba(127,127,127,.6) 50%); }
.file-chip .f-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .f-info { flex: 1; min-width: 0; }

@media (min-width: 861px) {
  body.side-collapsed .sidebar { display: none; }
  body.side-collapsed .menu-toggle { display: inline-grid; }
}

@media (max-width: 600px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { min-height: 104px; padding: 12px; gap: 14px; }
  .tile .tile-title { font-size: 15px; }
  .hero-clock { text-align: left; }
}
