:root {
  --bg: #0f0f11;
  --bg-soft: #17171b;
  --bg-card: #1c1c21;
  --bg-hover: #23232a;
  --border: #2a2a33;
  --border-strong: #3a3a46;
  --fg: #ebe8e1;
  --fg-muted: #9a968d;
  --fg-dim: #6a6760;
  --accent: #f5a524;
  --accent-soft: rgba(245, 165, 36, 0.12);
  --accent-line: rgba(245, 165, 36, 0.4);
  --danger: #e5484d;
  --success: #46a758;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Belt-and-braces: any single overflowing child (long unbroken
     mono URL, unexpected fixed-px row, etc.) shouldn't force the
     whole page to scroll horizontally on mobile. Individual scroll
     regions (tables, pre, .folder-strip-scroll) still work — they
     opt in with their own overflow-x: auto. */
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-decoration: none;
}
.topbar .brand .dot { color: var(--accent); }
.topbar .brand-icon { display: block; flex: 0 0 auto; }
.topbar .nav {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}
.topbar .nav a {
  color: var(--fg-muted);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
}
.topbar .nav a:hover { background: var(--bg-hover); color: var(--fg); text-decoration: none; }
.topbar .nav a.active { color: var(--accent); background: var(--accent-soft); }
.topbar .spacer { flex: 1; }
.topbar .user {
  font-size: 12px;
  color: var(--fg-muted);
  font-family: var(--mono);
}
.topbar .user .role {
  color: var(--accent);
  margin-left: 6px;
}

/* Hamburger button — hidden on desktop, shown below breakpoint.
   Nav-user-inline block (inside .nav) is the opposite — hidden on
   desktop (where dedicated .nav-user-desktop shows), revealed inside
   the drawer on mobile. */
.topbar .nav-hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.topbar .nav-hamburger:hover { background: var(--bg-hover); }
.topbar .nav-user-inline { display: none; }
/* Nav entries that duplicate a desktop icon (Notifications -> bell,
   New to you -> inbox). Hidden on desktop where the icon shows; revealed
   as text inside the mobile drawer where the icons are hidden. */
.topbar .nav a.nav-drawer-only { display: none; }

/* Narrow viewport: swap the inline nav for a hamburger drawer.
   Breakpoint chosen at ~1100px because with 10-12 nav items the row
   starts clipping the user badge + logout button well before it
   reaches a phone width. */
@media (max-width: 1100px) {
  .topbar { gap: 10px; padding: 10px 14px; position: relative; }
  .topbar .spacer { flex: 1; }
  .topbar .nav-user-desktop { display: none; }
  .topbar .nav-hamburger { display: inline-flex; align-items: center; justify-content: center; }

  .topbar .nav {
    display: none;   /* hidden until hamburger opens */
    position: absolute;
    top: 100%;
    right: 8px;
    min-width: 220px;
    max-width: calc(100vw - 16px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35);
    padding: 6px;
    margin: 6px 0 0;
    flex-direction: column;
    gap: 2px;
    z-index: 20;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  .topbar[data-nav-open="1"] .nav { display: flex; }
  .topbar .nav a {
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 4px;
  }
  .topbar .nav a.nav-drawer-only { display: inline-flex; align-items: center; gap: 6px; }
  .topbar .nav-user-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px 6px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
  }
  .topbar .nav-user-inline .user { font-size: 12px; }
  .topbar .brand { font-size: 13px; }
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
  /* Wrap so the action button (e.g. "+ New prompt") drops to a second
     row on narrow screens instead of getting pushed off the right edge
     by a long H1 + subtitle. */
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.page-header .subtitle {
  color: var(--fg-muted);
  font-size: 13px;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.search-bar input[type="search"] {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 14px;
}
.search-bar input[type="search"]:focus {
  outline: none;
  border-color: var(--accent-line);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  grid-auto-rows: 1fr;
  gap: 14px;
  align-items: stretch;
}
/* card-wrap is the positioning context for the kebab; make it stretch to
   the row height so the inner card fills it. */
.card-wrap { display: flex; }
.card-wrap > .card { flex: 1; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.12s ease, transform 0.12s ease;
  text-decoration: none;
  color: var(--fg);
}
.card:hover {
  border-color: var(--accent-line);
  text-decoration: none;
  transform: translateY(-1px);
}
.card .thumb {
  position: relative;
  height: 100px;
  border-radius: 6px;
  background: linear-gradient(135deg, #26262e 0%, #1c1c22 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  color: var(--accent);
  font-size: 28px;
  font-weight: 600;
  overflow: hidden;
}
.card .thumb-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  display: block;
}
.card .thumb-letter { display: none; }
.card .thumb.thumb-fallback .thumb-letter { display: inline; }
.card .thumb.thumb-fallback { /* image removed by onerror */ }
.card .title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.005em;
}
.card .meta {
  color: var(--fg-muted);
  font-size: 12px;
  font-family: var(--mono);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
/* Producer (owner) name — tinted bright blue so you can spot who made
   a drop at a glance, on both the card meta line and the list column. */
.owner-name { color: #5ca8ff; font-weight: 600; }
.card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  /* Pin tags to the bottom so cards with shorter titles still align. */
  margin-top: auto;
}
/* Two-row card footer: variable free-form tags on top, fixed system
   badges (share status / kind / from-idea / visibility / revs) on the
   bottom row. The whole block is pinned to the card bottom, so the
   fixed badge row is always in the same place regardless of how many
   free tags a card has. */
.card .card-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card .card-tags,
.card .card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}
.tag.visibility-private { color: var(--fg-dim); }
.tag.visibility-shared { color: #a78bfa; border-color: rgba(167, 139, 250, 0.3); }
.tag.visibility-public { color: var(--success); border-color: rgba(70, 167, 88, 0.3); }

/* Ownership / sharing badge on a card. "Shared with you" (someone
   else's drop you can access) is accent-tinted so it stands out in a
   mixed "All visible" list; "Shared" (yours, shared out) is quieter. */
.tag.share-badge { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.tag.share-badge svg { width: 11px; height: 11px; }
.tag.share-in {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.tag.share-out {
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.3);
  background: rgba(167, 139, 250, 0.08);
}
/* Not shared with you — you can see it as admin, but it wasn't shared
   to you. Muted so it reads as an oversight/context marker, not a grant. */
.tag.share-none {
  color: var(--fg-dim);
  border-color: var(--border);
  background: transparent;
}

/* Package kind — MD (drop) vs HTML (explainer). Distinct from visibility
   colours so the two stack readably. */
.tag.kind-md {
  color: #7cc4ff;
  border-color: rgba(124, 196, 255, 0.4);
  background: rgba(124, 196, 255, 0.08);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.tag.kind-html {
  color: #c4f47c;
  border-color: rgba(196, 244, 124, 0.4);
  background: rgba(196, 244, 124, 0.08);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.tag.source-idea {
  color: #d8a0ff;
  border-color: rgba(216, 160, 255, 0.4);
  background: rgba(216, 160, 255, 0.08);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--fg-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}
.empty h2 {
  color: var(--fg);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent-line); background: var(--bg-hover); text-decoration: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1306;
  font-weight: 600;
}
.btn-primary:hover { background: #ffb84a; border-color: #ffb84a; color: #1a1306; }
.btn-danger {
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.3);
}
.btn-ghost { background: transparent; }

/* Compact icon button used by inline row/card actions (delete, etc.).
   Appears on hover for the grid card, always-on for the list row so
   it's reachable on touch. */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 80ms ease, border-color 80ms ease, background 80ms ease;
}
.btn-icon:hover { color: var(--fg); border-color: var(--border-strong); }
.btn-icon-danger:hover {
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.4);
  background: rgba(229, 72, 77, 0.08);
}

/* Grid card: position the delete form on top of the card. The form is a
   sibling of <a class="card"> (forms can't legally be nested inside <a>)
   so we use card-wrap as the positioning context. */
.card-wrap { position: relative; }
.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  z-index: 2;
  opacity: 0;
  transition: opacity 100ms ease;
}
.card-wrap:hover .card-actions,
.card-actions:focus-within { opacity: 1; }
/* On touch devices there's no hover — keep it visible. */
@media (hover: none) {
  .card-actions { opacity: 0.7; }
}

/* List row actions: keep the cell narrow so it doesn't push everything
   else around. The td gets onclick=stopPropagation so clicking the
   button doesn't trigger the row navigation. */
.list-table .actions-col { width: 44px; padding: 6px 10px; text-align: right; }
.row-actions { margin: 0; display: inline-block; }

.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(245, 165, 36, 0.08), transparent);
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 420px;
}
.auth-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.auth-card .brand-mark {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.auth-card p {
  color: var(--fg-muted);
  margin: 0 0 20px;
}
.auth-card input[type="text"],
.auth-card input[type="password"],
.auth-card input[type="email"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 14px;
  margin-bottom: 12px;
  box-sizing: border-box;
}
.auth-card input[type="text"]:focus,
.auth-card input[type="password"]:focus,
.auth-card input[type="email"]:focus {
  outline: none; border-color: var(--accent-line);
}
.auth-card .full { width: 100%; justify-content: center; }
.auth-card .error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

.viewer-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 54px);
  transition: grid-template-columns 180ms ease;
}
.viewer-layout.sidebar-collapsed {
  grid-template-columns: 32px 1fr;
}
.viewer-sidebar {
  position: relative;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 18px 16px;
  overflow-y: auto;
  max-height: calc(100vh - 54px);
}
.viewer-layout.sidebar-collapsed .viewer-sidebar {
  padding: 18px 0;
  overflow: hidden;
}
.viewer-layout.sidebar-collapsed .viewer-sidebar > *:not(.sidebar-toggle) {
  display: none;
}
.sidebar-toggle {
  position: absolute;
  top: 14px;
  right: 8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg-muted);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.sidebar-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}
