/* ============ Work Hub — light-first design tokens ============ */
:root {
  --site-bg: #f5f3ed;
  --site-fg: #211d38;
  --site-accent: #6d4aff;
  --site-on-accent: #ffffff;
  --site-surface: #ffffff;
  --site-muted: #6e6887;
  --site-border: #e5e1d4;
  --site-font: 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --site-radius: 14px;
  --site-space: 1;
  --site-type: 1;
  --site-motion: 1;

  --sp: calc(24px * var(--site-space, 1));
  --sp-sm: calc(12px * var(--site-space, 1));
  --sp-xs: calc(6px * var(--site-space, 1));
  --dur: calc(180ms * var(--site-motion, 1));

  --c-green: #0e9f6e;
  --c-cyan: #0891b2;
  --c-amber: #d97706;
  --c-magenta: #db2777;
  --c-red: #dc2626;
  --c-blue: #2563eb;
  --c-violet: #7c3aed;
  --c-teal: #0d9488;

  --surface-2: color-mix(in srgb, var(--site-surface) 82%, var(--site-bg));
  --surface-3: color-mix(in srgb, var(--site-surface) 55%, var(--site-bg));
  --accent-soft: color-mix(in srgb, var(--site-accent) 13%, transparent);
  --danger: var(--c-red);
  --success: var(--c-green);
  --warning: var(--c-amber);
  --info: var(--c-blue);

  --shadow-1: 0 1px 2px rgba(33,29,56,.05), 0 6px 20px rgba(33,29,56,.07);
  --shadow-2: 0 2px 6px rgba(33,29,56,.08), 0 18px 44px rgba(33,29,56,.14);
  --scrim: rgba(33,29,56,.38);
  --aurora-op: .5;
  --dot-op: .55;
  --grain-op: .04;
  color-scheme: light;
}

[data-theme="dark"] {
  --site-bg: #0c0f1d;
  --site-fg: #edefff;
  --site-accent: #8b70ff;
  --site-on-accent: #ffffff;
  --site-surface: #151a30;
  --site-muted: #8f96bb;
  --site-border: #2a3155;

  --c-green: #2fd483;
  --c-cyan: #38d6f5;
  --c-amber: #ffb224;
  --c-magenta: #ff5ca8;
  --c-red: #ff6257;
  --c-blue: #6ea8ff;
  --c-violet: #a78bff;
  --c-teal: #2dd4bf;

  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --shadow-2: 0 2px 6px rgba(0,0,0,.4), 0 20px 50px rgba(0,0,0,.5);
  --scrim: rgba(5,7,15,.62);
  --aurora-op: .8;
  --dot-op: .35;
  --grain-op: .05;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--site-bg);
  color: var(--site-fg);
  font-family: var(--site-font);
  font-size: calc(16px * var(--site-type, 1));
  line-height: 1.5;
  transition: background var(--dur) ease, color var(--dur) ease;
}

::selection { background: var(--site-accent); color: var(--site-on-accent); }

/* Scrollbars in the hub's own language */
* { scrollbar-width: thin; scrollbar-color: var(--site-border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--site-border);
  border-radius: 8px;
  border: 2px solid var(--site-bg);
}
*::-webkit-scrollbar-thumb:hover { background: var(--site-accent); }

/* ============ Layered background ============ */
.aurora { position: fixed; inset: 0; z-index: -3; overflow: hidden; opacity: var(--aurora-op); }
.blob {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(95px);
  opacity: .3;
  animation: drift calc(26s * var(--site-motion, 1)) ease-in-out infinite alternate;
}
.blob-a { top: -24vmax; left: -16vmax; background: radial-gradient(circle, color-mix(in srgb, var(--site-accent) 55%, transparent), transparent 65%); }
.blob-b { bottom: -28vmax; right: -18vmax; background: radial-gradient(circle, color-mix(in srgb, var(--c-magenta) 42%, transparent), transparent 65%); animation-delay: -9s; opacity: .22; }
.blob-c { top: 22%; left: 46%; width: 38vmax; height: 38vmax; background: radial-gradient(circle, color-mix(in srgb, var(--c-cyan) 38%, transparent), transparent 65%); animation-delay: -17s; opacity: .18; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(7vmax, 5vmax) scale(1.12); }
}
.dots {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  opacity: var(--dot-op);
  background-image: radial-gradient(color-mix(in srgb, var(--site-muted) 26%, transparent) 1px, transparent 1.4px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 78%);
}
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--grain-op);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* ============ Top bar ============ */
.topbar {
  position: relative; flex: none; z-index: 40;
  background: color-mix(in srgb, var(--site-bg) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--site-border);
  animation: fadein calc(var(--dur) * 2) ease both;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.topbar-inner {
  width: 100%;
  padding: var(--sp-sm) var(--sp);
  display: flex; align-items: center; gap: var(--sp-sm);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--site-fg); }
