/* =====================================================================
   STF Taskboard — application styles
   Calm studio cockpit · Apple-like restraint · light + dark
   Built on Studio Tim Fu design tokens (colors_and_type.css)
   ===================================================================== */

* { box-sizing: border-box; }
*, *::before, *::after { user-select: none; -webkit-user-select: none; }
input, textarea, [contenteditable="true"] { user-select: text; -webkit-user-select: text; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-1);
  color: var(--fg-1);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
#root { height: 100vh; }
button { font-family: inherit; }

/* ---------------------------------------------------------------------
   DARK THEME — obsidian gallery at night. Calm, not contrasty.
   --------------------------------------------------------------------- */
[data-theme="dark"] {
  --stf-canvas:   #0E0E0D;
  --stf-paper:    #161614;
  --stf-mist:     #1C1C1A;
  --stf-fog:      #232320;
  --stf-hairline: #2A2A27;
  --stf-rule:     #3A3A36;
  --stf-silver:   #6E6E68;
  --stf-steel:    #95958E;
  --stf-graphite: #C7C7C1;
  --stf-ink:      #F4F4F0;
  --stf-obsidian: #FFFFFF;
  --stf-blueprint: #7E9BBA;
  --stf-blueprint-faint: #1E2630;
  --stf-amber:    #C9A77F;
  --stf-amber-faint: #2A231A;
  --stf-success:  #7FA083;

  --fg-1: var(--stf-ink);
  --fg-2: var(--stf-graphite);
  --fg-3: var(--stf-steel);
  --fg-4: var(--stf-silver);
  --bg-1: var(--stf-canvas);
  --bg-2: var(--stf-paper);
  --bg-3: var(--stf-mist);
  --border-1: var(--stf-hairline);
  --border-2: var(--stf-rule);

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 10px 30px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.4);
  --shadow-lg: 0 28px 70px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.5);
  --shadow-overlay: 0 50px 120px rgba(0,0,0,0.7);
}

.tb-root { height: 100vh; background: var(--bg-1); color: var(--fg-1); }

/* ---------------------------------------------------------------------
   SIGN-IN
   --------------------------------------------------------------------- */
.tb-signin {
  height: 100vh; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: flex-start;
  background: var(--bg-1);
}
.tb-signin-render {
  position: absolute; inset: 0;
  background-image: url("./login-bg.png");
  background-size: cover; background-position: center right;
}
.tb-signin-veil {
  position: absolute; inset: 0;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--bg-1) 86%, transparent),
    color-mix(in srgb, var(--bg-1) 58%, transparent) 30%,
    color-mix(in srgb, var(--bg-1) 12%, transparent) 52%,
    transparent 72%);
}
[data-theme="dark"] .tb-signin-veil {
  background: linear-gradient(90deg,
    color-mix(in srgb, #0E0E0D 88%, transparent),
    color-mix(in srgb, #0E0E0D 64%, transparent) 32%,
    color-mix(in srgb, #0E0E0D 16%, transparent) 56%,
    transparent 76%);
}
.tb-signin-core {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  width: min(520px, 100%); padding: 0 clamp(52px, 8vw, 132px);
  opacity: 1;
}
.tb-signin-eyebrow {
  font-size: 10px; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--fg-3); font-weight: 600; margin-bottom: 26px;
  padding-bottom: 18px; position: relative;
}
.tb-signin-eyebrow::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 34px; height: 1px; background: var(--border-2);
}
.tb-signin-wordmark {
  font-family: var(--font-display); font-weight: 300;
  font-size: clamp(40px, 5vw, 60px); letter-spacing: -0.035em; line-height: 1.02;
  color: var(--fg-1); margin: 0;
}
.tb-signin-slogan {
  font-family: var(--font-sans); font-weight: 400;
  font-size: clamp(14px, 1.4vw, 17px); line-height: 1.55; letter-spacing: 0;
  color: var(--fg-2); margin: 20px 0 38px; max-width: 30ch; text-wrap: pretty;
}
.tb-gbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  align-self: flex-start; padding: 13px 24px; border-radius: var(--radius-md); white-space: nowrap;
  border: 1px solid var(--border-2); background: var(--bg-1);
  color: var(--fg-1); font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: all var(--dur-base) var(--ease-stf); box-shadow: var(--shadow-sm);
}
.tb-gbtn:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--fg-3); }
.tb-gbtn:active { transform: translateY(0); }
.tb-gbtn svg { width: 17px; height: 17px; }
.tb-signin-fineprint { margin-top: 22px; font-size: 11px; color: var(--fg-4); letter-spacing: 0.02em; }

