/* ─────────────────────────────────────────────────────────────────────────────
   Bili — application stylesheet (glass frames, flat panels)

   backdrop-filter is reserved for the page frames and overlays only — the
   sidebar, the main pane, the mobile topbar and its scrim, the modal, drawer
   and their scrims. Every other container, control and chip uses the same
   translucent fills at a higher opacity, so a page composites a handful of
   blurred backdrops instead of one per component.

   Pairs with base.html that includes (right after <body>):
     <body class="glass">
     <div class="bg-stage"><div class="blob b1"></div>...</div>
     <div class="bg-grain"></div>
     <div class="bili-mobile-topbar">…</div>
     <div class="bili-sidebar-overlay"></div>
───────────────────────────────────────────────────────────────────────────── */

/* ── Custom font ─────────────────────────────────────────────────────────── */
[x-cloak] { display: none !important; }
@font-face {
  font-family: 'DieGrotesk';
  src: url('../fonts/DieGrotesk-B-Regular.otf') format('opentype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'DieGrotesk';
  src: url('../fonts/DieGrotesk-B-Medium.otf') format('opentype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'DieGrotesk';
  src: url('../fonts/DieGrotesk-C-Medium.otf') format('opentype');
  font-weight: 700;
  font-style: bold;
  font-display: swap;
}

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  --bili-font-family: 'DieGrotesk', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bili-sidebar-width: 232px;
  --bili-sidebar-width-folded: 64px;
  --bili-page-bar-height: 55px;
  --bili-topbar-height: 52px;
  --bili-content-padding: 1.75rem;
  --bili-content-padding-mobile: 1rem;

  /* Ink */
  --surface: oklch(100% 0 0);
  --surface-border: oklch(87% 0 0);
  --surface-code: oklch(20% 0.02 250);
  --surface-code-fg: oklch(92% 0.01 250);
  --warn-bg: oklch(98% 0.03 85);
  --warn-border: oklch(78% 0.15 75);
  --warn-text: oklch(40% 0.10 75);
  --bili-ink:   oklch(18% 0.022 50);
  --bili-ink-2: oklch(38% 0.022 55);
  --bili-ink-3: oklch(54% 0.020 58);

  /* Brand */
  --bili-green-cta:  oklch(66% 0.22 140);
  --bili-green-dark: oklch(30% 0.09 140);
  --bili-gold:       oklch(70% 0.17 85);
  --bili-gold-text:  oklch(34% 0.10 85);
  --bili-sage:       oklch(52% 0.13 138);
  --bili-purple:     oklch(54% 0.13 288);
  --bili-red:        oklch(58% 0.20 25);
  --bili-cream:      oklch(96% 0.06 85);

  /* Organisations area (see "Organisations area" section) */
  --bo-hair:   color-mix(in oklch, var(--bili-ink) 8%, transparent);
  --bo-hair-2: color-mix(in oklch, var(--bili-ink) 5%, transparent);
  --bo-ok:     oklch(58% 0.15 145);
  --bo-busy:   oklch(70% 0.14 75);
  --bo-bad:    oklch(56% 0.19 25);
  --bo-idle:   oklch(62% 0.015 60);

  /* Glass primitives.
     --glass-blur stays for the page frames (see the stylesheet header).
     Components keep the same fills: on every shipped page they sit on a
     frame that already blurs, so their own backdrop-filter only blurred an
     already-smooth backdrop. */
  --glass-fill:    rgba(255, 255, 255, 0.42);
  --glass-fill-2:  rgba(255, 255, 255, 0.55);
  --glass-border:  rgba(255, 255, 255, 0.55);
  --glass-shine:   rgba(255, 255, 255, 0.85);
  --glass-shadow:  0 10px 40px oklch(20% 0.04 50 / 0.18),
                   0 2px 8px  oklch(20% 0.04 50 / 0.08);
  --glass-blur:    blur(22px) saturate(170%);

  /* Shape */
  --r-pill:    9999px;
  --r-pill-sm: 10px;
  --r-xl:      22px;
  --r-lg:      16px;
  --r-md:      12px;
  --r-sm:      8px;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--bili-font-family);
  color: var(--bili-ink);
  background-color: transparent; /* let .bg-stage show through — was hiding it */
  overflow: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
/* Fallback colour on html in case .bg-stage isn't in the DOM */
html { background-color: oklch(83% 0.030 60); }

/* ── ANIMATED BACKGROUND ─────────────────────────────────────────────────── */
/* Texture controls — overridable from JS (tweaks panel) */
:root {
  --bg-dot-opacity: 0.04;
  --bg-dot-size: 48px;
  --bg-dot-radius: 4.7px;
  --bg-sheen-opacity: 0.32;
  --bg-vignette-opacity: 0.26;
  --bg-grain-opacity: 0.38;
  --bg-blob-opacity: 0.12;
}

.bg-stage {
  position: fixed; inset: 0; z-index: -2; overflow: hidden;
  background:
    /* Soft diagonal caustic sheen */
    linear-gradient(115deg, transparent 0%, oklch(96% 0.012 80 / var(--bg-sheen-opacity)) 38%, transparent 62%),
    /* Original warm radial wash */
    radial-gradient(ellipse at top left, oklch(88% 0.035 65) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, oklch(80% 0.040 55) 0%, transparent 60%),
    oklch(83% 0.030 60);
}

/* Corner vignette — first ::before so it sits behind blobs, hugging the edges */
.bg-stage::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    oklch(55% 0.040 55 / var(--bg-vignette-opacity)) 100%
  );
}

/* Dot-grid layer — ::after so it paints AFTER .blob children, otherwise the
   big blurred blobs cover it. Multiply blend lets it darken the warm
   wash + blobs together.                                                  */
.bg-stage::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background-image: radial-gradient(
    circle at 50% 50%,
    oklch(20% 0.025 60) 0,
    oklch(20% 0.025 60) var(--bg-dot-radius),
    transparent calc(var(--bg-dot-radius) + 0.6px)
  );
  background-size: var(--bg-dot-size) var(--bg-dot-size);
  opacity: var(--bg-dot-opacity);
  mix-blend-mode: multiply;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: var(--bg-blob-opacity);
  will-change: transform;
}
.blob.b1 {
  width: 540px; height: 540px;
  background: radial-gradient(circle, oklch(70% 0.22 140) 0%, transparent 70%);
  top: -10%; left: -8%;
  animation: drift1 28s ease-in-out infinite alternate;
}
.blob.b2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, oklch(72% 0.18 85) 0%, transparent 70%);
  top: 18%; right: -5%;
  animation: drift2 34s ease-in-out infinite alternate;
}
.blob.b3 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, oklch(60% 0.16 288) 0%, transparent 70%);
  bottom: -12%; left: 22%;
  animation: drift3 40s ease-in-out infinite alternate;
}
.blob.b4 {
  width: 360px; height: 360px;
  background: radial-gradient(circle, oklch(58% 0.18 25) 0%, transparent 70%);
  top: 50%; right: 28%;
  animation: drift4 32s ease-in-out infinite alternate;
  opacity: calc(var(--bg-blob-opacity) * 0.76);
}

@keyframes drift1 { 0% { transform: translate(0,0) scale(1); }    100% { transform: translate(140px,100px) scale(1.15); } }
@keyframes drift2 { 0% { transform: translate(0,0) scale(1); }    100% { transform: translate(-160px,160px) scale(0.92); } }
@keyframes drift3 { 0% { transform: translate(0,0) scale(1); }    100% { transform: translate(180px,-120px) scale(1.08); } }
@keyframes drift4 { 0% { transform: translate(0,0) scale(1); }    100% { transform: translate(-100px,-180px) scale(1.2); } }

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none !important; }
}

/* Grain overlay — two-scale SVG noise so the panels have texture. Plain
   alpha, no mix-blend-mode: the blend forced the compositor to re-blend the
   whole viewport on every blob animation frame. */
.bg-grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: var(--bg-grain-opacity);
  background-image:
    /* Coarser "paper fibre" — larger, sparser strokes */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='n2'><feTurbulence type='fractalNoise' baseFrequency='0.32' numOctaves='1' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.30 0'/></filter><rect width='100%' height='100%' filter='url(%23n2)' opacity='0.55'/></svg>"),
    /* Fine film-grain — original */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.45 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
  background-size: 320px 320px, 180px 180px;
}

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
.bili-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  height: 100vh;
  padding: 14px;
  gap: 14px;
  overflow: hidden;
  transition: grid-template-columns 0.3s ease;
}

/* Mobile topbar — hidden on desktop, visible on small screens */
.bili-mobile-topbar { display: none; }
.bili-sidebar-overlay { display: none; }

/* ── SIDEBAR (glass) ─────────────────────────────────────────────────────── */
.bili-sidebar {
  width: var(--bili-sidebar-width);
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    inset 0 -1px 1px rgba(255,255,255,0.15),
    var(--glass-shadow);
  padding: 22px 14px 16px;
  display: flex; flex-direction: column;
  overflow: visible; position: relative;
  transition: width .42s cubic-bezier(.4,.01,.2,1), padding .42s cubic-bezier(.4,.01,.2,1);
}
.bili-sidebar.is-folded {
  width: 64px;
  padding: 9px 9px 16px;
}
.bili-sidebar::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 30%);
  pointer-events: none;
}

/* ── Edge tab (fold trigger straddling right border) ───────────────────── */
.bili-sidebar__tab {
  position: absolute; top: 74px; right: -13px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-shine), 0 2px 6px rgba(40,25,15,0.1);
  color: var(--bili-ink-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: transform .42s cubic-bezier(.4,.01,.2,1), background .15s;
}
.bili-sidebar__tab:hover { background: rgba(255, 255, 255, 1); color: var(--bili-ink); }
.bili-sidebar__tab svg { width: 14px; height: 14px; display: block; }
.bili-sidebar.is-folded .bili-sidebar__tab { transform: rotate(180deg); }

/* ── Logo — shrink in place, no horizontal jump ────────────────────────── */
.bili-sidebar__logo {
  position: relative; height: 50px; flex-shrink: 0;
  margin-bottom: 12px;
}
.bili-logo {
  position: absolute; top: 50%; left: 4px;
  transform: translateY(-50%);
  height: 50px; width: auto; display: block;
  transition: height .42s cubic-bezier(.4,.01,.2,1), left .42s cubic-bezier(.4,.01,.2,1);
}
.bili-logo path, .bili-logo rect, .bili-logo circle { fill: var(--bili-ink); }
.bili-sidebar.is-folded .bili-logo { height: 30px; left: 2px; }

/* ── DEV MODE / STALE IMAGE badge — dark red superscript right of the logo.
   The wrapper is the hover target; hovering or focusing it reveals the code
   identity (which code is actually serving the page) in a panel beside it. ── */
.bili-dev-wrap {
  position: absolute;
  bottom: -2px;
  left: 85px;
}
.bili-sidebar.is-folded .bili-dev-wrap { display: none; }
.bili-dev-badge {
  display: inline-block;
  font-size: 0.67rem;
  font-weight: bold;
  color: #c62828;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: help;
  user-select: none;
  line-height: 0.8rem;
}
.bili-dev-badge:focus-visible { outline: 2px solid #c62828; outline-offset: 2px; }

/* The image was built from different code than the tree mounted over it, so the
   page being tested is not the code in the repo. Loud on purpose. */
.bili-dev-badge--drift {
  background: #c62828;
  color: #fff;
  padding: 1px 4px;
  border-radius: 3px;
}

/* The code-identity panel: service build, image code, mounted code. Stale (the
   image is older than the mounted tree) is called out in dark red. */
.bili-build-panel {
  position: absolute;
  left: calc(100% + 12px);
  top: -6px;
  z-index: 30;
  width: 236px;
  display: none;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  font-size: 11px;
  line-height: 1.35;
  color: var(--bili-ink-2);
  white-space: nowrap;
  text-align: left;
}
.bili-dev-wrap:hover .bili-build-panel,
.bili-dev-wrap:focus-within .bili-build-panel { display: flex; }
.bili-build-panel__line { display: block; }
.bili-build-panel code {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 0;
  background: none;
  color: var(--bili-ink);
}
.bili-build-panel .is-stale,
.bili-build-panel .is-stale code { color: #8b1a1a; font-weight: 600; }
.bili-build-panel__hint {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--surface-border);
  color: #8b1a1a;
  white-space: normal;
}

.bili-sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 0;
  margin: 0;
  scrollbar-gutter: auto;
}
.bili-nav-section { padding: 4px 0 12px; }

/* Collapsible nav section — wrap menu-label in a button-like toggle */
.bili-sidebar__nav .menu-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--bili-ink-2);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px 8px;
  margin: 0;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}
.bili-sidebar__nav .menu-label:hover { color: var(--bili-ink); }
.bili-sidebar__nav .menu-label__chevron {
  font-size: 14px;
  line-height: 1;
  opacity: 0.85;
  color: var(--bili-ink);
  transition: transform 0.2s ease;
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
}
.bili-nav-section.is-collapsed .menu-list { display: none; }
.bili-nav-section.is-collapsed .menu-label__chevron { transform: rotate(-90deg); }

/* Instance org context — anchoring header, aligned with the logo */
.bili-sidebar__nav .bili-nav-org {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 4px 10px;
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--bo-hair);
}
.bili-sidebar__nav .bili-nav-org__eyebrow {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--bili-ink-3);
}
.bili-sidebar__nav .bili-nav-org__name {
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
  color: var(--bili-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bili-sidebar.is-folded .bili-nav-org { display: none; }

.bili-sidebar__nav .menu-list { padding: 0; list-style: none; margin: 0; }
.bili-sidebar__nav .menu-list li + li { margin-top: 8px; }
.bili-sidebar__nav .menu-list a {
  display: flex; align-items: center; gap: 11px;
  color: var(--bili-ink);
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--r-pill);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  transition: background .2s, transform .15s, gap .42s cubic-bezier(.4,.01,.2,1), padding .42s cubic-bezier(.4,.01,.2,1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}
.bili-sidebar__nav .menu-list a:hover { background: rgba(255, 255, 255, 0.4); }
.bili-sidebar__nav .menu-list a.is-active {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    0 2px 8px rgba(40,25,15,0.08);
}
.bili-sidebar.is-folded .bili-sidebar__nav .menu-list { margin-top: 45px;}

/* ── Nav icon ──────────────────────────────────────────────────────────── */
.nav-ico { flex-shrink: 0; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.nav-ico svg { width: 18px; height: 18px; }

/* ── Label collapse (max-width fade, no display:none) ─────────────────── */
.menu-list a .label,
.menu-label .label,
.bili-profile-label.label,
.bili-profile-link.label,
.bili-orgs-link .label,
.bili-logout-link.label {
  display: inline-block; overflow: hidden; white-space: nowrap;
  max-width: 150px; opacity: 1;
  transition: opacity .25s ease, max-width .42s cubic-bezier(.4,.01,.2,1);
}
.bili-sidebar.is-folded .menu-list a .label,
.bili-sidebar.is-folded .menu-label .label,
.bili-sidebar.is-folded .bili-profile-label.label,
.bili-sidebar.is-folded .bili-profile-link.label,
.bili-sidebar.is-folded .bili-orgs-link .label,
.bili-sidebar.is-folded .bili-logout-link.label { max-width: 0; opacity: 0; }

/* ── Icon rail — centre when folded ────────────────────────────────────── */
.bili-sidebar.is-folded .menu-list a { gap: 0; padding: 8px; justify-content: center; }
.bili-sidebar.is-folded .menu-list a .nav-ico { opacity: 1; }

/* ── Section header collapse — no dead gap ─────────────────────────────── */
.bili-sidebar.is-folded .menu-label {
  height: 0; padding: 0; overflow: hidden;
  opacity: 0;
  transition: height .42s cubic-bezier(.4,.01,.2,1), padding .42s cubic-bezier(.4,.01,.2,1), opacity .25s ease;
}

/* My organisations switcher (above the profile pill) */
.bili-sidebar__orgs { flex-shrink: 0; margin-top: 12px; }
.bili-orgs-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 12px;
  color: var(--bili-ink); text-decoration: none; font-size: 13px;
}
.bili-orgs-link:hover { background: rgba(255, 255, 255, 0.45); }
.bili-orgs-link.is-active { background: rgba(255, 255, 255, 0.55); }
.bili-orgs-link .nav-ico { flex-shrink: 0; }

/* Instance org switcher popup */
.bili-orgs-pop {
  margin: 6px 4px 0; padding: 6px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  max-height: 40vh; overflow: auto;
}
.bili-orgs-pop__item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-radius: 8px; text-decoration: none;
  color: var(--bili-ink); font-size: 12px;
}
.bili-orgs-pop__item:hover { background: rgba(255, 255, 255, 0.7); }
.bili-orgs-pop__item.is-current { background: oklch(66% 0.20 140 / 0.16); font-weight: 600; }
.bili-orgs-pop__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bili-orgs-pop__more {
  display: block; padding: 6px 8px; font-size: 12px;
  color: var(--bili-ink-2); text-decoration: none;
}
.bili-orgs-pop__more:hover { text-decoration: underline; }

/* User profile pill */
.bili-sidebar__profile {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 10px 12px; margin-top: 8px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
  font-size: 13px;
  color: var(--bili-ink);
}
.bili-profile-id { display: flex; align-items: center; gap: 9px; min-width: 0; }
.bili-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: oklch(58% 0.04 55);
  color: #fff; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; object-fit: cover;
}
.bili-avatar svg { display: block; }
.bili-profile-label {
  font-weight: 500;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.25;
}
.bili-profile-actions { display: flex; gap: 14px; padding-left: 41px; }
.bili-profile-link,
.bili-logout-link {
  color: var(--bili-ink-2) !important;
  font-size: 11px;
  text-decoration: none;
  opacity: 0.75;
}
.bili-profile-link:hover,
.bili-logout-link:hover { opacity: 1; }
.bili-profile-link.is-active { opacity: 1; font-weight: 600; }

/* ── Profile collapse ──────────────────────────────────────────────────── */
.bili-sidebar.is-folded .bili-sidebar__profile { gap: 0; padding: 9px 0 9px 5px; justify-content: center; }
.bili-sidebar.is-folded .bili-logout-link { margin-left: 0; }

/* ── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .bili-sidebar, .bili-sidebar.is-folded, .bili-logo, .bili-sidebar__tab,
  .bili-sidebar__profile, .menu-list a, .menu-label,
  .menu-list a .label, .menu-label .label,
  .bili-profile-label.label, .bili-logout-link.label {
    transition: none !important;
  }
}

/* ── No-load-animation gate ──────────────────────────────────────────────── */
.bili-sidebar:not(.bili-sidebar--ready),
.bili-sidebar:not(.bili-sidebar--ready) .bili-logo,
.bili-sidebar:not(.bili-sidebar--ready) .bili-sidebar__tab,
.bili-sidebar:not(.bili-sidebar--ready) .bili-sidebar__profile,
.bili-sidebar:not(.bili-sidebar--ready) .menu-list a,
.bili-sidebar:not(.bili-sidebar--ready) .menu-label,
.bili-sidebar:not(.bili-sidebar--ready) .menu-list a .label,
.bili-sidebar:not(.bili-sidebar--ready) .menu-label .label,
.bili-sidebar:not(.bili-sidebar--ready) .bili-profile-label.label,
.bili-sidebar:not(.bili-sidebar--ready) .bili-logout-link.label {
  transition: none !important;
}

/* ── MAIN (glass) ────────────────────────────────────────────────────────── */
.bili-main {
  display: flex; flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine), var(--glass-shadow);
  position: relative;
}
.bili-main::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 25%);
  pointer-events: none;
}

/* Page bar — the title, the section's top-level tabs, then the page's bar
   actions. Replaces the old breadcrumb bar. */
.bili-page-bar {
  flex-shrink: 0;
  min-height: var(--bili-page-bar-height);
  display: flex; align-items: center; gap: 25px;
  padding: 0 var(--bili-content-padding) 0 1.3em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.18);
  border-radius: 22px 22px 0 0;
}
.bili-page-title {
  flex: 0 0 auto;
  margin: 0;
  /* Same type as the in-content section titles (.title.is-4). */
  font-size: 1.4rem; font-weight: 500; letter-spacing: -0.01em;
  color: var(--bili-ink); white-space: nowrap;
}

/* The section's tabs fill the space the title does not. Same glass pill as
   before, tucked to fit the bar's height, scrolling sideways if they overflow. */
.bili-page-tabs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; }
.bili-page-tabs .tabs { margin: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.bili-page-tabs .tabs::-webkit-scrollbar { display: none; }
/* A shallower pill than the standalone .tabs, so the bar keeps 48px with room
   above and below. Segments match the .bo-seg view switcher (26px). */
.bili-page-tabs .tabs ul { flex-wrap: nowrap; padding: 3px; }
.bili-page-tabs .tabs li a { height: 26px; padding: 0 14px; font-size: 12.5px; }

.bili-page-bar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bili-page-bar__actions > * { margin: 0; }
.breadcrumb { margin: 0; font-size: 12px; }.breadcrumb a { color: var(--bili-ink-2); padding: 0 12px; }
.breadcrumb li:first-child a { padding-left: 0; }
.breadcrumb li.is-active a { color: var(--bili-ink); font-weight: 500; }
.breadcrumb ul { align-items: center; }
.breadcrumb li + li::before {
  content: '›';
  color: var(--bili-ink-2);
  font-size: 18px;
  font-weight: 500;
  padding: 0;
  opacity: 0.85;
  margin-top: -2px;
}

/* Content */
.bili-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--bili-content-padding);
  position: relative;
  /* Reserve gutter on both sides so the scrollbar doesn't push content off-centre */
  scrollbar-gutter: stable both-edges;
}

/* A page that fills the viewport exactly says so, so the content area does not
   add a second scrollbar for a few stray pixels. */
.bili-content--lock { overflow-y: hidden; }
@media (max-width: 1180px) {
  /* Below the split layout the page stacks and genuinely needs to scroll. */
  .bili-content--lock { overflow-y: auto; }
}

/* Flash region */
#flash-region { flex-shrink: 0; }
#flash-region .notification {
  margin: 14px var(--bili-content-padding) 0;
}

/* ── GLASS CARDS ─────────────────────────────────────────────────────────── */
.box, .glass-card {
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 22px 24px;
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    inset 0 -1px 2px rgba(255,255,255,0.15),
    var(--glass-shadow);
  position: relative;
  overflow: hidden;
}
.box::before, .glass-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 60%;
  background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 100%);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  pointer-events: none;
}
.box > *, .glass-card > * { position: relative; }
.box { margin-bottom: 20px; }

/* A .box that is itself the page frame — the provisioning interstitial has no
   .bili-main behind it — keeps its own blur. */