.viewer-layout.sidebar-collapsed .sidebar-toggle {
  right: 50%;
  transform: translateX(50%);
}
.viewer-sidebar h2 {
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 16px 0 6px;
  font-weight: 500;
}
.viewer-sidebar h2:first-child { margin-top: 0; }
.viewer-sidebar .pkg-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
}
.viewer-sidebar .pkg-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
  margin-bottom: 14px;
}
.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.file-list li a {
  display: block;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}
.file-list li a:hover { background: var(--bg-hover); color: var(--fg); text-decoration: none; }
.file-list li a.active { color: var(--accent); background: var(--accent-soft); }

.viewer-main {
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.viewer-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-muted);
}
.viewer-frame {
  flex: 1;
  border: 0;
  background: var(--bg);
  color-scheme: dark;
  width: 100%;
}
/* Compact icon-only button — sits in the viewer toolbar next to the
   "Open standalone" link without the heavy border of a regular .btn. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 0;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.icon-btn:disabled { cursor: default; }
.icon-btn.flash-ok { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.icon-btn.flash-bad { color: var(--danger); border-color: var(--danger); }
.icon-btn.liked { color: #ef4444; border-color: #ef4444; }
.icon-btn.liked svg { fill: currentColor; }
.icon-btn.liked:hover { color: #b91c1c; border-color: #b91c1c; background: rgba(239, 68, 68, 0.08); }
.icon-btn.starred { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.icon-btn.starred svg { fill: currentColor; }
.icon-btn.starred:hover { color: var(--accent); border-color: var(--accent); }
/* Notification bell badge — red pill absolutely positioned on the
   top-right corner of the bell icon-btn. In the mobile drawer we
   override position:static inline so it sits inline with the label. */
.nav-bell-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  border: 1px solid var(--bg);
  box-sizing: border-box;
}
.nav-capture .lucide,
.nav-capture svg { color: var(--accent); }
.nav-capture:hover { color: var(--accent); }

/* ---- Quick-capture sheet ------------------------------------------- */
.qc-overlay[hidden] { display: none; }
.qc-overlay {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 16px;
}
.qc-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.qc-sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
.qc-header { display: flex; align-items: center; justify-content: space-between; }
.qc-title { font-size: 14px; font-weight: 600; }
.qc-x {
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.qc-x:hover { color: var(--fg); }
.qc-text, .qc-tags {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  padding: 10px;
  font-family: var(--sans);
  font-size: 14px;
  box-sizing: border-box;
}
.qc-text { resize: vertical; min-height: 96px; line-height: 1.5; }
.qc-text:focus, .qc-tags:focus { outline: none; border-color: var(--accent-line); }
.qc-convert {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 0;
}
.qc-convert input { cursor: pointer; }
.qc-dim { color: var(--fg-muted); font-size: 12px; }
.qc-status { font-size: 12px; min-height: 16px; color: var(--fg-muted); }
.qc-status-error { color: var(--danger); }
.qc-actions { display: flex; justify-content: flex-end; gap: 8px; }
.qc-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--accent-line);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  max-width: 80vw;
}
.qc-toast a { color: var(--accent); font-weight: 600; margin-left: 4px; }
/* Mobile: dock the sheet to the bottom as a slide-up sheet. */
@media (max-width: 620px) {
  .qc-overlay { align-items: flex-end; padding: 0; }
  .qc-sheet {
    max-width: 100%;
    border-radius: 14px 14px 0 0;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .qc-toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ---- Admin quick-edit modal ---------------------------------------- */
.qe-overlay[hidden] { display: none; }
.qe-overlay {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 70px 16px 16px;
}
.qe-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.qe-panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}
.qe-header { display: flex; align-items: center; justify-content: space-between; }
.qe-title { font-size: 14px; font-weight: 600; }
.qe-x { background: transparent; border: 0; color: var(--fg-muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.qe-x:hover { color: var(--fg); }
.qe-row { display: flex; flex-direction: column; gap: 6px; }
.qe-row .field-label { margin: 0; }
.qe-actions { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 4px; }
@media (max-width: 620px) {
  .qe-overlay { align-items: flex-end; padding: 0; }
  .qe-panel { max-width: 100%; border-radius: 14px 14px 0 0; max-height: 85vh; }
}

/* Conversation panel — comment-body markdown renders inline tags only;
   give paragraphs sane spacing and lists their own breathing room. */
#comments-panel .comment-body p { margin: 0 0 6px; }
#comments-panel .comment-body p:last-child { margin-bottom: 0; }
#comments-panel .comment-body code { background: var(--bg); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
#comments-panel .comment-body pre { background: var(--bg); padding: 8px 10px; border-radius: 6px; font-size: 12px; overflow-x: auto; margin: 6px 0; }
#comments-panel .comment-body ul, #comments-panel .comment-body ol { margin: 4px 0; padding-left: 20px; }
#comments-panel .comment-body a { color: var(--accent); }
.md-panel {
  padding: 24px;
  max-width: 780px;
  margin: 0 auto;
  overflow-y: auto;
}
.md-panel pre {
  background: var(--bg-card);
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
}
.md-panel code {
  background: var(--bg-soft);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 0.92em;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.table th {
  background: var(--bg-soft);
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.table tr:last-child td { border-bottom: 0; }
.table .mono { font-family: var(--mono); font-size: 12px; color: var(--fg-muted); }

/* One-cell inline edit form inside admin tables. Kept on a single line
   (nowrap) so the apply button never drops to a new row, tightened
   padding to fit table cells, and the button is accent-tinted at rest
   so the "press to save" affordance is obvious. */
.table form.inline.cell-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  margin: 0;
}
.table form.inline.cell-edit input,
.table form.inline.cell-edit select {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  height: 26px;
  box-sizing: border-box;
}
.table form.inline.cell-edit select {
  padding-right: 22px;
  background-size: 8px 6px;
  background-position: right 8px center;
  min-width: 92px;
}
.table form.inline.cell-edit input[type="number"] {
  width: 78px;
}
.icon-btn.apply-btn {
  width: 26px;
  height: 26px;
  padding: 3px;
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  flex: 0 0 auto;
}
.icon-btn.apply-btn:hover {
  color: #1a1306;
  border-color: var(--accent);
  background: var(--accent);
}
/* Dirty state: JS tags .cell-edit forms with .dirty as soon as the
   value drifts from the DOM default. The apply button flips to solid
   accent + a soft ring pulse so it's obvious the change needs
   pressing to commit. */
.cell-edit.dirty .icon-btn.apply-btn {
  color: #1a1306;
  background: var(--accent);
  border-color: var(--accent);
  animation: apply-pulse 1.4s ease-in-out infinite;
}
@keyframes apply-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 165, 36, 0.55); }
  50%      { box-shadow: 0 0 0 5px rgba(245, 165, 36, 0); }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
}
.panel h2 {
  font-size: 15px;
  margin: 0 0 14px;
  font-weight: 600;
}
.panel p.dim {
  color: var(--fg-muted);
  font-size: 13px;
  margin: 0 0 14px;
}

form.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
form.inline input, form.inline select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px;
}
form.inline input:focus, form.inline select:focus {
  outline: none; border-color: var(--accent-line);
}