/* =====================================================================
   SPATIAL LOCK-IN — login → dashboard transition (main easing per brief)
   ===================================================================== */
:root { --tx-ease: cubic-bezier(0.22, 1, 0.36, 1); }

/* --- 1. button compresses ~2px · icon→spinner · label→Authenticating -- */
.tb-gbtn { position: relative; transition: transform 0.13s var(--tx-ease), box-shadow var(--dur-base) var(--ease-stf), border-color var(--dur-base) var(--ease-stf); }
.tb-gbtn[disabled] { cursor: default; pointer-events: none; }
.tb-gbtn-label { display: inline-flex; align-items: center; gap: 12px; transition: opacity 0.14s var(--ease-precise); }
.tb-gbtn-auth {
  position: absolute; inset: 0; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  opacity: 0; color: var(--fg-2); font-size: 13px; white-space: nowrap;
  transition: opacity 0.16s var(--ease-precise);
}
.tb-gbtn-spin {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in srgb, var(--fg-1) 18%, transparent);
  border-top-color: var(--fg-1); animation: tb-auth-spin 0.8s linear infinite;
}
.tb-signin[data-phase="auth"] .tb-gbtn,
.tb-signin[data-phase="clear"] .tb-gbtn { transform: translateY(2px) scale(0.985); }
.tb-signin[data-phase="auth"] .tb-gbtn-label,
.tb-signin[data-phase="clear"] .tb-gbtn-label { opacity: 0; }
.tb-signin[data-phase="auth"] .tb-gbtn-auth,
.tb-signin[data-phase="clear"] .tb-gbtn-auth { opacity: 1; }

/* --- 2. landing content clears; the STF lockup stays put -------------- */
.tb-signin[data-phase="clear"] .tb-signin-eyebrow,
.tb-signin[data-phase="clear"] .tb-signin-slogan,
.tb-signin[data-phase="clear"] .tb-signin-fineprint,
.tb-signin[data-phase="clear"] .tb-gbtn {
  animation: tb-auth-fade 0.2s var(--tx-ease) forwards;
}
.tb-signin[data-phase="clear"] .tb-signin-slogan { animation-delay: 0.03s; }
.tb-signin[data-phase="clear"] .tb-signin-fineprint { animation-delay: 0.05s; }

@keyframes tb-auth-spin { to { transform: rotate(360deg); } }
@keyframes tb-auth-fade { to { opacity: 0; transform: translateY(-5px); } }