.bili-provisioning__card {
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

/* ── GLASS BUTTONS ───────────────────────────────────────────────────────── */
.button {
  font-family: var(--bili-font-family);
  border-radius: var(--r-pill);
  font-weight: 500;
  font-size: 13px;
  padding: 7px 16px;
  height: auto;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: var(--bili-ink);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 2px 6px rgba(40,25,15,0.08);
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.button:hover {
  background: rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.8),
    0 4px 12px rgba(40,25,15,0.12);
}
.button:active { transform: translateY(0); }
.button.is-small { font-size: 11px; padding: 5px 12px; }
.button.is-fullwidth { width: 100%; justify-content: center; }

.button.is-primary, .button.is-success {
  background: oklch(68% 0.20 140 / 0.85);
  border: 1px solid oklch(74% 0.16 140 / 0.5);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.35),
    0 2px 8px oklch(50% 0.16 140 / 0.28);
}
.button.is-primary:hover, .button.is-success:hover {
  background: oklch(66% 0.22 140 / 0.92);
}
.button.is-primary[disabled],
.button.is-primary.is-disabled,
fieldset[disabled] .button.is-primary {
  background: oklch(68% 0.20 140 / 0.42) !important;
  border-color: oklch(74% 0.16 140 / 0.3) !important;
  color: rgba(255,255,255,0.6) !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

.button.is-link {
  background: oklch(38% 0.10 140 / 0.88);
  border: 1px solid oklch(48% 0.09 140 / 0.45);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 2px 8px oklch(28% 0.08 140 / 0.28);
}

.button.is-danger {
  background: oklch(64% 0.19 25 / 0.85);
  border: 1px solid oklch(70% 0.15 25 / 0.5);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.28),
    0 2px 8px oklch(50% 0.16 25 / 0.28);
}
.button.is-danger.is-light {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid oklch(70% 0.15 25 / 0.4);
  color: oklch(45% 0.16 25);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.button.is-light {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  color: var(--bili-ink);
}

/* ── TAGS — tinted glass pills ───────────────────────────────────────────── */
.tag {
  border-radius: var(--r-pill-sm);
  font-size: 11px; font-weight: 500;
  padding: 4px 11px; height: auto;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: var(--bili-ink-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
  text-wrap: auto;
}
.tag.is-success { background: oklch(45% 0.12 140 / 0.85); border-color: oklch(55% 0.10 140 / 0.45); color: #fff; }
.tag.is-warning { background: oklch(76% 0.17 85 / 0.85);  border-color: oklch(82% 0.13 85 / 0.45);  color: var(--bili-gold-text); }
.tag.is-info    { background: oklch(58% 0.12 288 / 0.85); border-color: oklch(66% 0.10 288 / 0.45); color: #fff; }
.tag.is-danger  { background: oklch(64% 0.19 25 / 0.85);  border-color: oklch(72% 0.15 25 / 0.45);  color: #fff; }
.tag.is-primary { background: oklch(56% 0.12 138 / 0.85); border-color: oklch(64% 0.10 138 / 0.45); color: #fff; }
.tag.is-light   { background: rgba(255, 255, 255, 0.55); color: var(--bili-ink-2); }
.tag.is-dark    { background: oklch(28% 0.04 50 / 0.85); color: #fff; }

/* ── APPLE-STYLE SLIDE TOGGLE (liquid glass) ────────────────────────────── */
.bili-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bili-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.bili-toggle__track {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow:
    inset 0 1px 2px rgba(40, 25, 15, 0.12),
    inset 0 -1px 1px rgba(255, 255, 255, 0.5);
  transition: background 0.25s ease, border-color 0.25s ease;
}
.bili-toggle__input:checked + .bili-toggle__track {
  background: oklch(66% 0.20 140 / 0.88);
  border-color: oklch(68% 0.16 140 / 0.5);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.25),
    0 0 10px oklch(66% 0.20 140 / 0.25);
}
.bili-toggle__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    0 2px 4px rgba(40, 25, 15, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: transform 0.25s cubic-bezier(0.4, 0.0, 0.2, 1),
              background 0.25s ease;
}
.bili-toggle__input:checked + .bili-toggle__track .bili-toggle__knob {
  transform: translateX(18px);
  background: #fff;
  box-shadow:
    0 2px 6px rgba(40, 25, 15, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.bili-toggle__input:focus-visible + .bili-toggle__track {
  outline: 2px solid var(--bili-green-cta);
  outline-offset: 2px;
}
.bili-toggle:hover .bili-toggle__track {
  background: rgba(255, 255, 255, 0.45);
}
.bili-toggle__input:checked:hover + .bili-toggle__track {
  background: oklch(64% 0.22 140 / 0.92);
}

/* ── RACI split pill — segmented R/A/C/I counter ─────────────────────────── */
/* Compact horizontal pill with four equal-width coloured segments.
   Use case: job-functions list, anywhere RACI counts need to be compact.
   Mapping: R=green (success), A=gold (warning), C=purple (info), I=neutral.
   Zero counts auto-dim via the .zero modifier.                            */
:root {
  --raci-r-bg:  oklch(85% 0.10 140); --raci-r-ink: oklch(30% 0.09 140);
  --raci-a-bg:  oklch(88% 0.10 85);  --raci-a-ink: oklch(34% 0.10 85);
  --raci-c-bg:  oklch(88% 0.06 288); --raci-c-ink: oklch(34% 0.10 288);
  --raci-i-bg:  oklch(92% 0.012 60); --raci-i-ink: oklch(40% 0.012 60);
}
.raci-split {
  display: inline-flex;
  border-radius: var(--r-pill);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  height: 26px;
  font-variant-numeric: tabular-nums;
}
.raci-split > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  min-width: 52px;
  justify-content: center;
  border-right: 1px solid rgba(255,255,255,0.55);
}
.raci-split > span:last-child { border-right: 0; }
.raci-split > span .k { opacity: 0.65; font-weight: 400; }
.raci-split .r { background: var(--raci-r-bg); color: var(--raci-r-ink); }
.raci-split .a { background: var(--raci-a-bg); color: var(--raci-a-ink); }
.raci-split .c { background: var(--raci-c-bg); color: var(--raci-c-ink); }
.raci-split .i { background: var(--raci-i-bg); color: var(--raci-i-ink); }
.raci-split > span.zero { opacity: 0.4; }

/* ── TABS — glass pill segment control ───────────────────────────────────── */
/* Targets Bulma .tabs (incl. .is-boxed / .is-toggle / .is-fullwidth) and
   replaces the underline/box styling with a single rounded glass pill
   containing inset segment buttons. Sits flush above the content card
   below — works whether the card has a box border or not.                  */
.tabs {
  margin: 0 0 14px;
  font-size: 13px;
  overflow: visible;
  border: none;
}
.tabs ul {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  margin: 0;
  list-style: none;
  background: rgba(255, 255, 255, 0.32);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    0 2px 8px oklch(20% 0.04 50 / 0.06);
  border-bottom: 1px solid var(--glass-border); /* override Bulma's bottom border */
}
.tabs li { margin: 0; }
.tabs li a,
.tabs.is-boxed li a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border: 1px solid transparent; /* override Bulma's .is-boxed borders */
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--bili-ink-2);
  font-family: var(--bili-font-family);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  margin-bottom: 0; /* override Bulma's -1px nudge */
}
.tabs li a:hover,
.tabs.is-boxed li a:hover {
  background: rgba(255, 255, 255, 0.45);
  border-color: transparent;
  color: var(--bili-ink);
}
.tabs li.is-active a,
.tabs.is-boxed li.is-active a {
  background: oklch(28% 0.04 50 / 0.92);
  border-color: transparent;
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 1px 3px oklch(20% 0.04 50 / 0.18);
}
/* Optional icon glyph inside a tab */
.tabs li a .icon { color: inherit; }

/* Full-width variant: stretch each segment evenly */
.tabs.is-fullwidth ul { display: flex; width: 100%; }
.tabs.is-fullwidth li { flex: 1 1 0; }
.tabs.is-fullwidth li a { justify-content: center; }

/* Mobile: allow horizontal scroll if many tabs */
@media (max-width: 768px) {
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabs ul { flex-wrap: nowrap; }
}

/* ── TABLES ──────────────────────────────────────────────────────────────── */
.table {
  background: transparent;
  font-size: 13px;
  color: var(--bili-ink);
}
.table thead th {
  background: transparent;
  color: var(--bili-ink-2);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  padding: 10px 12px;
}
.table tbody td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  padding: 14px 12px;
  vertical-align: middle;
}
.table.is-hoverable tbody tr:hover { background: rgba(255, 255, 255, 0.18); }
.table.is-striped tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.12); }
.table tbody tr:last-child td { border-bottom: none; }
.table code {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.5);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--bili-ink);
}
.table strong { font-weight: 500; }

/* ── INPUTS ──────────────────────────────────────────────────────────────── */
.input, .textarea, .select select {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--r-md);
  font-family: var(--bili-font-family);
  color: var(--bili-ink);
  font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
  /* Bulma gives .input less vertical padding than .button, so a textbox beside a
     button (e.g. a has-addons search row) came out 3px shorter. Match .button's
     7px and let the height follow, so every control in a row agrees. */
  padding-top: 7px;
  padding-bottom: 7px;
  height: auto;
}
.input:focus, .textarea:focus, .select select:focus {
  border-color: rgba(255,255,255,0.85);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--bili-ink-3); }
.label { color: var(--bili-ink); font-weight: 500; font-size: 12px; }

/* ── TYPE / HEADINGS ─────────────────────────────────────────────────────── */
.title { color: var(--bili-ink); font-weight: 500; letter-spacing: -0.01em; margin-bottom: 0; }
.title.is-4 { font-size: 1.4rem; }
.title.is-6 { font-size: 0.95rem; }
.subtitle { color: var(--bili-ink-2); font-weight: 400; }
.level { margin-bottom: 20px; }

/* ── NOTIFICATION (glass) ────────────────────────────────────────────────── */
.notification {
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--bili-ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
  padding: 14px 18px;
}
.notification.is-success.is-light { background: oklch(85% 0.10 140 / 0.55); color: var(--bili-green-dark); }
.notification.is-warning.is-light { background: oklch(88% 0.10 85 / 0.55);  color: var(--bili-gold-text); }
.notification.is-danger.is-light  { background: oklch(80% 0.10 25 / 0.55);  color: oklch(40% 0.14 25); }
.notification.is-info.is-light    { background: oklch(86% 0.08 220 / 0.55); color: oklch(34% 0.06 220); }

/* ── PAGINATION ──────────────────────────────────────────────────────────── */
.pagination-link, .pagination-previous, .pagination-next {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: var(--r-md);
  color: var(--bili-ink);
  font-size: 12px;
}
.pagination-link.is-current {
  background: oklch(24% 0.025 50 / 0.9);
  border-color: oklch(20% 0.025 50);
  color: #fff;
}
.pagination-info {
  font-size: 11px; color: var(--bili-ink-3);
  margin-left: auto; align-self: center;
}

/* ── MODALS (glass) ──────────────────────────────────────────────────────── */
.modal.is-active { display: flex; }
.modal-background { background: rgba(40, 25, 15, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card {
  background: var(--glass-fill-2);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    var(--glass-shadow);
  overflow: hidden;
}
.modal-card-head, .modal-card-foot {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}
.modal-card-body { background: rgba(255, 255, 255, 0.18); }
.modal-card-title { color: var(--bili-ink); font-weight: 500; }

/* ── LINKS ───────────────────────────────────────────────────────────────── */
a { color: oklch(46% 0.14 268); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── SCROLLBARS ──────────────────────────────────────────────────────────── */
.bili-content::-webkit-scrollbar,
.bili-sidebar__nav::-webkit-scrollbar { width: 6px; }
.bili-content::-webkit-scrollbar-thumb,
.bili-sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.4);
  border-radius: 6px;
}
.bili-content::-webkit-scrollbar-track,
.bili-sidebar__nav::-webkit-scrollbar-track { background: transparent; }

/* ═══════════════════════════════════════════════════════════════════════════
   DASHBOARD WIDGETS — glass-styled
═════════════════════════════════════════════════════════════════════════════ */
.bili-dashboard-toolbar { margin-bottom: 1rem; }

.bili-dashboard-grid {
  position: relative;
  /* GridStack's item margin (bili-dashboard.js `margin: 12`) also insets the
     outer edge, so the canvas sat 12px inside the page title. Pull the grid out
     by that gutter so the outermost cards line up with the toolbar. */
  margin-inline: -12px;
}

/* Gridstack placeholder — match card's rounded corners */
.grid-stack-placeholder > .placeholder-content {
  border-radius: var(--r-lg);
}

/* Resize handle — "Cut Corner": a glass wedge nestled into the card's
   bottom-right corner like a polished bevel. The outer arc reuses --r-lg
   so it lines up exactly with .bili-card's corner; the inner edge is a
   large-radius curve that carves the petal shape.

   !important on width/height/transform/background-image is required
   because gridstack.min.css is loaded *after* this file (via the
   {% block head %} expansion in dashboards/view.html) and so its same-
   specificity defaults would otherwise win the cascade. */
.grid-stack-item > .ui-resizable-se {
  /* gridstack.min.css declares position:absolute but no edge offsets — JS
     pins it at runtime. We set them here too so the handle lands in the
     right place regardless of init order or test/preview contexts. */
  right: 0;
  bottom: 0;
  width: 28px !important;
  height: 28px !important;
  transform: none !important;
  /* !important on the shorthand both suppresses gridstack's
     default SVG background-image and lets our gradient paint. */
  background:
    linear-gradient(135deg,
      rgba(255, 255, 255, 0.00) 20%,
      rgba(255, 255, 255, 0.55) 55%,
      rgba(255, 255, 255, 0.92) 100%) !important;
  border-top-left-radius: 28px;     /* full-size radius carves the inner petal curve */
  border-bottom-right-radius: var(--r-lg);  /* matches .bili-card's own corner */
  box-shadow:
    inset -1px -1px 0 rgba(255, 255, 255, 0.92),
    inset  2px  2px 3px rgba(60, 40, 25, 0.10);
  filter: drop-shadow(0 1px 2px rgba(40, 25, 15, 0.12));
  transition: filter 0.18s ease, transform 0.18s ease;
}
.grid-stack-item > .ui-resizable-se:hover {
  filter: drop-shadow(0 2px 5px rgba(40, 25, 15, 0.20)) brightness(1.04);
}
/* Two short diagonal grip ticks etched into the wedge */
.grid-stack-item > .ui-resizable-se::after {
  content: '';
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: 52% 52%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'><g stroke='rgba(50,32,20,0.6)' stroke-width='1.8' stroke-linecap='round'><line x1='15' y1='22' x2='22' y2='15'/><line x1='18' y1='24' x2='24' y2='18'/></g></svg>");
}

/* Dashboard card — same glass treatment as .box but tighter padding for widgets */
.bili-card {
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    var(--glass-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.bili-card:hover {
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    0 14px 50px oklch(20% 0.04 50 / 0.22),
    0 4px 12px oklch(20% 0.04 50 / 0.10);
}
.bili-card--ghost {
  opacity: 0.5;
  background: rgba(255, 255, 255, 0.18);
}
.bili-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.20);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.bili-card__header:active { cursor: grabbing; }
.bili-card__title {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--bili-ink-2);
  letter-spacing: 0.02em;
}
.bili-card__actions {
  display: flex;
  gap: 0.3rem;
}
.bili-card__actions .button {
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1;
}
.bili-card__actions .bili-card__config {
  display: inline-flex;
  align-items: center;
  padding: 3px 6px;
}
.bili-card__actions .bili-card__config svg { display: block; }
/* The remove control appears only while the title bar is hovered (or the button
   is focused), so it doesn't clutter the card. Touch devices always show it. */
.bili-card__actions .bili-card__remove {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.bili-card__header:hover .bili-card__remove,
.bili-card__actions .bili-card__remove:focus-visible {
  opacity: 1;
  pointer-events: auto;
}
@media (hover: none) {
  .bili-card__actions .bili-card__remove { opacity: 1; pointer-events: auto; }
}
.bili-card__body {
  flex: 1;
  overflow: auto;
  padding: 0.75rem 0.9rem;
  position: relative;
  scrollbar-gutter: stable;
}
.bili-card__body canvas { max-height: 200px; }

/* Top task card */
.bili-top-task { padding: 0.4rem 0; }

/* Task list card */
.bili-task-list table { margin-bottom: 0; }
.bili-task-feed-item { border-bottom: 1px solid rgba(255, 255, 255, 0.35); padding: 0.6rem 0; }
.bili-task-feed-item:last-child { border-bottom: none !important; }

/* === Playbook status / attention card === */
.bili-attention--clear {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid color-mix(in oklch, var(--bili-green-cta) 35%, transparent);
  border-radius: var(--r-md);
  background: color-mix(in oklch, var(--bili-green-cta) 10%, transparent);
}
.bili-attention__clear-icon {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  display: grid;
  place-items: center;
  border-radius: 9999px;
  background: var(--bili-green-cta);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}
.bili-attention__score { color: var(--bili-ink-3); }
.bili-attention__item {
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.55rem 0;
}
.bili-attention__item:first-of-type { border-top: none; }
.bili-attention__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.bili-attention__tags { flex-shrink: 0; }
.bili-attention__risk { margin-top: 0.15rem; }
.bili-attention__owner { margin-top: 0.2rem; color: var(--bili-ink-3); }
.bili-attention__mine { color: var(--bili-green-dark); font-weight: 600; }
.bili-attention__guidance { margin-top: 0.35rem; }
.bili-attention__guidance summary {
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--bili-ink-2);
}
.bili-attention__guidance-body {
  white-space: pre-wrap;
  font-size: 0.72rem;
  color: var(--bili-ink-2);
  padding: 0.4rem 0.6rem;
  margin-top: 0.3rem;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.30);
}
.bili-attention__others { margin-top: 0.4rem; }
.bili-attention__others summary {
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--bili-ink-2);
}
.bili-attention--pending { padding: 0.4rem 0; }

/* Upload zone */
.bili-upload-zone {
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: var(--r-md);
  padding: 1.4rem 1rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.2);
  transition: border-color 0.2s ease, background 0.2s ease;
  cursor: pointer;
}
.bili-upload-zone--active,
.bili-upload-zone:hover {
  border-color: oklch(66% 0.15 140 / 0.7);
  background: oklch(85% 0.08 140 / 0.25);
}
.bili-upload-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.5rem 0;
}
.bili-upload-item:last-child { border-bottom: none; }

/* Progress bar — glass-flavoured */
.bili-progress-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 80px;
}
.bili-progress-wrapper progress {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  border: none;
  background: rgba(255, 255, 255, 0.4);
  overflow: hidden;
}
.bili-progress-wrapper progress::-webkit-progress-bar { background: rgba(255, 255, 255, 0.4); border-radius: 4px; }
.bili-progress-wrapper progress::-webkit-progress-value { background: var(--bili-green-cta); border-radius: 4px; }
.bili-progress-wrapper progress::-moz-progress-bar { background: var(--bili-green-cta); border-radius: 4px; }
.bili-progress-label {
  font-size: 0.75rem;
  min-width: 32px;
  text-align: right;
  color: var(--bili-ink-2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   ORGANISATION PICKER
═════════════════════════════════════════════════════════════════════════════ */
.bili-org-picker {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 8px 40px;
}
.bili-org-picker__hero {
  margin-bottom: 28px;
  text-align: center;
}
.bili-org-picker__hero h1 {
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--bili-ink);
  letter-spacing: -0.015em;
  margin-bottom: 8px;
}
.bili-org-picker__hero p {
  font-size: 14px;
  color: var(--bili-ink-2);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.5;
}

.bili-org-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.bili-org-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 22px 22px 20px;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    var(--glass-shadow);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none;
  color: inherit;
  min-height: 168px;
}
.bili-org-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 60%;
  background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 100%);
  pointer-events: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.bili-org-card:hover {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    0 18px 50px oklch(20% 0.04 50 / 0.22),
    0 4px 14px oklch(20% 0.04 50 / 0.12);
  text-decoration: none;
}
/* Keep the card focused while the pointer is over its menu button/dropdown
   (both are siblings of the card, so the card's own :hover no longer matches). */
.bili-org-card-wrap:hover .bili-org-card:not(.bili-org-card--resume),
.bili-org-card-wrap.is-menu-open .bili-org-card:not(.bili-org-card--resume) {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    0 18px 50px oklch(20% 0.04 50 / 0.22),
    0 4px 14px oklch(20% 0.04 50 / 0.12);
  text-decoration: none;
}

.bili-org-card__avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: oklch(58% 0.04 55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
  flex-shrink: 0;
  margin-bottom: 14px;
  box-shadow: 0 4px 10px rgba(40,25,15,0.18);
  position: relative;
}
/* Per-card accent palette (rotated via :nth-child) */
.bili-org-card:nth-child(3n+1) .bili-org-card__avatar { background: oklch(50% 0.13 140); }
.bili-org-card:nth-child(3n+2) .bili-org-card__avatar { background: oklch(54% 0.12 288); }
.bili-org-card:nth-child(3n+3) .bili-org-card__avatar { background: oklch(54% 0.13 25); }

.bili-org-card__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--bili-ink);
  margin-bottom: 4px;
  line-height: 1.3;
  position: relative;
}
.bili-org-card__role {
  font-size: 12px;
  color: var(--bili-ink-2);
  margin-bottom: 14px;
  position: relative;
}
.bili-org-card__cta {
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 12px;
  color: oklch(46% 0.14 140);
  font-weight: 500;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.bili-org-card:hover .bili-org-card__cta {
  opacity: 1;
  transform: translateX(0);
}
.bili-org-card-wrap:hover .bili-org-card__cta,
.bili-org-card-wrap.is-menu-open .bili-org-card__cta {
  opacity: 1;
  transform: translateX(0);
}

/* "Onboard a new organisation" card */
.bili-org-card--new {
  background: rgba(255, 255, 255, 0.30);
  border: 2px dashed rgba(255, 255, 255, 0.6);
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 168px;
}
.bili-org-card--new::before { display: none; }
.bili-org-card--new .bili-org-card__avatar {
  background: linear-gradient(135deg, var(--bili-cream) 0%, oklch(82% 0.13 85) 100%);
  color: var(--bili-gold-text);
  font-size: 22px;
  margin-bottom: 12px;
}
.bili-org-card--new .bili-org-card__name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}
.bili-org-card--new p {
  font-size: 12px;
  color: var(--bili-ink-2);
  max-width: 220px;
}
.bili-org-card--new:hover {
  border-color: oklch(72% 0.16 85);
  background: oklch(94% 0.06 85 / 0.4);
}

.bili-org-card--resume {
  background: rgba(255, 255, 255, 0.30);
  border: 2px solid oklch(78% 0.14 80);
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 168px;
}
.bili-org-card--resume::before { display: none; }
.bili-org-card--resume .bili-org-card__avatar {
  background: oklch(50% 0.13 140);
  color: #fff;
  font-size: 22px;
  margin-bottom: 12px;
  align-self: center;
}
.bili-org-card--resume .bili-org-card__name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}
.bili-org-card--resume .bili-org-card__company {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--bili-ink-2);
  margin-top: 2px;
}
.bili-org-card--resume p {
  font-size: 12px;
  color: oklch(55% 0.12 65);
  max-width: 220px;
}
.bili-org-card--resume:hover {
  border-color: oklch(68% 0.16 75);
  background: oklch(92% 0.06 80 / 0.4);
}
.bili-org-card__resume-content {
  width: 100%; display: flex; flex-direction: column; align-items: center;
}

/* Three-dot menu & type-to-confirm delete */
.bili-org-card-wrap {
  position: relative;
}
.bili-org-card__menu-btn {
  position: absolute;
  bottom: 15px;
  right: 15px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--bili-ink-3);
  opacity: 0;
  transition: opacity 0.18s ease, background 0.18s ease;
  z-index: 5;
}
.bili-org-card-wrap:hover .bili-org-card__menu-btn {
  opacity: 1;
}
.bili-org-card-wrap.is-menu-open .bili-org-card__menu-btn {
  opacity: 1;
}
.bili-org-card__menu-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--bili-ink);
}
.bili-org-card__dropdown {
  position: absolute;
  bottom: 47px;
  right: 15px;
  min-width: 180px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 4px;
  z-index: 20;
}
.bili-org-card__dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none; background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--bili-red);
  white-space: nowrap;
}
.bili-org-card__dropdown-item:hover {
  background: color-mix(in oklab, var(--bili-red) 10%, white);
}
.bili-org-card__dropdown-item--action {
  color: var(--bili-ink);
}
.bili-org-card__dropdown-item--action:hover {
  background: rgba(0,0,0,0.06);
}
.bili-org-card__confirm {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.bili-org-card__confirm-title {
  font-size: 12px;
  color: var(--bili-ink-2);
  margin: 0;
  line-height: 1.3;
  text-align: center;
}
.bili-org-card__confirm-title strong {
  color: var(--bili-ink);
}
.bili-org-card__confirm-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--glass-border, #ddd);
  border-radius: 6px;
  outline: none;
  text-align: center;
  box-sizing: border-box;
}
.bili-org-card__confirm-input:focus {
  border-color: var(--bili-red);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--bili-red) 20%, transparent);
}
.bili-org-card__confirm-actions {
  display: flex;
  gap: 6px;
  width: 100%;
}
.bili-org-card__confirm-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.bili-org-card__confirm-btn--delete {
  background: var(--bili-red);
  color: #fff;
}
.bili-org-card__confirm-btn--delete:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.bili-org-card__confirm-btn--delete:not(:disabled):hover {
  filter: brightness(1.1);
}
.bili-org-card__confirm-btn--cancel {
  background: transparent;
  color: var(--bili-ink-2);
}
.bili-org-card__confirm-btn--cancel:hover {
  background: rgba(0,0,0,0.06);
}

/* Search row above the grid */
.bili-org-picker__filter {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.bili-org-picker__filter .input { flex: 1; }
.bili-org-picker__filter .count {
  font-size: 12px;
  color: var(--bili-ink-3);
  white-space: nowrap;
}

/* ── CORNER TOAST ────────────────────────────────────────────────────────── */
.bili-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.bili-toast-container.is-hidden {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}
.bili-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  /* Floats over the raw page background, not on a blurred frame — so it
     needs its own near-opaque fill now that it has no backdrop-filter. */
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  padding: 10px 18px;
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    0 8px 30px oklch(20% 0.04 50 / 0.22);
  font-size: 13px;
  font-weight: 500;
  color: var(--bili-ink);
}
.bili-toast__icon {
  color: var(--bili-green-cta);
  font-size: 16px;
  flex-shrink: 0;
}
.bili-toast__text {
  white-space: nowrap;
}

/* ── TIER TOGGLE PILLS ──────────────────────────────────────────────────── */
.tag.tier-toggle {
  cursor: pointer;
  transition: background 0.2s ease, transform 0.12s ease;
  user-select: none;
}
.tag.tier-toggle:hover {
  transform: translateY(-1px);
}
.tag.tier-toggle.is-light:hover {
  background: rgba(255, 255, 255, 0.7);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE (≤ 768px)
═════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  body { overflow: auto; }

  .bili-layout {
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    height: 100vh;
  }

  /* Top bar with hamburger */
  .bili-mobile-topbar {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: var(--bili-topbar-height);
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.42);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 1px 8px rgba(40,25,15,0.08);
    z-index: 100;
    position: relative;
  }
  .bili-mobile-topbar .hamburger {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--r-md);
    width: 36px; height: 36px;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    color: var(--bili-ink);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .bili-mobile-topbar .hamburger:active { background: rgba(255, 255, 255, 0.7); }
  .bili-mobile-topbar .page-title {
    flex: 1;
    text-align: center;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--bili-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 36px; /* balance the hamburger so title stays centred */
  }

  /* Sidebar — slides in from left */
  .bili-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 270px;
    height: 100vh;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 8px 0 30px rgba(40,25,15,0.25);
  }
  .bili-sidebar.is-open { transform: translateX(0); }

  /* Overlay behind opened sidebar */
  .bili-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(40,25,15,0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    transition: opacity 0.3s ease;
  }
  .bili-sidebar-overlay.is-visible { display: block; }

  /* Main content fills the rest */
  .bili-main {
    flex: 1;
    border-radius: 0;
    border: none;
    background: rgba(255, 255, 255, 0.25);
  }
  .bili-main::before { display: none; }

  /* Page bar: the title sits above the (scrollable) tab row on small screens. */
  .bili-page-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px var(--bili-content-padding-mobile);
  }
  .bili-page-title { font-size: 1.15rem; }
  .bili-page-tabs { flex-basis: 100%; }

  .bili-content {
    padding: var(--bili-content-padding-mobile);
  }
  #flash-region .notification {
    margin: 12px var(--bili-content-padding-mobile) 0;
  }

  /* Single-column grid on mobile */
  .bili-dashboard-grid > .grid-stack-item {
    width: 100% !important;
    left: 0 !important;
  }

  .bili-task-detail .columns { flex-direction: column; }

  /* Slightly smaller padding inside box on mobile */
  .box, .glass-card { padding: 16px 18px; }

  /* Mobile-friendly level (stack rows on small screens) */
  .level { display: block; }
  .level-left, .level-right { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
  .level-item { margin: 0; }

  .bili-toast-container {
    right: 12px;
    bottom: 16px;
  }
}
/* ───────────────────────────────────────────────────────────────────────────
   Document-upload redesign — new components, layered on top of app.css
   Everything here is namespaced .dt-* so it can be lifted into the real
   stylesheet without collisions.
─────────────────────────────────────────────────────────────────────────── */

.dt-page {
  margin: 0 auto;
  padding-bottom: 2.5rem;
  /* The chat page fills the content area exactly. Sizing the grid from the
     viewport instead (calc(100vh - 180px)) overflowed the content box by ~35px,
     which is what left the page itself scrollable. */
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Glass card primitive (mirrors .box but with our own hook) ───────────── */
.dt-card {
  position: relative;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    0 1px 2px rgba(60, 40, 20, 0.05),
    0 12px 34px rgba(60, 40, 20, 0.10);
  padding: 22px 24px;
}
.dt-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 56%;
  background: linear-gradient(180deg, rgba(255,255,255,0.30) 0%, transparent 100%);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  pointer-events: none;
}
.dt-card > * { position: relative; }

