/* Ten Goede · base: reset, typography, the shell (levels 1–2), focus mode (level 3),
   external pages, and the overlays (drawer, modal, popover, palette, toast). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--desk); color: var(--ink);
  font: 400 var(--t-m)/1.5 var(--f-ui); font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1 { font-size: var(--t-xxl); line-height: 1.2; font-weight: 600; letter-spacing: -.02em; }
h2 { font-size: var(--t-l); line-height: 1.35; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: var(--t-m); line-height: 1.4; font-weight: 600; }
h4 { font-size: var(--t-s); line-height: 1.4; font-weight: 600; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img, svg { display: block; }
code, .mono { font-family: var(--f-mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-s); }
::selection { background: var(--accent-soft); }
.skip { position: absolute; left: 12px; top: -48px; z-index: 200; background: var(--ink); color: var(--on-ink); padding: 8px 12px; border-radius: var(--r); font-weight: 600; }
.skip:focus { top: 12px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.muted { color: var(--ink-3); }
.faint { color: var(--ink-4); }
.small { font-size: var(--t-s); }
.xs { font-size: var(--t-xs); }
.strong { font-weight: 600; }
.lede { font-size: var(--t-l); color: var(--ink-2); line-height: 1.55; max-width: 68ch; }
.prose p + p { margin-top: .7em; }
.prose { max-width: 70ch; color: var(--ink-2); line-height: 1.6; }
.prose strong { color: var(--ink); font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ── layout primitives ─────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.s { gap: 6px; } .stack.l { gap: 24px; } .stack.xl { gap: 40px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cluster.s { gap: 4px; } .cluster.l { gap: 16px; }
.hstack { display: flex; align-items: center; gap: 8px; min-width: 0; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ── the shell ──────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding: 12px 10px; gap: 2px; overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 9px; padding: 6px 10px 18px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; color: var(--ink); }
.mobile-only { display: none !important; }
@media (max-width: 900px) { .mobile-only { display: grid !important; } }
.side-org {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r); text-align: left; width: 100%;
}
.side-org:hover { background: var(--hover); }
.org-mark { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-weight: 600; font-size: 12px; color: #fff; background: var(--tone, #2b3a55); flex: none; letter-spacing: .02em; }
.side-org b { display: block; font-size: var(--t-s); font-weight: 600; line-height: 1.25; }
.side-org small { display: block; font-size: var(--t-xs); color: var(--ink-3); line-height: 1.25; }
.nav-i {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--r);
  color: var(--ink-2); font-weight: 500; font-size: var(--t-m); width: 100%; text-align: left;
}
.nav-i svg { color: var(--ink-3); flex: none; }
.nav-i:hover { background: var(--hover); color: var(--ink); }
.nav-i[aria-current="page"] { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-s), 0 0 0 1px var(--line); }
.nav-i[aria-current="page"] svg { color: var(--ink); }
.nav-i .count { margin-left: auto; font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav-i .count.hot { color: var(--bad); font-weight: 600; }
.side-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 12px; }
.side-me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r); width: 100%; text-align: left; }
.side-me:hover { background: var(--hover); }
.side-me b { display: block; font-size: var(--t-s); font-weight: 600; line-height: 1.25; }
.side-me small { display: block; font-size: var(--t-xs); color: var(--ink-3); line-height: 1.25; }

.main { min-width: 0; padding: 8px 8px 8px 0; display: flex; flex-direction: column; }
.sheet {
  flex: 1; background: var(--sheet); border-radius: var(--r-l); box-shadow: 0 0 0 1px var(--line), var(--shadow-s);
  display: flex; flex-direction: column; min-height: calc(100vh - 16px); min-width: 0;
}
.top {
  position: sticky; top: 8px; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 12px;
  padding: 0 20px 0 24px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--sheet) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-radius: var(--r-l) var(--r-l) 0 0;
}
.top::before { content: ""; position: absolute; left: 0; right: 0; top: -9px; height: 9px; background: var(--desk); }
@media (max-width: 900px) { .top::before { display: none; } }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--t-s); color: var(--ink-3); }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--ink-4); }
.crumbs [aria-current] { color: var(--ink); font-weight: 500; }
.crumbs > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-tag { font-size: 11px; font-weight: 500; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.search-btn {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 10px; border-radius: var(--r); color: var(--ink-3);
  border: 1px solid var(--line); background: var(--sunk); min-width: 220px; font-size: var(--t-s);
}
.search-btn:hover { border-color: var(--line-2); color: var(--ink-2); }
.search-btn .kbd { margin-left: auto; }
.icon-btn { position: relative; width: 32px; height: 32px; border-radius: var(--r); display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--sheet); }
.menu-btn { display: none; }
.view { flex: 1; min-width: 0; position: relative; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 60; left: 0; top: 0; width: 280px; background: var(--desk); transform: translateX(-100%); transition: transform .2s var(--ease); box-shadow: var(--shadow-lg); }
  body.nav-open .side { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 55; }
  .main { padding: 0; }
  .sheet { border-radius: 0; min-height: 100vh; }
  .top { top: 0; border-radius: 0; padding: 0 12px; }
  .menu-btn { display: grid; }
  .search-btn { min-width: 0; }
  .search-btn span, .search-btn .kbd { display: none; }
  .level-tag { display: none; }
  :root { --gut: 16px; }
}

/* ── pages (level 1) and workspaces (level 2) ──────────────────────── */
.page { padding: 28px var(--gut) 64px; width: 100%; max-width: 1240px; margin: 0 auto; }
.page.narrow { max-width: 920px; }
.page.wide { max-width: none; }
.ph { display: flex; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.ph-t { flex: 1 1 420px; min-width: 0; }
.ph-t h1 + p { margin-top: 6px; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.oh { padding: 22px var(--gut) 0; border-bottom: 1px solid var(--line); }
.oh-type { display: flex; align-items: center; gap: 8px; font-size: var(--t-xs); color: var(--ink-3); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.oh-row { display: flex; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.oh-row h1 { font-size: 24px; flex: 1 1 360px; min-width: 0; }
.oh-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 8px; color: var(--ink-3); font-size: var(--t-s); }
.oh-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.oh-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.oh .tabs { margin-top: 18px; border-bottom: 0; margin-bottom: -1px; }
.ws-body { padding: 28px var(--gut) 64px; }
.ws-body.flush { padding: 0; }

.sec { margin-top: 36px; }
.sec:first-child { margin-top: 0; }
.sec-h { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.sec-h h2 { font-size: var(--t-l); }
.sec-h .count { color: var(--ink-3); font-weight: 400; font-size: var(--t-m); }
.sec-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: var(--t-s); }

/* ── level 3: focus mode ────────────────────────────────────────────── */
body.is-focus { background: var(--sunk); }
.focus { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.focus-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 60px; padding: 0 20px;
  background: color-mix(in srgb, var(--sheet) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.focus-top .ft-title { min-width: 0; }
.focus-top .ft-title small { display: block; font-size: var(--t-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }
.focus-top .ft-title b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focus-top .ft-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.focus-progress { height: 3px; background: var(--line); position: sticky; top: 60px; z-index: 19; }
.focus-progress > i { display: block; height: 100%; background: var(--ink); transition: width .3s var(--ease); }
.focus-body { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 40px 20px 96px; }
.focus-body.wide { max-width: 1120px; }
.saved-hint { font-size: var(--t-xs); color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }

/* ── external pages (participants, no account) ─────────────────────── */
body.is-ext { background: var(--desk); }
.ext { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 32px 16px 64px; }
.ext-head { width: 100%; max-width: 640px; display: flex; align-items: center; gap: 10px; margin-bottom: 20px; color: var(--ink-3); font-size: var(--t-s); }
.ext-card { width: 100%; max-width: 640px; background: var(--sheet); border-radius: var(--r-l); box-shadow: 0 0 0 1px var(--line), var(--shadow); padding: 32px; }
.ext-foot { max-width: 640px; width: 100%; margin-top: 16px; font-size: var(--t-xs); color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
@media (max-width: 600px) { .ext-card { padding: 22px 18px; } }

/* ── overlays ───────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 80; animation: fade .15s var(--ease); }
.drawer {
  position: fixed; z-index: 81; top: 8px; right: 8px; bottom: 8px; width: min(var(--drawer-w), calc(100vw - 16px));
  background: var(--sheet); border-radius: var(--r-l); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slide-in .2s var(--ease);
}
.drawer.wide { --drawer-w: 760px; }
.dr-h { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.dr-h .dr-t { flex: 1; min-width: 0; }
.dr-h .dr-t small { display: flex; align-items: center; gap: 8px; font-size: var(--t-xs); color: var(--ink-3); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.dr-h .dr-t h2 { font-size: 18px; margin-top: 4px; }
.dr-b { flex: 1; overflow-y: auto; padding: 20px; }
.dr-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dr-f .spacer { flex: 1; }
@media (max-width: 640px) { .drawer { top: 0; right: 0; bottom: 0; border-radius: 0; width: 100vw; } }

.modal-wrap { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; }
.modal-wrap > .scrim, .palette-wrap > .scrim { z-index: 0; }
.modal {
  position: relative; z-index: 1; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--sheet); border-radius: var(--r-l); box-shadow: var(--shadow-lg); animation: pop .18s var(--ease);
}
.modal.wide { width: min(880px, 100%); }
.modal.xwide { width: min(1080px, 100%); }
.m-h { padding: 20px 22px 0; display: flex; gap: 12px; align-items: flex-start; }
.m-h > div { flex: 1; min-width: 0; }
.m-h h2 { font-size: 18px; }
.m-h p { color: var(--ink-3); margin-top: 4px; font-size: var(--t-s); }
.m-b { padding: 18px 22px; overflow-y: auto; }
.m-f { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.m-f .left { margin-right: auto; }

.pop {
  position: fixed; z-index: 95; min-width: 220px; max-width: min(380px, calc(100vw - 16px)); background: var(--sheet); border-radius: var(--r);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); padding: 6px; animation: pop .12s var(--ease); max-height: 70vh; overflow-y: auto;
}
.pop.wide { max-width: min(420px, calc(100vw - 16px)); width: 420px; }

.palette-wrap { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette { position: relative; z-index: 1; width: min(640px, 100%); background: var(--sheet); border-radius: var(--r-l); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .15s var(--ease); display: flex; flex-direction: column; max-height: 70vh; }
.palette-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-in input { flex: 1; height: 52px; border: 0; background: none; font-size: var(--t-l); outline: none; }
.palette-res { overflow-y: auto; padding: 6px; }
.palette-g { padding: 10px 10px 4px; font-size: var(--t-xs); color: var(--ink-3); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.palette-i { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); cursor: pointer; }
.palette-i[aria-selected="true"] { background: var(--hover); }
.palette-i .pi-t { flex: 1; min-width: 0; }
.palette-i .pi-t b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-i .pi-t small { color: var(--ink-3); font-size: var(--t-xs); }
.palette-i .pi-k { font-size: var(--t-xs); color: var(--ink-4); }
.palette-foot { border-top: 1px solid var(--line); padding: 8px 16px; display: flex; gap: 16px; font-size: var(--t-xs); color: var(--ink-3); }

.toasts { position: fixed; z-index: 120; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: var(--r);
  background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-lg); font-size: var(--t-s); animation: rise .2s var(--ease); max-width: min(560px, calc(100vw - 32px));
}
.toast button { color: inherit; font-weight: 600; padding: 2px 8px; border-radius: var(--r-s); opacity: .9; white-space: nowrap; }
.toast button:hover { background: rgba(255,255,255,.12); opacity: 1; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.99); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }
/* a modal or drawer that is already open and only redrawn (while typing) does not animate in again */
.still, .still > .scrim, .still > .modal { animation: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