/* --- 3+4. overlay: corridor blurs/fades into the dashboard canvas ----- */
.tb-tx { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.tb-tx-corridor {
  position: absolute; inset: 0;
  background-image: url("./login-bg.png");
  background-size: cover; background-position: center right;
  animation: tx-corridor 0.34s var(--tx-ease) forwards;
}
.tb-tx-veil {
  position: absolute; inset: 0;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--bg-1) 86%, transparent),
    color-mix(in srgb, var(--bg-1) 58%, transparent) 30%,
    color-mix(in srgb, var(--bg-1) 12%, transparent) 52%,
    transparent 72%);
  animation: tx-veil 0.34s var(--tx-ease) forwards;
}
[data-theme="dark"] .tb-tx-veil {
  background: linear-gradient(90deg,
    color-mix(in srgb, #0E0E0D 88%, transparent),
    color-mix(in srgb, #0E0E0D 64%, transparent) 32%,
    color-mix(in srgb, #0E0E0D 16%, transparent) 56%,
    transparent 76%);
}
@keyframes tx-corridor { from { filter: blur(0); opacity: 1; } to { filter: blur(8px); opacity: 0; } }
@keyframes tx-veil { from { opacity: 1; } to { opacity: 0; } }

/* --- 3. brand lockup glides + shrinks into the sidebar brand slot ----- */
.tb-tx-brand {
  position: fixed; margin: 0; transform-origin: top left;
  font-family: var(--font-display); font-weight: 300;
  font-size: clamp(40px, 5vw, 60px); letter-spacing: -0.035em; line-height: 1.02;
  color: var(--fg-1);
  animation: tx-brand-out 0.22s var(--tx-ease) 0.26s forwards;
}
@keyframes tx-brand-out { to { opacity: 0; } }

/* =====================================================================
   DASHBOARD ASSEMBLY — rise/fade in once, gated by .is-entering.
   Resting state (no .is-entering) is fully visible, so a stuck animation
   can never hide the shell.
   ===================================================================== */
@keyframes tx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tx-rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes tx-card { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes tx-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* 5. sidebar forms (real brand fades in as the morph clone fades out) */
.tb-app.is-entering .tb-side-brand { opacity: 0; animation: tx-fade 0.26s var(--tx-ease) 0.26s forwards; }
.tb-app.is-entering .tb-nav-item { animation: tx-rise 0.3s var(--tx-ease) both; }
.tb-app.is-entering .tb-nav-item:nth-child(1) { animation-delay: 0.18s; }
.tb-app.is-entering .tb-nav-item:nth-child(2) { animation-delay: 0.21s; }
.tb-app.is-entering .tb-nav-item:nth-child(3) { animation-delay: 0.24s; }
.tb-app.is-entering .tb-nav-item:nth-child(4) { animation-delay: 0.27s; }
.tb-app.is-entering .tb-nav-item:nth-child(5) { animation-delay: 0.30s; }
.tb-app.is-entering .tb-nav-item:nth-child(6) { animation-delay: 0.33s; }
.tb-app.is-entering .tb-side-foot { animation: tx-fade 0.28s var(--tx-ease) 0.34s both; }

/* 6. header → divider draws → filters → health bands → cards (stagger) */
.tb-app.is-entering .tb-topbar-nav,
.tb-app.is-entering .tb-crumb { animation: tx-rise 0.3s var(--tx-ease) 0.18s both; }
.tb-app.is-entering .tb-topbar { border-bottom-color: transparent; }
.tb-app.is-entering .tb-topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--border-1); transform-origin: left center;
  animation: tx-draw 0.32s var(--tx-ease) 0.26s both;
}
.tb-app.is-entering .tb-head-actions { animation: tx-rise 0.28s var(--tx-ease) 0.34s both; }
.tb-app.is-entering .tb-health-band { animation: tx-rise 0.3s var(--tx-ease) 0.36s both; }
.tb-app.is-entering .tb-matrix > * { animation: tx-card 0.3s var(--tx-ease) both; }
.tb-app.is-entering .tb-matrix > *:nth-child(1) { animation-delay: 0.42s; }
.tb-app.is-entering .tb-matrix > *:nth-child(2) { animation-delay: 0.47s; }
.tb-app.is-entering .tb-matrix > *:nth-child(3) { animation-delay: 0.52s; }
.tb-app.is-entering .tb-matrix > *:nth-child(4) { animation-delay: 0.57s; }
.tb-app.is-entering .tb-matrix > *:nth-child(n+5) { animation-delay: 0.58s; }
.tb-app.is-entering .tb-framefloat { animation: tx-fade 0.28s var(--tx-ease) 0.5s both; }

/* ---------------------------------------------------------------------
   APP SHELL
   --------------------------------------------------------------------- */
/* Grid track is never animated — transitioning grid-template-columns forces a full
   reflow of the content tree on every frame (cards, tables, gantt rows), which is
   the source of collapse/expand jank on slower machines. Snap it instantly and mask
   the jump with a brief opacity dip on .tb-content instead (see .is-toggling below,
   same principle already used for Mission Control's sidebar drawer). */
.tb-app { display: grid; grid-template-columns: 244px 1fr; height: 100vh; }
.tb-app.is-collapsed { grid-template-columns: 0 1fr; }
@keyframes tb-content-dip { 0% { opacity: 1; } 42% { opacity: 0.45; } 100% { opacity: 1; } }
.tb-app.is-toggling .tb-content { animation: tb-content-dip var(--dur-base) var(--ease-glide); }

.tb-side {
  grid-column: 1;
  background: var(--bg-2);
  border-right: 1px solid var(--border-1);
  display: flex; flex-direction: column;
  padding: 22px 16px 16px;
  gap: 4px;
  overflow: hidden;
  position: relative;
  transition: opacity var(--dur-fast) var(--ease-stf), padding var(--dur-base) var(--ease-stf);
}
.tb-side-handle {
  position: absolute; top: 0; right: 0; width: 12px; height: 100%;
  border: none; background: none; padding: 0; cursor: ew-resize; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.tb-side-handle .grip {
  width: 4px; height: 32px; border-radius: 999px; background: var(--border-2);
  transition: background var(--dur-fast) var(--ease-stf), height var(--dur-fast) var(--ease-stf);
}
.tb-side-handle:hover .grip { background: var(--fg-3); height: 52px; }
.tb-app.is-collapsed .tb-side {
  opacity: 0; pointer-events: none;
  padding-left: 0; padding-right: 0; border-right-color: transparent;
}
.tb-side-brand {
  display: flex; align-items: baseline; gap: 10px;
  padding: 6px 10px 22px;
}
.tb-side-brand .wm {
  font-family: var(--font-display); font-weight: 300; font-size: 22px;
  letter-spacing: 0.16em; color: var(--fg-1);
}
.tb-side-brand .sub {
  font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--fg-4); font-weight: 500;
}
.tb-nav { display: flex; flex-direction: column; gap: 0; flex: 1; }
.tb-nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.tb-nav-group-label {
  display: block;
  padding: 10px 12px 4px;
  font-size: 9.5px; font-family: var(--font-mono);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-4); font-weight: 500;
}
.tb-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-md);
  background: none; border: none; cursor: pointer;
  color: var(--fg-3); font-size: 13.5px; font-weight: 500; letter-spacing: 0.01em;
  text-align: left; width: 100%;
  transition: background var(--dur-fast) var(--ease-stf), color var(--dur-fast) var(--ease-stf);
}
.tb-nav-item svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.tb-nav-item:hover { background: var(--bg-3); color: var(--fg-1); }
.tb-nav-item.is-active { background: var(--bg-3); color: var(--fg-1); }
.tb-nav-item.is-active svg { opacity: 1; color: var(--stf-blueprint); }
.tb-nav-count {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--fg-4); letter-spacing: 0.04em;
}