.dt-card__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: 4px;
}
.dt-card__title {
  font-size: 1.05rem; font-weight: 500; letter-spacing: -0.01em;
  color: var(--bili-ink);
}
.dt-card__sub {
  font-size: 0.82rem; color: var(--bili-ink-3); margin: 2px 0 0;
}
.dt-card__count {
  font-size: 0.78rem; font-weight: 500; color: var(--bili-ink-2);
  white-space: nowrap;
}

/* ── Step progress header ───────────────────────────────────────────────── */
.dt-progress {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 1.4rem;
}
.dt-progress__steps {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.78rem; font-weight: 500; color: var(--bili-ink-2);
  white-space: nowrap;
}
.dt-progress__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
.dt-progress__dot.is-done { background: var(--bili-green-cta); border-color: transparent; }
.dt-progress__dot.is-active {
  background: var(--bili-green-cta);
  box-shadow: 0 0 0 4px oklch(66% 0.22 140 / 0.18);
}
.dt-progress__track {
  flex: 1; height: 8px; border-radius: 999px;
  background: rgba(255,255,255,0.42);
  border: 1px solid rgba(255,255,255,0.5);
  overflow: hidden;
}
.dt-progress__fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--bili-sage), var(--bili-green-cta));
  transition: width 0.6s cubic-bezier(.2,.7,.2,1);
}
.dt-progress__label { font-size: 0.78rem; color: var(--bili-ink-3); white-space: nowrap; }
.dt-progress__caption {
  display: none;
}

/* ── Per-item progress list (Playbook Generator) ────────────────────────── */
.pg-item-list { margin-top: 4px; max-height: 260px; overflow-y: auto; }
.pg-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; line-height: 1.25;
  padding: 2px 6px;
  color: var(--bili-ink-2);
}
.pg-item__icon { width: 1em; text-align: center; flex-shrink: 0; color: var(--bili-ink-3); }
.pg-item__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-item__tokens { color: var(--bili-ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pg-item__err { color: var(--bili-red); font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-item--done .pg-item__icon { color: var(--bili-green-cta); }
.pg-item--failed .pg-item__icon { color: var(--bili-red); }
.pg-item--failed .pg-item__name { color: var(--bili-red); }
.pg-item--more { color: var(--bili-ink-3); font-style: italic; }

/* ── Sidebar onboarding journey ─────────────────────────────────────────── */
.dt-journey { display: flex; flex-direction: column; padding: 4px 2px; }
.dt-journey__title {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--bili-ink-3);
  padding: 0 10px 14px;
}
.dt-jstep { display: flex; gap: 12px; padding: 0 10px; }
.dt-jstep__rail { display: flex; flex-direction: column; align-items: center; }
.dt-jstep__marker {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 600;
  background: rgba(255,255,255,0.45);
  border: 1.5px solid rgba(255,255,255,0.6);
  color: var(--bili-ink-3);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
.dt-jstep__marker svg { width: 13px; height: 13px; }
.dt-jstep__line {
  width: 2px; flex: 1; min-height: 16px; margin: 3px 0;
  background: rgba(150,120,90,0.22); border-radius: 2px;
}
.dt-jstep__body { padding-bottom: 16px; padding-top: 3px; }
.dt-jstep__label { font-size: 0.88rem; font-weight: 500; color: var(--bili-ink-2); line-height: 1.25; }
.dt-jstep__meta { font-size: 0.72rem; color: var(--bili-ink-3); margin-top: 2px; }

/* done — green, clickable to go back */
.dt-jstep--done .dt-jstep__marker {
  background: var(--bili-green-cta); border-color: transparent; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 1px 3px oklch(50% 0.16 140 / 0.3);
}
.dt-jstep--done .dt-jstep__line { background: var(--bili-green-cta); opacity: 0.55; }
.dt-jstep--done .dt-jstep__label { color: var(--bili-ink); }
.dt-jstep--done { cursor: pointer; border-radius: 10px; transition: background 0.15s ease; }
.dt-jstep--done:hover { background: rgba(255,255,255,0.34); }
.dt-jstep--done:hover .dt-jstep__meta::after { content: " · go back"; color: var(--bili-green-dark); }

/* current — accent ring, emphasised */
.dt-jstep--current .dt-jstep__marker {
  background: var(--bili-green-cta); border-color: transparent; color: #fff;
  box-shadow: 0 0 0 4px oklch(66% 0.22 140 / 0.18);
}
.dt-jstep--current .dt-jstep__label { color: var(--bili-ink); font-weight: 600; }
.dt-jstep--current .dt-jstep__meta { color: var(--bili-green-dark); font-weight: 500; }

/* upcoming — locked, muted */
.dt-jstep--upcoming .dt-jstep__marker { color: var(--bili-ink-3); opacity: 0.7; }
.dt-jstep--upcoming .dt-jstep__label,
.dt-jstep--upcoming .dt-jstep__meta { opacity: 0.6; }

/* ── Intro ──────────────────────────────────────────────────────────────── */
.dt-intro { margin-bottom: 1.5rem; max-width: 52rem; }
.dt-intro h1 {
  font-size: 1.7rem; font-weight: 500; letter-spacing: -0.015em;
  color: var(--bili-ink); margin: 0 0 0.4rem; line-height: 1.2;
}
.dt-intro p {
  font-size: 0.98rem; color: var(--bili-ink-2); line-height: 1.55; margin: 0;
  text-wrap: pretty;
}
.dt-intro strong { font-weight: 500; color: var(--bili-ink); }

/* ── Layout grid (slots arranged per variant) ───────────────────────────── */
.dt-grid { display: grid; gap: 20px; align-items: start; }
.dt-slot--activity { display: none; }

/* Right-hand column: upload + (live) activity + privacy, stacked */
.dt-railcol { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* Variant A — Split: checklist | right column */
.layout-split.dt-grid {
  grid-template-columns: minmax(0,1.08fr) minmax(0,0.92fr);
}
.layout-split .dt-railcol { position: sticky; top: 4px; }

/* Variant B — Upload hero on top, checklist (2-col rows) below */
.layout-hero.dt-grid {
  grid-template-columns: 1fr;
  gap: 18px;
}
.layout-hero .dt-railcol { order: -1; }
.layout-hero .dt-checklist { columns: 2; column-gap: 28px; }
.layout-hero .dt-cat { break-inside: avoid; }
.layout-hero .dt-upload__drop { padding: 30px 22px; }

/* Variant C — Guided rail: narrow checklist spine | right column */
.layout-rail.dt-grid {
  grid-template-columns: 304px minmax(0,1fr);
  gap: 18px;
}
.layout-rail .dt-slot--checklist { position: sticky; top: 4px; }
/* Activity panel is hidden until processing starts (toggled by JS .is-visible) */
.dt-slot--activity.is-visible { display: block; animation: dt-chip-in 0.35s cubic-bezier(.2,.7,.2,1); }
.dt-slot--activity.is-leaving { animation: dt-fade-out 0.35s ease forwards; }
@keyframes dt-fade-out { to { opacity: 0; transform: translateY(8px); } }
/* Rail checklist header: stack so the count never collides with the title */
.layout-rail .dt-slot--checklist .dt-card__head { flex-direction: column; align-items: flex-start; gap: 4px; }
.layout-rail .dt-slot--checklist .dt-card__count {
  order: -1; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--bili-ink-3);
}
/* Rail activity panel: a "live" pulse on the status while processing */
.dt-activity__status { display: inline-flex; align-items: center; gap: 9px; }
.dt-activity.is-processing .dt-activity__status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bili-green-cta);
  box-shadow: 0 0 0 0 oklch(66% 0.22 140 / 0.5);
  animation: dt-pulse 1.8s ease-out infinite;
}
@keyframes dt-pulse {
  0% { box-shadow: 0 0 0 0 oklch(66% 0.22 140 / 0.45); }
  70% { box-shadow: 0 0 0 7px oklch(66% 0.22 140 / 0); }
  100% { box-shadow: 0 0 0 0 oklch(66% 0.22 140 / 0); }
}
@media (prefers-reduced-motion: reduce) {
  .dt-activity.is-processing .dt-activity__status::before { animation: none; }
}
.layout-rail .dt-card { padding: 18px 18px; }
.layout-rail .dt-cat__value { display: none; }
.layout-rail .dt-cat { padding: 8px 8px; }

/* (slots flow naturally inside .dt-grid / .dt-railcol — no grid-area mapping) */

/* ── Checklist ──────────────────────────────────────────────────────────── */
.dt-checklist { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }

.dt-cat {
  border-radius: var(--r-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.16s ease;
  border: 1px solid transparent;
}
.dt-cat:hover { background: rgba(255,255,255,0.34); }
.dt-cat.is-open { background: rgba(255,255,255,0.40); border-color: rgba(255,255,255,0.5); }

.dt-cat__row { display: flex; align-items: center; gap: 12px; }

/* status mark */
.dt-mark {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; line-height: 1;
}
.dt-mark--found {
  background: var(--bili-green-cta);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 1px 3px oklch(50% 0.16 140 / 0.35);
}
.dt-mark--partial {
  background: oklch(76% 0.17 85 / 0.9);
  color: oklch(34% 0.10 85);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}
.dt-mark--empty {
  background: rgba(255,255,255,0.35);
  border: 1.5px dashed var(--bili-ink-3);
  color: transparent;
}

.dt-cat__main { flex: 1; min-width: 0; }
.dt-cat__label {
  font-size: 0.92rem; font-weight: 500; color: var(--bili-ink);
  display: flex; align-items: center; gap: 8px;
}
.dt-pending {
  font-size: 0.65rem; font-weight: 500; color: var(--bili-ink);
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine);
  padding: 0 8px; border-radius: 99px;
  line-height: 1.6;
}
.dt-pending.has-error {
  border-color: oklch(58% 0.22 25);
  background: oklch(92% 0.06 25 / 0.3);
}
.dt-cat__value {
  font-size: 0.82rem; color: var(--bili-ink-2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dt-cat__value.is-empty { color: var(--bili-ink-3); font-style: italic; }

.dt-cat__right { display: flex; align-items: center; gap: 10px; flex: none; }
.dt-chev {
  font-size: 19px; font-weight: 600; color: var(--bili-ink-2);
  line-height: 1;
  transition: transform 0.2s ease, color 0.15s ease; transform: rotate(0deg);
}
.dt-cat:hover .dt-chev { color: var(--bili-ink); }
.dt-cat.is-open .dt-chev { transform: rotate(180deg); }

/* confidence cue */
/* confidence cue — gold stars: ★ Good / ★★ Great */
.dt-conf {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; font-weight: 500;
  color: var(--bili-ink-2);
}
.dt-conf__stars {
  display: inline-flex; gap: 1px; align-items: center;
  font-size: 0.86rem; line-height: 1; color: var(--bili-gold);
  letter-spacing: 0.5px;
}

/* expanded detail keys */
.dt-keys {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.24s ease;
}
.dt-cat.is-open .dt-keys { grid-template-rows: 1fr; }
.dt-keys__inner { overflow: hidden; }
.dt-keys__list { padding: 10px 0 4px 34px; display: flex; flex-direction: column; gap: 1px; }
.dt-key {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 8px; border-radius: 7px;
  font-size: 0.8rem;
}
.dt-key + .dt-key { border-top: 1px solid rgba(255,255,255,0.4); }
.dt-key__dot { flex: none; width: 6px; height: 6px; border-radius: 50%; margin-top: 6px; }
.dt-key__dot--found   { background: var(--bili-green-cta); }
.dt-key__dot--partial { background: var(--bili-gold); }
.dt-key__dot--empty   { background: var(--bili-ink-3); opacity: 0.4; }
.dt-key__main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dt-key__label { font-size: 0.72rem; color: var(--bili-ink-3); }
.dt-key__val { color: var(--bili-ink); font-weight: 500; line-height: 1.3; text-wrap: pretty; }
.dt-key__val.is-empty { color: var(--bili-ink-3); font-weight: 400; font-style: italic; }

/* ── Upload panel ───────────────────────────────────────────────────────── */
.dt-upload__drop {
  margin-top: 14px;
  border: 2px dashed rgba(150,120,90,0.4);
  border-radius: var(--r-lg);
  background: rgba(255,255,255,0.18);
  padding: 26px 22px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.dt-upload__drop:hover { border-color: oklch(66% 0.15 140 / 0.7); background: oklch(85% 0.08 140 / 0.22); }
.dt-upload__drop.is-drag {
  border-color: var(--bili-green-cta);
  background: oklch(85% 0.10 140 / 0.32);
  transform: scale(1.01);
}
.dt-upload__icon {
  width: 46px; height: 46px; margin: 0 auto 12px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 4px 12px rgba(60,40,20,0.08);
  color: var(--bili-ink);
}
.dt-upload__icon svg { width: 22px; height: 22px; }
.dt-upload__head { font-size: 0.98rem; font-weight: 500; color: var(--bili-ink); margin: 0 0 3px; }
.dt-upload__sub { font-size: 0.82rem; color: var(--bili-ink-3); margin: 0 0 14px; }
.dt-upload__btn-row { display: flex; justify-content: center; }
.dt-upload__types {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin-top: 14px;
}
.dt-upload__reassure {
  margin: 16px 0 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--bili-green-dark);
}
.dt-upload__reassure::after { content: none; }
.dt-type {
  font-size: 0.68rem; font-weight: 500; color: var(--bili-ink-2);
  background: rgba(255,255,255,0.42);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 7px; padding: 3px 9px;
}

/* file chips */
.dt-chips { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.dt-chips:empty { display: none; }
.dt-chip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.40);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.dt-chip.htmx-added {
  animation: dt-chip-in 0.32s cubic-bezier(.2,.7,.2,1);
}
@keyframes dt-chip-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dt-chip__icon {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: oklch(64% 0.19 25 / 0.14);
  color: oklch(48% 0.18 25);
  font-size: 0.6rem; font-weight: 600; letter-spacing: 0.03em;
}
.dt-chip__body { flex: 1; min-width: 0; }
.dt-chip__name {
  font-size: 0.86rem; font-weight: 500; color: var(--bili-ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dt-chip__status { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.dt-chip__bar {
  flex: 1; height: 5px; border-radius: 999px;
  background: rgba(150,120,90,0.18); overflow: hidden;
}
.dt-chip__bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--bili-sage), var(--bili-green-cta));
  border-radius: 999px; transition: width 0.5s ease;
}
/* Pending state — shimmer to signal queued */
.dt-chip.is-pending .dt-chip__bar > i {
  width: 18%;
  background: linear-gradient(90deg, transparent, rgba(150,120,90,0.35), transparent);
  background-size: 200% 100%;
  animation: dt-shimmer 1.6s ease-in-out infinite;
}
@keyframes dt-shimmer {
  0%   { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}
.dt-chip__state {
  font-size: 0.72rem; color: var(--bili-ink-2); white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
}
.dt-chip__state .dt-spin {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid rgba(120,90,60,0.25); border-top-color: var(--bili-sage);
  animation: dt-spin 0.7s linear infinite;
}
@keyframes dt-spin { to { transform: rotate(360deg); } }
.dt-chip.is-done .dt-chip__state { color: var(--bili-green-dark); }
.dt-chip.is-failed .dt-chip__state { color: oklch(48% 0.18 30); }
.dt-chip.is-failed .dt-chip__bar > i { background: oklch(68% 0.20 30 / 0.5); width: 100%; }
.dt-chip__remove {
  flex: none; background: transparent; border: none; cursor: pointer;
  color: var(--bili-ink-3); font-size: 16px; line-height: 1; padding: 2px 4px;
  border-radius: 6px;
}
.dt-chip__remove:hover { background: rgba(255,255,255,0.5); color: var(--bili-ink); }

/* Admin toggle on chips */
.dt-chip__admin-toggle {
  flex: none; background: transparent; border: none; cursor: pointer;
  color: var(--bili-ink-3); font-size: 14px; line-height: 1; padding: 4px 6px;
  border-radius: 6px; opacity: 0.5; transition: opacity 0.2s;
}
.dt-chip__admin-toggle:hover { opacity: 1; background: rgba(255,255,255,0.4); }
.dt-chip__admin-toggle.is-active { opacity: 1; color: var(--bili-gold); }
.dt-chip__detail-wrap {
  flex: 0 0 100%; margin-top: 4px; padding-top: 10px;
  border-top: 1px solid rgba(150,120,90,0.15);
}
.dt-chip__detail-placeholder { font-size: 0.78rem; color: var(--bili-ink-3); display: flex; align-items: center; gap: 8px; }
.dt-chip__detail {
  font-size: 0.78rem; color: var(--bili-ink-2);
}
.dt-chip__detail-section { margin-bottom: 10px; }
.dt-chip__detail-section--last { margin-bottom: 0; }
.dt-chip__detail-title {
  font-weight: 600; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--bili-ink-3); margin-bottom: 4px;
}
/* Softer label variant (replaces uppercase title in detail panel) */
.dt-chip__detail-label {
  font-weight: 600; font-size: 0.7rem; color: var(--bili-ink-3);
  margin-bottom: 5px; display: flex; align-items: center; gap: 6px;
}
.dt-chip__detail-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; font-size: 0.6rem; font-weight: 600;
  background: rgba(150,120,90,0.14); color: var(--bili-ink-3);
}
.dt-chip__detail-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dt-chip__detail-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dt-chip__detail-empty {
  font-size: 0.74rem; color: var(--bili-ink-3); font-style: italic;
  padding: 4px 0;
}
.dt-chip__detail-badge {
  display: inline-block; font-size: 0.65rem; padding: 1px 7px; border-radius: 4px;
  background: rgba(150,120,90,0.12); color: var(--bili-ink-2);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.dt-chip__detail-badge--parsed { background: oklch(72% 0.18 150 / 0.18); color: oklch(35% 0.12 150); }
.dt-chip__detail-badge--extracted { background: oklch(66% 0.22 140 / 0.18); color: oklch(35% 0.15 140); }
.dt-chip__detail-badge--failed,
.dt-chip__detail-badge--parse_failed,
.dt-chip__detail-badge--extract_failed { background: oklch(68% 0.20 30 / 0.15); color: oklch(40% 0.18 30); }
.dt-chip__detail-badge--method { background: oklch(65% 0.10 260 / 0.15); color: oklch(35% 0.12 260); }
.dt-chip__detail-badge--pending { background: rgba(150,120,90,0.08); color: var(--bili-ink-3); }
.dt-chip__detail-error { font-size: 0.75rem; color: oklch(48% 0.18 30); }
.dt-chip__detail-collapse { margin-top: 4px; }
.dt-chip__detail-collapse summary { cursor: pointer; font-size: 0.7rem; color: var(--bili-ink-3); }
.dt-chip__detail-pre {
  margin-top: 4px; padding: 6px 8px; border-radius: 6px;
  background: rgba(0,0,0,0.04); font-size: 0.7rem; line-height: 1.4;
  max-height: 160px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.dt-chip__detail-source { margin-bottom: 6px; }
.dt-chip__detail-source-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.dt-chip__detail-source-file { font-size: 0.72rem; color: var(--bili-ink-3); }
/* Admin card on onboarding page */
.dt-card--admin { border: 1px dashed oklch(65% 0.20 30 / 0.3); background: oklch(85% 0.06 30 / 0.06); }

/* ── Activity feed (rail variant) ───────────────────────────────────────── */
.dt-activity__list { margin-top: 14px; display: flex; flex-direction: column; gap: 0; }
.dt-act {
  display: flex; gap: 12px; padding: 10px 2px;
  border-top: 1px solid rgba(255,255,255,0.4);
  font-size: 0.84rem;
  animation: dt-chip-in 0.3s ease;
}
.dt-act:first-child { border-top: none; }
.dt-act__time { flex: none; font-size: 0.72rem; color: var(--bili-ink-3); width: 52px; padding-top: 1px; }
.dt-act__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px;
  background: var(--bili-green-cta); }
.dt-act__dot--read { background: var(--bili-gold); }
.dt-act__text { color: var(--bili-ink-2); line-height: 1.4; }
.dt-act__text b { font-weight: 500; color: var(--bili-ink); }
.dt-activity__empty { font-size: 0.85rem; color: var(--bili-ink-3); margin-top: 12px; }

/* ── Privacy & confidentiality panel ────────────────────────────────────── */
.dt-privacy {
  display: flex; align-items: flex-start; gap: 16px;
  margin-top: 0; padding: 18px 22px;
}
.dt-privacy__icon {
  flex: none; width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  background: oklch(72% 0.10 200 / 0.18);
  color: oklch(46% 0.10 220);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
.dt-privacy__icon svg { width: 21px; height: 21px; }
.dt-privacy__title { font-size: 0.96rem; font-weight: 500; color: var(--bili-ink); margin-bottom: 2px; }
.dt-privacy__text { font-size: 0.86rem; color: var(--bili-ink-2); line-height: 1.5; margin: 0; max-width: 60ch; text-wrap: pretty; }

/* ── Actions bar ────────────────────────────────────────────────────────── */
.dt-actions {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 1rem; margin-top: 22px; padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.45);
}
.dt-actions__btns { display: flex; gap: 10px; }
.dt-actions__cta { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.dt-actions__hint { font-size: 0.8rem; color: var(--bili-ink-3); }
/* Primary call-to-action — sized up; it's the main action on the page */
.dt-cta.button {
  font-size: 1.02rem; font-weight: 500;
  padding: 0 28px; height: 52px; line-height: 52px;
  border-radius: 14px;
  transition: background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}
/* Disabled until the user provides information */
.dt-cta.button.is-disabled {
  background: rgba(120,90,60,0.16) !important;
  color: var(--bili-ink-3) !important;
  box-shadow: none !important;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Chat (onboarding step 4b) ──────────────────────────────────────────── */

.dt-card.dt-chat-card {
  display: flex; flex-direction: column;
  padding: 0; overflow: hidden;
  min-height: 0;
  position: relative;
  grid-area: chat;
}

.dt-chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 14px;
  /* No smooth scrolling: landing at the newest message must be exact and
     immediate. A smooth animation is cancelled or left part-way by the next
     layout change, which is what left the last line cut off on reload. */
  scroll-behavior: auto;
}

.dt-chat-upload-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: 0.82rem; color: var(--bili-ink-2);
  border-bottom: 1px solid var(--glass-border);
  background: oklch(66% 0.16 140 / 0.05);
  cursor: pointer; user-select: none;
  transition: background 0.15s;
  position: sticky; top: 0; z-index: 2; flex-shrink: 0;
}
.dt-chat-upload-bar:hover {
  background: oklch(66% 0.16 140 / 0.10);
}
.dt-chat-upload-bar svg {
  flex-shrink: 0; color: oklch(56% 0.18 140 / 0.75);
}
.dt-chat-upload-bar__text { flex: 1; min-width: 0; }
.dt-chat-upload-bar__formats {
  font-size: 0.68rem; opacity: 0.55; flex-shrink: 0;
}

.dt-chat-card.is-drag::after {
  content: ''; position: absolute; inset: 0; z-index: 10;
  border: 2.5px dashed var(--bili-green-cta);
  border-radius: inherit;
  background: oklch(82% 0.12 140 / 0.18);
  pointer-events: none;
}

.dt-chat-msg {
  display: flex; max-width: 85%;
}
.dt-chat-msg--system { align-self: flex-start; }
.dt-chat-msg--user   { align-self: flex-end; }

.dt-chat-bubble {
  padding: 12px 16px; border-radius: var(--r-lg);
  font-size: 0.92rem; line-height: 1.55; color: var(--bili-ink);
}
.dt-chat-msg--system .dt-chat-bubble {
  background: var(--glass-fill-2);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine);
  border-bottom-left-radius: 4px;
}
.dt-chat-msg--user .dt-chat-bubble {
  background: var(--bili-green-cta);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px oklch(50% 0.16 140 / 0.25);
}

/* ── Message status (WhatsApp-style ticks) ──────────────────────────────── */
.dt-chat-status {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: 6px; vertical-align: middle; line-height: 1;
}
.dt-chat-status__tick {
  font-size: 10px; color: oklch(78% 0.1 140);
}
.dt-chat-status__tick--seen {
  color: oklch(78% 0.1 140);
}
/* ── Inline review card (chat stream) ─────────────────────────────────────── */
.dt-review-text { line-height: 1.6; font-size: 1.1em; }
.dt-review-pill {
  display: inline-flex; align-items: center;
  background: oklch(66% 0.22 140 / 0.12);
  border: 1px solid oklch(66% 0.22 140 / 0.3);
  border-radius: 6px; padding: 3px 7px;
  margin: 3px 1px;
  cursor: pointer; transition: background 0.15s;
  vertical-align: baseline; font-size: 0.9rem;
}
.dt-review-pill__label { display: inline; }
.dt-review-pill:hover {
  background: oklch(66% 0.22 140 / 0.22);
}
.dt-review-input {
  display: inline-block; width: auto; min-width: 6rem;
  font-size: 0.9rem; padding: 3px 8px;
  border: 1px solid var(--bili-green-cta); border-radius: 6px;
  outline: none; background: rgba(255,255,255,0.85);
  color: var(--bili-ink); vertical-align: baseline;
}
.dt-review-input--block {
  display: block; width: 100%; box-sizing: border-box;
  padding: 8px 10px; line-height: 1.5; margin: 4px 0;
}
.dt-review-pill--editing {
  display: inline-flex;
}
.dt-review-pill--editing.dt-review-pill--block {
  display: block; width: 100%;
}
.dt-review-select {
  display: inline-block; width: auto;
  font-size: 0.9rem; padding: 6px 10px;
  border: 1px solid var(--bili-green-cta); border-radius: 6px;
  outline: none; background: rgba(255,255,255,0.9);
  color: var(--bili-ink);
  cursor: pointer;
}
/* Money edit: amount + currency side by side */
.dt-review-pill--money { gap: 4px; }
.dt-review-pill--money .dt-review-input[type="number"] { min-width: 5rem; }
.dt-review-pill--money .dt-review-select { max-width: 14rem; }
.dt-review-input[type="date"],
.dt-review-input[type="datetime-local"],
.dt-review-input[type="number"] {
  display: inline-block; width: auto;
  font-size: 0.9rem; padding: 6px 10px;
  border: 1px solid var(--bili-green-cta); border-radius: 6px;
  outline: none; background: rgba(255,255,255,0.9);
  color: var(--bili-ink);
}
.dt-review-missing {
  display: inline; font-style: italic; color: var(--bili-ink-3);
}

/* ── Review mode (replaces the transcript once all categories are filled) ── */
.dt-review-mode {
  /* Overlay the chat card so it can cross-fade without competing for space. */
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column;
  background: var(--glass-fill);
}

.dt-review-mode__head {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--glass-border);
  background: oklch(66% 0.16 140 / 0.08);
}
.dt-review-mode__headtext { flex: 1; min-width: 0; }
.dt-review-mode__head h2 {
  margin: 0; font-size: 1.32rem; font-weight: 500; color: var(--bili-ink);
  line-height: 1.25; text-wrap: pretty;
}
.dt-review-mode__head p {
  margin: 3px 0 0; font-size: 0.86rem; color: var(--bili-ink-2);
}

.dt-review-tick {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bili-green-cta);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px oklch(50% 0.16 140 / 0.28);
}
.dt-review-tick svg { width: 18px; height: 18px; fill: #fff; }

.dt-review-chip {
  display: inline-flex; align-items: center; gap: 7px;
  flex-shrink: 0;
  font-size: 0.8rem; padding: 5px 11px;
  border-radius: var(--r-pill);
  background: oklch(66% 0.22 140 / 0.14);
  color: var(--bili-green-dark);
  border: 1px solid oklch(66% 0.22 140 / 0.28);
}

.dt-review-mode__body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 26px 30px;
}
/* The prose emitted by the reviewHtml getter */
.dt-review-prose {
  font-size: 1.1rem; line-height: 2;
  color: var(--bili-ink);
  text-wrap: pretty;
}