.brand-mark { flex: none; filter: drop-shadow(0 2px 8px var(--accent-soft)); }
.brand-name { font-weight: 700; font-size: calc(20px * var(--site-type, 1)); letter-spacing: .02em; white-space: nowrap; }

.clockbox {
  display: flex; align-items: baseline; gap: 8px;
  margin-left: var(--sp-sm);
  color: var(--site-muted);
  font-size: calc(14px * var(--site-type, 1));
  min-width: 0;
}
.greeting { color: var(--site-fg); font-weight: 500; white-space: nowrap; }
.clock { font-variant-numeric: tabular-nums; color: var(--c-cyan); font-weight: 600; }
.dateline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-xs); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--site-accent), color-mix(in srgb, var(--site-accent) 50%, var(--c-magenta)));
  color: var(--site-on-accent);
  border: none; cursor: pointer; text-decoration: none;
  font: 600 calc(14.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(10px * var(--site-space, 1)) calc(18px * var(--site-space, 1));
  border-radius: calc(var(--site-radius) * .7);
  box-shadow: 0 4px 16px var(--accent-soft);
  transition: transform var(--dur) ease, box-shadow var(--dur) ease, filter var(--dur) ease;
  white-space: nowrap;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 6px 22px var(--accent-soft); }
.btn-primary:active { transform: translateY(0) scale(.98); }
.btn-primary.small { padding: calc(8px * var(--site-space, 1)) calc(13px * var(--site-space, 1)); font-size: calc(13px * var(--site-type, 1)); }

.btn-ghost {
  background: transparent; color: var(--site-muted);
  border: 1px solid var(--site-border); cursor: pointer;
  font: 500 calc(14.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(10px * var(--site-space, 1)) calc(18px * var(--site-space, 1));
  border-radius: calc(var(--site-radius) * .7);
  transition: color var(--dur), border-color var(--dur), background var(--dur);
}
.btn-ghost:hover { color: var(--site-fg); border-color: var(--site-muted); background: var(--surface-3); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  background: var(--site-surface); color: var(--site-muted);
  border: 1px solid var(--site-border); border-radius: calc(var(--site-radius) * .7);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(33,29,56,.04);
  transition: color var(--dur), border-color var(--dur), background var(--dur), transform var(--dur), box-shadow var(--dur);
}
.icon-btn:hover { color: var(--site-accent); border-color: var(--site-accent); transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-soft); }
.icon-btn.small { width: 30px; height: 30px; border-radius: calc(var(--site-radius) * .5); }
.icon-btn[aria-pressed="true"] { color: var(--site-on-accent); background: var(--site-accent); border-color: var(--site-accent); }
#themeBtn svg { transition: transform calc(var(--dur) * 2) ease; }
#themeBtn:hover svg { transform: rotate(-18deg); }