.tb-help-btn {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-md); border: none; background: none; cursor: pointer;
  color: var(--fg-3); font-family: inherit; font-size: 13px; width: 100%; text-align: left;
  transition: background var(--dur-fast) var(--ease-stf), color var(--dur-fast) var(--ease-stf);
}
.tb-help-btn svg { flex: none; }
.tb-help-btn:hover { background: var(--bg-3); color: var(--fg-1); }

.tb-side-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--border-1); }
.tb-theme {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-md); border: none; background: none; cursor: pointer;
  color: var(--fg-3); font-size: 13px; font-weight: 500; width: 100%;
  transition: background var(--dur-fast) var(--ease-stf), color var(--dur-fast) var(--ease-stf);
}
.tb-theme:hover { background: var(--bg-3); color: var(--fg-1); }
.tb-theme svg { width: 16px; height: 16px; }
.tb-theme .tb-theme-track {
  margin-left: auto; width: 34px; height: 18px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--border-1); position: relative;
  transition: background var(--dur-base) var(--ease-stf);
}
.tb-theme .tb-theme-knob {
  position: absolute; top: 1px; left: 1px; width: 14px; height: 14px; border-radius: 999px;
  background: var(--fg-2); transition: transform var(--dur-base) var(--ease-stf);
}
[data-theme="dark"] .tb-theme .tb-theme-knob { transform: translateX(16px); }