/* Themed select — strip native chrome, apply our own chevron, match input look. */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%239a968d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 7px;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 30px 8px 10px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  line-height: 1.2;
}
select:hover { border-color: var(--border-strong); }
select:focus {
  outline: none;
  border-color: var(--accent-line);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23f5a524' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
/* Inside option list — best-effort across browsers (Firefox respects, Chrome/Safari mostly don't). */
select option {
  background: var(--bg-card);
  color: var(--fg);
}

label.field-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-right: 4px;
  display: block;
}

/* Stack: vertical form column with consistent spacing. */
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack > .field-label { margin: 6px 0 -2px; }

/* Field: themed input/select that fills its container. */
.field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px;
  box-sizing: border-box;
}
.field:focus { outline: none; border-color: var(--accent-line); }
select.field {
  /* keep the chevron aware of full width */
  padding-right: 32px;
}

.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-soft);
  color: var(--fg-muted);
}

.banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--fg);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  margin-bottom: 18px;
}
.banner .label {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  color: var(--fg-muted);
  background: var(--bg-card);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--fg);
}
.drop-zone input[type="file"] { display: none; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }

.footer {
  margin-top: auto;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
  text-align: center;
}

/* ---- Yawasa landing + portal ----------------------------------------- */

.splash-body {
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: var(--sans);
}

.splash-header {
  display: flex;
  justify-content: flex-end;
  padding: 20px 24px;
}

.splash-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.yawasa-logo {
  font-family: "Silkscreen", "JetBrains Mono", ui-monospace, monospace;
  font-weight: 700;
  font-size: clamp(3.5rem, 13vw, 9rem);
  line-height: 1;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-align: center;
  user-select: none;
  text-shadow:
    2px 2px 0 rgba(245, 165, 36, 0.18),
    -1px -1px 0 rgba(245, 165, 36, 0.18);
}

.splash-footer {
  text-align: center;
  padding: 24px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.18em;
}

.burger-wrap { position: relative; }
.burger {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 18px;
  font-family: var(--mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.burger:hover { color: var(--fg); border-color: var(--border-strong); }
.burger:focus { outline: none; border-color: var(--accent-line); }
.burger-menu {
  position: absolute;
  top: 48px;
  right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px;
  display: none;
  z-index: 50;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.burger-menu.show { display: flex; flex-direction: column; gap: 1px; }
.burger-menu a,
.burger-menu button {
  display: block;
  padding: 9px 12px;
  color: var(--fg);
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--sans);
  font-size: 13px;
  border-radius: 5px;
  cursor: pointer;
  width: 100%;
}
.burger-menu a:hover,
.burger-menu button:hover {
  background: var(--bg-hover);
  text-decoration: none;
  color: var(--accent);
}

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}
.portal-brand {
  font-family: "Silkscreen", "JetBrains Mono", ui-monospace, monospace;
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.portal-main {
  flex: 1;
  padding: 56px 32px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.portal-greeting {
  font-size: 26px;
  color: var(--fg);
  margin-bottom: 32px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.portal-greeting .dim { color: var(--fg-muted); font-weight: 400; }

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.service-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.service-tile:hover {
  border-color: var(--accent-line);
  text-decoration: none;
  transform: translateY(-1px);
}
.service-tile-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  color: var(--accent);
}
.service-tile-title { font-weight: 600; font-size: 15px; }
.service-tile-desc { color: var(--fg-muted); font-size: 12px; line-height: 1.5; }

.site-footer {
  margin-top: auto;
  padding: 28px 32px 36px;
  border-top: 1px solid var(--border);
  background: rgba(14, 17, 22, 0.6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}
.site-footer .left { display: flex; align-items: center; gap: 10px; }
.site-footer .left .mark {
  width: 18px;
  height: 18px;
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 9px;
  font-weight: 600;
}
.site-footer .copy { color: var(--fg-dim); }
.site-footer .copy strong { color: var(--fg); font-weight: 600; }
.site-footer .right { color: var(--fg-muted); font-size: 10px; }
@media (max-width: 600px) {
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 22px 18px 28px;
  }
}

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
}
.tag-pill:hover { color: var(--fg); border-color: var(--border-strong); text-decoration: none; }
.tag-pill.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.tag-pill-count {
  font-size: 10px;
  color: var(--fg-dim);
  font-weight: 500;
}
.tag-pill.active .tag-pill-count { color: var(--accent); opacity: 0.7; }

.tag-link {
  cursor: pointer;
  text-decoration: none;
}
.tag-link:hover {
  border-color: var(--accent-line);
  color: var(--accent);
}

.layout-toggle { display: inline-flex; gap: 4px; }

/* Multi-select checkboxes + sticky action bar */
.multiselect-cb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-card);
  cursor: pointer;
  position: relative;
  margin: 0;
  flex: 0 0 18px;
}
.multiselect-cb:hover { border-color: var(--accent-line); }
.multiselect-cb:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.multiselect-cb:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
/* Indeterminate state — horizontal bar instead of checkmark. Browsers
   don't trigger :checked when :indeterminate, so this overrides the empty
   state and replaces (via the more specific selector ordering below). */
.multiselect-cb:indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}
.multiselect-cb:indeterminate::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--bg);
  border: none;
  transform: none;
  width: auto;
}
.card-wrap > .multiselect-cb {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  /* Don't set background here — equal specificity to :checked / :indeterminate
     would override the amber-fill of the selected state. The base rule
     already gives an unchecked checkbox its bg-card chip. */
  box-shadow: 0 0 0 2px var(--bg-card);
}
/* Checkbox column — header AND body, identical widths. */
.list-table th.multiselect-cb-col,
.list-table td.multiselect-cb-cell {
  width: 36px;
  min-width: 36px;
  padding: 8px 6px 8px 12px;
  text-align: left;
}
/* Icon column — class on both header and body for matched widths. */
.list-table th.icon-col,
.list-table td.icon-col {
  width: 32px;
  min-width: 32px;
  padding-right: 4px;
}

/* Page-header select-all wrapper (grid view). */
.multiselect-all-label {
  display: inline-flex;
  align-items: center;
  margin-right: 12px;
}
.list-row.selected,
.card-wrap.selected > .card {
  border-color: var(--accent);
  background: rgba(245, 165, 36, 0.05);
}