.dt-review-mode__foot {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 20px;
  padding: 20px 26px;
  border-top: 1px solid var(--glass-border);
  background: linear-gradient(0deg,
    oklch(66% 0.16 140 / 0.12),
    oklch(66% 0.16 140 / 0.04));
}
.dt-review-mode__ask { flex: 1; min-width: 0; }
.dt-review-mode__ttl {
  margin: 0 0 3px; font-size: 1.06rem; font-weight: 500;
  color: var(--bili-ink); text-wrap: pretty;
}
.dt-review-mode__hint {
  margin: 0; font-size: 0.94rem; color: var(--bili-ink-2);
}

/* The confirm button: Bulma .button.is-primary plus size/emphasis */
.button.dt-review-confirm {
  flex-shrink: 0;
  font-size: 1.08rem;
  padding: 15px 30px; height: auto;
  border-radius: var(--r-pill);
  box-shadow: 0 6px 18px oklch(50% 0.16 140 / 0.30);
}

/* In review mode the block-level pill should read as a paragraph, not a chip */
.dt-review-prose .dt-review-pill--block {
  display: block; padding: 9px 11px; margin: 6px 0; line-height: 1.5;
}

/* ── Review intro (brief friendly interstitial before the confirmation view) ── */
.dt-review-intro {
  /* Overlay the chat card: no flex competition, so nothing jumps as it fades. */
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 34px;
  background: var(--glass-fill);
}
.dt-review-intro__inner { max-width: 34rem; text-align: center; }
.dt-review-intro__title {
  margin: 0 0 14px;
  font-size: 2.1rem; font-weight: 600; letter-spacing: -0.01em;
  color: var(--bili-green-dark);
}
.dt-review-intro__text {
  margin: 0;
  font-size: 1.28rem; line-height: 1.7;
  color: var(--bili-ink); text-wrap: pretty;
}
.dt-review-intro__text strong { font-weight: 600; }

/* Numberless ring: depletes over the interstitial so it feels like something
   is about to happen, then the summary loads. */
.dt-review-intro__countdown {
  width: 48px; height: 48px;
  margin: 0 auto 22px;
}
.dt-review-intro__countdown svg {
  display: block; width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.dt-review-intro__ring-track {
  fill: none;
  stroke: var(--glass-border);
  stroke-width: 4;
}
.dt-review-intro__ring-fill {
  fill: none;
  stroke: var(--bili-green-cta);
  stroke-width: 4;
  stroke-linecap: round;
  /* 2πr with r=18 ≈ 113.1 */
  stroke-dasharray: 113.1;
  stroke-dashoffset: 0;
  animation-name: dt-intro-countdown;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  animation-duration: var(--intro-duration, 6s);
}
@keyframes dt-intro-countdown {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: 113.1; }
}

@media (max-width: 768px) {
  .dt-review-intro { padding: 28px 20px; }
  .dt-review-intro__title { font-size: 1.7rem; }
  .dt-review-intro__text { font-size: 1.1rem; }
  .dt-review-mode__head { padding: 16px 18px; gap: 10px; flex-wrap: wrap; }
  .dt-review-mode__head h2 { font-size: 1.15rem; }
  .dt-review-chip { order: 3; width: 100%; justify-content: center; }
  .dt-review-mode__body { padding: 18px; }
  .dt-review-prose { font-size: 1rem; line-height: 1.9; }
  .dt-review-mode__foot { padding: 16px 18px; flex-direction: column; align-items: stretch; gap: 14px; }
  .button.dt-review-confirm { width: 100%; justify-content: center; }
}

/* ── Address autocomplete dropdown ──────────────────────────────────────── */