.tb-framectl {
  display: flex; flex-direction: column; gap: 8px; padding: 9px 12px;
  border-radius: var(--radius-md); color: var(--fg-3);
}
.tb-framectl-top { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; }
.tb-framectl-top > svg { width: 16px; height: 16px; flex: none; }
.tb-framectl-top .pct { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--fg-4); }
.tb-frameslider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 3px;
  background: var(--border-2); border-radius: 999px; outline: none; cursor: pointer; margin: 2px 0;
}
.tb-frameslider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 999px;
  background: var(--fg-1); border: 2px solid var(--bg-2); box-shadow: var(--shadow-xs);
  transition: transform var(--dur-fast) var(--ease-stf);
}
.tb-frameslider::-webkit-slider-thumb:hover { transform: scale(1.12); }
.tb-frameslider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 999px; background: var(--fg-1);
  border: 2px solid var(--bg-2); box-shadow: var(--shadow-xs);
}
.tb-frameslider:focus-visible { box-shadow: 0 0 0 2px var(--stf-blueprint); }

/* interface scale — compact density locked on. zoom the whole surface incl. portals.
   compensate height so the shell still fills the viewport (no base white margin). */
html[data-scale="small"] body { zoom: 0.9; }
html[data-scale="small"] #root,
html[data-scale="small"] .tb-app,
html[data-scale="small"] .tb-main,
html[data-scale="small"] .tb-signin,
html[data-scale="small"] .tb-root { height: calc(100vh / 0.9); }