.multiselect-bar {
  position: sticky;
  top: 54px; /* below topbar */
  z-index: 30;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: var(--bg-card);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  flex-wrap: wrap;
}
.multiselect-bar.show { display: flex; }
@media (max-width: 720px) {
  /* On narrow viewports collapse the flex spacer so Cancel/Delete
     wrap onto the same row as the primary actions instead of being
     pushed off the right edge (which used to force a horizontal
     scroll of the whole page). Buttons stay tap-sized. */
  .multiselect-bar > div[style*="flex:1"] { display: none; }
  .multiselect-bar .btn { padding: 6px 10px; font-size: 12px; }
  .multiselect-bar { gap: 6px; padding: 8px 10px; }
}
.multiselect-summary {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  padding-right: 6px;
}

/* Kebab trigger button */
.kebab {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kebab:hover { background: var(--bg-hover); color: var(--fg); border-color: var(--border); }
.kebab:focus { outline: none; border-color: var(--accent-line); }
.card-wrap { position: relative; }
.card-wrap > .kebab,
.card .kebab {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}
.card { position: relative; }

/* Menu popover */
.kebab-menu {
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  padding: 4px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.kebab-menu button {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.kebab-menu button:hover { background: var(--bg-hover); }
.kebab-menu button.danger { color: var(--danger); }
.kebab-menu button.danger:hover { background: rgba(229, 72, 77, 0.1); }
.kebab-sep {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.list-table { width: 100%; }
.list-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  padding: 8px 10px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  white-space: nowrap;
}
.list-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.list-table td.title-col { white-space: normal; min-width: 240px; }
.list-row { transition: background 80ms ease; }
.list-row:hover { background: var(--bg-hover); }
.list-row td.title-col { color: var(--fg); }
.list-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
  border-radius: 3px;
}

.tabs { display: flex; gap: 6px; }
.tab {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}
.tab:hover { color: var(--fg); background: var(--bg-hover); text-decoration: none; }
.tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  margin: 2px 4px 2px 0;
}
.chip .x {
  cursor: pointer;
  color: var(--fg-muted);
  font-weight: bold;
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}
.chip .x:hover { color: var(--danger); }

.typeahead { position: relative; }
.typeahead-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
.typeahead-results.show { display: block; }
.typeahead-result {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.typeahead-result:last-child { border-bottom: none; }
.typeahead-result:hover, .typeahead-result.focused {
  background: var(--bg-hover);
  color: var(--accent);
}
.typeahead-result .role-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-dim);
  margin-left: 6px;
}

/* ---- Folders --------------------------------------------------------- */

.folder-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.folder-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  margin-left: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  flex-wrap: wrap;
}
.breadcrumb-link {
  color: var(--fg-muted);
  padding: 2px 4px;
  border-radius: 4px;
}
.breadcrumb-link:hover {
  color: var(--accent);
  background: var(--bg-hover);
  text-decoration: none;
}
.breadcrumb-current {
  color: var(--fg);
  padding: 2px 4px;
}
.breadcrumb-sep {
  color: var(--fg-dim);
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.folder-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 14px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.12s ease, transform 0.12s ease;
  /* Floor so all folder cards have a consistent height regardless of
     how many meta lines they carry — empty-state placeholder, plain
     folder, Unpublished (which has a 2-line description) all match. */
  min-height: 132px;
}
.folder-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-1px);
  text-decoration: none;
}
.folder-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
}
.folder-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.folder-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  word-break: break-word;
}
.folder-shared {
  font-family: var(--mono);
  color: var(--fg-muted);
}
.folder-kebab {
  position: absolute;
  top: 6px;
  right: 6px;
}
.folder-card-unpublished {
  border-style: dashed;
  border-color: var(--accent-line);
  background: linear-gradient(180deg, rgba(245, 165, 36, 0.04), var(--bg-card));
}
.folder-card-unpublished .folder-icon { color: var(--accent); }
.folder-card-unpublished .folder-name::after {
  content: " · drafts";
  color: var(--fg-dim);
  font-weight: 400;
  font-size: 11px;
  font-family: var(--mono);
}
/* Empty-state subfolder placeholder: rendered as a real folder-card
   shape (so the row height is naturally identical to a populated row,
   regardless of card-content tweaks elsewhere) but visually muted so it
   doesn't read as an interactive folder. */
.folder-card-empty {
  cursor: default;
  border-style: dashed;
  border-color: var(--border);
  background: var(--bg-soft);
  color: var(--fg-dim);
}
.folder-card-empty:hover {
  border-color: var(--border);
  transform: none;
}
.folder-card-empty .folder-icon { color: var(--fg-dim); opacity: 0.5; }

/* ---- Root-browse folder home: strips + browse-all modal ----------- */
.folder-home { margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.folder-strip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
}
.folder-strip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.folder-strip-title { font-weight: 600; }
.folder-strip-count {
  font-family: var(--mono);
  color: var(--fg-dim);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}
.folder-strip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.folder-tile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: border-color 120ms ease, background 120ms ease;
  position: relative;
}
.folder-tile:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  text-decoration: none;
}
.folder-tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent);
}
.folder-tile-icon svg { width: 100%; height: 100%; }
.folder-tile-name { overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.folder-tile-unpublished { border-style: dashed; }
.folder-star {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--fg-dim);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  transition: color 120ms ease;
}
.folder-star:hover { color: var(--accent); }
.folder-star.starred { color: var(--accent); }
.folder-browse-all { display: flex; justify-content: flex-end; }

.folder-picker[hidden] { display: none; }
.folder-picker {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.folder-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.folder-picker-panel {
  position: relative;
  margin: 40px;
  flex: 1;
  max-width: 1100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 80px);
}
.folder-picker-header {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.folder-picker-header input[type="search"] {
  flex: 1;
  min-width: 220px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  font-size: 13px;
}
.folder-picker-controls { display: flex; gap: 8px; align-items: center; }
.folder-picker-viewtoggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.folder-picker-viewtoggle button {
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1;
}
.folder-picker-viewtoggle button.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.folder-picker-body {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding-right: 4px;
}
.folder-picker-body[data-view="list"] {
  grid-template-columns: 1fr;
  gap: 2px;
}
.folder-picker-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  min-width: 0;
  transition: border-color 120ms ease, background 120ms ease;
}
.folder-picker-item:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  text-decoration: none;
}
.folder-picker-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-picker-item[hidden] { display: none; }

/* ---- Modal (folder picker, share, etc.) ----------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
  animation: modal-fade 120ms ease-out;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  /* Two declarations: vh fallback for older browsers, dvh wins where
     supported. Mobile Safari's 100vh includes the address bar + bottom
     toolbar, which is invisible chrome — so the modal would exceed the
     visible viewport and push .modal-footer (Save/Cancel) off-screen.
     dvh tracks the *currently visible* viewport. */
  max-height: calc(100vh - 60px);
  max-height: calc(100dvh - 60px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-title {
  font-size: 14px;
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  /* flex-basis: auto so the body's preferred size is its content's
     natural size — modal sizes to fit (with title + body + footer all
     visible). Without this (basis: 0), the body collapses to 0 since
     the modal has no defined height, and only title + footer render —
     all form fields hidden.

     min-height: 0 is the second half of the trick: when content
     EXCEEDS the modal's max-height cap, this lets the body shrink
     past its intrinsic size so it can scroll internally and the
     footer stays visible. */
  flex: 1 1 auto;
  min-height: 0;
}
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--bg-soft);
  /* Belt-and-suspenders: even if a future modal somehow defeats the
     flex sizing, sticky-bottom keeps the action row pinned to the
     bottom of the visible modal. */
  position: sticky;
  bottom: 0;
  z-index: 5;
}

/* ---- Modal responsive (phone-friendly) ----------------------------- */
/* Inline style="max-width:Npx" still wins on the .modal element above
   600px. Below 600px we override it with !important so a 720px-wide
   editor modal doesn't overflow a 360px screen, and we tighten the
   padding rings so input fields don't get cropped. */