.dt-address-dropdown {
  position: absolute;
  z-index: 100;
  background: var(--glass-fill-1, #fff);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 280px;
  overflow-y: auto;
  width: 360px;
  max-width: calc(100vw - 32px);
  margin-top: 4px;
}
.dt-address-dropdown__item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color, #eee);
}
.dt-address-dropdown__item:last-child { border-bottom: none; }
.dt-address-dropdown__item:hover { background: var(--hover-fill, #f5f5f5); }
.dt-address-dropdown__main {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-color, #222);
}
.dt-address-dropdown__sec {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-top: 2px;
}
.dt-address-dropdown__powered {
  padding: 6px 14px;
  font-size: 10px;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
  border-top: 1px solid var(--border-color, #eee);
  background: #fafafa;
}

.dt-chat-status__dots {
  display: inline-flex; align-items: center; gap: 2px;
}
.dt-chat-status__dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: oklch(90% 0.04 140 / 0.9);
  animation: dt-chat-status-blink 1.2s ease-in-out infinite;
}
.dt-chat-status__dot:nth-child(2) { animation-delay: 0.2s; }
.dt-chat-status__dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dt-chat-status-blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
.dt-chat-msg--system .dt-chat-bubble p { margin: 0 0 6px; }
.dt-chat-msg--system .dt-chat-bubble p:last-child { margin: 0; }
.dt-chat-msg--system .dt-chat-bubble .is-size-7 {
  font-size: 0.78rem; color: var(--bili-ink-3); margin-top: 8px;
}

.dt-chat-msg--system .dt-chat-bubble .dt-chat-bubble__hint {
  font-size: 0.78rem; color: var(--bili-ink-3); margin-top: 6px;
}

@keyframes dt-chat-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ── Chat input bar ─────────────────────────────────────────────────────── */
.dt-chat-input {
  border-top: 1px solid var(--glass-border);
  padding: 14px 18px;
  background: rgba(255,255,255,0.18);
}
.dt-chat-input__row {
  display: flex; align-items: flex-end; gap: 10px;
}
.dt-chat-mic {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.2rem;
  border: 1px solid var(--glass-border) !important;
  background: var(--glass-fill) !important;
  transition: background 0.15s ease, transform 0.12s ease;
}
.dt-chat-mic:hover { background: var(--glass-fill-2) !important; transform: scale(1.06); }
.dt-chat-mic.is-danger {
  background: var(--bili-red) !important; color: #fff !important;
  animation: dt-chat-pulse 1s ease-in-out infinite;
}
.dt-chat-input__wrap { flex: 1; min-width: 0; }
.dt-chat-textarea {
  resize: none; min-height: 42px; max-height: 120px;
  font-size: 0.92rem;
  border-radius: var(--r-md);
  border-color: var(--glass-border);
  background: var(--glass-fill);
  box-shadow: inset 0 1px 3px rgba(60,40,20,0.06);
}
.dt-chat-textarea:focus {
  border-color: var(--bili-green-cta);
  box-shadow: inset 0 1px 3px rgba(60,40,20,0.06), 0 0 0 3px oklch(66% 0.22 140 / 0.14);
}

/* ── Data Store Detail Rows ──────────────────────────────────────────────── */
.detail-row td {
  background: var(--bili-bg-1, #fafafa);
  border-top: none !important;
  padding-top: 0 !important;
  padding-bottom: 0.5rem !important;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0.4rem 0.2rem 0.1rem;
}
.detail-note {
  font-size: 0.78rem;
  color: var(--bili-ink-3, #718096);
  font-style: italic;
  align-self: start;
}
.detail-items { align-self: start; }
.playbook-ref-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.35rem;
}
.recheck-panel { margin-top: 0.25rem; font-size: 0.78rem; }
.follow-up-row td { background: var(--bili-warning-bg, #fffdf0); border-top: none !important; }
.follow-up-row .follow-up-panel {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--bili-warning-border, #f0e8c0);
  border-radius: 4px;
  background: var(--bili-warning-bg, #fffdf0);
}
.follow-up-panel .follow-up-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bili-warning-text, #b7791f);
  margin-bottom: 0.5rem;
}
.follow-up-fields { display: grid; gap: 0.5rem; }
.follow-up-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--bili-ink-2, #4a5568);
  margin-bottom: 0.2rem;
}
.follow-up-field input,
.follow-up-field select { font-size: 0.82rem; }

/* ── Onboarding (Welcome + CH Search + Detail + Duplicate) ──────────────── */
.bili-onboarding-hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
  transition: padding 0.4s ease;
}
.bili-onboarding-hero.hero-collapsed {
  padding-top: 1rem;
  padding-bottom: 3rem;
}
.bili-onboarding-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}
.lead-wrapper {
  overflow: hidden;
  max-height: 200px;
  opacity: 1;
  transition: max-height 0.5s ease, opacity 0.5s ease, margin 0.5s ease;
}
.lead-wrapper.lead-hidden {
  max-height: 0;
  opacity: 0;
  margin: 0;
}
.bili-onboarding-hero .lead {
  max-width: 36rem;
  margin: 0 auto;
  font-size: 1.1rem;
  color: var(--bili-ink-3, #666);
  line-height: 1.6;
}
.bili-onboarding-layout {
  max-width: 36rem;
  margin: 0 auto;
  padding: 0 1rem;
  transition: margin-top 0.4s ease, max-width 0.4s ease;
}
.bili-onboarding-layout.slide-up {
  margin-top: -1rem;
}
.bili-onboarding-left-col {
  min-width: 0;
}
#ch-detail:not(:empty) {
  margin-top: 1.5rem;
}
@media (min-width: 768px) {
  .bili-onboarding-layout:has(#ch-detail > :not(style)) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    max-width: 60rem;
  }
  .bili-onboarding-layout:has(#ch-detail > :not(style)) #ch-detail {
    margin-top: 0;
    position: sticky;
    top: 1rem;
    align-self: start;
  }
}
.bili-onboarding-search-prompt {
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--bili-ink-3, #666);
}
.bili-onboarding-search-box {
  margin-bottom: 1.5rem;
}
.bili-onboarding-search-results {
  min-height: 60px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.bili-ch-results-list {
  border: 1px solid var(--bili-border, #ddd);
  border-radius: 8px;
  overflow: hidden;
}
.bili-ch-result-item {
  border-bottom: 1px solid var(--bili-border-light, #eee);
}
.bili-ch-result-item:last-child {
  border-bottom: none;
}
.bili-ch-result-button {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.bili-ch-result-button:hover,
.bili-ch-result-button--selected {
  background: var(--bili-hover-bg, #f5f5f5);
}
.bili-ch-result-button--selected {
  position: relative;
}
.bili-ch-result-button--selected::after {
  content: "▼";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--bili-ink-3, #888);
}
@media (min-width: 768px) {
  .bili-ch-result-button--selected::after {
    content: "▶";
  }
}
.bili-ch-result-button--duplicate {
  border-left: 3px solid #f59e0b;
}
.bili-ch-result-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.bili-ch-result-meta {
  font-size: 0.8rem;
  color: var(--bili-ink-3, #888);
}
.bili-ch-status {
  font-weight: 600;
  color: var(--bili-ink-3, #888);
}
.bili-ch-status--active {
  color: #22c55e;
}
.bili-ch-duplicate-badge {
  background: #fef3c7;
  color: #92400e;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}
.bili-ch-detail-card {
  border: 1px solid var(--bili-border, #ddd);
  border-radius: 12px;
  padding: 1.5rem;
  background: var(--bili-card-bg, #fff);
}
.bili-ch-detail-header {
  margin-bottom: 1rem;
}
.bili-ch-detail-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.bili-ch-detail-number {
  font-size: 0.85rem;
  color: var(--bili-ink-3, #888);
}
.bili-ch-detail-body {
  margin-bottom: 1.5rem;
}
.bili-ch-detail-row {
  display: flex;
  gap: 1rem;
  padding: 0.4rem 0;
  font-size: 0.95rem;
}
.bili-ch-detail-row .label {
  width: 8rem;
  flex-shrink: 0;
  color: var(--bili-ink-3, #888);
  font-weight: 500;
}
.bili-ch-detail-row .value {
  flex: 1;
}
.bili-ch-detail-role {
  border-top: 1px solid var(--bili-border-light, #eee);
  padding-top: 1rem;
  margin-bottom: 1rem;
}
.bili-ch-detail-role-label {
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.bili-ch-detail-role-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.bili-role-option {
  display: block;
  padding: 0.75rem 1rem;
  border: 2px solid var(--bili-border, #ddd);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.bili-role-option.active {
  border-color: var(--bili-primary, #485fc7);
  background: var(--bili-primary-bg, #f0f3ff);
}
.bili-role-option input {
  display: none;
}
.bili-role-option-content strong {
  display: block;
  margin-bottom: 0.15rem;
}
.bili-role-option-content span {
  font-size: 0.85rem;
  color: var(--bili-ink-3, #888);
}
.bili-ch-detail-actions {
  text-align: right;
}
.bili-ch-duplicate-card {
  border: 2px solid #f59e0b;
}
.bili-ch-duplicate-header {
  margin-bottom: 1rem;
}
.bili-ch-duplicate-badge-lg {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.bili-ch-duplicate-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.bili-ch-duplicate-body {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: #fffbeb;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}
.bili-ch-duplicate-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}
.bili-ch-duplicate-body p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.bili-onboarding-banner {
  background: linear-gradient(135deg, #eff6ff, #f0f3ff);
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.bili-onboarding-banner-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}
.bili-onboarding-banner-text {
  display: flex;
  flex-direction: column;
}
.bili-onboarding-banner-text strong {
  font-size: 0.95rem;
}
.bili-onboarding-banner-text span {
  font-size: 0.85rem;
  color: #6b7280;
}
.bili-digital-twin-summary {
  margin-bottom: 1.5rem;
}
.bili-digital-twin-summary h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.bili-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.bili-health-card {
  background: var(--bili-card-bg, #fff);
  border: 1px solid var(--bili-border, #eee);
  border-radius: 8px;
  padding: 0.75rem;
}
.bili-health-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.bili-health-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bili-ink-3, #666);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.bili-health-card-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bili-ink-3, #888);
}
.bili-health-card-bar {
  height: 4px;
  background: var(--bili-border, #eee);
  border-radius: 2px;
  overflow: hidden;
}
.bili-health-card-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── Markdown Editor (EasyMDE) ───────────────────────────────────────────── */
.EasyMDEContainer { flex: 1 1 auto; display: flex; flex-direction: column; }
.EasyMDEContainer .CodeMirror { flex: 1 1 auto; height: 100%; }
.EasyMDEContainer .editor-toolbar { flex-shrink: 0; }
.EasyMDEContainer .CodeMirror-scroll { min-height: 200px; }

/* ── Inline-style utility classes ─────────────────────────────────────────── */
.wf-btn-mt { margin-top: 6px; }
.wf-test-intro { font-size: 11px; color: var(--bili-ink-3); margin-top: 10px; line-height: 1.5; }
.wf-modal-cancel { margin-left: auto; }
.dt-search-input { width: 260px; }
.dt-table-wrap { overflow-x: auto; }
.dt-value-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-nowrap { white-space: nowrap; }
.dt-field-max { max-width: 320px; }
.sch-form-row { gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.sch-search-input { max-width: 300px; }
.pb-form-inline { display: inline; }

/* ── Upload two-column split ────────────────────────────────────────────── */
.dt-upload-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.dt-upload-split__drop .dt-upload__drop {
  margin-top: 0;
}

/* ── Chat 2×2 grid ──────────────────────────────────────────────────────── */
.dt-chat-grid {
  display: grid;
  grid-template-areas:
    "title title"
    "chat checklist"
    "chat skip";
  grid-template-columns: minmax(0, 1fr) 420px;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
}

/* ── Chat title cell (grid area) ─────────────────────────────────────────── */
.dt-chat-title {
  grid-area: title;
  display: flex; flex-direction: column; justify-content: center;
  padding-right: 8px;
}
.dt-chat-title h1 {
  font-size: 24px; font-weight: 500; letter-spacing: -0.015em;
  color: var(--bili-ink); margin: 0 0 6px; line-height: 1.2;
}
.dt-chat-title p {
  font-size: 16px; color: var(--bili-ink-2);
  line-height: 1.55; margin: 0; text-wrap: pretty;
}

/* ── Upload drop zone (top-right) ───────────────────────────────────────── */
.dt-upload-zone {
  border: 2px dashed rgba(150,120,90,0.38);
  border-radius: 13px;
  background: rgba(255,255,255,0.16);
  padding: 16px 20px;
  display: flex; align-items: flex-start; gap: 14px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.dt-upload-zone:hover {
  border-color: oklch(66% 0.15 140 / 0.5);
  background: rgba(255,255,255,0.26);
}
.dt-upload-zone.is-drag {
  border-color: var(--bili-green-cta);
  background: oklch(85% 0.10 140 / 0.32);
}
.dt-upload-zone__icon {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  display: grid; place-items: center;
  color: var(--bili-ink);
}
.dt-upload-zone__icon svg { width: 18px; height: 18px; }
.dt-upload-zone__body { flex: 1; min-width: 0; }
.dt-upload-zone__head {
  font-size: 14px; font-weight: 500; color: var(--bili-ink);
  margin: 0 0 3px;
}
.dt-upload-zone__sub {
  font-size: 12px; color: var(--bili-ink-3);
  margin: 0 0 11px; line-height: 1.45;
}
.dt-upload-zone__controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.dt-upload-zone__btn.button {
  font-size: 12px; padding: 2px 10px; height: auto;
}
.dt-upload-zone__formats {
  font-size: 10.5px; color: var(--bili-ink-3);
}

/* ── Interim-transcript sending spinner ─────────────────────────────────── */
/* The file upload bubble that used to live here is now .dt-filecard (below).
   This rule stays: fileIcon('pending') still drives the spinner shown next to
   a user message while it is being sent. */
.dt-chat-file-spinner {
  animation: dt-spin 1.2s linear infinite;
  transform-origin: center center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Onboarding chat — unified bubble grammar + extraction ledger
   Design package: plans/design-packages/design_handoff-upload-status-chat-bubbles
   One grammar for everything the system says: system text, standalone
   extractions and the live question share fill, border, radius and tail.
   The file card (.dt-filecard) and skeleton (.dt-sk) land with ticket #175.
   Existing tokens only — no new custom properties.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Message wrapper: one wide variant for system artifacts ──────────────── */
/* .dt-chat-msg is max-width:85% and display:flex. The extraction ledger needs
   more room than a sentence bubble. */
.dt-chat-msg--wide {
  max-width: min(660px, 90%);
  align-self: flex-start;
  width: 100%;
}

/* A question message: full-width column so the thread marker stretches the row
   and the focus card stays left-aligned, exactly as when it was standalone.
   Being a real flex item also preserves the transcript's bottom-anchoring. */
.dt-chat-msg--question {
  display: flex; flex-direction: column; gap: 14px;
  align-self: stretch; max-width: none;
}

/* A quiet, full-width row summarising documents added before this visit. */
.dt-chat-msg--upload-summary { align-self: stretch; max-width: none; }
.dt-upload-summary {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.35);
  font-size: 13px; color: var(--bili-ink-2);
}
.dt-upload-summary > svg {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: var(--bili-ink-3); opacity: 0.8;
}
.dt-upload-summary__text { flex: 1; min-width: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.dt-upload-summary__names {
  color: var(--bili-ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%;
}
.dt-upload-summary__link { flex-shrink: 0; color: var(--bili-green-dark); }

/* ═══════════════════════════════════════════════════════════════════════════
   Thread marker — the question's position in the conversation
   Was the kicker INSIDE the focus card. It is a position in the thread, not a
   property of the message, so it sits between messages as a ruled label.
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-marker {
  display: flex; align-items: center; gap: 11px;
  align-self: stretch;
  padding: 4px 0;
  max-width: none;
}
.dt-marker__label {
  flex-shrink: 0;
  font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--bili-ink-2);
}
.dt-marker__rule { flex: 1; border-top: 1px solid rgba(120,90,60,0.15); }

/* ═══════════════════════════════════════════════════════════════════════════
   Focus card — a system bubble with two type tiers
   Same fill, border, tail corner and shadow as .dt-chat-msg--system's bubble.
   Lead-in and question share one size; only weight + ink mark the call to
   action. Example and hint sit one tier down.
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-focus {
  align-self: flex-start;
  max-width: min(660px, 86%);
  padding: 16px 19px;
  background: var(--glass-fill-2);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 4px;
}
/* Lead-in sentence — same size as the question, regular weight, ink-2.
   One voice at one size; emphasis alone marks which line to act on. */
.dt-focus__lead {
  margin: 0 0 7px;
  font-size: 17px; line-height: 1.42;
  color: var(--bili-ink-2);
  text-wrap: pretty;
}

/* The question — the single call to action */
.dt-focus__q {
  margin: 0;
  font-size: 17px; font-weight: 500; line-height: 1.42;
  letter-spacing: -0.005em;
  color: var(--bili-ink);
  text-wrap: pretty;
}

/* Supporting copy — example and hint, both one tier down */
.dt-focus__eg,
.dt-focus__hint {
  margin: 11px 0 0;
  font-size: 13.5px; line-height: 1.6;
  color: var(--bili-ink-2);
  text-wrap: pretty;
}
.dt-focus__hint { margin-top: 8px; }

/* The quoted example reads as speech, not italic prose */
.dt-focus__eg em { font-style: normal; color: var(--bili-ink); }

/* Two answers to a question that is not free text: an inferred website. */
.dt-focus__actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 14px;
}
.dt-focus__actions .button { margin: 0; }

/* A value below high confidence was inferred, not stated. Mark it wherever it
   is shown, so a guess never reads as a fact the user gave us. */
.dt-led__guess,
.dt-kw-item__guess {
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px; line-height: 1.5; letter-spacing: 0.01em;
  color: var(--bili-ink-2);
  background: var(--glass-fill-2);
  border: 1px solid var(--glass-border);
  white-space: nowrap;
}

/* Per-category progress, right-aligned before the chevron. */
.dt-kw-cat__count {
  flex-shrink: 0;
  font-size: 12px; color: var(--bili-ink-3);
  font-variant-numeric: tabular-nums;
}

/* Keeps a URL whole — as prose it broke mid-domain. Plain text, not a token. */
.dt-focus__url { white-space: nowrap; }

/* Pending question — shown while the model generates it, so the card can appear
   instantly with the lead. Three pulsing dots in place of the question line. */
.dt-focus__thinking {
  display: flex; align-items: center; gap: 5px;
  height: 24px; margin: 2px 0 0;
}
.dt-focus__thinking i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bili-ink-2);
  animation: dt-thinking 1.1s ease-in-out infinite;
}
.dt-focus__thinking i:nth-child(2) { animation-delay: 0.15s; }
.dt-focus__thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dt-thinking {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50%      { opacity: 1;    transform: translateY(-2px); }
}
/* .dt-focus__kicker is GONE — that content is now .dt-marker. */

/* ═══════════════════════════════════════════════════════════════════════════
   Shared value ledger — used by the file card AND standalone extractions
   Two-column grid. Each row is a wrapper with display:contents so its two
   spans join the parent grid (Alpine x-for must emit a single root per item).
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-led {
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  gap: 0 18px; margin: 0;
  font-size: 14px;
}
.dt-led__r { display: contents; }
.dt-led__k,
.dt-led__v {
  padding: 7px 0;
  border-top: 1px solid rgba(120,90,60,0.15);
  line-height: 1.4;
}
.dt-led__k { color: var(--bili-ink-2); white-space: nowrap; }
.dt-led__v { color: var(--bili-ink); font-weight: 500; word-break: break-word; }
.dt-led__r:first-child .dt-led__k,
.dt-led__r:first-child .dt-led__v { border-top: 0; }

/* rows rise and fade in, staggered, when the card reaches its done state */
.dt-filecard .dt-led__k,
.dt-filecard .dt-led__v,
.dt-extract .dt-led__k,
.dt-extract .dt-led__v {
  opacity: 0; transform: translateY(5px);
  transition: opacity 0.3s ease, transform 0.36s cubic-bezier(0.2,0.8,0.25,1);
}
.dt-filecard.is-done .dt-led__k,
.dt-filecard.is-done .dt-led__v,
.dt-extract.is-in .dt-led__k,
.dt-extract.is-in .dt-led__v { opacity: 1; transform: none; }
/* 40ms per row, capped at 8 so a 30-field extraction's last row is not
   1.2s behind the first */
.dt-led__r:nth-child(2) > * { transition-delay: 40ms; }
.dt-led__r:nth-child(3) > * { transition-delay: 80ms; }
.dt-led__r:nth-child(4) > * { transition-delay: 120ms; }
.dt-led__r:nth-child(5) > * { transition-delay: 160ms; }
.dt-led__r:nth-child(6) > * { transition-delay: 200ms; }
.dt-led__r:nth-child(7) > * { transition-delay: 240ms; }
.dt-led__r:nth-child(8) > * { transition-delay: 280ms; }
.dt-led__r:nth-child(n+9) > * { transition-delay: 320ms; }

/* ═══════════════════════════════════════════════════════════════════════════
   Green result header — shared by the file card and standalone extractions
   A ~44px tinted flag at the TOP of the message, not a wash behind the data.
   Tint is 13% — reads as a highlight without competing with the user's
   full-saturation bubbles.
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-reshead {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: oklch(66% 0.16 140 / 0.13);
  border-bottom: 1px solid oklch(66% 0.18 140 / 0.18);
  transition: background 0.5s ease, border-color 0.5s ease;
}
.dt-reshead__tx {
  flex: 1; min-width: 0;
  font-size: 13.5px; line-height: 1.4; color: var(--bili-green-dark);
  transition: color 0.5s ease;
}
.dt-reshead__tx b { font-weight: 500; }
.dt-reshead__ct {
  flex-shrink: 0;
  font-size: 11.5px; font-weight: 500;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: oklch(66% 0.22 140 / 0.2);
  color: var(--bili-green-dark);
}

/* tick / spinner slot — the tick pops in, the spinner fades out */
.dt-reshead__glyph { position: relative; width: 20px; height: 20px; flex-shrink: 0; }
.dt-tick {
  border-radius: 50%; background: var(--bili-green-cta);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dt-tick svg { fill: #fff; }
.dt-tick--20 { width: 20px; height: 20px; }
.dt-tick--20 svg { width: 12px; height: 12px; }
.dt-reshead__glyph .dt-tick {
  position: absolute; inset: 0;
  transform: scale(0); opacity: 0;
  transition: transform 0.4s cubic-bezier(0.2,1.5,0.4,1), opacity 0.2s;
}
.dt-spinner {
  position: absolute; inset: 2px; border-radius: 50%;
  border: 2px solid oklch(66% 0.22 140 / 0.25);
  border-top-color: var(--bili-green-cta);
  opacity: 0; transition: opacity 0.25s;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Standalone extraction — a fact learned from CHAT, with no file to attach to
   Same grammar as the file card's result region, without the file row.
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-extract {
  width: 100%;
  overflow: hidden;
  background: var(--glass-fill-2);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 4px;
}
.dt-extract__summary {
  padding: 14px 18px 0;
  font-size: 15px; line-height: 1.55; color: var(--bili-ink);
}
.dt-extract__bd { padding: 13px 18px 15px; }
.dt-extract .dt-reshead__glyph .dt-tick { transform: scale(1); opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════════════
   FILE CARD — one component, four states, never unmounted
   Every transition is an interpolation because the DOM does not change:
   only the state class on .dt-filecard changes.
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-filecard {
  width: 100%;
  overflow: hidden;
  background: var(--glass-fill-2);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 4px;
  transition: box-shadow 0.5s ease;
}
.dt-filecard.is-done {
  box-shadow: inset 0 1px 0 var(--glass-shine), 0 6px 22px oklch(50% 0.16 140 / 0.13);
}

/* ── the file row ───────────────────────────────────────────────────────── */
.dt-filecard__file {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.44);
}
/* FIX: filename and file type were inline siblings and ran together.
   Flex column with a gap — do not revert to inline spans. */
.dt-filecard__tx {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
}
.dt-filecard__name {
  font-size: 15px; font-weight: 500; line-height: 1.35;
  color: var(--bili-ink);
  word-break: break-word;
}
.dt-filecard__status {
  position: relative;
  min-height: 1.2em;
  font-size: 13px; line-height: 1.4; color: var(--bili-ink-2);
}
/* all status strings live in the DOM and cross-fade in place; swapping
   textContent would snap */
.dt-filecard__status > span {
  display: block;
  transition: opacity 0.34s ease, transform 0.34s ease;
}
.dt-filecard__status > span[hidden] {
  display: block;
  position: absolute; inset: 0;
  opacity: 0; transform: translateY(-3px);
  pointer-events: none;
}

/* ── the document glyph and its three treatments ────────────────────────── */
.dt-filecard__doc {
  position: relative; overflow: hidden;
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: var(--r-sm);
  background: oklch(66% 0.22 140 / 0.14);
  color: var(--bili-green-dark);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.5s ease;
}
.dt-filecard__doc > svg {
  position: relative; z-index: 1;
  width: 23px; height: 23px; fill: currentColor;
}

/* uploading: a conic ring sweeps the glyph's edge */
.dt-filecard__ring {
  position: absolute; inset: -1px; z-index: 3;
  border-radius: inherit;
  opacity: 0; transition: opacity 0.3s ease;
  background: conic-gradient(from 0deg, transparent 0deg, oklch(66% 0.22 140 / 0.85) 60deg, transparent 120deg);
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2.5px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2.5px));
}
.dt-filecard.is-uploading .dt-filecard__ring {
  opacity: 1; animation: dt-spin 1s linear infinite;
}

/* analysing: a soft green light sweeps down the page */
.dt-filecard__scan {
  position: absolute; left: 0; right: 0; height: 38%; z-index: 2;
  opacity: 0; transition: opacity 0.3s ease;
  background: linear-gradient(180deg, transparent, oklch(78% 0.20 140 / 0.55), transparent);
}
.dt-filecard.is-analysing .dt-filecard__scan {
  opacity: 1; animation: dt-scan 1.15s ease-in-out infinite;
}
@keyframes dt-scan {
  0%   { transform: translateY(-120%); }
  100% { transform: translateY(320%); }
}

/* done: the tick pops onto the corner at 1.5 overshoot */
.dt-filecard__badge {
  position: absolute; right: -5px; bottom: -5px; z-index: 4;
  border: 2px solid oklch(94% 0.02 62);
  transform: scale(0); opacity: 0;
  transition: transform 0.42s cubic-bezier(0.2,1.5,0.4,1), opacity 0.2s ease;
}
.dt-filecard.is-done .dt-filecard__doc {
  overflow: visible;
  background: oklch(66% 0.22 140 / 0.2);
}
.dt-filecard.is-done .dt-filecard__badge {
  transform: scale(1); opacity: 1; transition-delay: 0.1s;
}

/* upload progress hairline along the bottom of the file row. A faint track
   sits behind it so the bar reads as progress, and both lift slightly off the
   row's edge rather than hugging it. */
.dt-filecard__file::before {
  content: ''; position: absolute; left: 0; right: 0; bottom: 6px;
  height: 2px; border-radius: 2px;
  background: rgba(120,90,60,0.12);
  opacity: 0; transition: opacity 0.3s ease;
}
.dt-filecard.is-uploading .dt-filecard__file::before { opacity: 1; }
.dt-filecard__prog {
  position: absolute; left: 0; bottom: 6px;
  height: 2px; width: 0; border-radius: 2px;
  background: var(--bili-green-cta);
  opacity: 0;
  transition: width 0.2s linear, opacity 0.3s ease;
}
.dt-filecard.is-uploading .dt-filecard__prog { opacity: 1; }

/* ── collapsible regions ────────────────────────────────────────────────────
   grid-template-rows 0fr → 1fr, NOT max-height. It interpolates to the
   content's real height, so nothing needs a hardcoded pixel height and a long
   filename or a tenth row never clips. */
.dt-filecard__head,
.dt-filecard__body {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.46s cubic-bezier(0.2,0.8,0.25,1);
}
.dt-filecard__head > div,
.dt-filecard__body > div { overflow: hidden; min-height: 0; }
.dt-filecard.is-analysing .dt-filecard__head,
.dt-filecard.is-done .dt-filecard__head,
.dt-filecard.is-failed .dt-filecard__head,
.dt-filecard.is-analysing .dt-filecard__body,
.dt-filecard.is-done .dt-filecard__body { grid-template-rows: 1fr; }

.dt-filecard__head .dt-reshead { border-top: 1px solid rgba(120,90,60,0.15); }
/* while analysing the header is NEUTRAL — it only turns green on success */
.dt-filecard.is-analysing .dt-reshead {
  background: rgba(255,255,255,0.3);
  border-bottom-color: rgba(120,90,60,0.15);
}
.dt-filecard.is-analysing .dt-reshead__tx { color: var(--bili-ink-2); }
.dt-filecard.is-analysing .dt-spinner { opacity: 1; animation: dt-spin 0.8s linear infinite; }
.dt-filecard.is-done .dt-reshead__glyph .dt-tick { transform: scale(1); opacity: 1; }
.dt-filecard__ct {
  opacity: 0; transform: scale(0.88);
  transition: opacity 0.3s ease 0.12s, transform 0.3s cubic-bezier(0.2,1.4,0.4,1) 0.12s;
}
.dt-filecard.is-done .dt-filecard__ct { opacity: 1; transform: none; }

.dt-filecard__bodyin { padding: 13px 18px 15px; }

/* ── skeleton / real ledger swap ────────────────────────────────────────────
   The skeleton exists to stop the height LURCHING: four shimmer rows bring the
   card to roughly its final size, so real data arriving is a swap not a jump. */
.dt-filecard__sk {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows 0.4s cubic-bezier(0.2,0.8,0.25,1), opacity 0.25s;
}
.dt-filecard__sk > div { overflow: hidden; min-height: 0; }
.dt-filecard.is-done .dt-filecard__sk { grid-template-rows: 0fr; opacity: 0; }

.dt-filecard__real {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.5s cubic-bezier(0.2,0.8,0.25,1);
}
.dt-filecard__real > div { overflow: hidden; min-height: 0; }
.dt-filecard.is-done .dt-filecard__real { grid-template-rows: 1fr; }

.dt-sk { display: flex; flex-direction: column; gap: 12px; padding: 3px 0; }
.dt-sk__r { display: flex; gap: 18px; align-items: center; }
.dt-sk__b {
  position: relative; overflow: hidden;
  height: 9px; border-radius: 5px;
  background: rgba(120,90,60,0.15);
}
/* a bright highlight band travels across a solid base — not the base pulsing */
.dt-sk__b::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(100deg,
    transparent 18%,
    rgba(255,255,255,0.95) 48%,
    oklch(88% 0.10 140 / 0.5) 58%,
    transparent 84%);
  background-size: 220% 100%;
  animation: dt-sheen 1.25s ease-in-out infinite;
}
@keyframes dt-sheen {
  0%   { background-position: 170% 0; }
  100% { background-position: -70% 0; }
}
.dt-sk__r .dt-sk__b:first-child { width: 118px; flex-shrink: 0; }
.dt-sk__r .dt-sk__b:last-child  { flex: 1; max-width: 170px; }
.dt-sk__r:nth-child(2) .dt-sk__b:last-child { max-width: 110px; }
.dt-sk__r:nth-child(3) .dt-sk__b:last-child { max-width: 200px; }
.dt-sk__r:nth-child(4) .dt-sk__b:last-child { max-width: 140px; }
/* the highlight travels DOWN the rows as a wave, not all at once */
.dt-sk__r:nth-child(1) .dt-sk__b::after { animation-delay: 0ms; }
.dt-sk__r:nth-child(2) .dt-sk__b::after { animation-delay: 90ms; }
.dt-sk__r:nth-child(3) .dt-sk__b::after { animation-delay: 180ms; }
.dt-sk__r:nth-child(4) .dt-sk__b::after { animation-delay: 270ms; }

/* ── failed state ───────────────────────────────────────────────────────── */
.dt-filecard.is-failed .dt-filecard__doc {
  background: rgba(120,90,60,0.14);
  color: var(--bili-ink-2);
}
.dt-filecard.is-failed .dt-reshead {
  background: rgba(120,90,60,0.08);
  border-bottom-color: rgba(120,90,60,0.15);
}
.dt-filecard.is-failed .dt-reshead__tx { color: var(--bili-ink-2); }

/* ═══════════════════════════════════════════════════════════════════════════
   Reduced motion — states still change, they just do not move. Keep this.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .dt-filecard,
  .dt-filecard *,
  .dt-extract *,
  .dt-marker,
  .dt-focus,
  .dt-focus__thinking i {
    animation: none !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Onboarding chat — "What we know" panel, team outline, team modal
   Target: frontend/static/css/app.css

   Paste where the old "What we know" panel block was: after
   .dt-chat-msg--extraction__val, before .dt-chat-grid.
   See 01-css.md for the two blocks to delete first.
   Uses existing tokens only — no new custom properties.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── FIX: transcript bottom-anchoring ────────────────────────────────────────
   .dt-chat-messages previously used justify-content to bottom-anchor/centre.
   In a column flex container that pushes content past the BLOCK-START edge,
   and block-start overflow cannot be scrolled to — the top of a long
   transcript became unreachable. Anchor with auto margin instead. */
.dt-chat-messages {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 14px; padding: 22px 24px;
}
.dt-chat-messages > :first-child { margin-top: auto; }

/* ── FIX: panel survives narrow viewports ───────────────────────────────────
   .dt-chat-grid is height-locked to the viewport. Below ~1180px the single
   column resolved the panel row to ~5px, because .dt-kw-card's only child is
   flex:1 and contributes no intrinsic height. Let the page scroll instead. */
@media (max-width: 1180px) {
  /* Flex column (not block) so explicit order keeps the chat first even though
     the checklist markup comes first in the DOM. */
  .dt-chat-grid {
    display: flex; flex-direction: column;
    height: auto; min-height: 0;
  }
  /* Stacked, the page is taller than the viewport on purpose: let it grow and
     the content area scroll again. */
  .dt-page { height: auto; }
  .dt-chat-grid > .dt-chat-title { order: 1; }
  .dt-chat-grid > .dt-chat-card  { order: 2; min-height: 60vh; display: flex; }
  .dt-chat-grid > .dt-kw-card    { order: 3; margin-top: 16px; min-height: 420px; max-height: 70vh; }
  .dt-chat-grid > .dt-kw-skip    { order: 4; margin-top: 12px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   "What we know" panel — de-chromed
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-kw-card {
  grid-area: checklist;
  display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
  padding: 0;
  /* The panel reads as one card, so it carries the panel's own green edge
     rather than the neutral glass border the other cards use. */
  border-color: oklch(66% 0.22 140 / 0.42);
}

/* The category being talked about, stated once above the lists */
.dt-kw-now {
  display: flex; flex-direction: column; gap: 3px;
  padding: 2px 18px 16px;
}
.dt-kw-now__label {
  font-size: 17px; font-weight: 500; line-height: 1.35;
  color: var(--bili-ink);
}

/* Full-bleed rule separating "currently talking about" from the lists below */
.dt-kw-rule { height: 1px; background: oklch(66% 0.22 140 / 0.45); }

/* "Skip for now" sits under the panel at full column width: visible, but a
   quiet tinted grey rather than the primary green so it never competes. */
.dt-kw-skip {
  grid-area: skip;
  width: 100%;
  font-family: inherit;
  font-size: 13.5px; line-height: 1.4;
  padding: 11px 16px;
  border-radius: var(--r-md);
  border: 1px solid oklch(66% 0.22 140 / 0.22);
  background: oklch(95% 0.014 140);
  color: var(--bili-ink-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.dt-kw-skip:hover {
  background: oklch(93% 0.03 140);
  border-color: oklch(66% 0.22 140 / 0.40);
  color: var(--bili-ink);
}

.dt-kw-header {
  flex-shrink: 0;
  padding: 16px 18px 13px;
}
.dt-kw-header__row {
  display: flex; align-items: baseline; gap: 10px;
}
.dt-kw-header__title {
  flex: 1;
  margin: 0;
  font-size: 15px; font-weight: 500; color: var(--bili-ink);
}
.dt-kw-header__count {
  font-size: 12.5px; color: var(--bili-ink-2);
}
.dt-kw-header__count b { color: var(--bili-ink); font-weight: 500; }

.dt-kw-prog {
  height: 4px; border-radius: 2px;
  background: rgba(120,90,60,0.14);
  margin-top: 10px; overflow: hidden;
}
.dt-kw-prog__fill {
  display: block; height: 100%;
  background: var(--bili-green-cta);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.dt-kw-cats {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0 8px 12px;
}

/* ── a category row ──────────────────────────────────────────────────────── */
.dt-kw-cat {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px;
  border: 0; background: none; text-align: left;
  border-radius: var(--r-md);
  font-family: inherit; font-size: inherit; color: inherit;
  cursor: pointer;
}
.dt-kw-cat + .dt-kw-cat { box-shadow: 0 -1px 0 rgba(120,90,60,0.15); }
.dt-kw-cat:hover { background: rgba(255,255,255,0.55); }
/* suppress the separator above a hovered or open row */
.dt-kw-cat:hover + .dt-kw-cat,
.dt-kw-cat.is-open + .dt-kw-cat { box-shadow: none; }

/* status glyph gutter */
.dt-kw-cat__marker {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.dt-kw-cat__marker--found {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bili-green-cta);
  display: flex; align-items: center; justify-content: center;
}
.dt-kw-cat__marker--found svg { width: 11px; height: 11px; fill: #fff; }
.dt-kw-cat__marker--partial {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px dotted var(--bili-green-cta);
}
.dt-kw-cat__marker--empty {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px dotted rgba(120,90,60,0.28);
}
.dt-kw-cat__marker--now {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid var(--bili-green-cta);
}
/* A partial row is still in "still to cover", so keep its label at full ink. */
.dt-kw-cat--partial .dt-kw-cat__label { color: var(--bili-ink); }

/* IMPORTANT: must be a flex column. As display:block the label and value are
   inline boxes — they render as one run of text and the value's ellipsis
   truncation silently does nothing. */
.dt-kw-cat__tx {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.dt-kw-cat__label {
  font-size: 14px; line-height: 1.35; color: var(--bili-ink);
}
.dt-kw-cat__val {
  font-size: 13px; color: var(--bili-ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* found rows go quiet so the live row is the loudest thing in the panel */
.dt-kw-cat--found .dt-kw-cat__label { color: var(--bili-ink-2); }

/* the category being talked about — a chip in "Still to cover", and the
   kicker above the card's list */
.dt-kw-chip--now {
  background: oklch(66% 0.22 140 / 0.12);
  border-color: oklch(66% 0.22 140 / 0.45);
  color: var(--bili-ink);
}
.dt-kw-cat__nowkicker {
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--bili-sage);
}

.dt-kw-cat__arrow {
  width: 16px; height: 16px; flex-shrink: 0;
  color: var(--bili-ink-3);
  transition: transform 0.18s;
}
.dt-kw-cat__arrow svg { width: 16px; height: 16px; display: block; }
.dt-kw-cat.is-open .dt-kw-cat__arrow { transform: rotate(180deg); }

/* Team structure's affordance — opens the modal, does not expand in place */
.dt-kw-cat__opener {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  font-size: 12.5px; color: var(--bili-sage);
}
.dt-kw-cat__opener svg { width: 13px; height: 13px; }
.dt-kw-cat:hover .dt-kw-cat__opener { color: var(--bili-green-dark); }

/* ── expanded key/value pairs, with per-item provenance ──────────────────── */
.dt-kw-foldout {
  padding: 2px 12px 14px 42px;
  display: flex; flex-direction: column; gap: 9px;
}
.dt-kw-item { display: flex; flex-direction: column; gap: 1px; }
.dt-kw-item__head { display: flex; align-items: baseline; gap: 10px; }
.dt-kw-item__k {
  flex: 1; min-width: 0;
  font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--bili-ink-2);  /* NOT ink-3 — see contrast note in 01-css.md */
}
.dt-kw-item__src {
  flex-shrink: 0; max-width: 52%;
  display: flex; align-items: center; gap: 4px;
  font-size: 11.5px; color: var(--bili-ink-2);
}
.dt-kw-item__src svg { width: 11px; height: 11px; flex-shrink: 0; opacity: 0.8; }
.dt-kw-item__src span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dt-kw-item__val { font-size: 14px; line-height: 1.45; color: var(--bili-ink); }
.dt-kw-item__val a {
  text-decoration: none;
  border-bottom: 1px solid oklch(52% 0.13 138 / 0.35);
}
.dt-kw-item__val--missing { color: var(--bili-ink-3); }

/* ── "Still to cover" group ──────────────────────────────────────────────── */
.dt-kw-group {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 12px 7px;
  font-size: 11.5px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--bili-ink-2);
}
.dt-kw-group i { flex: 1; border-top: 1px solid rgba(120,90,60,0.15); }
.dt-kw-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 12px 8px;
}
.dt-kw-chip {
  font-family: inherit;
  font-size: 13px; padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(120,90,60,0.15);
  color: var(--bili-ink-2);
  cursor: pointer;
}
.dt-kw-chip:hover { background: #fff; color: var(--bili-ink); }

/* The live-question focus card and its thread marker are defined with the
   unified bubble grammar above (search ".dt-focus"). */

/* ═══════════════════════════════════════════════════════════════════════════
   Indented outline — shared by the modal AND the inline chat panel
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-ol { display: flex; flex-direction: column; }

.dt-ol__row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-radius: var(--r-sm);
  position: relative;
  transition: padding-left 0.18s ease, background 0.15s;
}
.dt-ol__row:hover { background: rgba(255,255,255,0.62); }
.dt-ol__row.is-selected { background: oklch(66% 0.22 140 / 0.10); }

/* dotted depth rails, one per level, positioned inline by the template */
.dt-ol__rail {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px dotted rgba(120,90,60,0.28);
}

.dt-ol__avatar {
  width: 34px; height: 34px; border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: oklch(66% 0.22 140 / 0.18);
  color: var(--bili-green-dark);
  font-size: 13px; font-weight: 500;
}
.dt-ol__avatar--muted {
  background: rgba(120,90,60,0.14); color: var(--bili-ink-2);
}
.dt-ol__avatar--sm { width: 24px; height: 24px; font-size: 10.5px; }

.dt-ol__name {
  flex-shrink: 0;
  font-size: 15px; font-weight: 500; color: var(--bili-ink);
}
.dt-ol__title {
  flex: 1; min-width: 0;
  font-size: 14px; color: var(--bili-ink-2);
}
.dt-ol__mgr {
  flex-shrink: 0; white-space: nowrap;
  font-size: 11.5px; color: var(--bili-ink-2);
  padding: 2px 8px; border-radius: var(--r-pill);
  background: rgba(255,255,255,0.6);
}

/* click a job title to retype it */
.dt-ol__edit {
  padding: 1px 3px; border-radius: 3px;
  border-bottom: 1px dashed rgba(120,90,60,0.28);
  cursor: pointer;
}
.dt-ol__edit:hover {
  border-bottom-color: var(--bili-green-cta);
  background: oklch(66% 0.22 140 / 0.10);
  color: var(--bili-sage);
}

/* indent controls — revealed on hover/focus only, so a settled list is calm */
.dt-ol__ind {
  display: flex; gap: 3px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.12s;
}
.dt-ol__row:hover .dt-ol__ind,
.dt-ol__row:focus-within .dt-ol__ind { opacity: 1; }
.dt-ol__ind button {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(120,90,60,0.28);
  background: rgba(255,255,255,0.72);
  color: var(--bili-ink-2);
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 13px;
  cursor: pointer;
}
.dt-ol__ind button:hover:not(:disabled) {
  background: #fff; color: var(--bili-ink);
  border-color: var(--bili-sage);
}
.dt-ol__ind button:disabled { opacity: 0.25; cursor: default; }

.dt-ol__more {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  font-size: 13px; color: var(--bili-ink-2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Team modal — over the WHOLE app, including the left nav
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-team-scrim {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
  background: oklch(30% 0.03 50 / 0.38);
  backdrop-filter: blur(3px);
  animation: dtTeamFade 0.18s ease;
}
@keyframes dtTeamFade { from { opacity: 0; } to { opacity: 1; } }

.dt-team-modal {
  width: 780px; max-width: 100%; max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(170deg, rgba(255,255,255,0.94), rgba(255,255,255,0.86));
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: var(--r-xl);
  box-shadow: 0 28px 80px oklch(20% 0.04 50 / 0.3);
  animation: dtTeamPop 0.22s cubic-bezier(0.2,0.8,0.3,1);
}
@keyframes dtTeamPop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.dt-team-modal__head {
  flex-shrink: 0;
  display: flex; align-items: flex-start; gap: 14px;
  padding: 20px 24px 18px;
  border-bottom: 1px solid rgba(120,90,60,0.15);
  background: oklch(66% 0.16 140 / 0.07);
}
.dt-team-modal__head h2 {
  margin: 0;
  font-size: clamp(18px, 1.7vw, 21px); font-weight: 500;
  line-height: 1.25; color: var(--bili-ink);
}
.dt-team-modal__head p {
  margin: 4px 0 0;
  font-size: 14px; color: var(--bili-ink-2); line-height: 1.5;
}
.dt-team-modal__tick {
  flex-shrink: 0; margin-top: 2px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bili-green-cta);
  display: inline-flex; align-items: center; justify-content: center;
}
.dt-team-modal__tick svg { width: 18px; height: 18px; fill: #fff; }
.dt-team-modal__x {
  margin-left: auto; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(120,90,60,0.28);
  background: rgba(255,255,255,0.6);
  color: var(--bili-ink-2);
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 16px; line-height: 1;
  cursor: pointer;
}
.dt-team-modal__x:hover { background: #fff; color: var(--bili-ink); }

.dt-team-modal__body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px 22px;
}

.dt-team-modal__foot {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 24px;
  border-top: 1px solid rgba(120,90,60,0.15);
  background: rgba(255,255,255,0.55);
}
.dt-team-modal__hint {
  flex: 1; min-width: 210px;
  margin: 0;
  font-size: 12.5px; color: var(--bili-ink-2); line-height: 1.5;
}
.dt-team-modal__foot kbd {
  font-family: inherit; font-size: 11.5px;
  border: 1px solid rgba(120,90,60,0.28); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px;
  background: rgba(255,255,255,0.7); color: var(--bili-ink-2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Inline outline panel — appears in the transcript after "That's not right"
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-ip {
  flex-shrink: 0; align-self: flex-start;
  max-width: min(720px, 100%);
  overflow: hidden;
  background: rgba(255,255,255,0.58);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 18px oklch(20% 0.04 50 / 0.08), inset 0 1px 0 var(--glass-shine);
}
.dt-ip__head {
  padding: 14px 17px 12px;
  border-bottom: 1px solid rgba(120,90,60,0.15);
  background: oklch(66% 0.16 140 / 0.07);
}
.dt-ip__head h3 {
  margin: 0; font-size: 15px; font-weight: 500; line-height: 1.3;
  color: var(--bili-ink);
}
.dt-ip__head p {
  margin: 3px 0 0; font-size: 13px; color: var(--bili-ink-2); line-height: 1.5;
}
.dt-ip__body { padding: 8px 10px; }
.dt-ip__foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 17px;
  border-top: 1px solid rgba(120,90,60,0.15);
  background: rgba(255,255,255,0.4);
}
.dt-ip__hint {
  flex: 1; min-width: 180px;
  margin: 0; font-size: 12.5px; color: var(--bili-ink-2);
}
.dt-ip__foot kbd {
  font-family: inherit; font-size: 11.5px;
  border: 1px solid rgba(120,90,60,0.28); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px;
  background: rgba(255,255,255,0.7); color: var(--bili-ink-2);
}


/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dt-chat-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .dt-chat-card { height: auto; min-height: 420px; }
  .dt-chat-messages { padding: 14px 14px; }
  .dt-chat-msg { max-width: 92%; }
}
@media (max-width: 1024px) {
  .layout-split.dt-grid,
  .layout-rail.dt-grid {
    grid-template-columns: 1fr;
  }
  .layout-split .dt-railcol,
  .layout-rail .dt-railcol,
  .layout-rail .dt-slot--checklist { position: static; }
  .dt-upload-split {
    grid-template-columns: 1fr;
  }
  .layout-hero .dt-checklist { columns: 1; }
}

/* #chat-checklist-slot is the flex pass-through between the card and the
   panel partial. Without it the panel's rows cannot scroll in place. */
#chat-checklist-slot {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}


/* === Inline-style utilities (converted from template style attrs) === */

.u-code-block {
  background:var(--surface-code);
  color:var(--surface-code-fg);
  padding:0.4rem 0.6rem;
  border-radius:4px;
  white-space:pre-wrap;
  word-break:break-all;
}

.u-dropdown {
  display:none;
  position:absolute;
  top:100%;
  left:0;
  right:0;
  z-index:120;
  background:var(--surface);
  border:1px solid var(--surface-border);
  border-radius:4px;
  max-height:200px;
  overflow-y:auto;
  box-shadow:0 2px 8px color-mix(in srgb, var(--bili-ink) 10%, transparent);
}

.u-dropdown-180 {
  display:none;
  position:absolute;
  top:100%;
  left:0;
  right:0;
  z-index:50;
  background:var(--surface);
  border:1px solid var(--surface-border);
  border-radius:4px;
  max-height:180px;
  overflow-y:auto;
  box-shadow:0 2px 8px color-mix(in srgb, var(--bili-ink) 10%, transparent);
}

.u-dropdown-240 {
  display:none;
  position:absolute;
  top:100%;
  left:0;
  right:0;
  z-index:100;
  background:var(--surface);
  border:1px solid var(--surface-border);
  border-radius:4px;
  max-height:240px;
  overflow-y:auto;
  box-shadow:0 2px 8px color-mix(in srgb, var(--bili-ink) 10%, transparent);
}

.u-ellipsis {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.u-ellipsis-160-muted {
  max-width:160px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-style:italic;
  color:var(--bili-ink-3);
}

.u-ellipsis-200 {
  max-width:200px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.u-float-right-xs {
  float:right;
  font-size:0.65rem;
}

.u-form-warning {
  max-width:560px;
  border:2px solid var(--warn-border);
  background:var(--warn-bg);
}

.u-full {
  width:100%;
}

.u-hidden {
  display:none;
}

.u-icon-14 {
  display:inline-flex;
  width:14px;
  height:14px;
}

.u-inline {
  display:inline;
}

.u-italic {
  font-style:italic;
}

.u-justify-end {
  justify-content:flex-end;
}

.u-maxw-400 {
  max-width:400px;
}

.u-maxw-480 {
  max-width:480px;
}

.u-maxw-560 {
  max-width:560px;
}

.u-maxw-680 {
  max-width:680px;
}

.u-meta-70 {
  font-size:0.7rem;
  color:var(--bili-ink-3);
}

.u-meta-80 {
  color:var(--bili-ink-3);
  font-size:0.8rem;
}

.u-meta-block {
  font-size:0.7rem;
  color:var(--bili-ink-3);
  display:block;
}

.u-minh-400 {
  min-height:400px;
}

.u-ml-auto-muted {
  margin-left:auto;
  opacity:0.5;
  font-size:0.8rem;
}

.u-modal-860 {
  width:min(860px,95vw);
}

.u-mt-12 {
  margin-top:12px;
}

.u-muted-italic {
  color:var(--bili-gold-text);
  font-style:italic;
}

.u-nowrap {
  white-space:nowrap;
}

.u-op-55 {
  opacity:0.55;
}

.u-pad-2 {
  padding:2rem;
}

.u-pl-46 {
  padding-left:46px;
}

.u-pointer {
  cursor:pointer;
}

.u-pre-wrap {
  white-space:pre-wrap;
}

.u-relative {
  position:relative;
}

.u-row-divider {
  border-bottom:1px solid color-mix(in srgb, var(--bili-ink) 5%, transparent);
}

.u-scroll {
  overflow:auto;
}

.u-scroll-300 {
  max-height:300px;
  overflow-y:auto;
}

.u-scroll-x {
  overflow-x:auto;
}

.u-timeline-line {
  border-left:2px solid var(--surface-border);
}

.u-warning-text {
  color:var(--warn-text);
}

/* === Organisations area === */
/* ── 1. Page bar — actions alignment ───────────────────────────────────────
   Bulma's `.buttons` adds -0.5rem/+0.5rem margins that push a bar action (the
   org view switcher) off centre; the bar's own gap spaces them.             */
.bili-page-bar__actions{gap:8px}
.bili-page-bar__actions>*{margin:0}

/* ── 2. Shared primitives ─────────────────────────────────────────────────── */
.bo-mono{font-family:var(--font-mono);font-size:12px;letter-spacing:-.01em}
.bo-cap{font-size:11px;font-weight:500;letter-spacing:.07em;text-transform:uppercase;color:var(--bili-ink-3)}
.bo-muted{color:var(--bili-ink-3)}

/* Segmented control — view switcher; same visual language as .tabs */
.bo-seg{display:inline-flex;gap:2px;padding:3px;border-radius:var(--r-pill);background:rgba(255,255,255,.32);border:1px solid var(--glass-border);box-shadow:inset 0 1px 0 var(--glass-shine),0 2px 8px oklch(20% 0.04 50/.06)}
.bo-seg a,.bo-seg button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 12px;border-radius:var(--r-pill);font-size:12px;font-weight:500;color:var(--bili-ink-2);cursor:pointer;transition:background .15s,color .15s}
.bo-seg a:hover,.bo-seg button:hover{background:rgba(255,255,255,.45);color:var(--bili-ink)}
.bo-seg .is-active,.bo-seg .is-active:hover{background:oklch(28% 0.04 50/.92);color:#fff;box-shadow:inset 0 1px 0 rgba(255,255,255,.18),0 1px 3px oklch(20% 0.04 50/.18)}
.bo-seg svg{width:14px;height:14px;flex-shrink:0}

/* Request Input — right-hand guidance panel */
.wf-guidance{position:sticky;top:16px}
.wf-guidance__eyebrow{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--bili-ink-3);margin-bottom:10px}
.wf-guidance__body{font-size:14px;line-height:1.55;color:var(--bili-ink-2)}
.wf-guidance__body > :last-child{margin-bottom:0}

/* === Request Input — question cards ===
   One glass card per question. State classes (set by Alpine): is-active shows the
   question, is-done shows the question + confirmed answer (tap to re-open),
   is-pending shows just the question, dimmed. Open/close animates grid rows. */
.wf-form__head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:14px;padding:0 4px}
.wf-form__head .title{margin:0}
.wf-form__count{font-size:12px;color:var(--bili-ink-2);white-space:nowrap}
.wf-q-section{margin:18px 4px 8px;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--bili-ink-3)}
.wf-q{position:relative;margin-bottom:12px;border-radius:var(--r-xl);background:var(--glass-fill);border:1px solid var(--glass-border);box-shadow:inset 0 1px 0 var(--glass-shine),0 4px 16px oklch(20% 0.04 50/.06);transition:background .45s ease,box-shadow .45s ease,opacity .45s ease}
.wf-q.is-pending{opacity:.62}
.wf-q.is-done{background:var(--glass-fill-2)}
.wf-q.is-active{background:var(--glass-fill-2);box-shadow:inset 0 1px 0 var(--glass-shine),var(--glass-shadow)}

.wf-q__collapse{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows .5s cubic-bezier(.4,.01,.2,1),opacity .35s ease}
.wf-q__in{min-height:0;overflow:hidden;visibility:hidden;transition:visibility 0s .5s}
.wf-q.is-active .wf-q__body,.wf-q.is-done .wf-q__sum,.wf-q.is-pending .wf-q__sum{grid-template-rows:1fr;opacity:1}
.wf-q.is-active .wf-q__body > .wf-q__in,.wf-q.is-done .wf-q__sum > .wf-q__in,.wf-q.is-pending .wf-q__sum > .wf-q__in{visibility:visible;transition-delay:0s}

.wf-q__sumbtn{all:unset;box-sizing:border-box;display:flex;align-items:center;gap:16px;width:100%;min-height:72px;padding:14px 22px;border-radius:var(--r-xl);cursor:default}
.wf-q.is-done .wf-q__sumbtn{cursor:pointer}
.wf-q.is-done .wf-q__sumbtn:hover{background:rgba(255,255,255,.35)}
.wf-q__sumbtn:focus-visible,.wf-tile input:focus-visible + .wf-tile__face{outline:2px solid oklch(28% 0.04 50/.35);outline-offset:2px}
.wf-q__badge{flex:none;width:30px;height:30px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;color:var(--bili-ink);background:rgba(255,255,255,.8);border:1px solid rgba(255,255,255,.95);transition:background .4s,color .4s}
.wf-q__done{display:none;width:16px;height:16px}
.wf-q.is-done .wf-q__badge{background:var(--bili-green-cta);border-color:transparent;color:var(--bili-green-dark)}
.wf-q.is-done .wf-q__num{display:none}
.wf-q.is-done .wf-q__done{display:block}
.wf-q__sumtext{display:flex;flex-direction:column;gap:2px;min-width:0}
.wf-q__sumlabel{font-size:13px;color:var(--bili-ink-2)}
.wf-q.is-pending .wf-q__sumlabel{font-size:15px;font-weight:500;color:var(--bili-ink)}
.wf-q__sumanswer{font-size:16px;font-weight:500;color:var(--bili-ink)}
.wf-q.is-pending .wf-q__sumanswer{display:none}
.wf-q__change{display:none;align-items:center;gap:6px;margin-left:auto;font-size:12px;font-weight:500;color:var(--bili-ink-2)}
.wf-q.is-done .wf-q__change{display:flex}
.wf-q__change svg{width:14px;height:14px}

.wf-q__pad{padding:24px 26px}
.wf-q__fieldset{border:0;margin:0;padding:0;min-width:0}
.wf-q__title{display:block;width:100%;padding:0;margin:0 0 16px;font-size:22px;font-weight:500;letter-spacing:-.015em;line-height:1.25;color:var(--bili-ink)}
.wf-q__fieldset > legend.wf-q__title{float:left}
.wf-q__fieldset > legend.wf-q__title + *{clear:both}
.wf-q__pad .input,.wf-q__pad .textarea,.wf-q__pad .select select{border-color:color-mix(in oklch,var(--bili-ink) 24%,transparent)}
.wf-q__check{font-size:16px;font-weight:500}
.wf-q__foot{display:flex;justify-content:flex-end;margin-top:18px}

/* Choice tile — a radio option for questions with a handful of choices */
.wf-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
.wf-tile{position:relative;display:block;cursor:pointer}
.wf-tile input{position:absolute;opacity:0;width:0;height:0;pointer-events:none}
.wf-tile__face{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:68px;padding:12px 18px;border-radius:var(--r-lg);font-size:15px;font-weight:500;line-height:1.25;color:var(--bili-ink);background:rgba(255,255,255,.65);border:1px solid rgba(255,255,255,.85);box-shadow:inset 0 1px 0 var(--glass-shine),0 4px 14px oklch(20% 0.04 50/.08);transition:background .2s,color .2s,transform .12s}
.wf-tile:hover .wf-tile__face{background:rgba(255,255,255,.9);transform:translateY(-1px)}
.wf-tile input:checked + .wf-tile__face,.wf-tile:hover input:checked + .wf-tile__face{background:oklch(28% 0.04 50/.92);color:#fff;border-color:oklch(28% 0.04 50/.92);box-shadow:inset 0 1px 0 rgba(255,255,255,.18),0 6px 20px oklch(20% 0.04 50/.3)}
.wf-tile__tick{display:none;width:18px;height:18px;flex:none}
.wf-tile input:checked + .wf-tile__face .wf-tile__tick{display:block}

.wf-actions{display:flex;align-items:center;gap:6px;padding:6px 6px 0}
.wf-actions__spacer{flex:1}

/* Date control — one box holding the value strip and the calendar, for a field
   whose type is `date`. Open while there is no answer; picking a day, a quick
   pick or the no-value answer collapses it to the value; the × clears it and
   opens it again. The collapse uses the same technique as .wf-q__collapse, so
   the motion matches the question card it sits in. */
.bili-date{width:min(20.5rem,100%);background:rgba(255,255,255,.92);border:1px solid rgba(255,255,255,.85);border-radius:var(--r-lg);box-shadow:0 8px 26px oklch(20% 0.04 50/.12);transition:border-radius .3s cubic-bezier(.4,.01,.2,1)}
.bili-date.is-open{border-radius:var(--r-lg) var(--r-lg) 0 0}
.bili-date__strip{display:flex;align-items:center;gap:10px;padding:11px 12px 11px 14px;cursor:pointer;border-radius:inherit}
.bili-date__strip:focus-visible{outline:2px solid oklch(28% 0.04 50/.35);outline-offset:2px}
.bili-date__val{flex:1;font-size:13px;color:var(--bili-ink)}
.bili-date__val.is-empty{color:var(--bili-ink-3)}
.bili-date__val.is-none{color:var(--bili-ink-2);font-size:12px}
.bili-date__cal{width:15px;height:15px;flex:none;color:var(--bili-sage)}
.bili-date__clear{width:22px;height:22px;flex:none;display:flex;align-items:center;justify-content:center;padding:0;border:0;border-radius:50%;background:oklch(38% 0.022 55);color:#fff;font-size:10px;font-weight:700;line-height:1;cursor:pointer}
.bili-date__clear:hover{background:oklch(30% 0.022 55)}
.bili-date__clear:focus-visible{outline:2px solid oklch(28% 0.04 50/.35);outline-offset:2px}
.bili-date__panel{display:grid;grid-template-rows:1fr;opacity:1;transition:grid-template-rows .32s cubic-bezier(.4,.01,.2,1),opacity .26s ease}
.bili-date:not(.is-open) .bili-date__panel{grid-template-rows:0fr;opacity:0;pointer-events:none}
.bili-date__in{min-height:0;overflow:hidden;visibility:visible;transition:visibility 0s}
.bili-date:not(.is-open) .bili-date__in{visibility:hidden;transition:visibility 0s .32s}
.bili-date__head{display:flex;align-items:center;justify-content:space-between;padding:9px 12px 2px;border-top:1px solid rgba(0,0,0,.06)}
.bili-date__month{font-size:12px;font-weight:600;color:var(--bili-ink)}
.bili-date__nav{display:flex;gap:4px}
.bili-date__nav button{width:22px;height:22px;display:flex;align-items:center;justify-content:center;padding:0;border:0;border-radius:var(--r-sm);background:rgba(0,0,0,.045);color:var(--bili-ink-2);font:inherit;font-size:12px;cursor:pointer}
.bili-date__nav button:hover{background:rgba(0,0,0,.09)}
.bili-date__grid{display:grid;grid-template-columns:repeat(7,1fr);gap:3px;padding:4px 12px 8px}
.bili-date__dow{font-size:9px;color:var(--bili-ink-3);text-align:center;padding:2px 0;text-transform:uppercase;letter-spacing:.05em}
.bili-date__d{padding:6px 0;border:0;border-radius:var(--r-sm);background:none;font:inherit;font-size:12px;color:var(--bili-ink);text-align:center;cursor:pointer}
.bili-date__d:hover:not(:disabled){background:rgba(0,0,0,.06)}
.bili-date__d.is-dim{color:var(--bili-ink-3);opacity:.5;cursor:default}
.bili-date__d.is-today{box-shadow:inset 0 0 0 1.5px var(--bili-sage)}
.bili-date__d.is-on{background:var(--bili-green-cta);color:#fff;font-weight:600}
.bili-date__ft{display:flex;flex-wrap:wrap;gap:6px;padding:0 12px 11px}
.bili-date__ft button{padding:4px 10px;border:0;border-radius:var(--r-pill);background:rgba(0,0,0,.045);font:inherit;font-size:10.5px;color:var(--bili-ink-2);cursor:pointer}
.bili-date__ft button:hover{background:rgba(0,0,0,.09)}
.bili-date__ft button.is-quick{background:oklch(66% 0.22 140/.16);color:var(--bili-green-dark);font-weight:600}
.bili-date__ft button.is-quick:hover{background:oklch(66% 0.22 140/.26)}
.bili-date__none{background:transparent;border:1px dashed rgba(0,0,0,.18)}

@media (max-width:768px){
  .wf-q__pad{padding:20px 18px}
  .wf-q__sumbtn{padding:12px 16px}
  .wf-q__title{font-size:19px}
}
@media (prefers-reduced-motion:reduce){
  .wf-q,.wf-q__collapse,.wf-q__in,.wf-q__badge,.wf-tile__face,.bili-date,.bili-date__panel,.bili-date__in{transition:none}
}

/* State: dot + label */
.bo-state{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500;color:var(--bili-ink-2);white-space:nowrap;--state:var(--bo-idle)}
.bo-state i{width:7px;height:7px;border-radius:50%;background:var(--state);box-shadow:0 0 0 3px color-mix(in oklch,var(--state) 22%,transparent);flex-shrink:0}
.bo-state--ok{--state:var(--bo-ok)}.bo-state--busy{--state:var(--bo-busy)}.bo-state--bad{--state:var(--bo-bad);color:oklch(46% 0.17 25)}.bo-state--idle{--state:var(--bo-idle);color:var(--bili-ink-3)}
.bo-state--busy i{animation:bo-pulse 1.4s ease-in-out infinite}
.bo-state--static i{animation:none}
.bo-state--lg{font-size:16px;gap:10px;color:var(--bili-ink)}.bo-state--lg i{width:9px;height:9px}
@keyframes bo-pulse{50%{box-shadow:0 0 0 6px color-mix(in oklch,var(--state) 0%,transparent)}}

/* Search field */
.bo-search{position:relative;display:flex;align-items:center;flex:1;min-width:0}
.bo-search svg{position:absolute;left:13px;width:15px;height:15px;color:var(--bili-ink-3);pointer-events:none}
.bo-search input{all:unset;box-sizing:border-box;width:100%;height:36px;padding:0 14px 0 36px;border-radius:var(--r-pill);font-size:13px;color:var(--bili-ink);background:rgba(255,255,255,.5);border:1px solid rgba(255,255,255,.65);box-shadow:inset 0 1px 2px oklch(20% 0.04 50/.06);transition:background .15s,box-shadow .15s}
.bo-search input::placeholder{color:var(--bili-ink-3)}
.bo-search input:focus{background:rgba(255,255,255,.75);box-shadow:0 0 0 3px oklch(66% 0.20 140/.22)}
.bo-tagfilter{display:flex;align-items:center;padding:8px 6px 0}
.bo-tagfilter select{height:36px;padding:0 12px;border-radius:var(--r-pill);font-size:13px;color:var(--bili-ink);background:rgba(255,255,255,.5);border:1px solid rgba(255,255,255,.65);cursor:pointer}
.bo-tags{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}
.bo-tag{display:inline-flex;align-items:center;gap:6px;padding:2px 10px;border-radius:var(--r-pill);font-size:12px;background:oklch(66% 0.20 140/.14);color:var(--bili-ink);border:1px solid oklch(66% 0.20 140/.25)}
.bo-tag__x{all:unset;cursor:pointer;font-size:14px;line-height:1;color:var(--bili-ink-3)}
.bo-tag__x:hover{color:var(--bili-ink)}
.bo-tag-add{display:flex;gap:6px;align-items:center}
.bo-tag-add .input{max-width:220px}

/* Avatar */
.bo-av{width:40px;height:40px;border-radius:12px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;color:#fff;font-size:14px;font-weight:500;letter-spacing:.02em;background:var(--av,oklch(58% 0.04 55));box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 3px 8px rgba(40,25,15,.16)}
.bo-av--sm{width:30px;height:30px;border-radius:9px;font-size:11px}
.bo-av--xs{width:26px;height:26px;border-radius:50%;font-size:10px;box-shadow:none}
.bo-av[data-tone="0"]{--av:oklch(50% 0.13 140)}.bo-av[data-tone="1"]{--av:oklch(54% 0.12 288)}.bo-av[data-tone="2"]{--av:oklch(56% 0.13 25)}.bo-av[data-tone="3"]{--av:oklch(58% 0.12 75)}
.bo-av--soft{background:color-mix(in oklch,var(--av) 16%,white);color:color-mix(in oklch,var(--av) 80%,black)}

/* Buttons — one size (32px) for all inline actions in this area */
.bo-btn{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:7px;height:32px;padding:0 14px;border-radius:var(--r-pill);font-size:13px;font-weight:500;white-space:nowrap;cursor:pointer;color:var(--bili-ink);background:rgba(255,255,255,.55);border:1px solid rgba(255,255,255,.7);box-shadow:inset 0 1px 0 rgba(255,255,255,.8),0 2px 6px rgba(40,25,15,.08);transition:background .15s,box-shadow .15s,color .15s}
.bo-btn:hover{background:rgba(255,255,255,.8)}
.bo-btn svg{width:14px;height:14px}
.bo-btn--primary{background:oklch(52% 0.15 140);border-color:oklch(58% 0.14 140/.6);color:#fff;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 2px 8px oklch(50% 0.16 140/.28)}
.bo-btn--primary:hover{background:oklch(47% 0.15 140)}
.bo-btn--danger{color:oklch(46% 0.17 25);border-color:color-mix(in oklch,var(--bili-red) 40%,transparent);background:color-mix(in oklch,var(--bili-red) 6%,rgba(255,255,255,.6))}
.bo-btn--danger:hover{background:oklch(55% 0.19 25);color:#fff}
.bo-btn--ghost{background:transparent;border-color:transparent;box-shadow:none;color:var(--bili-ink-2)}
.bo-btn--ghost:hover{background:rgba(255,255,255,.5);color:var(--bili-ink)}
.bo-btn--icon{width:32px;padding:0}
.bo-btn[disabled]{opacity:.5;pointer-events:none}

/* Glass panel */
.bo-panel{background:var(--glass-fill);border:1px solid var(--glass-border);border-radius:var(--r-xl);box-shadow:inset 0 1px 0 var(--glass-shine),var(--glass-shadow);position:relative}
.bo-panel::before{content:'';position:absolute;inset:0 0 auto;height:120px;border-radius:var(--r-xl) var(--r-xl) 0 0;background:linear-gradient(180deg,rgba(255,255,255,.3),transparent);pointer-events:none}
.bo-panel>*{position:relative}

/* ── 3. Page header ──────────────────────────────────────────────────────── */
.bo-page{max-width:1480px;margin:0 auto;display:flex;flex-direction:column;gap:20px}
.bo-page--cards{max-width:960px;padding-top:28px}
.bo-hero{text-align:center;display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
.bo-hero h1{font-size:30px;font-weight:500;letter-spacing:-.02em;margin:0;line-height:1.15}
.bo-hero p{font-size:14px;line-height:1.5;color:var(--bili-ink-2);max-width:46ch;margin:0 auto;text-wrap:pretty}
.bo-toolbar{display:flex;align-items:center;gap:14px}
.bo-count{font-size:12px;color:var(--bili-ink-3);white-space:nowrap;font-variant-numeric:tabular-nums}

/* ── 4. Cards view (picker.html) — overrides on existing .bili-org-card ── */
.bili-org-picker__filter{display:flex;align-items:center;gap:14px}
.bili-org-picker__filter .bo-search{flex:1}
.bili-org-card{min-height:172px}
.bili-org-card__body{display:flex;flex-direction:column;align-items:flex-start;flex:1;width:100%;position:relative}
.bili-org-card__role{margin-bottom:0}
.bili-org-card__foot{margin-top:auto;width:100%;padding-top:12px;margin-top:16px;border-top:1px solid var(--bo-hair);display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:12px;color:var(--bili-ink-3)}
.bili-org-card__body .bili-org-card__foot{margin-top:auto}
.bili-org-card__foot .bo-state{font-size:12px}
/* ⋯ menu moves to the top-right, level with the avatar; footer tier cross-fades to the CTA on hover */
.bili-org-card-wrap .bili-org-card__menu-btn{top:18px;right:14px;bottom:auto}
.bili-org-card-wrap .bili-org-card__dropdown{top:50px;bottom:auto}
.bili-org-card__foot-end{display:grid;justify-items:end;align-items:center}
.bili-org-card__foot-end>*{grid-area:1/1;transition:opacity .18s ease,transform .18s ease}
.bili-org-card__body .bili-org-card__cta{position:static;font-size:12px;opacity:0;transform:translateX(-6px);white-space:nowrap;text-decoration:none}
.bili-org-card-wrap:hover .bili-org-card__cta,.bili-org-card-wrap:focus-within .bili-org-card__cta,.bili-org-card-wrap.is-menu-open .bili-org-card__cta{opacity:1;transform:none}
.bili-org-card-wrap:hover .bili-org-card__tier,.bili-org-card-wrap:focus-within .bili-org-card__tier,.bili-org-card-wrap.is-menu-open .bili-org-card__tier{opacity:0}
/* Old palette used :nth-child on .bili-org-card, which is always the 1st child of its wrap → every avatar went green. Tone now comes from data-tone. */
.bili-org-grid .bili-org-card .bili-org-card__avatar[data-tone="0"]{background:oklch(50% 0.13 140)}
.bili-org-grid .bili-org-card .bili-org-card__avatar[data-tone="1"]{background:oklch(54% 0.12 288)}
.bili-org-grid .bili-org-card .bili-org-card__avatar[data-tone="2"]{background:oklch(56% 0.13 25)}
.bili-org-grid .bili-org-card .bili-org-card__avatar[data-tone="3"]{background:oklch(58% 0.12 75)}
.bili-org-grid .bili-org-card--new{border:1.5px dashed color-mix(in oklch,var(--bili-ink) 18%,transparent);background:rgba(255,255,255,.18);box-shadow:none;align-items:center;justify-content:center;text-align:center}
.bili-org-grid .bili-org-card--new:hover{background:rgba(255,255,255,.34);box-shadow:none}
.bili-org-grid .bili-org-card--new .bili-org-card__avatar--new{background:rgba(255,255,255,.6);border:1px solid rgba(255,255,255,.8);color:oklch(42% 0.13 140);box-shadow:none}

/* ── 5. Details view: master–detail ──────────────────────────────────────── */
.bo-console{display:grid;grid-template-columns:minmax(280px,340px) minmax(0,1fr);gap:20px;align-items:start}
.bo-list{padding:14px;display:flex;flex-direction:column;gap:10px;position:sticky;top:0}
.bo-list__head{display:flex;align-items:baseline;justify-content:space-between;padding:4px 6px 0}
.bo-list__head h1{font-size:18px;font-weight:500;margin:0;letter-spacing:-.01em}
.bo-rows{display:flex;flex-direction:column;gap:2px}
.bo-row{all:unset;box-sizing:border-box;color:inherit;text-decoration:none;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;padding:10px;border-radius:14px;cursor:pointer;transition:background .12s}
.bo-row:hover{background:rgba(255,255,255,.3)}
.bo-row.is-active{background:rgba(255,255,255,.72);box-shadow:inset 0 1px 0 #fff,0 2px 8px oklch(20% 0.04 50/.08)}
.bo-row__text{min-width:0;display:flex;flex-direction:column}
.bo-row:hover,.bo-row:focus-visible{color:inherit}
.bo-row:focus-visible{outline:2px solid oklch(66% 0.20 140/.5);outline-offset:1px}
.bo-row__name{font-size:14px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bo-row__sub{font-size:12px;color:var(--bili-ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px}
.bo-row .bo-state{font-size:12px}

.bo-detail{padding:24px 28px 28px;min-width:0}
.bo-detail__head{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
.bo-detail__title{flex:1;min-width:200px}
.bo-detail__title h2{font-size:22px;font-weight:500;letter-spacing:-.015em;margin:0;line-height:1.2}
.bo-detail__title a{display:inline-flex;align-items:center;gap:5px;margin-top:4px;color:var(--bili-ink-3);text-decoration:none}
.bo-detail__title a:hover{color:var(--bili-ink)}
.bo-detail__title a svg{width:12px;height:12px}
.bo-detail__actions{display:flex;align-items:center;gap:8px}
.bo-detail .tabs{margin:22px 0 24px;overflow-x:auto}
.bo-detail .tabs ul{flex-wrap:nowrap}
.bo-detail .tabs li a{padding:6px 14px}
.bo-empty{padding:56px 24px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:8px}
.bo-empty h3{font-size:15px;font-weight:500;margin:0}
.bo-empty p{font-size:13px;color:var(--bili-ink-2);margin:0;max-width:44ch;line-height:1.5;text-wrap:pretty}
.bo-empty .bo-btn{margin-top:10px}

/* Sections inside a tab */
.bo-tab{display:flex;flex-direction:column;gap:28px}
.bo-sec{display:flex;flex-direction:column;gap:12px}
.bo-sec__head{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:32px}
.bo-sec__head h3{font-size:15px;font-weight:500;margin:0}
.bo-sec__head .bo-meta{font-size:12px;color:var(--bili-ink-3);font-variant-numeric:tabular-nums}
.bo-sub{background:rgba(255,255,255,.34);border:1px solid rgba(255,255,255,.55);border-radius:var(--r-lg);box-shadow:inset 0 1px 0 rgba(255,255,255,.6)}

/* Field groups (Organisation / Subscription) */
.bo-fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:16px}
.bo-group{padding:16px 18px 6px}
.bo-group .bo-cap{margin-bottom:6px}
.bo-dl{display:grid;grid-template-columns:minmax(110px,40%) minmax(0,1fr);margin:0}
.bo-dl dt,.bo-dl dd{padding:10px 0;margin:0;font-size:13px;border-top:1px solid var(--bo-hair-2);min-width:0;overflow-wrap:anywhere}
.bo-dl dt:first-of-type,.bo-dl dt:first-of-type+dd{border-top:0}
.bo-dl dt{color:var(--bili-ink-3)}
.bo-dl dd{color:var(--bili-ink)}

/* Data table */
.bo-table{width:100%;border-collapse:collapse;font-size:13px}
.bo-table th{text-align:left;font-size:11px;font-weight:500;letter-spacing:.06em;text-transform:uppercase;color:var(--bili-ink-3);padding:0 14px 10px;white-space:nowrap}
.bo-table td{padding:11px 14px;border-top:1px solid var(--bo-hair-2);vertical-align:middle}
.bo-table tbody tr:hover td{background:rgba(255,255,255,.22)}
.bo-table .num{text-align:right;font-variant-numeric:tabular-nums}
.bo-table .shrink{width:1%;white-space:nowrap}
.bo-person{display:flex;align-items:center;gap:10px;font-weight:500}
.bo-scroll{overflow-x:auto}

/* ── 6. Hosting ─────────────────────────────────────────────────────────── */
.bo-inst{padding:18px 20px;display:flex;align-items:center;gap:16px;flex-wrap:wrap}
.bo-inst__main{flex:1;min-width:220px;display:flex;flex-direction:column;gap:6px}
.bo-inst__meta{font-size:12.5px;color:var(--bili-ink-3);font-variant-numeric:tabular-nums;padding-left:19px}
.bo-steps{list-style:none;margin:0;padding:4px 18px}
.bo-step{display:flex;align-items:center;gap:12px;padding:11px 0;font-size:13.5px}
.bo-step+.bo-step{border-top:1px solid var(--bo-hair-2)}
.bo-step__ico{width:22px;height:22px;flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;border-radius:50%}
.bo-step--done .bo-step__ico{color:oklch(46% 0.14 145);background:oklch(58% 0.15 145/.14)}
.bo-step--error .bo-step__ico{color:oklch(50% 0.19 25);background:oklch(56% 0.19 25/.12)}
.bo-step--pending{color:var(--bili-ink-3)}
.bo-step--pending .bo-step__ico{font-size:11px;font-weight:500;border:1px solid var(--bo-hair)}
.bo-step--running{font-weight:500}
.bo-step__label{flex:1;min-width:0}
.bo-step__label{display:flex;flex-direction:column;gap:2px}
.bo-step__err{font-size:12.5px;font-weight:400;color:oklch(46% 0.17 25)}
.bo-alert{padding:12px 14px;border-radius:12px;font-size:13px;color:oklch(40% 0.15 25);background:oklch(56% 0.19 25/.08);border:1px solid oklch(56% 0.19 25/.18)}
.bo-step__dur{font-size:12px;color:var(--bili-ink-3);font-variant-numeric:tabular-nums}
.bo-spin{width:14px;height:14px;border:2px solid color-mix(in oklch,var(--bili-ink) 15%,transparent);border-top-color:var(--bili-ink);border-radius:50%;animation:bo-spin .8s linear infinite}
@keyframes bo-spin{to{transform:rotate(360deg)}}
.bo-chip{display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 10px;border-radius:var(--r-pill);font-size:12px;font-weight:500;color:var(--bili-ink-2);border:1px solid var(--bo-hair);text-decoration:none;white-space:nowrap;background:rgba(255,255,255,.4)}
.bo-chip:hover{background:rgba(255,255,255,.8);color:var(--bili-ink)}
.bo-chip svg{width:13px;height:13px}

.bo-chart{padding:16px 18px 12px;display:flex;flex-direction:column;gap:10px}
.bo-chart svg{width:100%;height:160px;display:block;overflow:visible}
.bo-chart__axis{display:flex;justify-content:space-between;font-size:11px;color:var(--bili-ink-3);font-variant-numeric:tabular-nums}
.bo-legend{display:flex;flex-wrap:wrap;gap:6px 18px;font-size:12px;color:var(--bili-ink-2);align-items:center}
.bo-legend span{display:inline-flex;align-items:center;gap:7px}
.bo-legend .sw{width:14px;height:3px;border-radius:2px;background:currentColor}
.bo-chart__base{stroke:oklch(18% 0.022 50/.14);stroke-width:1}
.bo-chart__restart{stroke:var(--bo-bad);stroke-width:1;stroke-dasharray:3 3}
.bo-chart__queued{fill:none;stroke:oklch(52% 0.13 288);stroke-width:1.8;stroke-linejoin:round}
.bo-chart__picked{fill:none;stroke:oklch(55% 0.15 145);stroke-width:1.8;stroke-linejoin:round}
.bo-legend .sw--queued{color:oklch(52% 0.13 288)}.bo-legend .sw--picked{color:oklch(55% 0.15 145)}
.bo-legend .sw--dash{height:12px;width:0;border-left:1.5px dashed var(--bo-bad);border-radius:0;background:none}
.bo-legend .stat{margin-left:auto;color:var(--bili-ink-3);font-variant-numeric:tabular-nums;gap:14px}
.bo-legend .stat b{font-weight:500;color:var(--bili-ink)}

.bo-log{list-style:none;margin:0;padding:6px 18px}
.bo-log li{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;padding:10px 0;font-size:13px}
.bo-log li+li{border-top:1px solid var(--bo-hair-2)}
.bo-log .tr{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.bo-log .arrow{color:var(--bili-ink-3);font-size:12px}
.bo-log time{font-size:12px;color:var(--bili-ink-3);font-variant-numeric:tabular-nums;white-space:nowrap}
.bo-log .day{grid-column:1/-1;padding:14px 0 2px;border:0}
.bo-log__controls{display:flex;align-items:center;gap:10px}
.bo-log--lines{max-height:440px;overflow-y:auto;overscroll-behavior:contain}
.bo-log--lines li{grid-template-columns:auto minmax(0,1fr);align-items:start;gap:14px;padding:6px 0;font-family:var(--font-mono);font-size:12px;letter-spacing:-.01em}
.bo-log--lines time{color:var(--bili-ink-3);white-space:nowrap;font-variant-numeric:tabular-nums}
.bo-log--lines .bo-log__msg{white-space:pre-wrap;word-break:break-word;min-width:0}
.bo-log--lines .bo-log__empty{grid-column:1/-1}
.bo-log--lines .bo-log__empty:not(:only-child){display:none}
.bo-log-more summary{cursor:pointer;list-style:none;font-size:12.5px;font-weight:500;color:var(--bili-ink-2);padding:10px 18px 14px}
.bo-log-more summary::-webkit-details-marker{display:none}
.bo-log-more[open] summary{display:none}
.bo-log-more .bo-log{padding-top:0}
.bo-table{margin-top:10px}
.bo-more{all:unset;cursor:pointer;font-size:12.5px;font-weight:500;color:var(--bili-ink-2);padding:10px 18px 14px;display:block}
.bo-more:hover{color:var(--bili-ink)}

@media (max-width:1100px){.bo-console{grid-template-columns:1fr}.bo-list{position:static}}
@media (prefers-reduced-motion:reduce){.bo-spin,.bo-state--busy i{animation-duration:3s}}

/* Scope the hidden attribute so it beats .bo-sec{display:flex} */
.bo-sec[hidden]{display:none}

/* === Holding page === */
/* Org-host interstitial while an instance is starting, asleep, failed or gone
   (frontend/templates/routing/holding.html). Served from HyperBili via
   /__bili/static/, so it must not depend on Bulma or app.js. State lives on
   .bh-page: data-motion = bounce | sleep | ready | still, data-tone = busy |
   idle | bad | ok. */
body.bh{overflow:auto}
.bh-page{min-height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;padding:2rem 1rem}
.bh-card{position:relative;width:100%;max-width:27rem;padding:2.5rem 2.25rem 2rem;text-align:center;background:var(--glass-fill);backdrop-filter:var(--glass-blur);-webkit-backdrop-filter:var(--glass-blur);border:1px solid var(--glass-border);border-radius:var(--r-xl);box-shadow:inset 0 1px 0 var(--glass-shine),inset 0 -1px 1px rgba(255,255,255,.15),var(--glass-shadow)}
.bh-card::before{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(180deg,rgba(255,255,255,.18) 0%,transparent 30%)}

/* Living logo — logo.svg inline; the two i-dots hop in turn and their stems "catch" them */
.bh-logo{display:block;height:72px;width:auto;margin:0 auto 26px;overflow:visible}
.bh-logo__ink{fill:var(--bili-ink)}
.bh-logo__stem,.bh-logo__dot{transform-box:fill-box;transform-origin:50% 100%}
.bh-logo__dot{transition:fill .4s}
.bh-logo__dot--a{fill:var(--bili-green-cta)}
.bh-logo__dot--b{fill:var(--bili-gold)}
[data-motion="bounce"] .bh-logo__dot--a{animation:bh-hop 1.8s cubic-bezier(.45,0,.55,1) infinite}
[data-motion="bounce"] .bh-logo__dot--b{animation:bh-hop 1.8s cubic-bezier(.45,0,.55,1) .9s infinite}
[data-motion="bounce"] .bh-logo__stem--a{animation:bh-catch 1.8s ease-out infinite}
[data-motion="bounce"] .bh-logo__stem--b{animation:bh-catch 1.8s ease-out .9s infinite}
[data-motion="sleep"] .bh-logo__dot{animation:bh-breathe 3.6s ease-in-out infinite}
[data-motion="sleep"] .bh-logo__dot--b{animation-delay:1.8s}
[data-motion="ready"] .bh-logo__dot{animation:bh-hop .9s cubic-bezier(.45,0,.55,1) 1}
[data-motion="ready"] .bh-logo__dot--b{animation-delay:.12s}
[data-tone="idle"] .bh-logo__dot{fill:var(--bo-idle)}
[data-tone="bad"] .bh-logo__dot{fill:var(--bili-red)}
[data-tone="ok"] .bh-logo__dot{fill:var(--bili-green-cta)}
@keyframes bh-hop{0%,62%,100%{transform:translateY(0) scale(1,1)}10%{transform:translateY(0) scale(1.12,.86)}30%{transform:translateY(-34px) scale(.94,1.06)}50%{transform:translateY(0) scale(1.1,.88)}}
@keyframes bh-catch{0%,46%,70%,100%{transform:scaleY(1)}54%{transform:scaleY(.95)}}
@keyframes bh-breathe{50%{opacity:.35}}

/* Identity + copy */
.bh-org{display:inline-flex;align-items:center;gap:8px;margin:0 0 14px;padding:4px 12px 4px 4px;border-radius:var(--r-pill);background:var(--glass-fill-2);border:1px solid var(--glass-border);box-shadow:inset 0 1px 0 var(--glass-shine);font-size:13px;font-weight:500;color:var(--bili-ink-2)}
.bh-title{font-size:1.4rem;font-weight:500;letter-spacing:-.01em;line-height:1.25;margin:0 0 8px;text-wrap:balance}
.bh-text{color:var(--bili-ink-2);line-height:1.55;margin:0 auto;max-width:22rem;text-wrap:pretty}
.bh-swap{transition:opacity .35s ease}
.bh-swap.is-out{opacity:0}

/* Indeterminate progress — sage, never a percentage */
.bh-progress{position:relative;height:4px;max-width:15rem;margin:26px auto 10px;border-radius:var(--r-pill);overflow:hidden;background:var(--bo-hair)}
.bh-progress::after{content:"";position:absolute;inset:0 auto 0 0;width:38%;border-radius:inherit;background:linear-gradient(90deg,transparent,var(--bili-sage) 30%,var(--bili-green-cta) 70%,transparent);animation:bh-slide 1.9s cubic-bezier(.65,0,.35,1) infinite}
.bh-progress[hidden]{display:none}
@keyframes bh-slide{from{transform:translateX(-100%)}to{transform:translateX(265%)}}
.bh-meta{font-size:12px;color:var(--bili-ink-3);font-variant-numeric:tabular-nums;min-height:1.2em}
.bh-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin-top:22px}
.bh-actions:empty,.bh-actions[hidden]{display:none}
.bh-foot{margin:0;font-size:12px;color:var(--bili-ink-3)}
.bh-foot a{color:inherit}
.bh-page:has(.bh-actions:not([hidden]):not(:empty)) .bh-foot__link{display:none}

@media (max-width:480px){
  .bh-card{padding:2rem 1.25rem 1.5rem}
  .bh-logo{height:60px}
  .bh-actions .bo-btn{flex:1 1 100%}
}
@media (prefers-reduced-motion:reduce){
  .bh-logo__dot,.bh-logo__stem,.bh-progress::after{animation:none!important}
  .bh-progress::after{width:100%;opacity:.35}
  [data-motion="bounce"] .bh-logo__dot,[data-motion="sleep"] .bh-logo__dot{animation:bh-breathe 2.4s ease-in-out infinite!important}
  [data-motion="bounce"] .bh-logo__dot--b,[data-motion="sleep"] .bh-logo__dot--b{animation-delay:1.2s!important}
}

/* ═══════════════════════════════════════════════════════════════════════════
   DOCUMENTS — list + detail pane (reuses the bo-* master–detail vocabulary)
   ═══════════════════════════════════════════════════════════════════════════ */
.docs-page{height:100%;display:flex;flex-direction:column;min-height:0}
.docs-console{flex:1;min-height:0;border-radius:var(--r-xl);transition:box-shadow .15s}
.docs-console.is-dragging{box-shadow:0 0 0 2px oklch(66% 0.22 140/.55),0 0 0 8px oklch(66% 0.22 140/.14)}
.docs-console__grid{height:100%;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) 480px;gap:24px;align-items:stretch}

/* Left column */
.docs-list{position:static;min-height:0;padding:18px 16px 14px;gap:12px}
.docs-list__head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 4px}
.docs-list__head h1{font-size:26px;font-weight:500;letter-spacing:-.02em;margin:0}
.docs-search-form{display:flex}
.docs-search input,.bo-search.docs-search input{height:44px;font-size:14px}
.docs-tabs{align-self:flex-start;flex-wrap:wrap;max-width:100%}
.docs-tabs a{height:44px;padding:0 16px;font-size:13.5px}
.docs-tabs .is-active .bo-count{color:rgba(255,255,255,.72)}
.docs-rows{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-right:4px;scrollbar-gutter:stable}
.docs-file{width:34px;height:40px;border-radius:9px;font-size:10.5px;letter-spacing:.04em}
.docs-list__empty{padding:8px 0}
.docs-list__empty .bo-empty{padding:32px 16px}
.docs-drop-hint{margin:4px 0 0;text-align:center;font-size:13px;color:var(--bili-ink-3)}
.docs-list .pagination{margin-top:4px}

/* Right column — detail pane */
.docs-detail{min-height:0;display:flex;flex-direction:column;padding:24px 24px 20px;gap:18px}
.docs-detail--empty{align-items:center;justify-content:center;gap:14px}
.docs-detail__head{align-items:center}
.docs-av-lg{width:42px;height:50px;border-radius:11px;font-size:12px;letter-spacing:.04em}
.docs-type{font-size:13px}
.docs-meta{margin:0;display:grid;grid-template-columns:1.2fr 1fr 1fr;gap:14px;font-size:13.5px}
.docs-meta dt{font-size:11.5px;color:var(--bili-ink-3);margin-bottom:6px}
.docs-meta dd{margin:0}
.docs-select{position:relative;display:flex;align-items:center}
.docs-select select{width:100%;height:44px;padding:0 34px 0 12px;border-radius:10px;
  border:1px solid rgba(255,255,255,.7);background:rgba(255,255,255,.65);
  font:inherit;font-size:13.5px;color:var(--bili-ink);appearance:none;-webkit-appearance:none}
.docs-select svg{position:absolute;right:11px;width:16px;height:16px;pointer-events:none;color:var(--bili-ink-3)}

.docs-extract{flex:1;min-height:0;display:flex;flex-direction:column}
.docs-extract__head{display:flex;align-items:baseline;gap:10px;padding:0 4px 8px}
.docs-extract__head .bo-cap{flex:1;margin:0}
.docs-extract__head .bo-meta{font-size:12.5px;color:var(--bili-ink-3)}
.docs-extract__scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-right:4px}
.docs-extract__empty{padding:6px 4px}
.docs-xv{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2px 12px;
  align-items:start;padding:12px 4px;border-top:1px solid var(--bo-hair-2)}
.docs-xv:first-child{border-top:0}
.docs-xv__k{grid-column:1;font-size:11.5px;color:var(--bili-ink-3)}
.docs-xv__v{grid-column:1;font-size:14px;line-height:1.45;overflow-wrap:anywhere}
.docs-xv__state{grid-column:2;grid-row:1 / span 2;align-self:center;display:inline-flex;align-items:center;gap:4px}
.docs-reject{width:26px;height:26px}

.docs-detail__actions{display:flex;gap:10px;padding-top:16px;border-top:1px solid rgba(255,255,255,.75)}
.docs-confirm-form{flex:1;display:flex}
.docs-confirm-form .bo-btn{flex:1}
.docs-detail__actions .bo-btn{flex:1}
.docs-ctl{height:44px;padding:0 18px;font-size:14px}
.docs-ctl svg{width:16px;height:16px}

@media (max-width:1024px){
  .docs-page{height:auto}
  .docs-console__grid{grid-template-columns:1fr;height:auto}
  .docs-list{min-height:auto}
  .docs-rows{overflow:visible;max-height:none}
  .docs-detail{min-height:0}
  .docs-extract__scroll{overflow:visible;max-height:none}
}

/* === Reference releases (ADR 0013) =========================================
   Tier pills, diff lists, publish drawer and run progress for the Reference
   console, the Playbooks "Review & publish" flow and the Hosting panel. Built on
   the .bo-* console components (buttons, states, sub-panels, tables). */
.rf-tier{display:inline-flex;align-items:center;gap:6px;height:22px;padding:0 10px;border-radius:999px;font:500 12px/1 var(--bili-font-family);border:1px solid transparent;white-space:nowrap;background:none}
.rf-tier--starter{background:rgba(255,255,255,.6);border-color:rgba(255,255,255,.95);color:var(--bili-ink-2)}
.rf-tier--growth{background:color-mix(in oklch,var(--bili-sage) 16%,white);color:oklch(36% 0.09 138);border-color:color-mix(in oklch,var(--bili-sage) 35%,transparent)}
.rf-tier--enterprise{background:color-mix(in oklch,var(--bili-purple) 14%,white);color:oklch(38% 0.11 288);border-color:color-mix(in oklch,var(--bili-purple) 32%,transparent)}
button.rf-tier{cursor:pointer}
button.rf-tier:hover{filter:brightness(.97);box-shadow:0 1px 4px oklch(20% 0.04 50/.15)}
button.rf-tier svg{width:11px;height:11px;opacity:.6}
.rf-badge{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font:500 11px/1 var(--bili-font-family);letter-spacing:.02em;white-space:nowrap}
.rf-badge svg{width:11px;height:11px}
.rf-badge--warn{background:color-mix(in oklch,var(--bili-gold) 22%,white);color:var(--bili-gold-text)}
.rf-badge--ok{background:color-mix(in oklch,var(--bo-ok) 16%,white);color:oklch(36% 0.1 145)}
.rf-badge--bad{background:color-mix(in oklch,var(--bo-bad) 14%,white);color:oklch(44% 0.17 25)}
.rf-badge--mute{background:rgba(255,255,255,.55);color:var(--bili-ink-3)}
.rf-dim td{opacity:.62}
.rf-dim td:last-child{opacity:1}
.rf-actions{display:flex;gap:6px;justify-content:flex-end;align-items:center}
.rf-note{font-size:12px;color:var(--bili-ink-3);margin-top:6px;line-height:1.5}
.rf-spin{width:14px;height:14px;border-radius:50%;border:2px solid currentColor;border-right-color:transparent;animation:rf-rot .7s linear infinite;display:inline-block;vertical-align:-2px}
@keyframes rf-rot{to{transform:rotate(360deg)}}
.rf-seg-lg .bo-seg a,.rf-seg-lg .bo-seg button{height:30px;padding:0 16px}
.rf-lockbar{display:flex;align-items:center;gap:8px;padding:10px 14px;border-radius:var(--r-lg);background:rgba(255,255,255,.45);font-size:12px;color:var(--bili-ink-2);margin-bottom:16px}
.rf-lockbar svg{width:14px;height:14px;flex-shrink:0}
.rf-banner{display:flex;align-items:center;gap:14px;padding:12px 16px;border-radius:var(--r-lg);background:color-mix(in oklch,var(--bili-gold) 16%,rgba(255,255,255,.7));border:1px solid color-mix(in oklch,var(--bili-gold) 40%,transparent);font-size:13px;margin-bottom:16px}
.rf-banner.is-ok{background:color-mix(in oklch,var(--bo-ok) 12%,rgba(255,255,255,.7));border-color:color-mix(in oklch,var(--bo-ok) 35%,transparent)}
.rf-banner.is-bad{background:color-mix(in oklch,var(--bo-bad) 10%,rgba(255,255,255,.7));border-color:color-mix(in oklch,var(--bo-bad) 35%,transparent)}
.rf-banner__ico{flex-shrink:0;display:flex}
.rf-banner__ico svg{width:18px;height:18px}
.rf-banner__main{flex:1;min-width:0}
.rf-banner__main b{font-weight:500}
.rf-banner__sub{font-size:12px;color:var(--bili-ink-2);margin-top:1px}

/* Packaging dropdown (tier pill on the Playbooks list) */
.rf-popwrap{position:relative;display:inline-block}
.rf-pop{position:absolute;z-index:40;top:calc(100% + 8px);left:0;width:340px;padding:16px;border-radius:var(--r-lg);background:rgba(255,255,255,.96);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);text-align:left}
.rf-pop h4{margin:0 0 4px;font-size:14px;font-weight:500}
.rf-pop p{margin:0 0 12px;font-size:12px;color:var(--bili-ink-2);line-height:1.5}
.rf-pop__foot{display:flex;gap:8px;justify-content:flex-end;margin-top:14px}
.rf-impact{margin-top:12px;padding:10px 12px;border-radius:var(--r-lg);background:rgba(255,255,255,.55);font-size:12px;color:var(--bili-ink-2);line-height:1.5}
.rf-impact b{color:var(--bili-ink);font-weight:500}
.rf-tiers{display:flex;min-width:0}
/* Equal-width pills in a 32px track, so the selection fills its segment and
   lines up with the buttons beside it. */
.rf-tiers .bo-seg{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:2px;padding:2px;flex:1;min-width:0}
.rf-tiers .bo-seg label{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;height:26px;min-width:0;border-radius:var(--r-pill);font-size:12px;font-weight:500;color:var(--bili-ink-2);white-space:nowrap;cursor:pointer;transition:background .15s,color .15s}
.rf-tiers .bo-seg label:hover{background:rgba(255,255,255,.45);color:var(--bili-ink)}
.rf-tiers input{position:absolute;opacity:0;pointer-events:none}
.rf-tiers input:checked + span,.rf-tiers label.is-active{background:oklch(28% 0.04 50/.92);color:#fff;border-radius:var(--r-pill);box-shadow:inset 0 1px 0 rgba(255,255,255,.18),0 1px 3px oklch(20% 0.04 50/.18)}
.rf-tiers label span{display:inline-flex;align-items:center;justify-content:center;width:100%;height:100%;padding:0 12px;border-radius:var(--r-pill)}
/* Packaging row, directly in the Packaging group (no card wrapper) */
.rf-pack{display:flex;align-items:center;gap:18px;flex-wrap:wrap}
.rf-pack .rf-impact{margin:0;flex:0 1 auto}
.rf-pack .bo-btn{margin-left:auto}

/* Stat tiles */
.rf-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:20px}
.rf-stat{padding:16px 18px}
.rf-stat__k{font-size:11px;font-weight:500;letter-spacing:.07em;text-transform:uppercase;color:var(--bili-ink-3)}
.rf-stat__v{font-size:26px;font-weight:500;letter-spacing:-.02em;margin-top:4px;font-variant-numeric:tabular-nums}
.rf-stat__v--mono{font-family:var(--font-mono);font-size:17px;padding-top:7px;letter-spacing:-.01em;word-break:break-all}
.rf-stat__s{font-size:12px;color:var(--bili-ink-2);margin-top:2px}
@media (max-width:900px){.rf-stats{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* Change list (draft vs release, release history) */
.rf-diff{overflow:hidden}
.rf-diff__head{padding:10px 14px 8px;font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--bili-ink-3);background:rgba(255,255,255,.25)}
.rf-diff__row{display:grid;grid-template-columns:22px 1fr auto;gap:10px;padding:10px 14px;border-top:1px solid var(--bo-hair-2);font-size:13px;align-items:start}
.rf-diff__head + .rf-diff__row{border-top:0}
.rf-diff__title{font-weight:500}
.rf-diff__sub{font-size:12px;color:var(--bili-ink-3);margin-top:2px}
.rf-mk{width:20px;height:20px;border-radius:6px;display:flex;align-items:center;justify-content:center;font:600 13px/1 var(--font-mono)}
.rf-mk--add{background:color-mix(in oklch,var(--bo-ok) 18%,white);color:oklch(36% 0.1 145)}
.rf-mk--mod{background:color-mix(in oklch,var(--bo-busy) 22%,white);color:var(--bili-gold-text)}
.rf-mk--del{background:color-mix(in oklch,var(--bo-bad) 16%,white);color:oklch(44% 0.17 25)}

/* Run progress */
.rf-prog{height:6px;border-radius:99px;background:oklch(20% 0.04 50/.08);overflow:hidden;min-width:90px}
.rf-prog>i{display:block;height:100%;width:0;background:var(--bo-ok);transition:width .7s ease}
.rf-prog.is-bad>i{background:var(--bo-bad)}
.rf-run{display:grid;grid-template-columns:minmax(0,1fr) 110px minmax(96px,auto);gap:14px;align-items:center;padding:10px 14px;border-top:1px solid var(--bo-hair-2);font-size:13px}
.rf-run:first-child{border-top:0}
.rf-run__err{font-size:11px;color:var(--bili-ink-3);white-space:normal;margin-top:2px}

/* Review & publish drawer */
.rf-drawer-bg{position:fixed;inset:0;z-index:90;background:oklch(20% 0.04 50/.28);opacity:0;pointer-events:none;transition:opacity .25s}
.rf-drawer-bg.is-open{opacity:1;pointer-events:auto}
.rf-drawer{position:fixed;top:0;right:0;bottom:0;z-index:95;width:min(560px,100vw);display:flex;flex-direction:column;background:rgba(255,255,255,.9);-webkit-backdrop-filter:blur(28px);backdrop-filter:blur(28px);border-left:1px solid var(--glass-border);box-shadow:-20px 0 60px oklch(20% 0.04 50/.2);transform:translateX(105%);transition:transform .35s cubic-bezier(.4,.01,.2,1)}
.rf-drawer.is-open{transform:none}
.rf-drawer__form{display:flex;flex-direction:column;flex:1;min-height:0}
.rf-drawer__head{padding:20px 24px 14px;border-bottom:1px solid var(--bo-hair-2);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}
.rf-drawer__head h3{margin:0;font-size:18px;font-weight:500;letter-spacing:-.01em}
.rf-drawer__head p{margin:2px 0 0;font-size:12px;color:var(--bili-ink-2)}
.rf-drawer__body{flex:1;overflow:auto;padding:18px 24px;display:flex;flex-direction:column;gap:20px}
.rf-drawer__foot{padding:14px 24px;border-top:1px solid var(--bo-hair-2);display:flex;justify-content:space-between;align-items:center;gap:12px}
.rf-check{display:flex;align-items:center;gap:10px;padding:10px 14px;border-top:1px solid var(--bo-hair-2);font-size:13px;cursor:pointer}
.rf-check:first-child{border-top:0}
.rf-check input{accent-color:oklch(52% 0.15 140);width:16px;height:16px}
.rf-check__main{flex:1;min-width:0}
.rf-check.is-off{opacity:.55;cursor:default}
.rf-field{display:flex;flex-direction:column;gap:6px}
.rf-field label{font-size:12px;color:var(--bili-ink-3)}
.rf-field .input{border-color:color-mix(in oklch,var(--bili-ink) 24%,transparent)}
.rf-sec-h{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:8px}
.rf-sec-h h3{font-size:15px;font-weight:500;margin:0}
.rf-sec-h span{font-size:12px;color:var(--bili-ink-3)}
.rf-kv{display:grid;grid-template-columns:150px 1fr;gap:8px 16px;font-size:13px;align-items:center}
.rf-kv dt{color:var(--bili-ink-3);font-size:12px}
.rf-kv dd{margin:0}
#rf-drawer-body{display:flex;flex-direction:column;flex:1;min-height:0}
/* A card that hosts a dropdown (the glass .box clips its children by default). */
.box.rf-box-visible{overflow:visible}

/* === Digital Twin (inspector) === */
.twin-lede {
  max-width: var(--measure, 68ch);
  margin: -0.5rem 0 1.25rem;
  color: var(--bili-ink-2);
  font-size: 0.95rem;
}
.twin {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.twin-rail {
  padding: 0.75rem;
  position: sticky;
  top: 0;
}
.twin-search { margin-bottom: 0.5rem; }
.twin-count {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.25rem 0.5rem;
  color: var(--bili-ink-2);
  font-size: 0.75rem;
  border-bottom: 1px solid var(--hair, rgba(0, 0, 0, 0.1));
}
.twin-list { list-style: none; margin: 0; padding: 0.5rem 0 0; }
.twin-key {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 0.75rem;
  row-gap: 2px;
  align-items: baseline;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--r-md, 12px);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.twin-key:hover { background: var(--glass-fill-2); }
.twin-key.is-active {
  background: rgba(255, 255, 255, 0.78);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine), var(--shadow-soft);
}
.twin-key__name { grid-column: 1; min-width: 0; font-size: 0.875rem; font-weight: 500; }
.twin-key__value {
  grid-column: 2;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.twin-key__path {
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--bili-ink-2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}
.twin-key__meta {
  grid-column: 2;
  text-align: right;
  color: var(--bili-ink-2);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.twin-empty { padding: 1rem 0.75rem; color: var(--bili-ink-2); font-size: 0.8125rem; }

.twin-pane { min-width: 0; padding: 0; overflow: hidden; }
.twin-pane__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.25rem 1.25rem 1rem;
}
.twin-pane__title { margin: 0; }
.twin-path {
  display: block;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
  color: var(--bili-ink-2);
  font-size: 0.75rem;
}
.twin-section { padding: 1.25rem; border-top: 1px solid var(--hair, rgba(0, 0, 0, 0.1)); }
.twin-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.twin-section__title {
  margin: 0;
  color: var(--bili-ink-2);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.twin-big {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.twin-text { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.twin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.75rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
  background: var(--glass-fill-2);
  font-size: 0.75rem;
}
.twin-badge.is-yes { color: var(--bili-green-dark); }
.twin-badge.is-no { color: var(--bili-ink-2); }
.twin-doc { overflow-wrap: anywhere; }
.twin-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.twin-chips li {
  padding: 0.1875rem 0.75rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
  background: var(--glass-fill-2);
  font-size: 0.75rem;
}
.twin-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem 1.25rem; margin: 0.75rem 0 0; }
.twin-facts dt, .twin-meta dt { color: var(--bili-ink-2); font-size: 0.75rem; }
.twin-facts dd, .twin-meta dd { margin: 0.125rem 0 0; font-size: 0.875rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.twin-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem 1.25rem; margin: 0; }
.twin-refs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.twin-refs a {
  display: inline-flex;
  padding: 0.1875rem 0.75rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
  background: var(--glass-fill-2);
  font-size: 0.75rem;
  text-decoration: none;
}
.twin-fresh { display: inline-flex; align-items: center; gap: 0.5rem; }
.twin-fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--bo-ok); }
.twin-fresh--warning::before { background: var(--bo-busy); }
.twin-fresh--danger::before { background: var(--bo-bad); }
.twin-fresh--none::before, .twin-fresh--unknown::before { background: var(--bo-idle); }
.twin-timeline { margin: 0; padding: 0; list-style: none; }
.twin-timeline li {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 1rem;
  padding: 0.625rem 0;
  border-top: 1px solid var(--hair-2, rgba(0, 0, 0, 0.07));
}
.twin-timeline li:first-child { border-top: 0; }
.twin-timeline time { color: var(--bili-ink-2); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.twin-timeline__value { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.twin-timeline__note { margin: 0.25rem 0 0; color: var(--bili-ink-2); font-size: 0.75rem; }
.twin-state { padding: 2rem 1.25rem; }

/* Chart */
.twin-chart { margin: 0; }
.twin-chart__head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.twin-chart__now { font-size: 1.5rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.twin-chart__caption { margin-left: 0.5rem; color: var(--bili-ink-2); font-size: 0.75rem; }
.twin-chart__plot { height: 120px; margin-top: 1rem; }
.twin-chart__plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.twin-chart__line { fill: none; stroke: var(--bili-sage); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.twin-chart__area { fill: color-mix(in oklch, var(--bili-sage) 15%, transparent); stroke: none; }
.twin-chart__axis { display: flex; justify-content: space-between; margin-top: 0.375rem; color: var(--bili-ink-2); font-size: 0.6875rem; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .twin { grid-template-columns: 1fr; }
  .twin-rail { position: static; }
  .twin-timeline li { grid-template-columns: 1fr; gap: 0.125rem; }
}

/* === Auth pages (login, passkeys) ===
   Served standalone — not through base.html — so they set body.auth-page and
   link this stylesheet directly. They reuse the shared tokens, the DieGrotesk
   face and the .bg-stage background; blur stays on the single page frame. */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  height: auto;
  overflow: auto;
  padding: 24px;
}
body.auth-page main { position: relative; z-index: 1; }

/* Login — split brand / form frame */
.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 760px;
  background: var(--glass-fill);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: inset 0 1px 0 var(--glass-shine), inset 0 -1px 1px rgba(255, 255, 255, 0.15), var(--glass-shadow);
  overflow: hidden;
}
/* Brand pane: the app greens, soft green + gold glows, a faint dot grid, cream logo. */
.auth-brandpane {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 24px;
  padding: 30px;
  color: var(--bili-cream);
  background:
    radial-gradient(ellipse at 15% 8%, oklch(66% 0.20 140 / 0.65), transparent 55%),
    radial-gradient(ellipse at 90% 95%, oklch(70% 0.17 85 / 0.32), transparent 50%),
    linear-gradient(165deg, var(--bili-green-dark), oklch(38% 0.10 140));
}
.auth-brandpane::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.03;
  background-image: radial-gradient(circle, #fff 0, #fff 2.4px, transparent 3px);
  background-size: 28px 28px;
}
.auth-brandpane > * { position: relative; z-index: 1; }
.auth-logo { display: block; height: 48px; width: auto; align-self: flex-start; }
.auth-logo rect, .auth-logo path, .auth-logo circle { fill: var(--bili-cream); }
.auth-logo .auth-logo__dot.is-gold { fill: var(--bili-gold); }
/* margin:auto centres the tagline in the space under the logo. */
.auth-tag {
  margin: auto; text-align: center;
  font-size: 22.8px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.3;
  text-wrap: balance;
}

.auth-formpane { padding: 32px 30px; }
.auth-formpane .auth-title,
.auth-formpane .auth-label {
  font-size: 1.25rem; font-weight: 500; letter-spacing: -0.01em; color: var(--bili-ink);
}
.auth-formpane .auth-title { margin: 0 0 20px; text-wrap: balance; }
.auth-sub { color: var(--bili-ink-3); font-size: 12.5px; margin: 0 0 20px; }

/* Either/or: engaging one sign-in route dims the other. */
.auth-group { transition: opacity 0.25s ease, filter 0.25s ease; }
.auth-formpane:has(.auth-group.is-direct:hover, .auth-group.is-direct:focus-within) .auth-group.is-email,
.auth-formpane:has(.auth-group.is-email:hover, .auth-group.is-email:focus-within) .auth-group.is-direct {
  opacity: 0.38; filter: saturate(0.6);
}
@media (prefers-reduced-motion: reduce) { .auth-group { transition: none; } }

/* Google: its own white fill and the four-colour G; the shape follows the house pill. */
.auth-google {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  height: 42px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid rgba(255, 255, 255, 0.7); background: #fff;
  color: var(--bili-ink); font-family: inherit; font-size: 14px; font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 6px rgba(40, 25, 15, 0.08);
  cursor: pointer; text-decoration: none; margin-bottom: 10px;
  transition: transform 0.12s, box-shadow 0.15s;
}
.auth-google:hover { text-decoration: none; transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 4px 12px rgba(40, 25, 15, 0.12); }
.auth-google svg { width: 18px; height: 18px; flex: 0 0 18px; }

.auth-method {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 42px; padding: 0 16px;
  border-radius: var(--r-pill); border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.55); color: var(--bili-ink); font-size: 14px; font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 6px rgba(40, 25, 15, 0.08);
  cursor: pointer; margin-bottom: 10px; font-family: inherit;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.auth-method:hover { background: rgba(255, 255, 255, 0.8); transform: translateY(-1px); }
.auth-method .icon { width: 18px; height: 18px; flex: 0 0 18px; }
.auth-method.is-primary {
  margin-top: 12px;
  background: oklch(68% 0.20 140 / 0.88); border-color: oklch(74% 0.16 140 / 0.5); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 8px oklch(50% 0.16 140 / 0.28);
}
.auth-method.is-primary:hover { background: oklch(66% 0.22 140 / 0.95); }
.auth-google:focus-visible, .auth-method:focus-visible, .auth-input:focus-visible { outline: 2px solid var(--bili-green-dark); outline-offset: 2px; }
.auth-sep { display: flex; align-items: center; gap: 10px; color: var(--bili-ink-3); font-size: 24px; margin: 14px 0; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: oklch(20% 0.02 50 / 0.12); }
.auth-formpane form { margin: 0; }
.auth-formpane form .auth-method { margin-bottom: 0; }
.auth-label { display: block; font-size: 11.5px; color: var(--bili-ink-3); margin-bottom: 10px; }
.auth-input {
  width: 100%; height: 42px; border-radius: var(--r-pill); border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.6); padding: 0 16px; font-size: 14px; color: var(--bili-ink);
  box-shadow: inset 0 1px 2px rgba(40, 25, 15, 0.06);
  font-family: inherit; margin-bottom: 10px;
}
.auth-input::placeholder { color: var(--bili-ink-3); }
.auth-input:focus { outline: none; border-color: var(--bili-green-cta); box-shadow: 0 0 0 3px oklch(66% 0.22 140 / 0.18); }
.auth-error {
  background: oklch(97% 0.02 25 / 0.9); border: 1px solid oklch(58% 0.20 25 / 0.35); color: oklch(38% 0.14 25);
  border-radius: var(--r-md); padding: 10px 12px; font-size: 12.5px; margin: 0 0 16px;
}
.auth-hint { color: var(--bili-ink-3); font-size: 11.5px; margin: 12px 0 0; }

/* Passkeys page — single card frame, same brand strip as the login */
.auth-card {
  width: 100%; max-width: 480px;
  background: var(--glass-fill);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: inset 0 1px 0 var(--glass-shine), inset 0 -1px 1px rgba(255, 255, 255, 0.15), var(--glass-shadow);
  overflow: hidden;
}
.auth-card__brand {
  position: relative; overflow: hidden; padding: 18px 26px; color: var(--bili-cream);
  background:
    radial-gradient(ellipse at 15% 8%, oklch(66% 0.20 140 / 0.65), transparent 55%),
    radial-gradient(ellipse at 90% 95%, oklch(70% 0.17 85 / 0.32), transparent 50%),
    linear-gradient(165deg, var(--bili-green-dark), oklch(38% 0.10 140));
}
.auth-card__brand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.03;
  background-image: radial-gradient(circle, #fff 0, #fff 2.4px, transparent 3px);
  background-size: 28px 28px;
}
.auth-card__brand .auth-logo { position: relative; height: 30px; }
.auth-card__body { padding: 26px 26px 24px; }
.auth-card .auth-title { font-size: 1.25rem; font-weight: 500; letter-spacing: -0.01em; margin: 0; }
.auth-card .auth-sub { font-size: 13px; margin: 4px 0 20px; }
.auth-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auth-back {
  display: inline-flex; font-size: 12px; padding: 5px 12px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(255, 255, 255, 0.7);
  color: var(--bili-ink-2); text-decoration: none; white-space: nowrap;
}
.auth-back:hover { color: var(--bili-ink); background: rgba(255, 255, 255, 0.8); text-decoration: none; }
.auth-pk {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.8); border-radius: var(--r-md); background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 1px 2px rgba(40, 25, 15, 0.05);
}
.auth-pk form { margin: 0 0 0 auto; }
.auth-pk .icon { width: 18px; height: 18px; flex: 0 0 18px; color: var(--bili-ink-3); }
.auth-pk__name { font-weight: 500; font-size: 14px; }
.auth-pk__meta { font-size: 11.5px; color: var(--bili-ink-3); }
/* Rename: a quiet text action that swaps the name for an inline form. It is a
   correction (the label is auto-derived at registration), so it stays out of
   the way until wanted, and never opens a dialog. */
.auth-pk__name-row { display: flex; align-items: center; gap: 8px; }
.auth-pk__rename {
  border: none; background: none; padding: 0; cursor: pointer; font-family: inherit;
  font-size: 11.5px; color: var(--bili-ink-3); text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-pk__rename:hover { color: var(--bili-ink); }
.auth-pk__rename-form { display: flex; align-items: center; gap: 6px; margin: 0; }
.auth-pk__rename-form[hidden] { display: none; }
.auth-pk__rename-input {
  font-family: inherit; font-size: 13px; color: var(--bili-ink); padding: 5px 8px;
  border: 1px solid oklch(20% 0.02 50 / 0.16); border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.9); min-width: 12ch;
}
.auth-pk__rename-input:focus {
  outline: none; border-color: var(--bili-green-cta);
  box-shadow: 0 0 0 2px oklch(66% 0.22 140 / 0.15);
}
.auth-pk__save, .auth-pk__cancel {
  border: none; background: none; padding: 0; cursor: pointer; font-family: inherit;
  font-size: 11.5px; text-underline-offset: 2px;
}
.auth-pk__save { color: var(--bili-green-dark); font-weight: 500; text-decoration: underline; }
.auth-pk__cancel { color: var(--bili-ink-3); text-decoration: underline; }
.auth-pk__rm { border: none; background: none; color: var(--bili-red); font-size: 12px; cursor: pointer; font-family: inherit; }
.auth-pk__rm:hover { text-decoration: underline; }
.auth-empty {
  border: 1px dashed oklch(20% 0.02 50 / 0.18); border-radius: var(--r-md); padding: 18px;
  text-align: center; color: var(--bili-ink-3); font-size: 12.5px; margin-bottom: 10px;
}
.auth-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 42px; padding: 0 16px; margin-top: 12px;
  border-radius: var(--r-pill); color: #fff; font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
  background: oklch(68% 0.20 140 / 0.88); border: 1px solid oklch(74% 0.16 140 / 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 8px oklch(50% 0.16 140 / 0.28);
}
.auth-btn:hover { background: oklch(66% 0.22 140 / 0.95); }
.auth-btn:focus-visible, .auth-back:focus-visible { outline: 2px solid var(--bili-green-dark); outline-offset: 2px; }
.auth-btn.sec { background: rgba(255, 255, 255, 0.7); color: var(--bili-ink); border: 1px solid oklch(20% 0.02 50 / 0.12); }
.auth-notice {
  border-radius: var(--r-md); padding: 10px 12px; font-size: 12.5px; margin: 0 0 16px;
  border: 1px solid oklch(66% 0.22 140 / 0.35); background: oklch(96% 0.04 140 / 0.7); color: oklch(32% 0.10 140);
}
.auth-notice.is-error { border-color: oklch(58% 0.20 25 / 0.35); background: oklch(97% 0.02 25 / 0.8); color: oklch(38% 0.14 25); }
.auth-err { color: var(--bili-red); font-size: 12.5px; margin: 10px 0 0; }
.auth-foot { margin-top: 18px; font-size: 11.5px; color: var(--bili-ink-3); }

@media (max-width: 620px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brandpane { padding: 22px 22px 18px; gap: 10px; }
  .auth-logo { height: 30px; }
  .auth-tag { display: none; }
  .auth-formpane { padding: 22px; }
}

/* === Profile page (.profile-*) ============================================ */
.profile-page { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* Hero — same green wash as the auth brand pane; a page-level frame, so it is
   a gradient surface rather than a glass fill (no backdrop-filter). */
.profile-hero {
  position: relative; overflow: hidden;
  padding: 26px 28px; border-radius: var(--r-xl);
  color: var(--bili-cream);
  background:
    radial-gradient(ellipse at 15% 8%, oklch(66% 0.20 140 / 0.65), transparent 55%),
    radial-gradient(ellipse at 90% 95%, oklch(70% 0.17 85 / 0.32), transparent 50%),
    linear-gradient(165deg, var(--bili-green-dark), oklch(38% 0.10 140));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), var(--glass-shadow);
}
.profile-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.03;
  background-image: radial-gradient(circle, #fff 0, #fff 2.4px, transparent 3px);
  background-size: 28px 28px;
}
.profile-hero > * { position: relative; z-index: 1; }
.profile-hero__row { display: flex; align-items: center; gap: 20px; }
.profile-hero__body { flex: 1; min-width: 0; }
.profile-hero__name { font-size: 26px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; overflow-wrap: anywhere; }
.profile-hero__email { font-size: 13px; color: oklch(96% 0.06 85 / 0.75); overflow-wrap: anywhere; }
.profile-hero__chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.profile-chip {
  display: inline-flex; align-items: center; padding: 3px 11px; border-radius: var(--r-pill);
  font-size: 12px; background: rgba(255, 255, 255, 0.16); color: var(--bili-cream);
}
.profile-chip.is-gold { background: var(--bili-gold); color: oklch(20% 0.06 85); }
.profile-hero__actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.profile-hero .button.is-ghost { color: var(--bili-cream); }
.profile-hero .button.is-ghost:hover { background: rgba(255, 255, 255, 0.12); }

/* Avatar — the whole disc is the upload control; the file input submits on change. */
.profile-avatar { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.profile-avatar .bili-avatar { width: 84px; height: 84px; font-size: 32px; background: var(--bili-cream); color: var(--bili-green-dark); }
.profile-avatar__edit {
  position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: #fff; color: var(--bili-ink-2); border: 1px solid var(--surface-border);
  box-shadow: 0 1px 3px oklch(20% 0.04 50 / 0.25);
}
.profile-avatar input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.profile-avatar:focus-within .profile-avatar__edit { outline: 2px solid var(--bili-gold); outline-offset: 2px; }

/* Inline name edit (hero) */
.profile-name-form { display: flex; align-items: center; gap: 8px; max-width: 360px; }
.profile-name-form .input { flex: 1; }

.profile-sec {
  font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--bili-ink-3); margin: 6px 0 -4px;
}
.profile-sec__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.profile-sec__row .profile-sec { margin: 0; }

/* Organisation tiles reuse .bili-org-card; the open prompt is always visible
   here (touch has no hover) and the grid is a touch denser than the picker. */
.profile-orgs { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.profile-orgs .bili-org-card { min-height: 132px; }
.profile-orgs .bili-org-card__body .bili-org-card__cta { opacity: 1; transform: none; }
.profile-orgs__more { font-size: 13px; color: var(--bili-ink-3); }

/* Sign-in & security: one card, two labelled groups, rows on .auth-pk */
.profile-security .auth-pk:last-child, .profile-security .auth-empty:last-child { margin-bottom: 0; }
.profile-security .auth-pk > .tag, .profile-security .auth-pk > .button { margin-left: auto; }
.profile-group__label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--bili-ink-3); margin: 4px 0 8px;
}
.profile-group__label.is-split {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--bo-hair);
}
.profile-group__label .button { text-transform: none; letter-spacing: 0; font-weight: 400; }
.profile-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none;
  background: var(--bo-hair-2); color: var(--bili-ink-2);
}

@media (max-width: 620px) {
  .profile-hero { padding: 20px; }
  .profile-hero__row { flex-wrap: wrap; }
  .profile-hero__actions { flex-direction: row; align-items: center; }
  .profile-avatar .bili-avatar { width: 68px; height: 68px; font-size: 26px; }
}