/* Menus */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  padding: var(--sp-xs);
  box-shadow: var(--shadow-2);
  animation: pop calc(var(--dur) * .9) ease both;
  z-index: 60;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--site-fg);
  font: 500 calc(14px * var(--site-type, 1)) var(--site-font);
  padding: calc(10px * var(--site-space, 1)) calc(12px * var(--site-space, 1));
  border-radius: calc(var(--site-radius) * .55);
  transition: background var(--dur);
}
.menu-item:hover { background: var(--accent-soft); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* Saved views menu */
.views-menu { width: 272px; }
.views-head {
  font-size: calc(12px * var(--site-type, 1)); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--site-muted);
  padding: calc(8px * var(--site-space, 1)) calc(12px * var(--site-space, 1)) calc(4px * var(--site-space, 1));
}
.views-list { max-height: 240px; overflow-y: auto; }
.views-empty { color: var(--site-muted); font-size: calc(13px * var(--site-type, 1)); padding: calc(8px * var(--site-space, 1)) calc(12px * var(--site-space, 1)); }
.view-item { display: flex; align-items: center; gap: 4px; border-radius: calc(var(--site-radius) * .55); }
.view-item:hover { background: var(--accent-soft); }
.view-apply {
  flex: 1; min-width: 0; background: none; border: none; cursor: pointer; text-align: left;
  color: var(--site-fg); font: 500 calc(13.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(8px * var(--site-space, 1)) calc(12px * var(--site-space, 1));
  display: flex; flex-direction: column; gap: 1px;
}
.view-apply .view-meta { font-size: calc(11.5px * var(--site-type, 1)); color: var(--site-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view-del {
  flex: none; width: 26px; height: 26px; margin-right: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 6px; cursor: pointer; color: var(--site-muted);
}
.view-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.views-save { display: flex; gap: 6px; padding: calc(8px * var(--site-space, 1)) calc(8px * var(--site-space, 1)) calc(6px * var(--site-space, 1)); border-top: 1px solid var(--site-border); margin-top: 4px; }
.views-save input {
  flex: 1; min-width: 0;
  background: var(--surface-3); border: 1px solid var(--site-border);
  border-radius: calc(var(--site-radius) * .55);
  color: var(--site-fg); font: 400 calc(13px * var(--site-type, 1)) var(--site-font);
  padding: calc(7px * var(--site-space, 1)) calc(10px * var(--site-space, 1));
  outline: none;
}
.views-save input:focus { border-color: var(--site-accent); }

/* Toolbar */
.toolbar {
  flex: none;
  padding: var(--sp-sm) var(--sp);
  display: flex; align-items: center; gap: var(--sp-sm);
  border-bottom: 1px solid var(--site-border);
  background: color-mix(in srgb, var(--site-bg) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.search {
  display: flex; align-items: center; gap: 8px;
  flex: 0 1 300px; min-width: 160px;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: calc(var(--site-radius) * .7);
  padding: 0 calc(12px * var(--site-space, 1));
  color: var(--site-muted);
  box-shadow: 0 1px 2px rgba(33,29,56,.04);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.search:focus-within { border-color: var(--site-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--site-fg);
  font: 400 calc(14.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(10px * var(--site-space, 1)) 0;
}
.search input::placeholder { color: var(--site-muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.chips {
  display: flex; gap: var(--sp-xs);
  overflow-x: auto; flex: 1;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  color: var(--site-muted);
  font: 500 calc(13.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(7px * var(--site-space, 1)) calc(13px * var(--site-space, 1));
  border-radius: 999px;
  cursor: pointer;
  transition: color var(--dur), border-color var(--dur), background var(--dur), transform var(--dur);
  white-space: nowrap;
}
.chip:hover { color: var(--site-fg); transform: translateY(-1px); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chip-color, var(--site-accent)); }
.chip .count { font-size: calc(12px * var(--site-type, 1)); opacity: .75; font-variant-numeric: tabular-nums; }
.chip.active {
  color: var(--site-fg);
  border-color: var(--chip-color, var(--site-accent));
  background: color-mix(in srgb, var(--chip-color, var(--site-accent)) 12%, var(--site-surface));
}

.sortwrap { display: flex; align-items: center; gap: 8px; flex: none; color: var(--site-muted); font-size: calc(13.5px * var(--site-type, 1)); }
.sortwrap select {
  background: var(--site-surface); color: var(--site-fg);
  border: 1px solid var(--site-border);
  border-radius: calc(var(--site-radius) * .7);
  font: 500 calc(13.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(9px * var(--site-space, 1)) calc(10px * var(--site-space, 1));
  cursor: pointer; outline: none;
  transition: border-color var(--dur);
}
.sortwrap select:hover, .sortwrap select:focus { border-color: var(--site-accent); }

/* ============ Main ============ */
.main { max-width: 1160px; margin: 0 auto; padding: var(--sp) var(--sp) calc(var(--sp) * 2); }

.hint {
  display: flex; align-items: flex-start; gap: var(--sp-sm);
  background: color-mix(in srgb, var(--info) 7%, var(--site-surface));
  border: 1px solid color-mix(in srgb, var(--info) 30%, var(--site-border));
  border-radius: var(--site-radius);
  padding: var(--sp-sm) var(--sp-sm) var(--sp-sm) var(--sp);
  margin-bottom: var(--sp);
  color: var(--site-fg);
  font-size: calc(14px * var(--site-type, 1));
  box-shadow: var(--shadow-1);
  animation: rise calc(var(--dur) * 2) ease both;
}
.hint svg { flex: none; margin-top: 3px; color: var(--info); }
.hint p { margin: 0; flex: 1; }
.hint strong { color: var(--info); }

.statsrow {
  display: flex; align-items: center; gap: var(--sp-sm);
  color: var(--site-muted);
  font-size: calc(13.5px * var(--site-type, 1));
  margin-bottom: var(--sp-sm);
  flex-wrap: wrap;
}
.stat strong { color: var(--site-fg); font-variant-numeric: tabular-nums; }
.stat-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--site-border); flex: none; }
.stat-hint { margin-left: auto; opacity: .85; }

/* ============ Card grid ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: var(--sp-sm);
}

.card {
  position: relative;
  display: flex; flex-direction: column; gap: calc(10px * var(--site-space, 1));
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  padding: calc(16px * var(--site-space, 1));
  cursor: pointer;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) ease, border-color var(--dur) ease, box-shadow var(--dur) ease, background var(--dur) ease;
  animation: rise calc(var(--dur) * 2.2) ease both;
  animation-delay: calc(var(--i, 0) * 40ms * var(--site-motion, 1));
  overflow: hidden;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--card-color), color-mix(in srgb, var(--card-color) 20%, transparent) 85%);
}
.card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--card-color) 45%, var(--site-border));
  box-shadow: var(--shadow-2), 0 0 24px color-mix(in srgb, var(--card-color) 14%, transparent);
}
.card:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 2px; }
.card.dragging { opacity: .45; transform: scale(.97); }
.card.drag-over { border-color: var(--site-accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card[draggable="true"] { cursor: grab; }
.card[draggable="true"]:active { cursor: grabbing; }

.card-top { display: flex; align-items: center; gap: var(--sp-sm); }
.tile {
  position: relative;
  width: 44px; height: 44px; flex: none;
  border-radius: calc(var(--site-radius) * .72);
  background: color-mix(in srgb, var(--card-color) 12%, var(--site-surface));
  border: 1px solid color-mix(in srgb, var(--card-color) 32%, transparent);
  display: flex; align-items: center; justify-content: center;
  color: color-mix(in srgb, var(--card-color) 75%, var(--site-fg));
  font-weight: 700; font-size: calc(18px * var(--site-type, 1));
  overflow: hidden;
}
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 9px; background: color-mix(in srgb, var(--card-color) 8%, var(--site-surface)); }
.card-heading { min-width: 0; flex: 1; }
.card-title {
  margin: 0; font-size: calc(15.5px * var(--site-type, 1)); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-domain { font-size: calc(12.5px * var(--site-type, 1)); color: var(--site-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pin-flag {
  flex: none; color: var(--warning);
  display: inline-flex;
  filter: drop-shadow(0 1px 4px color-mix(in srgb, var(--warning) 40%, transparent));
}

.card-note {
  margin: 0;
  font-size: calc(13px * var(--site-type, 1));
  color: var(--site-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-height: 1.4em;
}

.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: calc(12px * var(--site-type, 1)); font-weight: 600;
  color: color-mix(in srgb, var(--card-color) 72%, var(--site-fg));
  background: color-mix(in srgb, var(--card-color) 10%, var(--site-surface));
  border: 1px solid color-mix(in srgb, var(--card-color) 28%, transparent);
  padding: 3px 10px; border-radius: 999px;
  max-width: 60%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.opens { font-size: calc(12px * var(--site-type, 1)); color: var(--site-muted); font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; transition: opacity var(--dur); }

.card-tools {
  position: absolute; right: 12px; bottom: 13px;
  display: flex; gap: 4px;
  background: color-mix(in srgb, var(--site-surface) 94%, transparent);
  border: 1px solid var(--site-border);
  padding: 3px; border-radius: calc(var(--site-radius) * .6);
  box-shadow: var(--shadow-1);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur);
}
.card:hover .card-tools, .card:focus-within .card-tools { opacity: 1; pointer-events: auto; }
.card:hover .opens, .card:focus-within .opens { opacity: 0; }
@media (hover: none) { .card-tools { opacity: 1; pointer-events: auto; } .opens { display: none; } }
.proj-flag { flex: none; display: inline-flex; opacity: .9; }
.tool-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--surface-3); color: var(--site-muted);
  border: 1px solid var(--site-border); border-radius: calc(var(--site-radius) * .45);
  cursor: pointer;
  transition: color var(--dur), border-color var(--dur), transform var(--dur);
}
.tool-btn:hover { color: var(--site-accent); border-color: var(--site-accent); transform: translateY(-1px); }
.tool-btn.pin-on { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.tool-btn.del:hover { color: var(--danger); border-color: var(--danger); }

/* Selection mode */
.check {
  flex: none; width: 22px; height: 22px;
  border-radius: 7px;
  border: 1.6px solid var(--site-border);
  background: var(--site-surface);
  display: inline-flex; align-items: center; justify-content: center;
  color: transparent;
  transition: background var(--dur), border-color var(--dur), color var(--dur), transform var(--dur);
}
.card.selected { border-color: var(--site-accent); background: color-mix(in srgb, var(--site-accent) 5%, var(--site-surface)); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-1); }
.card.selected .check { background: var(--site-accent); border-color: var(--site-accent); color: var(--site-on-accent); transform: scale(1.05); }
body.selecting .card-tools { display: none; }
body.selecting .card { cursor: pointer; }

/* Bulk action bar */
.bulkbar {
  position: fixed; left: 50%; bottom: var(--sp); transform: translateX(-50%);
  z-index: 70;
  display: flex; align-items: center; gap: var(--sp-xs);
  background: var(--site-fg); color: var(--site-bg);
  border-radius: calc(var(--site-radius) * 1.1);
  padding: calc(8px * var(--site-space, 1)) calc(12px * var(--site-space, 1));
  box-shadow: var(--shadow-2);
  animation: bulkin calc(var(--dur) * 1.4) ease both;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
@keyframes bulkin { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.bulk-count { font-size: calc(13.5px * var(--site-type, 1)); padding: 0 6px; white-space: nowrap; }
.bulk-count strong { font-variant-numeric: tabular-nums; }
.bulk-sep { width: 1px; height: 20px; background: color-mix(in srgb, var(--site-bg) 30%, transparent); }
.bulk-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--site-bg) 14%, transparent);
  color: var(--site-bg);
  border: none; cursor: pointer;
  font: 600 calc(13px * var(--site-type, 1)) var(--site-font);
  padding: calc(7px * var(--site-space, 1)) calc(12px * var(--site-space, 1));
  border-radius: calc(var(--site-radius) * .6);
  transition: background var(--dur), transform var(--dur);
  white-space: nowrap;
}
.bulk-btn:hover { background: color-mix(in srgb, var(--site-bg) 26%, transparent); transform: translateY(-1px); }
.bulk-btn.danger { color: color-mix(in srgb, var(--c-red) 60%, var(--site-bg)); }
[data-theme="dark"] .bulk-btn.danger { color: var(--c-red); }
.bulk-btn.danger:hover { background: color-mix(in srgb, var(--c-red) 30%, transparent); }
.bulk-btn.done { background: var(--site-accent); color: var(--site-on-accent); }
.bulk-btn.done:hover { background: color-mix(in srgb, var(--site-accent) 85%, white); }
body.has-bulk .toasts { bottom: calc(var(--sp) + 68px); }

/* ============ Empty state ============ */
.empty {
  text-align: center;
  padding: calc(var(--sp) * 2.5) var(--sp);
  color: var(--site-muted);
  animation: rise calc(var(--dur) * 2) ease both;
}
.empty h2 { color: var(--site-fg); font-size: calc(22px * var(--site-type, 1)); margin: var(--sp-sm) 0 var(--sp-xs); }
.empty p { margin: 0 0 var(--sp); }

/* ============ Footer ============ */
.footer {
  max-width: 1160px; margin: 0 auto;
  padding: var(--sp-sm) var(--sp) var(--sp);
  display: flex; align-items: center; gap: var(--sp-sm); flex-wrap: wrap;
  color: var(--site-muted); font-size: calc(12.5px * var(--site-type, 1));
  border-top: 1px solid var(--site-border);
}
kbd {
  background: var(--site-surface); border: 1px solid var(--site-border);
  border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px;
  font: 600 calc(11.5px * var(--site-type, 1)) var(--site-font);
  color: var(--site-fg);
}

/* ============ Dialog ============ */
.dialog {
  background: var(--site-surface);
  color: var(--site-fg);
  border: 1px solid var(--site-border);
  border-radius: calc(var(--site-radius) * 1.2);
  padding: var(--sp);
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow-2);
}
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(6px); }
.dialog[open] { animation: pop calc(var(--dur) * 1.2) ease both; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-sm); }
.dialog-head h2 { margin: 0; font-size: calc(20px * var(--site-type, 1)); }

.field { display: flex; flex-direction: column; gap: var(--sp-xs); margin-bottom: var(--sp-sm); font-size: calc(13.5px * var(--site-type, 1)); color: var(--site-muted); }
.field > span em { color: var(--danger); font-style: normal; }
.field > span small { opacity: .8; }
.field input[type="text"] {
  background: var(--surface-3);
  border: 1px solid var(--site-border);
  border-radius: calc(var(--site-radius) * .6);
  color: var(--site-fg);
  font: 400 calc(14.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(10px * var(--site-space, 1)) calc(12px * var(--site-space, 1));
  outline: none; width: 100%;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.field input[type="text"]:focus { border-color: var(--site-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input.invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: calc(12.5px * var(--site-type, 1)); }
.field-row { display: flex; gap: var(--sp-sm); align-items: flex-end; }
.field-row .field { flex: 1; }
.pin-field { flex: 0 0 auto; align-items: flex-start; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; margin-top: 6px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0; pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--site-border);
  border-radius: 999px;
  transition: background var(--dur), border-color var(--dur);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--site-muted);
  transition: transform var(--dur), background var(--dur);
}
.switch input:checked + .switch-track { background: var(--accent-soft); border-color: var(--site-accent); }
.switch input:checked + .switch-track::after { transform: translateX(20px); background: var(--site-accent); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-soft); }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  background: var(--sw);
  transition: transform var(--dur), border-color var(--dur), box-shadow var(--dur);
}
.swatch:hover { transform: scale(1.12); }
.swatch[aria-checked="true"] { border-color: var(--site-fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sw) 40%, transparent); transform: scale(1.1); }

.dialog-actions { display: flex; justify-content: flex-end; gap: var(--sp-xs); margin-top: var(--sp); }

/* ============ Toasts ============ */
.toasts {
  position: fixed; bottom: var(--sp); left: 50%; transform: translateX(-50%);
  z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(440px, calc(100vw - 32px));
  transition: bottom var(--dur) ease;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-sm);
  width: 100%;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-left: 3px solid var(--toast-color, var(--site-accent));
  border-radius: calc(var(--site-radius) * .8);
  padding: calc(12px * var(--site-space, 1)) calc(16px * var(--site-space, 1));
  font-size: calc(14px * var(--site-type, 1));
  box-shadow: var(--shadow-2);
  animation: toast-in calc(var(--dur) * 1.4) ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.toast.leaving { animation: toast-out calc(var(--dur) * 1.2) ease both; }
@keyframes toast-out { to { opacity: 0; transform: translateY(12px); } }
.toast span { flex: 1; min-width: 0; }
.toast .undo {
  flex: none; background: none; border: none; cursor: pointer;
  color: var(--site-accent); font: 700 calc(14px * var(--site-type, 1)) var(--site-font);
  padding: 4px 8px; border-radius: 6px;
}
.toast .undo:hover { background: var(--accent-soft); }

/* ============ App shell ============ */
.shell { flex: 1; min-height: 0; display: flex; position: relative; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.listview { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.listscroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* ============ Sidebar ============ */
.sidebar {
  width: 268px; flex: none;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--site-border);
  background: color-mix(in srgb, var(--site-surface) 58%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
body.side-collapsed .sidebar { display: none; }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-sm); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-row {
  position: relative;
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--site-muted);
  font: 500 calc(14px * var(--site-type, 1)) var(--site-font);
  padding: calc(9px * var(--site-space, 1)) calc(11px * var(--site-space, 1));
  border-radius: calc(var(--site-radius) * .6);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.side-row:hover { background: var(--surface-3); color: var(--site-fg); }
.side-row:focus-visible { outline: 2px solid var(--site-accent); outline-offset: -2px; }
.side-row.active { background: color-mix(in srgb, var(--row-color, var(--site-accent)) 12%, transparent); color: var(--site-fg); font-weight: 600; }
.side-row.active::before {
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 3px; border-radius: 3px; background: var(--row-color, var(--site-accent));
}
.side-ico { flex: none; display: inline-flex; color: var(--row-color, currentColor); }
.side-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-count {
  flex: none; font-size: calc(11.5px * var(--site-type, 1)); font-variant-numeric: tabular-nums;
  color: var(--site-muted); background: var(--surface-3);
  border: 1px solid var(--site-border);
  padding: 1px 7px; border-radius: 999px;
}
.side-row.active .side-count { color: var(--site-fg); border-color: color-mix(in srgb, var(--row-color, var(--site-accent)) 35%, transparent); }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: var(--sp-sm) 0 var(--sp-xs);
  padding: 0 calc(11px * var(--site-space, 1));
  font-size: calc(11.5px * var(--site-type, 1)); font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em; color: var(--site-muted);
}
.side-projects { display: flex; flex-direction: column; gap: 2px; }
.proj-row {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: calc(9px * var(--site-space, 1)) calc(11px * var(--site-space, 1));
  border-radius: calc(var(--site-radius) * .6);
  cursor: pointer;
  color: var(--site-muted);
  font: 500 calc(14px * var(--site-type, 1)) var(--site-font);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.proj-row:hover { background: var(--surface-3); color: var(--site-fg); }
.proj-row:focus-visible { outline: 2px solid var(--site-accent); outline-offset: -2px; }
.proj-row.active { background: color-mix(in srgb, var(--row-color, var(--site-accent)) 12%, transparent); color: var(--site-fg); font-weight: 600; }
.proj-row.active::before {
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 3px; border-radius: 3px; background: var(--row-color, var(--site-accent));
}
.proj-ico { flex: none; display: inline-flex; }
.proj-tools {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 2px; opacity: 0; pointer-events: none; transition: opacity var(--dur);
}
.proj-row:hover .proj-tools, .proj-row:focus-within .proj-tools { opacity: 1; pointer-events: auto; }
.proj-row:hover .side-count, .proj-row:focus-within .side-count { visibility: hidden; }
@media (hover: none) {
  .proj-tools { opacity: 1; pointer-events: auto; }
  .proj-row .side-count { display: none; }
}
.mini-btn {
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--site-surface); border: 1px solid var(--site-border);
  border-radius: 7px; color: var(--site-muted); cursor: pointer;
  transition: color var(--dur), border-color var(--dur);
}
.mini-btn:hover { color: var(--site-accent); border-color: var(--site-accent); }
.mini-btn.del:hover { color: var(--danger); border-color: var(--danger); }
.proj-row.drop-target, .side-row.drop-target {
  background: color-mix(in srgb, var(--row-color, var(--site-accent)) 16%, transparent);
  box-shadow: inset 0 0 0 2px var(--row-color, var(--site-accent));
  color: var(--site-fg);
}
.side-empty { padding: var(--sp-xs) calc(11px * var(--site-space, 1)); color: var(--site-muted); font-size: calc(13px * var(--site-type, 1)); }
.side-empty p { margin: 0 0 var(--sp-xs); }
.side-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px * var(--site-space, 1)) var(--sp-sm);
  border-top: 1px solid var(--site-border);
  color: var(--site-muted); font-size: calc(12px * var(--site-type, 1));
}
.side-local { display: inline-flex; align-items: center; gap: 5px; }
.sidebar-scrim {
  position: fixed; inset: 0; z-index: 45;
  background: var(--scrim); backdrop-filter: blur(2px);
  animation: fadein var(--dur) ease both;
}