@media (max-width: 600px) {
  /* Switch from "internal-scroll modal" to "scroll-the-whole-backdrop":
     the modal renders at its natural height, the backdrop scrolls when
     it overflows the viewport, and the footer is sticky-pinned to the
     bottom of the viewport so Save/Cancel are always reachable.

     This matches how iOS sheet-style modals behave and avoids the
     flex-shrink trap where the body collapsed to a single field. */
  .modal-backdrop {
    padding: 8px;
    align-items: flex-start;
    overflow-y: auto;
    /* Stop iOS rubber-banding scroll bleeding into the page underneath. */
    overscroll-behavior: contain;
  }
  .modal {
    max-width: 100% !important;
    /* Drop the height cap and the flex-column layout so content sizes
       naturally and the backdrop owns scrolling. !important to defeat
       inline style="max-width:Npx" on per-instance modals. */
    max-height: none !important;
    display: block !important;
    overflow: visible !important;
    border-radius: var(--radius);
  }
  .modal-title {
    padding: 12px 14px;
    font-size: 13px;
    /* Sticky title so the user always sees what modal they're in even
       after scrolling down through a tall form. */
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 4;
  }
  .modal-body {
    padding: 12px 14px;
    /* Defeat the desktop rule's flex sizing — body now grows naturally
       to fit its content. */
    overflow: visible;
    flex: none;
    min-height: auto;
  }
  .modal-footer {
    padding: 10px 14px;
    flex-wrap: wrap;
    /* Pin to viewport bottom — works because the modal itself is no
       longer overflow:hidden. */
    position: sticky;
    bottom: 0;
    z-index: 6;
  }
  .modal-footer .btn {
    flex: 1 1 auto;
    min-width: 0;
  }
  /* Form fields and textareas inside modals — prevent horizontal overflow
     on phones; long placeholders / mono text shouldn't push the box wider
     than the screen. */
  .modal .field,
  .modal textarea.field,
  .modal input.field,
  .modal select.field {
    max-width: 100%;
    box-sizing: border-box;
  }
  /* Tall inline-styled min-heights (set to make textareas comfortable
     on desktop) are still relaxed so they don't dominate the viewport,
     but no longer fighting flex-shrink. */
  .modal textarea.field {
    min-height: 100px !important;
  }
  /* Tighter container padding so cards and forms get more horizontal
     room on a 360-400px screen. */
  .container {
    padding: 18px 14px;
  }
}

/* ---- Folder picker (used inside modal) ------------------------------ */

.folder-picker {
  display: flex;
  flex-direction: column;
}
.folder-picker-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.folder-picker-row {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.folder-picker-row:last-child { border-bottom: none; }
.folder-picker-row:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* ---- Share modal chips ---------------------------------------------- */

.share-typeahead .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 28px;
  margin-bottom: 8px;
}
.share-typeahead .typeahead-results {
  position: static;
  margin-top: 4px;
}

/* ---- Ideas (quick-capture snippets) -------------------------------- */

.ideas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.idea-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.12s ease;
  position: relative;
}
.idea-card:hover { border-color: var(--accent-line); }
.idea-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.idea-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  flex: 1;
  word-break: break-word;
}
.idea-card-text {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 8em;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 6px;
  line-height: 1.45;
}
.idea-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  /* Pin to the bottom of the flex column so the meta line lands at the
     same position on every card regardless of whether the idea has a
     body (the body div is conditionally rendered when idea.text is
     non-empty). Cards in the same grid row stretch to equal height via
     the grid's default align-items:stretch. */
  margin-top: auto;
}
.idea-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
}
.idea-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ---- Notes (short, complete, frequently-referenced) --------------- */

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.note-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 120ms ease;
  position: relative;
}
.note-row:hover { border-color: var(--accent-line); }
.note-row-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.note-row-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  flex: 1;
  word-break: break-word;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.note-pin-mark {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
}
.note-row-body { font-size: 14px; line-height: 1.55; }
.note-row-body:empty { display: none; }
.note-row-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.note-row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
}
.note-row-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.note-combined {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 26px 26px;
}

/* Shared markdown-rendered body styling — used by .note-row-body
   AND .note-combined inside the notes page. Sized for inline use
   (no full-page margins / huge h1). The CSS variables are already
   set on :root via the layout; this just lays out the elements. */
.md-prose-host { color: var(--fg); word-break: break-word; }
.md-prose-host h1 { font-size: 22px; margin: 0.6em 0 0.4em; line-height: 1.3; }
.md-prose-host h2 { font-size: 17px; margin: 1em 0 0.35em; line-height: 1.3; padding-top: 12px; border-top: 1px solid var(--border); }
.md-prose-host h2:first-child { padding-top: 0; border-top: none; margin-top: 0; }
.md-prose-host h3 { font-size: 14px; margin: 0.9em 0 0.3em; }
.md-prose-host h4 { font-size: 12px; margin: 0.8em 0 0.3em; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.md-prose-host p { margin: 0 0 0.7em; }
.md-prose-host p:last-child { margin-bottom: 0; }
.md-prose-host a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-line); word-break: break-all; }
.md-prose-host a:hover { border-bottom-color: var(--accent); }
.md-prose-host strong { color: var(--fg); font-weight: 600; }
.md-prose-host em { color: var(--fg-muted); font-style: italic; }
.md-prose-host ul, .md-prose-host ol { margin: 0 0 0.7em; padding-left: 1.4em; }
.md-prose-host li { margin: 0.2em 0; }
.md-prose-host blockquote {
  margin: 0.6em 0;
  padding: 4px 14px;
  border-left: 3px solid var(--accent-line);
  color: var(--fg-muted);
  background: var(--bg-soft);
  border-radius: 0 6px 6px 0;
}
.md-prose-host code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--accent);
  border: 1px solid var(--border);
}
.md-prose-host pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  margin: 0.6em 0;
  line-height: 1.5;
}
.md-prose-host pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--fg);
  font-size: 12.5px;
}
.md-prose-host hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}
.md-prose-host table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 13px;
}
.md-prose-host th, .md-prose-host td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.md-prose-host th {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  background: var(--bg-soft);
  font-weight: 500;
}
.md-prose-host img { max-width: 100%; height: auto; border-radius: 6px; }

/* ============================================================
   Projects — additive feature. All classes namespaced .pj-*.
   ============================================================ */
.pj-status{font-family:var(--mono);font-size:10px;text-transform:uppercase;letter-spacing:.06em;padding:3px 9px;border-radius:20px;font-weight:600;white-space:nowrap}
.pj-status.pj-active{color:var(--success);background:rgba(70,167,88,.12);border:1px solid rgba(70,167,88,.35)}
.pj-status.pj-hold{color:var(--accent);background:var(--accent-soft);border:1px solid var(--accent-line)}
.pj-status.pj-done{color:#5ca8ff;background:rgba(92,168,255,.12);border:1px solid rgba(92,168,255,.35)}
.pj-status.pj-archived{color:var(--fg-dim);background:transparent;border:1px solid var(--border)}

.pj-controls{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;margin-bottom:22px}
.pj-filters{display:flex;gap:6px;flex-wrap:wrap}
.pj-fpill{font-family:var(--mono);font-size:12px;padding:6px 12px;border-radius:20px;border:1px solid var(--border);background:var(--bg-soft);color:var(--fg-muted);cursor:pointer;display:inline-flex;align-items:center;gap:7px}
.pj-fpill:hover{color:var(--fg);border-color:var(--border-strong)}
.pj-fpill.active{color:var(--accent);border-color:var(--accent-line);background:var(--accent-soft)}
.pj-fpill .n{font-size:10px;background:var(--bg);border:1px solid var(--border);border-radius:9px;padding:0 6px;color:var(--fg-dim)}
.pj-search{flex:1;min-width:180px;background:var(--bg-soft);border:1px solid var(--border);color:var(--fg);border-radius:var(--radius);padding:8px 12px;font-size:13px;font-family:var(--sans)}
.pj-search:focus{outline:none;border-color:var(--accent-line)}
.pj-viewtoggle{display:inline-flex;border:1px solid var(--border);border-radius:6px;overflow:hidden}
.pj-viewtoggle button{background:transparent;border:0;color:var(--fg-muted);cursor:pointer;padding:5px 11px;font-size:14px;line-height:1}
.pj-viewtoggle button.active{background:var(--accent-soft);color:var(--accent)}

.pj-group{margin-bottom:8px}
.pj-grouphead{font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:var(--fg-muted);margin:22px 0 12px;display:flex;align-items:center;gap:9px}
.pj-grouphead::after{content:"";flex:1;height:1px;background:var(--border)}
.pj-grouphead .gc{color:var(--fg-dim)}
.pj-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:16px}
.pj-list{display:none;flex-direction:column;gap:2px}
#pj-body[data-view="list"] .pj-grid{display:none}
#pj-body[data-view="list"] .pj-list{display:flex}