.tb-user {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-md); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left; font-family: inherit;
  transition: background var(--dur-fast) var(--ease-stf);
}
.tb-user > svg { margin-left: auto; color: var(--fg-4); flex: none; transition: transform var(--dur-base) var(--ease-stf); }
.tb-user.open > svg { transform: rotate(180deg); }
.tb-user:hover { background: var(--bg-3); }
.tb-user-static { cursor: default; }
.tb-user-static:hover { background: none; }
.tb-ava {
  width: 28px; height: 28px; border-radius: 999px; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  color: #fff; letter-spacing: 0.02em;
}
.tb-user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.tb-user-name { font-size: 13px; font-weight: 500; color: var(--fg-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-user-role { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-4); }

/* identity switcher ("view the board as") */
.tb-userswitch { position: relative; }
.tb-userswitch-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-1); border: 1px solid var(--border-1); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 5px; z-index: 80;
  max-height: 332px; overflow-y: auto;
}
.tb-userswitch-cap { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-4); font-weight: 600; padding: 6px 9px 8px; }
.tb-userswitch-menu .item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: none; background: none; cursor: pointer; font-family: inherit;
  padding: 7px 9px; border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-stf);
}
.tb-userswitch-menu .item:hover { background: var(--bg-2); }
.tb-userswitch-menu .item .av { width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; font-size: 10px; font-weight: 600; color: #fff; flex: none; letter-spacing: 0.02em; }
.tb-userswitch-menu .item .meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; flex: 1; }
.tb-userswitch-menu .item .nm { font-size: 12.5px; color: var(--fg-1); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-userswitch-menu .item .role { font-size: 10px; color: var(--fg-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-userswitch-menu .item svg { color: var(--stf-blueprint); flex: none; }
.tb-userswitch-menu .item.sel .nm { font-weight: 600; }

/* ---------------------------------------------------------------------
   MAIN COLUMN
   --------------------------------------------------------------------- */
.tb-main { grid-column: 2; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.tb-topbar {
  height: 44px; flex: none;
  display: flex; align-items: center; gap: 14px;
  padding: 0 36px;
  border-bottom: 1px solid var(--border-1);
  background: color-mix(in srgb, var(--bg-1) 80%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  position: sticky; top: 0; z-index: 30;
}
.tb-crumb { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--fg-3); min-width: 0; }
.tb-crumb .sep { color: var(--fg-4); }
.tb-crumb .here { color: var(--fg-1); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-crumb button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.tb-crumb button:hover { color: var(--fg-1); }
.tb-topbar-spacer { flex: 1; }
/* shared actions slot — page-local controls (filters, legends, +New) portal
   in here so they share the one topbar headerspace instead of stacking
   their own row underneath it. display:contents keeps the portaled nodes
   as direct flex children of .tb-topbar (same gap rhythm as the rest). */
.tb-topbar-actionslot { display: contents; }

/* topbar page nav — large title + page-selection tabs */
.tb-topbar-nav { display: flex; align-items: center; gap: 18px; min-width: 0; }
.tb-topbar-title { font-family: var(--font-display); font-weight: 300; font-size: 21px; letter-spacing: -0.02em; color: var(--fg-1); margin: 0; line-height: 1; white-space: nowrap; position: relative; top: 0.09em; }
.tb-pagetabs { display: flex; align-items: center; gap: 3px; overflow-x: auto; scrollbar-width: thin; }
.tb-pagetab {
  border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 12.5px; font-weight: 500; color: var(--fg-3); white-space: nowrap; flex: none;
  padding: 5px 12px; border-radius: var(--radius-pill);
  transition: color var(--dur-fast) var(--ease-stf), background var(--dur-fast) var(--ease-stf);
}
.tb-pagetab:hover { color: var(--fg-1); }
.tb-pagetab.is-active { color: var(--fg-1); background: color-mix(in srgb, var(--fg-1) 8%, var(--bg-3)); }

/* floating frame-scale control — bottom-left of content, Project/Task only */
.tb-framefloat {
  position: fixed; bottom: 22px; left: calc(244px + 24px); z-index: 50;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 15px; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--bg-1) 82%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border-1); box-shadow: var(--shadow-md);
  transition: left var(--dur-base) var(--ease-stf);
}
.tb-app.is-collapsed .tb-framefloat { left: 24px; }
.tb-framefloat > svg { width: 15px; height: 15px; color: var(--fg-3); flex: none; }
.tb-framefloat .lbl { font-size: 11.5px; font-weight: 500; color: var(--fg-2); white-space: nowrap; }
.tb-framefloat .pct { font-size: 11px; color: var(--fg-3); font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }
.tb-framefloat .tb-frameslider { width: 116px; margin: 0; }
.tb-framefloat-toggle {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 15px; height: 15px; padding: 0; margin: 0; border: none; background: none; cursor: pointer;
}
.tb-framefloat-toggle svg { width: 15px; height: 15px; color: var(--fg-3); }
/* collapsed state — a plain circular magnifying-glass button */
.tb-framefloat.is-mini {
  padding: 0; width: 40px; height: 40px; border-radius: 50%;
  justify-content: center; gap: 0;
}
.tb-framefloat.is-mini .tb-framefloat-toggle { width: 17px; height: 17px; }
.tb-framefloat.is-mini .tb-framefloat-toggle svg { width: 17px; height: 17px; }
.tb-framefloat.is-mini:hover { box-shadow: var(--shadow-sm); border-color: var(--rule); }
.tb-content { flex: 1; overflow-y: auto; overflow-x: hidden; }
/* single source of truth for horizontal page gutter — used by every page wrapper */
:root { --page-gutter: 36px; }
.tb-scroll-pad { padding: 30px var(--page-gutter) 64px; max-width: 1340px; margin: 0 auto; }
.tb-scroll-pad.wide { max-width: none; }

/* ---------------------------------------------------------------------
   GENERIC BITS — buttons, chips, eyebrow, page head
   --------------------------------------------------------------------- */
.tb-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  padding: 8px 15px; border-radius: var(--radius-md);
  border: 1px solid var(--border-1); background: var(--bg-1); color: var(--fg-2);
  transition: all var(--dur-fast) var(--ease-stf);
  white-space: nowrap;
}
.tb-btn:hover { border-color: var(--fg-3); color: var(--fg-1); }
.tb-btn svg { width: 15px; height: 15px; }
.tb-btn--primary { background: var(--fg-1); color: var(--bg-1); border-color: var(--fg-1); }
.tb-btn--primary:hover { background: transparent; color: var(--fg-1); }
.tb-btn--ghost { background: none; border-color: transparent; color: var(--fg-3); }
.tb-btn--ghost:hover { background: var(--bg-3); color: var(--fg-1); }
.tb-btn--sm { padding: 6px 11px; font-size: 12px; }
.tb-icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: var(--radius-md); border: 1px solid transparent; background: none;
  color: var(--fg-3); cursor: pointer; transition: all var(--dur-fast) var(--ease-stf);
}
.tb-icon-btn:hover { background: var(--bg-3); color: var(--fg-1); }
.tb-icon-btn svg { width: 17px; height: 17px; }

.tb-eyebrow { font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--fg-3); font-weight: 500; }
.tb-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 8px; }
.tb-page-head--bare { justify-content: flex-end; margin-bottom: 4px; }
/* first task band sits right under the filter/New row — no double gap */
.tb-page-head--bare + div .tb-health-band:first-of-type { margin-top: 6px; }
.tb-page-title { font-family: var(--font-display); font-weight: 300; font-size: 38px; letter-spacing: -0.03em; line-height: 1.05; color: var(--fg-1); margin: 0; }
.tb-page-sub { font-size: 14px; font-weight: 300; color: var(--fg-3); margin-top: 10px; max-width: 56ch; line-height: 1.55; }
.tb-head-actions { display: flex; align-items: center; gap: 10px; }