/* ============ Embedded viewer ============ */
.viewer { flex: 1; min-height: 0; display: flex; flex-direction: column; animation: fadein calc(var(--dur) * 1.5) ease both; }
.viewer-bar {
  flex: none; display: flex; align-items: center; gap: var(--sp-sm);
  padding: calc(10px * var(--site-space, 1)) var(--sp);
  border-bottom: 1px solid var(--site-border);
  background: color-mix(in srgb, var(--site-surface) 72%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.viewer-id { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.viewer-fav { width: 36px; height: 36px; font-size: calc(15px * var(--site-type, 1)); border-radius: calc(var(--site-radius) * .6); }
.viewer-fav img { padding: 7px; }
.viewer-meta { min-width: 0; display: flex; flex-direction: column; }
.viewer-meta strong { font-size: calc(14.5px * var(--site-type, 1)); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-meta span { font-size: calc(12px * var(--site-type, 1)); color: var(--site-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-actions { flex: none; display: flex; align-items: center; gap: 6px; }
.viewer-actions .icon-btn { width: 36px; height: 36px; }
.viewer-actions .icon-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.viewer-stage { flex: 1; min-height: 0; position: relative; background: var(--surface-2); }
#viewerFrame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-sm); text-align: center; padding: var(--sp);
  background: var(--site-bg);
}
.viewer-overlay h2 { margin: 0; font-size: calc(20px * var(--site-type, 1)); }
.viewer-overlay p { margin: 0; color: var(--site-muted); max-width: 46ch; font-size: calc(14px * var(--site-type, 1)); }
.overlay-actions { display: flex; align-items: center; gap: var(--sp-xs); flex-wrap: wrap; justify-content: center; }
.overlay-sub { font-size: calc(13px * var(--site-type, 1)); }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--site-accent);
  animation: spin calc(900ms * var(--site-motion, 1)) linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.viewer-note {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-sm);
  padding: calc(7px * var(--site-space, 1)) var(--sp);
  border-top: 1px solid var(--site-border);
  background: color-mix(in srgb, var(--site-surface) 72%, transparent);
  color: var(--site-muted); font-size: calc(12.5px * var(--site-type, 1));
}
.viewer-note a { display: inline-flex; align-items: center; gap: 5px; color: var(--site-accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.viewer-note a:hover { text-decoration: underline; }

/* ============ Open-mode segmented control ============ */
.segmented {
  flex: none; display: flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border: 1px solid var(--site-border);
  border-radius: calc(var(--site-radius) * .7);
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--site-muted); font: 600 calc(12.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(6px * var(--site-space, 1)) calc(10px * var(--site-space, 1));
  border-radius: calc(var(--site-radius) * .5);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
  white-space: nowrap;
}
.segmented button:hover { color: var(--site-fg); }
.segmented button[aria-pressed="true"] { background: var(--site-surface); color: var(--site-accent); box-shadow: 0 1px 3px rgba(33,29,56,.12); }
.segmented button:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 1px; }

/* Bulk move menu opens upward from the bottom bar */
.bulkbar .menu { top: auto; bottom: calc(100% + 10px); right: 0; }
.move-menu { min-width: 216px; max-height: 264px; overflow-y: auto; }
.move-ico { display: inline-flex; flex: none; }

/* Project select in the link dialog */
.field select {
  background: var(--surface-3);
  border: 1px solid var(--site-border);
  border-radius: calc(var(--site-radius) * .6);
  color: var(--site-fg);
  font: 400 calc(14.5px * var(--site-type, 1)) var(--site-font);
  padding: calc(10px * var(--site-space, 1)) calc(12px * var(--site-space, 1));
  outline: none; width: 100%; cursor: pointer;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.field select:focus { border-color: var(--site-accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .segmented button span { display: none; }
  .segmented button { padding: calc(6px * var(--site-space, 1)) calc(8px * var(--site-space, 1)); }
}
@media (max-width: 960px) {
  .clockbox .dateline { display: none; }
  .toolbar { flex-wrap: wrap; }
  .search { flex: 1 1 100%; order: -1; }
  .chips { order: 2; flex-basis: 100%; }
  .sortwrap { order: 0; margin-left: auto; }
  .stat-hint { display: none; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: min(300px, 85vw);
    transform: translateX(-105%);
    transition: transform calc(var(--dur) * 1.4) ease;
    background: var(--site-bg);
    box-shadow: var(--shadow-2);
  }
  body.side-collapsed .sidebar { display: flex; }
  body.side-open .sidebar { transform: none; }
}
@media (max-width: 560px) {
  .clockbox { display: none; }
  .grid { grid-template-columns: 1fr; }
  .brand-name { font-size: calc(18px * var(--site-type, 1)); }
  .btn-primary { padding: calc(9px * var(--site-space, 1)) calc(14px * var(--site-space, 1)); }
  #addBtn { padding: calc(9px * var(--site-space, 1)) calc(11px * var(--site-space, 1)); }
  #addBtn span { display: none; }
  .topbar .icon-btn { width: 36px; height: 36px; }
  .field-row { flex-direction: column; align-items: stretch; }
  .pin-field { flex-direction: row; align-items: center; justify-content: space-between; }
  .switch { margin-top: 0; }
  .sort-label { display: none; }
  .topbar-inner { padding: var(--sp-sm) var(--sp-sm); gap: var(--sp-xs); }
  .toolbar { padding: var(--sp-sm) var(--sp-sm); }
  .main { padding: var(--sp-sm) var(--sp-sm) calc(var(--sp) * 2); }
  .viewer-bar { gap: 8px; padding: calc(8px * var(--site-space, 1)) var(--sp-sm); }
  #viewerBack span { display: none; }
  #viewerCopy { display: none; }
  #viewerTab span { display: none; }
  .viewer-actions { gap: 4px; }
  .viewer-actions .icon-btn { width: 34px; height: 34px; }
  .viewer-note { justify-content: flex-end; padding: calc(7px * var(--site-space, 1)) var(--sp-sm); }
  .viewer-note span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}