.pj-card{position:relative;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:18px 18px 16px 20px;display:flex;flex-direction:column;gap:11px;cursor:pointer;overflow:hidden;transition:border-color .12s,transform .12s;text-decoration:none;color:var(--fg)}
.pj-card:hover{border-color:var(--accent-line);transform:translateY(-2px);text-decoration:none}
.pj-card::before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--border-strong)}
.pj-card.pj-s-active::before{background:var(--success)}
.pj-card.pj-s-hold::before{background:var(--accent)}
.pj-card.pj-s-done::before{background:#5ca8ff}
.pj-card.pj-s-archived{opacity:.72}
.pj-card.pj-s-archived::before{background:var(--fg-dim)}
.pj-card.pj-s-archived:hover{opacity:1}
.pj-ctop{display:flex;align-items:center;gap:10px}
.pj-shared-chip{margin-left:auto;font-family:var(--mono);font-size:10px;font-weight:600;color:var(--accent);border:1px solid var(--accent-line);background:var(--accent-soft);border-radius:4px;padding:2px 7px;display:inline-flex;align-items:center;gap:4px}
.pj-shared-chip svg{width:11px;height:11px}
.pj-name{font-size:17px;font-weight:600;letter-spacing:-.01em;line-height:1.3;text-wrap:balance}
.pj-purpose{color:var(--fg-muted);font-size:13px;line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;min-height:38px}
.pj-tags{display:flex;gap:5px;flex-wrap:wrap}
.pj-tag{font-family:var(--mono);font-size:10px;color:var(--fg-muted);background:var(--bg-soft);border:1px solid var(--border);border-radius:4px;padding:1px 6px}
.pj-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:12px;border-top:1px solid var(--border)}
.pj-avatars{display:inline-flex}
.pj-avatars .pj-av{margin-left:-7px}
.pj-avatars .pj-av:first-child{margin-left:0}
.pj-av{width:22px;height:22px;border-radius:50%;border:2px solid var(--bg-card);display:inline-flex;align-items:center;justify-content:center;font-size:9px;font-weight:600;font-family:var(--mono);color:#12100b;flex:0 0 auto}
.pj-owner{font-family:var(--mono);font-size:11px;color:var(--fg-dim)}
.pj-owner b{color:#5ca8ff;font-weight:600}
.pj-foot .pj-meta{font-family:var(--mono);font-size:11px;color:var(--fg-dim);display:flex;gap:10px;margin-left:auto}

.pj-lrow{position:relative;display:flex;align-items:center;gap:12px;padding:10px 14px 10px 16px;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);text-decoration:none;color:var(--fg);overflow:hidden}
.pj-lrow:hover{border-color:var(--accent-line);text-decoration:none}
.pj-lrow::before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--border-strong)}
.pj-lrow.pj-s-active::before{background:var(--success)}
.pj-lrow.pj-s-hold::before{background:var(--accent)}
.pj-lrow.pj-s-done::before{background:#5ca8ff}
.pj-lrow.pj-s-archived::before{background:var(--fg-dim)}
.pj-lname{font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pj-lowner{font-size:11px;color:#5ca8ff;min-width:80px}
.pj-lmeta{font-size:11px;color:var(--fg-dim)}
@media(max-width:640px){.pj-lowner,.pj-lmeta{display:none}}

/* detail */
.pj-phead{display:flex;flex-wrap:wrap;align-items:flex-start;gap:16px 24px;margin-bottom:20px}
.pj-phead h1{font-size:24px;letter-spacing:-.01em}
.pj-pmeta{display:flex;flex-wrap:wrap;align-items:center;gap:6px 16px;margin-top:9px;font-size:12px;color:var(--fg-muted)}
.pj-pmeta b{color:#5ca8ff;font-weight:600}
.pj-actions{display:flex;gap:8px;flex-wrap:wrap}
.pj-tabs{display:flex;gap:2px;border-bottom:1px solid var(--border);margin-bottom:22px;overflow-x:auto}
.pj-tabs button{font-family:var(--mono);font-size:12px;letter-spacing:.03em;background:none;border:0;border-bottom:2px solid transparent;color:var(--fg-muted);padding:10px 14px;cursor:pointer;white-space:nowrap}
.pj-tabs button.active{color:var(--accent);border-bottom-color:var(--accent)}
.pj-tabs button:hover{color:var(--fg)}
.pj-tabs .ct{font-size:10px;opacity:.7;margin-left:4px}
.pj-layout{display:grid;grid-template-columns:1fr 300px;gap:22px;align-items:start}
@media(max-width:860px){.pj-layout{grid-template-columns:1fr}}
.pj-rail-h{font-size:12px;text-transform:uppercase;letter-spacing:.07em;color:var(--fg-muted);margin:0 0 12px;font-weight:600}
.pj-rail-h .c{font-family:var(--mono);font-size:10px;background:var(--bg-soft);border:1px solid var(--border);color:var(--fg-dim);padding:1px 6px;border-radius:10px}

.pj-rows{display:flex;flex-direction:column}
.pj-row{display:flex;align-items:center;gap:10px;padding:11px 14px;border-bottom:1px solid var(--border)}
.pj-row:last-child{border-bottom:0}
.pj-row:hover{background:var(--bg-hover)}
.pj-row-link{display:flex;align-items:center;gap:12px;flex:1;min-width:0;text-decoration:none;color:var(--fg)}
.pj-row-link:hover{text-decoration:none}
.pj-kind{font-family:var(--mono);font-size:10px;font-weight:600;padding:2px 6px;border-radius:4px;flex:0 0 auto}
.pj-k-md{color:#7cc4ff;border:1px solid rgba(124,196,255,.4);background:rgba(124,196,255,.08)}
.pj-k-html{color:#8ce99a;border:1px solid rgba(140,233,154,.35);background:rgba(140,233,154,.08)}
.pj-k-note{color:var(--accent);border:1px solid var(--accent-line);background:var(--accent-soft)}
.pj-row-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.pj-row-title{font-weight:600;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pj-row-sub{font-size:11px;color:var(--fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pj-row-sub b{color:#5ca8ff;font-weight:600}
.pj-orig{color:var(--fg-dim)}
.pj-badge{font-family:var(--mono);font-size:10px;font-weight:600;padding:2px 7px;border-radius:4px;display:inline-flex;align-items:center;gap:4px;white-space:nowrap;flex:0 0 auto}
.pj-badge svg{width:11px;height:11px}
.pj-b-all{color:var(--success);border:1px solid rgba(70,167,88,.35);background:rgba(70,167,88,.1)}
.pj-b-you{color:var(--accent);border:1px solid var(--accent-line);background:var(--accent-soft)}
.pj-b-some{color:#a78bfa;border:1px solid rgba(167,139,250,.3);background:rgba(167,139,250,.08)}
.pj-b-priv{color:var(--fg-dim);border:1px solid var(--border);background:transparent}
.pj-when{font-family:var(--mono);font-size:11px;color:var(--fg-dim);flex:0 0 auto}
.pj-unlink{background:transparent;border:0;color:var(--fg-dim);cursor:pointer;padding:4px;border-radius:4px;display:inline-flex;flex:0 0 auto}
.pj-unlink:hover{color:var(--danger);background:rgba(229,72,77,.1)}
@media(max-width:620px){.pj-when{display:none}.pj-badge{max-width:120px;overflow:hidden}}

.pj-mlist{display:flex;flex-direction:column;gap:9px}
.pj-mrow{display:flex;align-items:center;gap:9px;font-size:13px}
.pj-mrole{margin-left:auto;font-family:var(--mono);font-size:10px;color:var(--fg-dim);text-transform:uppercase;letter-spacing:.05em}
.pj-mremove{background:transparent;border:0;color:var(--fg-dim);cursor:pointer;padding:2px;display:inline-flex}
.pj-mremove:hover{color:var(--danger)}
.pj-feed{display:flex;flex-direction:column;gap:13px}
.pj-fitem{display:flex;gap:10px;font-size:12.5px;line-height:1.45}
.pj-fitem .pj-dot{width:8px;height:8px;border-radius:50%;margin-top:5px;flex:0 0 auto;background:var(--accent)}
.pj-fitem b{color:#5ca8ff;font-weight:600}
.pj-ts{color:var(--fg-dim);font-family:var(--mono);font-size:10px;margin-top:1px}

/* modals */
.pj-modal[hidden]{display:none}
.pj-modal{position:fixed;inset:0;z-index:240;display:flex;align-items:flex-start;justify-content:center;padding:70px 16px 16px}
.pj-modal-back{position:absolute;inset:0;background:rgba(0,0,0,.6)}
.pj-modal-panel{position:relative;width:100%;max-width:520px;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:18px 20px;display:flex;flex-direction:column;gap:12px;box-shadow:0 16px 48px rgba(0,0,0,.5);max-height:calc(100vh - 90px);overflow-y:auto}
.pj-modal-head{display:flex;align-items:center;justify-content:space-between}
.pj-modal-title{font-size:15px;font-weight:600}
.pj-x{background:transparent;border:0;color:var(--fg-muted);font-size:22px;line-height:1;cursor:pointer;padding:0 4px}
.pj-x:hover{color:var(--fg)}
@media(max-width:620px){.pj-modal{align-items:flex-end;padding:0}.pj-modal-panel{max-width:100%;border-radius:14px 14px 0 0;max-height:88vh}}

.pj-link-results{display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto}
.pj-link-opt{display:flex;align-items:center;gap:10px;text-align:left;background:var(--bg-soft);border:1px solid var(--border);border-radius:6px;padding:9px 11px;cursor:pointer;color:var(--fg);font-size:13px}
.pj-link-opt:hover:not(:disabled){border-color:var(--accent-line);background:var(--accent-soft)}
.pj-link-opt.linked{opacity:.5;cursor:default}
.pj-link-opt-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}
.pj-link-opt-badge{font-family:var(--mono);font-size:10px;color:var(--fg-dim);border:1px solid var(--border);border-radius:4px;padding:1px 6px}
.pj-link-opt-badge.own{color:var(--accent);border-color:var(--accent-line)}
.pj-share-toggle{display:flex;align-items:center;gap:8px;font-size:13px;cursor:pointer}
.pj-link-opt.atp-check{cursor:pointer}
.pj-link-opt.atp-on{border-color:var(--accent-line);background:var(--accent-soft)}
.atp-cb{flex:0 0 auto;width:15px;height:15px;cursor:pointer;accent-color:var(--accent)}
.atp-foot{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}
.pj-empty{color:var(--fg-muted);font-size:12px;padding:14px;text-align:center}

.md-inline p{margin:0 0 10px;max-width:70ch}
.md-inline p:last-child{margin-bottom:0}
.md-inline h1,.md-inline h2,.md-inline h3{font-size:15px;margin:14px 0 6px}
.md-inline ul,.md-inline ol{margin:6px 0;padding-left:20px}
.md-inline code{background:var(--bg);padding:1px 5px;border-radius:3px;font-size:12px}

/* Projects — select (avoid .field's background shorthand tiling the
   chevron), card kebab, and the status menu. */
.pj-select{width:100%;font-size:13px}
.pj-kebab-wrap{margin-left:auto;position:relative;z-index:1}
.pj-kebab{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--fg-muted);cursor:pointer;font-size:16px;line-height:1;display:inline-flex;align-items:center;justify-content:center}
.pj-kebab:hover{color:var(--fg);background:var(--bg-hover);border-color:var(--border)}
.pj-lrow .pj-kebab-wrap{margin-left:0}
.pj-menu[hidden]{display:none}
.pj-menu{position:absolute;z-index:250;min-width:170px;background:var(--bg-card);border:1px solid var(--border-strong);border-radius:8px;padding:5px;box-shadow:0 12px 32px rgba(0,0,0,.5);display:flex;flex-direction:column;gap:1px}
.pj-menu-item{display:block;width:100%;text-align:left;background:transparent;border:0;color:var(--fg);font-size:13px;font-family:var(--sans);padding:8px 10px;border-radius:5px;cursor:pointer}
.pj-menu-item:hover:not(:disabled){background:var(--bg-hover)}
.pj-menu-item:disabled{color:var(--fg-dim);cursor:default}
.pj-menu-item.danger{color:var(--danger)}
.pj-menu-item.danger:hover{background:rgba(229,72,77,.1)}
.pj-menu-sep{height:1px;background:var(--border);margin:4px 2px}

/* Projects phase 2 — sections + pins */
.pj-docbar{display:flex;justify-content:flex-end;margin-bottom:12px}
.pj-section{margin-bottom:14px}
.pj-shead{display:flex;align-items:center;gap:9px;padding:6px 2px 8px}
.pj-schev{background:transparent;border:0;color:var(--fg-dim);cursor:pointer;font-size:11px;padding:0;line-height:1;transition:transform .15s}
.pj-sname{font-weight:600;font-size:14px}
.pj-sct{font-size:11px;color:var(--fg-dim)}
.pj-srem{margin-left:auto;background:transparent;border:0;color:var(--fg-dim);cursor:pointer;padding:2px;display:inline-flex}
.pj-srem:hover{color:var(--danger)}
.pj-section .pj-rows{border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;background:var(--bg-card)}
.pj-row-empty{padding:12px 14px;font-size:12px}
.pj-row-section{font-size:12px;height:28px;padding:2px 24px 2px 8px;flex:0 0 auto}
.pj-pin{background:transparent;border:0;color:var(--fg-dim);cursor:pointer;font-size:15px;line-height:1;padding:2px 4px;flex:0 0 auto}
.pj-pin:hover{color:var(--accent)}
.pj-pin.on{color:var(--accent)}
.pj-pins{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:8px}
.pj-pin-card{display:flex;align-items:center;gap:8px;padding:10px 12px;background:var(--bg-soft);border:1px solid var(--border);border-radius:8px;text-decoration:none;color:var(--fg);font-size:13px;font-weight:500}
.pj-pin-card:hover{border-color:var(--accent-line);background:var(--accent-soft);text-decoration:none}
.pj-pin-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media(max-width:620px){.pj-row-section{display:none}}

/* Projects — members form (teams + individuals) */
.pj-teams{margin-bottom:12px}
.pj-mm-label{font-family:var(--mono);font-size:10px;text-transform:uppercase;letter-spacing:.06em;color:var(--fg-muted);margin-bottom:6px}
.pj-team-chips{display:flex;flex-wrap:wrap;gap:6px}
.pj-team-chip{display:inline-flex;align-items:center;gap:6px;font-size:12px;padding:5px 10px;border-radius:16px;border:1px solid var(--border);background:var(--bg-soft);color:var(--fg);cursor:pointer}
.pj-team-chip:hover{border-color:var(--accent-line);background:var(--accent-soft);color:var(--accent)}
.pj-team-chip svg{width:12px;height:12px}
.pj-team-n{font-family:var(--mono);font-size:10px;color:var(--fg-dim);background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:0 5px}
.pj-mm-toolbar{display:flex;gap:8px;align-items:center;margin:10px 0 8px}
.pj-mm-toolbar .field{flex:1}
.pj-people-list{display:flex;flex-direction:column;gap:1px;max-height:300px;overflow-y:auto;border:1px solid var(--border);border-radius:8px;padding:4px;background:var(--bg)}
.pj-person{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:6px;cursor:pointer;font-size:13px}
.pj-person:hover{background:var(--bg-hover)}
.pj-person-cb{cursor:pointer;flex:0 0 auto}
.pj-person-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pj-person-role{font-size:10px;color:var(--fg-dim);text-transform:uppercase;letter-spacing:.05em}

/* Projects — section description + edit button */
.pj-sedit{margin-left:auto;background:transparent;border:0;color:var(--fg-dim);cursor:pointer;padding:2px;display:inline-flex}
.pj-sedit:hover{color:var(--accent)}
.pj-shead .pj-srem{margin-left:0}
.pj-sdesc{margin:-4px 2px 8px;color:var(--fg-muted);font-size:12.5px;line-height:1.5;max-width:70ch}

/* Projects — latest additions on Overview + add-to-project modal */
.pj-latest{display:flex;flex-direction:column;gap:6px}
.pj-latest-row{display:flex;align-items:center;gap:10px;padding:9px 11px;background:var(--bg-soft);border:1px solid var(--border);border-radius:8px;text-decoration:none;color:var(--fg);font-size:13px}
.pj-latest-row:hover{border-color:var(--accent-line);background:var(--accent-soft);text-decoration:none}
.pj-latest-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}
.pj-latest-by{font-size:11px;color:#5ca8ff}
.atp-modal .atp-list{max-height:300px}

/* Projects — category chip, group-by toggle, tag filter bar */
.pj-cat-chip{font-family:var(--mono);font-size:10px;color:#a78bfa;border:1px solid rgba(167,139,250,.35);background:rgba(167,139,250,.08);border-radius:4px;padding:2px 8px;white-space:nowrap}
.pj-lrow .pj-cat-chip{flex:0 0 auto}
.pj-groupby{display:inline-flex;border:1px solid var(--border);border-radius:6px;overflow:hidden;font-family:var(--mono);font-size:11px}
.pj-groupby .pj-gb{padding:6px 11px;color:var(--fg-muted);text-decoration:none;border-right:1px solid var(--border)}
.pj-groupby .pj-gb:last-child{border-right:0}
.pj-groupby .pj-gb:hover{color:var(--fg);background:var(--bg-hover)}
.pj-groupby .pj-gb.active{color:var(--accent);background:var(--accent-soft)}
.pj-tag-click{cursor:pointer}
.pj-tag-click:hover{border-color:var(--accent-line);color:var(--accent)}
.pj-tagbar{display:flex;align-items:center;gap:8px;margin:-8px 0 16px}

/* Projects — documents card view */
.pj-cards{display:none}
#pj-docs-body[data-view="cards"] .pj-rows{display:none}
#pj-docs-body[data-view="cards"] .pj-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px}
.pj-doccard{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:14px;display:flex;flex-direction:column;gap:8px}
.pj-doccard:hover{border-color:var(--accent-line)}
.pj-doccard-link{display:flex;flex-direction:column;gap:6px;text-decoration:none;color:var(--fg)}
.pj-doccard-link:hover{text-decoration:none}
.pj-doccard-top{display:flex;align-items:center;justify-content:space-between}
.pj-doccard-pin{color:var(--accent);font-size:13px}
.pj-doccard-title{font-weight:600;font-size:14px;line-height:1.35}
.pj-doccard-sub{font-size:11px;color:var(--fg-muted)}
.pj-doccard-sub b{color:#5ca8ff;font-weight:600}
.pj-doccard-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:auto;padding-top:8px;border-top:1px solid var(--border)}

/* Viewer sidebar — collapsed source-md tree */
.file-source-tree{margin-top:6px}
.file-source-tree > summary{cursor:pointer;font-family:var(--mono);font-size:11px;color:var(--fg-muted);padding:4px 6px;border-radius:4px;list-style:none;display:flex;align-items:center;gap:6px}
.file-source-tree > summary::before{content:"\25B8";font-size:9px;color:var(--fg-dim);transition:transform .15s}
.file-source-tree[open] > summary::before{transform:rotate(90deg)}
.file-source-tree > summary::-webkit-details-marker{display:none}
.file-source-tree > summary:hover{color:var(--fg);background:var(--bg-hover)}

/* ---- Home dashboard ---------------------------------------------------- */
.dash{display:flex;flex-direction:column;gap:22px}
.dash-hero{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin-top:4px}
.dash-greet{margin:0 0 2px;font-size:26px;font-weight:650;letter-spacing:-.01em}
.dash-actions{display:flex;gap:8px;flex-wrap:wrap}
.dash-band{display:flex;flex-direction:column;gap:12px}
.dash-band-head{font-size:12px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--fg-muted);border-bottom:1px solid var(--border);padding-bottom:6px}
.dash-band-admin .dash-band-head{color:var(--accent)}
.dash-admin-pill{font-family:var(--mono);font-size:9px;color:var(--accent);border:1px solid var(--accent-line);border-radius:4px;padding:1px 5px;letter-spacing:0;text-transform:none;margin-left:6px}
/* tiles */
.dash-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px}
.dash-tile{display:flex;flex-direction:column;gap:2px;background:var(--bg-card);border:1px solid var(--border);border-radius:10px;padding:13px 15px;color:var(--fg);position:relative;overflow:hidden}
a.dash-tile:hover{border-color:var(--accent-line);background:var(--accent-soft)}
.dash-tile-accent{border-color:var(--accent-line)}
.dash-tile-ico{color:var(--fg-muted);margin-bottom:2px}
.dash-tile-accent .dash-tile-ico{color:var(--accent)}
.dash-tile-num{font-size:24px;font-weight:650;line-height:1.1;font-variant-numeric:tabular-nums}
.dash-tile-label{font-size:12px;color:var(--fg-dim)}
/* this-week band */
.dash-week{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;align-items:center;background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:16px 18px}
.dash-week-stat{display:flex;flex-direction:column;gap:2px}
.dash-week-num{font-size:28px;font-weight:650;line-height:1;font-variant-numeric:tabular-nums}
.dash-week-stat .dim{font-size:12px}
.dash-chart{display:flex;flex-direction:column;gap:4px;min-width:180px}
/* cards grid */
.dash-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:12px}
.dash-card{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:14px 16px;display:flex;flex-direction:column;gap:10px}
.dash-card-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
.dash-card-title{display:inline-flex;align-items:center;gap:7px;font-size:13px;font-weight:600;color:var(--fg)}
.dash-card-title .lucide{color:var(--fg-muted)}
.dash-more{font-size:12px;color:var(--accent)}
.dash-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:7px}
.dash-list li{font-size:13px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dash-list li a{color:var(--fg);font-weight:500}
.dash-list li a:hover{color:var(--accent)}
.dash-activity li{white-space:normal}
.dash-ranked{counter-reset:rank}
.dash-ranked li{counter-increment:rank}
.dash-ranked li::before{content:counter(rank);font-family:var(--mono);font-size:10px;color:var(--fg-muted);margin-right:7px}
.dash-empty{font-size:12px;color:var(--fg-muted);padding:6px 0}
/* AI spend */
.dash-spend{display:flex;flex-direction:column;gap:6px}
.dash-spend-row{display:flex;justify-content:space-between;font-size:12px}
.dash-bar{height:6px;border-radius:3px;background:var(--bg-soft);overflow:hidden;margin-bottom:4px}
.dash-bar>span{display:block;height:100%;background:var(--accent);border-radius:3px}
@media(max-width:640px){.dash-greet{font-size:22px}.dash-hero{align-items:flex-start}}