.tb-chips { display: flex; gap: 6px; align-items: center; }
.tb-chip {
  font-size: 12px; font-weight: 500; padding: 6px 13px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-1); background: none; color: var(--fg-3); cursor: pointer;
  transition: all var(--dur-fast) var(--ease-stf); letter-spacing: 0.01em;
}
.tb-chip:hover { color: var(--fg-1); border-color: var(--fg-3); }
.tb-chip.is-active { background: var(--fg-1); color: var(--bg-1); border-color: var(--fg-1); }

.tb-tag {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--radius-pill);
  color: var(--fg-3); background: var(--bg-3);
}
.tb-tag .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.tb-tag--review { color: var(--stf-blueprint); background: var(--stf-blueprint-faint); }
.tb-tag--active { color: var(--stf-amber); background: var(--stf-amber-faint); }
.tb-tag--done   { color: var(--stf-success); background: color-mix(in srgb, var(--stf-success) 16%, transparent); }
.tb-tag--open   { color: var(--fg-3); background: var(--bg-3); }

.tb-divider { height: 1px; background: var(--border-1); border: none; margin: 28px 0; }
.tb-token {
  display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 13px; color: var(--fg-1);
}
.tb-token svg { width: 14px; height: 14px; color: var(--stf-amber); }

/* progress meter */
.tb-meter { height: 3px; border-radius: 999px; background: var(--border-1); overflow: hidden; }
.tb-meter > span { display: block; height: 100%; background: var(--fg-2); border-radius: 999px; transition: width var(--dur-slow) var(--ease-stf); }

/* ---------------------------------------------------------------------
   PLACEHOLDER PAGES
   --------------------------------------------------------------------- */
.tb-placeholder {
  height: 100%; display: grid; place-items: center; padding: 40px;
}
.tb-placeholder-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 460px; }
.tb-placeholder-mark {
  width: 56px; height: 56px; border-radius: var(--radius-lg); display: grid; place-items: center;
  border: 1px solid var(--border-1); color: var(--fg-3); background: var(--bg-2);
}
.tb-placeholder-mark svg { width: 24px; height: 24px; }
.tb-placeholder-title { font-family: var(--font-display); font-weight: 300; font-size: 34px; letter-spacing: -0.02em; color: var(--fg-1); }
.tb-placeholder-body { font-size: 14px; font-weight: 300; color: var(--fg-3); line-height: 1.6; }
.tb-placeholder-pill { font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--fg-4); border: 1px solid var(--border-1); border-radius: 999px; padding: 5px 14px; }
