/* ==========================================================================
   Evolonic UI – base, app shell and components.
   Tokens: static/css/tokens.css. Docs: ui/README.md. Never hard-code colors
   here: always use var(--color-*).
   ========================================================================== */

/* -------------------------------------------------------------------- Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--color-canvas);
}

/* Responsive page gutter (PLAN_V4 A1): 16 / 24 / 32 / 40 px */
@media (min-width: 640px) { :root { --content-padding: var(--space-6); } }
@media (min-width: 1024px) { :root { --content-padding: var(--space-8); } }
@media (min-width: 1280px) { :root { --content-padding: var(--space-10); } }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--line-sm);
  font-feature-settings: "cv11", "ss01", "ss03";
  color: var(--color-text);
  background: var(--color-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-3);
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}
/* Type scale (PLAN_V4 A2): display 32/40 · h1 24/32 · h2 18/28 · h3 15/22 · UI 14/22 · meta 12/16 */
h1 { font-size: var(--text-xl); line-height: var(--line-lg); letter-spacing: -0.018em; }
h2 { font-size: 1.125rem; line-height: var(--line-md); }
h3 { font-size: var(--text-body-reading); line-height: var(--line-sm); }
h4 { font-size: var(--text-sm); line-height: var(--line-sm); }
h5, h6 { font-size: var(--text-xs); line-height: var(--line-xs); }
.display {
  font-size: var(--text-2xl);
  font-weight: 650;
  line-height: var(--line-xl);
  letter-spacing: var(--tracking-display);
}
.meta {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--line-xs);
}

/* Reading text (descriptions, knowledge pages, meeting notes) */
.prose {
  max-width: var(--content-reading);
  font-size: var(--text-body-reading);
  line-height: var(--leading-relaxed);
}
.prose > * + * { margin-top: 0.85em; }
.prose p, .prose ul, .prose ol, .prose pre, .prose blockquote, .prose table { margin-bottom: 0; }
.prose :where(h1, h2, h3, h4) { margin: 1.6em 0 0; }
.prose > :first-child { margin-top: 0; }
.prose :where(ul, ol) { padding-left: 1.4em; }
.prose li + li { margin-top: 0.3em; }
.prose pre { border-radius: var(--radius-md); }
.prose blockquote {
  margin-inline: 0;
  padding: 0 0 0 var(--space-4);
  border-left: 2px solid var(--color-border-strong);
  color: var(--color-text-muted);
}
.prose img { border-radius: var(--radius-md); }

p { margin: 0 0 var(--space-3); }

/* zero specificity, so component classes (and legacy [role=button]) always win */
:where(a) {
  color: var(--color-accent-text);
  text-decoration: none;
}
:where(a):hover { text-decoration: underline; text-underline-offset: 2px; }
/* Links inside running text are underlined – color alone is not enough (WCAG 1.4.1) */
:where(p, li, dd, blockquote, .prose) > a:not([class]),
:where(p, li, dd, blockquote, .prose) > :where(span, strong, em, small) > a:not([class]) {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  text-underline-offset: 2px;
}
:where(p, li, dd, blockquote, .prose) > a:not([class]):hover { text-decoration-color: currentColor; }

img, svg, video { max-width: 100%; }
svg.lucide { flex: none; stroke-width: 1.75; vertical-align: middle; }
i[data-lucide], .icon { display: inline-block; flex: none; vertical-align: middle; }

hr {
  height: 1px;
  margin: var(--space-6) 0;
  border: 0;
  background: var(--color-border);
}

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
code {
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-bg-muted);
}
pre {
  overflow-x: auto;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-bg-muted);
}
pre code { padding: 0; background: none; }

::selection { background: var(--color-accent-subtle); color: var(--color-text); }

/* Visible focus ring everywhere */
:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}
:focus:not(:focus-visible) { outline: none; }
/* Dialogs are containers – their content shows focus, not the dialog box itself */
dialog:focus,
dialog:focus-visible { outline: none; }

.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-4);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-weight: var(--weight-medium);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; text-decoration: none; }

[hidden] { display: none !important; }

/* Reduced motion (V4, PLAN_V4 3.8): system setting unless the profile says "full", or the profile says "reduced".
   Every transition/animation becomes (at most) a short cross-fade; JS animations go through UI.motion.animate,
   which drops transforms itself. */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) *,
  html:not([data-motion="full"]) *::before,
  html:not([data-motion="full"]) *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* Reduced motion, part 2 (agent A): components that enter with a transform get an opacity-only cross-fade instead,
   and hover/press transforms are dropped – so no transform animation or transition is left anywhere. */
@keyframes ui-fade-in { from { opacity: 0; } }
@keyframes ui-fade-out { to { opacity: 0; } }
html[data-motion="reduced"] :is(.toast, dialog.modal[open], dialog.drawer[open], .dropdown-menu, .ui-bulk-bar) { animation-name: ui-fade-in !important; }
html[data-motion="reduced"] .toast.is-leaving { animation-name: ui-fade-out !important; }
html[data-motion="reduced"] :is(.btn:active, .card-interactive:hover, .card--interactive:hover, a.card:hover) { transform: none !important; }
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) :is(.toast, dialog.modal[open], dialog.drawer[open], .dropdown-menu, .ui-bulk-bar) { animation-name: ui-fade-in !important; }
  html:not([data-motion="full"]) .toast.is-leaving { animation-name: ui-fade-out !important; }
  html:not([data-motion="full"]) :is(.btn:active, .card-interactive:hover, .card--interactive:hover, a.card:hover) { transform: none !important; }
}

/* --------------------------------------------------------------- Utilities */
.text-muted { color: var(--color-text-muted); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.text-danger { color: var(--color-danger-text); }
.text-success { color: var(--color-success-text); }
.text-warning { color: var(--color-warning-text); }
.fw-medium { font-weight: var(--weight-medium); }
.fw-semibold { font-weight: var(--weight-semibold); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.stack-sm { --stack-gap: var(--space-2); }
.stack-lg { --stack-gap: var(--space-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-2)); }
.cluster-lg { --cluster-gap: var(--space-4); }
.spacer { flex: 1 1 auto; }
.scroll-x { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.divider { height: 1px; margin: var(--space-4) 0; background: var(--color-border); border: 0; }

.kbd,
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-1);
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ui-spin 0.7s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ============================================================== APP SHELL */
.app {
  --app-sidebar-w: var(--sidebar-width);
  display: grid;
  grid-template-columns: var(--app-sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  /* paints the sidebar column below the sticky sidebar on long pages */
  background: linear-gradient(90deg,
    var(--color-bg-subtle) 0 calc(var(--app-sidebar-w) - 1px),
    var(--color-border) calc(var(--app-sidebar-w) - 1px) var(--app-sidebar-w),
    var(--color-canvas) var(--app-sidebar-w));
}

/* ------------------------------------------------------------- Sidebar */
.app-sidebar {
  position: sticky;
  top: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}

.sidebar-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  height: var(--topbar-height);
  padding: 0 var(--space-3) 0 var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; flex: none; color: var(--color-accent); }
.brand-text { overflow: hidden; text-overflow: ellipsis; }
.brand-sub { color: var(--color-text-muted); font-weight: var(--weight-medium); }

.sidebar-close { margin-left: auto; }

.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2) var(--space-3) var(--space-4);
}

.nav,
.nav ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  transition: background-color var(--motion-quick) var(--ease-out-soft), color var(--motion-quick) var(--ease-out-soft);
}
.nav-item:hover { background: var(--color-hover); color: var(--color-text); text-decoration: none; }
/* The active entry carries a background "pill"; with View Transitions it glides to the new entry on navigation. */
.nav-item[aria-current],
.nav-item.is-active {
  background: var(--color-accent-subtle);
  color: var(--color-accent-text);
}
.app-sidebar .nav-item[aria-current] { view-transition-name: nav-pill; }
.nav-item svg, .nav-item .nav-icon { width: var(--icon-md); height: var(--icon-md); flex: none; }
.nav-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item-sub { height: 28px; padding-left: var(--space-2); font-size: var(--text-sm); }
.nav-item-sub svg { width: var(--icon-sm); height: var(--icon-sm); }
.nav-item.is-unread { color: var(--color-text); font-weight: var(--weight-semibold); }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 var(--space-1);
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1;
}
.nav-dot {
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--color-accent);
}

.nav-section { margin-top: var(--space-6); }
.nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  margin: 0 0 var(--space-1);
  padding: 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--line-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav-channels { margin-top: 2px; }
.nav-channels:empty { display: none; }
.nav-group-title {
  margin: var(--space-2) 0 2px;
  padding: 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.sidebar-footer {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border);
}
.sidebar-footer .nav-item { width: 100%; min-height: 0; border: 0; background: none; font: inherit; font-weight: var(--weight-medium); cursor: pointer; text-align: left; }
.sidebar-footer .nav-item:hover { background: var(--color-hover); }
.sidebar-footer .nav-item .kbd { margin-left: auto; }

.icon-when-collapsed { display: none; }

/* Tooltips on nav items only when collapsed */
.app-sidebar [data-tooltip]::after { display: none; }

@media (min-width: 900px) {
  html.sidebar-collapsed .app { --app-sidebar-w: var(--sidebar-width-collapsed); }
  html.sidebar-collapsed .sidebar-header { justify-content: center; padding: 0; }
  html.sidebar-collapsed .brand-text,
  html.sidebar-collapsed .nav-label,
  html.sidebar-collapsed .nav-section-title > span,
  html.sidebar-collapsed .sidebar-footer .kbd {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  html.sidebar-collapsed .sidebar-scroll { overflow: visible; padding-inline: var(--space-2); }
  html.sidebar-collapsed .app-sidebar { overflow: visible; }
  html.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
  html.sidebar-collapsed .nav-section-title { height: 1px; margin: var(--space-3) var(--space-2); padding: 0; background: var(--color-border); }
  html.sidebar-collapsed .nav-section { margin-top: var(--space-2); }
  html.sidebar-collapsed .nav-channels { display: none; }
  html.sidebar-collapsed .nav-badge,
  html.sidebar-collapsed .nav-dot {
    position: absolute;
    top: 5px;
    right: 7px;
    min-width: 8px;
    width: 8px;
    height: 8px;
    padding: 0;
    font-size: 0;
  }
  html.sidebar-collapsed .sidebar-footer { padding-inline: var(--space-2); }
  html.sidebar-collapsed .icon-when-collapsed { display: inline-block; }
  html.sidebar-collapsed .icon-when-expanded { display: none; }
  html.sidebar-collapsed .app-sidebar [data-tooltip]::after { display: block; }
}

/* ------------------------------------------------------------- Main */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: clip;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-height);
  padding: 0 var(--content-padding);
  /* translucent; the bottom edge only appears once the page has scrolled (ui.js: .is-scrolled from 4 px) */
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: border-color var(--motion-quick) var(--ease-out-soft), box-shadow var(--motion-quick) var(--ease-out-soft);
}
.app-topbar.is-scrolled { border-bottom-color: var(--color-border); box-shadow: var(--shadow-xs); }

.btn.topbar-menu,
.btn.sidebar-close { display: none; }

.topbar-search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 520px;
  margin: 0;
}
.topbar-search .search-input {
  height: var(--control-h-md);
  margin: 0;
  padding-left: 36px;
  padding-right: var(--space-10);
  background: var(--color-bg-subtle);
}
.topbar-search .search-input:focus { background: var(--color-surface); }
.search-icon {
  position: absolute;
  top: 50%;
  left: var(--space-3);
  color: var(--color-text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.search-kbd {
  position: absolute;
  top: 50%;
  right: var(--space-2);
  transform: translateY(-50%);
  pointer-events: none;
}
.search-input:focus ~ .search-kbd,
.search-input:not(:placeholder-shown) ~ .search-kbd { display: none; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

.search-suggest {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  left: 0;
  z-index: var(--z-dropdown);
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-md);
}
.search-suggest:empty { display: none; }
.suggest-group + .suggest-group { margin-top: var(--space-1); padding-top: var(--space-1); border-top: 1px solid var(--color-border); }
.suggest-group-title {
  padding: var(--space-2) var(--space-2) var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text);
}
.suggest-item:hover,
.suggest-item:focus-visible,
.suggest-item[aria-selected="true"] { background: var(--color-hover); text-decoration: none; }
.suggest-item:focus-visible { outline-offset: -2px; }
.suggest-item svg { color: var(--color-text-muted); }
.suggest-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-meta { color: var(--color-text-muted); font-size: var(--text-xs); white-space: nowrap; }
.suggest-empty { padding: var(--space-3); color: var(--color-text-muted); }

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

.topbar-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-h-md);
  min-height: var(--control-h-md);
}

.counter {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 var(--space-1);
  border-radius: var(--radius-full);
  background: var(--color-danger);
  box-shadow: 0 0 0 2px var(--color-bg);
  color: var(--color-on-danger);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--line-xs);
  letter-spacing: -0.02em;
  text-align: center;
  pointer-events: none;
}
.counter:empty { display: none; }

.avatar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h-md);
  height: var(--control-h-md);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  cursor: pointer;
}
.avatar-button:hover { background: var(--color-hover); }

.app-content {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  padding: var(--space-8) var(--content-padding) var(--space-16);
  overflow-wrap: break-word;
}
.app-content:focus { outline: none; }
.app-content.content-narrow { max-width: calc(var(--content-narrow) + 2 * var(--content-padding)); margin-inline: auto; }
.app-content.content-medium { max-width: calc(var(--content-medium) + 2 * var(--content-padding)); margin-inline: auto; }
.app-content.content-flush { padding: 0; }

.app-overlay { display: none; }

/* ------------------------------------------------------------- Page header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-8);
}
.page-heading { min-width: 0; }
.page-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--line-lg);
  letter-spacing: -0.018em;
}
/* Only the page's own heading glides between pages (names must be unique per document). */
#main > .page-header .page-title { view-transition-name: page-title; }
.page-subtitle {
  margin: var(--space-1) 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--line-xs);
}
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.page-tabs { flex: 1 0 100%; min-width: 0; }

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 var(--space-2);
  padding: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  list-style: none;
}
.breadcrumbs a { color: var(--color-text-muted); }
.breadcrumbs a:hover { color: var(--color-text); }
.breadcrumbs > * + *::before {
  content: "/";
  display: inline-block;
  margin: 0 var(--space-2);
  color: var(--color-text-muted);
  opacity: 0.6;
}
.breadcrumbs [aria-current] { color: var(--color-text); }

/* ------------------------------------------------------------- Auth layout */
.auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-12) var(--space-4);
  background: var(--color-bg-subtle);
}
.auth-brand { margin-bottom: var(--space-6); font-size: var(--text-lg); }
.auth-brand .brand-mark { width: 32px; height: 32px; }
.auth-content { width: 100%; max-width: 560px; }

/* ------------------------------------------------------------- Mobile */
@media (max-width: 899.98px) {
  .app { grid-template-columns: minmax(0, 1fr); background: var(--color-canvas); }
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: calc(var(--z-overlay) + 1);
    width: min(300px, 86vw);
    visibility: hidden;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease-out), visibility 0s linear var(--duration-base);
  }
  html.sidebar-open .app-sidebar {
    visibility: visible;
    transform: none;
    transition: transform var(--duration-base) var(--ease-out), visibility 0s;
  }
  html.sidebar-open { overflow: hidden; }
  .app-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    display: block;
    background: var(--color-overlay);
  }
  .btn.topbar-menu,
  .btn.sidebar-close { display: inline-flex; }
  .nav-item.sidebar-collapse { display: none; }
  .app-topbar { gap: var(--space-2); padding: 0 var(--space-4); }
  .topbar-actions { gap: var(--space-1); }
  .search-kbd { display: none; }
  .topbar-search .search-input { padding-right: var(--space-3); }
  .hide-mobile {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .btn.btn-new { width: var(--control-h-md); padding: 0; }
  .page-title { font-size: 1.25rem; line-height: var(--line-md); }
  .page-header { margin-bottom: var(--space-6); }
  .page-header > .page-actions { flex: 1 0 100%; }
}

/* ============================================================= COMPONENTS */

/* ------------------------------------------------------------- Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h-md);
  min-height: 0;
  margin: 0;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--motion-quick) var(--ease-out-soft), border-color var(--motion-quick) var(--ease-out-soft), color var(--motion-quick), box-shadow var(--motion-quick), transform var(--motion-instant) var(--ease-out-soft);
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled, [aria-disabled="true"]) { transform: scale(0.98); }
.btn svg { width: var(--icon-md); height: var(--icon-md); }
.btn-secondary,
.btn:not(.btn-primary, .btn-ghost, .btn-danger) { box-shadow: var(--shadow-xs); }
.btn-secondary:hover,
.btn:not(.btn-primary, .btn-ghost, .btn-danger):hover { background: var(--color-bg-subtle); border-color: var(--color-border-input); }
.btn:not(.btn-primary, .btn-ghost, .btn-danger):active { background: var(--color-bg-muted); }

.btn-primary {
  border-color: transparent;
  background: var(--color-accent);
  color: var(--color-on-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:active { background: var(--color-accent-active); }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--color-text);
}
.btn-ghost:hover { background: var(--color-hover); }
.btn-ghost:active { background: var(--color-pressed); }
.btn-ghost.btn-muted { color: var(--color-text-muted); }
.btn-ghost.btn-muted:hover { color: var(--color-text); }

.btn-danger {
  border-color: transparent;
  background: var(--color-danger);
  color: var(--color-on-danger);
}
.btn-danger:hover { background: var(--color-danger-hover); }

.btn-sm {
  gap: var(--space-1);
  height: var(--control-h-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}
.btn-sm svg { width: var(--icon-sm); height: var(--icon-sm); }
.btn-icon { width: var(--control-h-md); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn-block { display: flex; width: 100%; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn.htmx-request,
.btn[aria-busy="true"] { cursor: progress; opacity: 0.75; }

.btn-group { display: inline-flex; align-items: center; }
.btn-group > .btn { border-radius: 0; box-shadow: none; }
.btn-group > .btn + .btn { margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.btn-group > .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.btn-group > .btn[aria-pressed="true"],
.btn-group > .btn[aria-current] { position: relative; z-index: 1; background: var(--color-accent-subtle); border-color: var(--color-accent); color: var(--color-accent-text); }

/* ------------------------------------------------------------- Form controls
   Django widgets (no classes) are styled through the :where() selectors. */
.input,
.select,
.textarea,
:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="submit"], [type="button"], [type="reset"], [type="image"], [type="hidden"]), select, textarea) {
  width: 100%;
  max-width: 100%;
  height: var(--control-h-md);
  margin: 0;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  vertical-align: middle;
  transition: border-color var(--motion-quick) var(--ease-out-soft), box-shadow var(--motion-quick) var(--ease-out-soft);
}
.input,
.select,
.textarea { display: block; }
/* Form fields are 40 px high; bare controls in toolbars keep the 36-px button height (ADR-0049). */
.field :where(.input, .select, input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="submit"], [type="button"], [type="reset"], [type="image"], [type="hidden"]), select:not([multiple], [size])) {
  height: var(--control-h-lg);
}
.textarea,
:where(textarea) {
  height: auto;
  min-height: 88px;
  padding: var(--space-2) var(--space-3);
  resize: vertical;
}
.select,
:where(select:not([multiple], [size])) {
  padding-right: var(--space-8);
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
    linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
:where(select[multiple], select[size]) { height: auto; padding: var(--space-1); }
.input-sm { height: var(--control-h-sm); font-size: var(--text-xs); }

.input::placeholder,
.textarea::placeholder,
:where(input, textarea)::placeholder { color: var(--color-text-muted); opacity: 1; }

.input:focus,
.select:focus,
.textarea:focus,
:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="submit"], [type="button"], [type="reset"]), select, textarea):focus {
  border-color: var(--color-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

[aria-invalid="true"],
.field.has-error :where(.input, .select, .textarea, input, select, textarea) {
  border-color: var(--color-danger);
}
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--color-danger-subtle); }

:where(input, select, textarea):disabled,
.input:disabled {
  background-color: var(--color-bg-muted);
  color: var(--color-text-disabled);
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--color-accent);
  vertical-align: middle;
  cursor: pointer;
}
input[type="color"] {
  width: 48px;
  height: var(--control-h-md);
  padding: 2px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
}
input[type="file"] { max-width: 100%; font: inherit; font-size: var(--text-sm); }
input[type="date"],
input[type="datetime-local"],
input[type="time"] { font-variant-numeric: tabular-nums; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.7; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-5);
}
.field-label {
  display: block;
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.field-required { color: var(--color-danger-text); margin-left: 2px; }
.field-help { margin: 0; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: var(--line-xs); }
.field-error {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  color: var(--color-danger-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.field-check {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}
.field-check .field-label { font-weight: var(--weight-regular); cursor: pointer; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 var(--space-4); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }

.input-group { position: relative; }
.input-group > svg,
.input-group > .input-icon {
  position: absolute;
  top: 50%;
  left: var(--space-3);
  color: var(--color-text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.input-group > .input { padding-left: 36px; }

/* ------------------------------------------------------------- Badge & chip */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.badge svg { width: 12px; height: 12px; }
.badge-neutral { background: var(--color-bg-muted); color: var(--color-text-muted); }
.badge-accent,
.badge-info { background: var(--color-info-subtle); color: var(--color-info-text); }
.badge-success { background: var(--color-success-subtle); color: var(--color-success-text); }
.badge-warning { background: var(--color-warning-subtle); color: var(--color-warning-text); }
.badge-danger { background: var(--color-danger-subtle); color: var(--color-danger-text); }
.badge-outline { border: 1px solid var(--color-border-strong); background: transparent; }
.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg-subtle);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
a.chip { transition: border-color var(--motion-quick), background-color var(--motion-quick); }
a.chip:hover { border-color: var(--color-border-strong); background: var(--color-surface); text-decoration: none; }
.chip svg { width: var(--icon-sm); height: var(--icon-sm); color: var(--chip-color, var(--color-text-muted)); }
.chip-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--chip-color, var(--color-text-muted));
}
.chip-text { overflow: hidden; text-overflow: ellipsis; }
.chip-remove {
  display: inline-flex;
  min-height: 0;
  margin-right: calc(-1 * var(--space-1));
  padding: 2px;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.chip-remove:hover { background: var(--color-hover); color: var(--color-text); }
.chip-remove svg { width: 12px; height: 12px; color: inherit; }

/* ------------------------------------------------------------- Avatar */
.avatar {
  --avatar-size: 24px;
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--avatar-size);
  height: var(--avatar-size);
  overflow: hidden;
  border-radius: 50%;
  background: var(--color-avatar-bg);
  color: var(--color-avatar-text);
  font-size: calc(var(--avatar-size) * 0.4);
  font-weight: var(--weight-semibold);
  line-height: 1;
  letter-spacing: 0;
  vertical-align: middle;
  user-select: none;
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* 2-px ring in the page color; a team color can tint it: style="--team-color: #hex" + .team-accent */
.avatar-ring,
.avatar.team-accent { box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--team-color, var(--color-border-strong)); }
.avatar-xs { --avatar-size: 20px; }
.avatar-sm { --avatar-size: 24px; }
.avatar-md { --avatar-size: 32px; }
.avatar-lg { --avatar-size: 40px; }
.avatar-xl { --avatar-size: 64px; }
.avatar-more { background: var(--color-bg-muted); color: var(--color-text-muted); }

.avatar-group { display: inline-flex; align-items: center; vertical-align: middle; }
.avatar-group > .avatar { box-shadow: 0 0 0 2px var(--avatar-ring, var(--color-bg)); }
dialog .avatar-group,
.dropdown-menu .avatar-group { --avatar-ring: var(--color-surface-raised); }
.avatar-group > .avatar + .avatar { margin-left: calc(var(--avatar-size) * -0.2); }

/* ------------------------------------------------------------- Card */
.card {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
}
a.card { display: block; color: inherit; }
a.card:hover { text-decoration: none; }
/* Interactive cards lift by 1 px on hover */
.card-interactive,
.card--interactive,
a.card {
  transition: transform var(--motion-quick) var(--ease-out-soft), box-shadow var(--motion-quick) var(--ease-out-soft), border-color var(--motion-quick) var(--ease-out-soft);
}
.card-interactive:hover,
.card--interactive:hover,
a.card:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--card-padding);
  border-bottom: 1px solid var(--color-border);
}
.card-title { margin: 0; font-size: var(--text-body-reading); font-weight: var(--weight-semibold); line-height: var(--line-sm); }
.card-subtitle { margin: 2px 0 0; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: var(--line-xs); }
.card-body { padding: var(--card-padding); }
.card-body > :last-child { margin-bottom: 0; }
.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--card-padding);
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--color-bg-subtle);
}
.card-compact .card-body { padding: var(--space-3) var(--space-4); }
.card-compact .card-header { padding: var(--space-3) var(--space-4); }

/* Team accent: a 3-px stripe on the left edge (project cards) – never text in the team color (contrast).
   <div class="card team-accent" style="--team-color: {{ team.color }}"> */
.team-accent:not(.avatar) { position: relative; overflow: hidden; }
.team-accent:not(.avatar)::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--team-color, var(--color-accent));
  pointer-events: none;
}

/* ------------------------------------------------------------- Modal & drawer */
dialog.modal,
dialog.drawer {
  padding: 0;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop,
dialog.drawer::backdrop { background: var(--color-overlay); }

dialog.modal {
  width: min(var(--modal-width, 560px), calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 64px);
  border-radius: var(--radius-xl);
}
.modal-sm { --modal-width: 400px; }
.modal-lg { --modal-width: 800px; }
dialog.modal[open] {
  display: flex;
  flex-direction: column;
  animation: ui-modal-in var(--motion-calm) var(--ease-out-soft);
}

dialog.drawer {
  inset: 0 0 0 auto;
  width: min(var(--drawer-width), 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  border-width: 0 0 0 1px;
  border-radius: 0;
}
.drawer-wide { --drawer-width: 760px; }
dialog.drawer[open] {
  display: flex;
  flex-direction: column;
  animation: ui-drawer-in var(--motion-calm) var(--ease-out-soft);
}

.modal-header,
.drawer-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 56px;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.modal-title,
.drawer-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-header .btn,
.drawer-header .btn { flex: none; }
.drawer-header-actions { display: flex; flex: none; align-items: center; gap: var(--space-1); margin-left: auto; }
.modal-body,
.drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-5);
  overscroll-behavior: contain;
}
.modal-body > :last-child,
.drawer-body > :last-child { margin-bottom: 0; }
.modal-footer,
.drawer-footer {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-raised);
}
/* A footer placed as last child inside the body sticks to the bottom edge */
.modal-body > .modal-footer:last-child,
.drawer-body > .drawer-footer:last-child {
  position: sticky;
  bottom: calc(-1 * var(--space-5));
  margin: var(--space-5) calc(-1 * var(--space-5)) calc(-1 * var(--space-5));
}
/* …and in drawers it is pushed down to the bottom of the panel */
.drawer-body:has(> .drawer-footer:last-child) { display: flex; flex-direction: column; }
.drawer-body > .drawer-footer:last-child { margin-top: auto; }

@keyframes ui-modal-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes ui-drawer-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}
dialog.modal[open]::backdrop,
dialog.drawer[open]::backdrop { animation: ui-fade-in var(--motion-calm) var(--ease-out-soft); }

/* ------------------------------------------------------------- Tabs */
.tabs {
  display: flex;
  gap: var(--space-1);
  margin: 0 0 var(--space-4);
  padding: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
  list-style: none;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  min-height: 0;
  margin: 0;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: none;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  cursor: pointer;
}
.tab svg { width: var(--icon-md); height: var(--icon-md); }
.tab:hover { color: var(--color-text); text-decoration: none; background: var(--color-hover); }
.tab:focus-visible { outline-offset: -2px; }
.tab[aria-selected="true"],
.tab[aria-current] { color: var(--color-text); }
.tab[aria-selected="true"]::after,
.tab[aria-current]::after {
  content: "";
  position: absolute;
  right: var(--space-2);
  bottom: -1px;
  left: var(--space-2);
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--color-accent);
}
.tab-count {
  min-width: 18px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.2;
  text-align: center;
}
.tab-panel:focus-visible { outline-offset: 4px; }

/* ------------------------------------------------------------- Dropdown */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  z-index: var(--z-dropdown);
  min-width: 200px;
  max-width: min(320px, calc(100vw - 16px));
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-md);
  transform-origin: top left;
  animation: ui-pop-in var(--motion-calm) var(--ease-out-soft);
}
.dropdown-menu-end { transform-origin: top right; }
.dropdown-menu-end { right: 0; left: auto; }
.dropdown-menu-up { transform-origin: bottom left; }
.dropdown-menu-up { top: auto; bottom: calc(100% + var(--space-1)); }
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  width: 100%;
  min-height: 32px;
  margin: 0;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  line-height: 1.3;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.dropdown-item:hover,
.dropdown-item:focus-visible { background: var(--color-hover); text-decoration: none; }
.dropdown-item:focus-visible { outline-offset: -2px; }
.dropdown-item svg { width: var(--icon-md); height: var(--icon-md); color: var(--color-text-muted); }
.dropdown-item .kbd { margin-left: auto; }
.dropdown-item-danger,
.dropdown-item-danger svg { color: var(--color-danger-text); }
.dropdown-item[aria-checked="true"] { color: var(--color-accent-text); font-weight: var(--weight-medium); }
.dropdown-item[aria-checked="true"] svg { color: var(--color-accent-text); }
.dropdown-item:disabled,
.dropdown-item[aria-disabled="true"] { color: var(--color-text-disabled); cursor: not-allowed; }
.dropdown-separator { height: 1px; margin: var(--space-1) calc(-1 * var(--space-1)); background: var(--color-border); }
.dropdown-label {
  padding: var(--space-2) var(--space-2) var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.dropdown-header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); }
.dropdown-header-text { min-width: 0; line-height: 1.3; }
.dropdown-header-text strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-header-text span { display: block; overflow: hidden; color: var(--color-text-muted); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.dropdown-menu form { margin: 0; }

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 0 var(--space-1) var(--space-1);
  padding: 2px;
  border-radius: var(--radius-md);
  background: var(--color-bg-muted);
}
.theme-switch .dropdown-item {
  justify-content: center;
  gap: var(--space-1);
  min-height: 28px;
  padding: 0 var(--space-1);
  font-size: var(--text-xs);
}
.theme-switch .dropdown-item svg { width: var(--icon-sm); height: var(--icon-sm); }
.theme-switch .dropdown-item[aria-checked="true"] {
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-xs);
}

@keyframes ui-pop-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------- Toast */
.toast-region {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  --toast-color: var(--color-info);
  --toast-text: var(--color-info-text);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--toast-color);
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-lg);
  color: var(--color-text);
  pointer-events: auto;
  animation: ui-toast-in var(--motion-calm) var(--ease-out-soft);
}
.toast-success { --toast-color: var(--color-success); --toast-text: var(--color-success-text); }
.toast-warning { --toast-color: var(--color-warning); --toast-text: var(--color-warning-text); }
.toast-error { --toast-color: var(--color-danger); --toast-text: var(--color-danger-text); }
.toast-icon { width: 18px; height: 18px; margin-top: 1px; color: var(--toast-text); }
.toast-message { flex: 1 1 auto; min-width: 0; padding-top: 1px; font-size: var(--text-sm); }
.toast-close { flex: none; margin: calc(-1 * var(--space-1)) 0; }
.toast.is-leaving { animation: ui-toast-out var(--motion-quick) var(--ease-in-out) forwards; }
.toast-static { animation: none; }
@keyframes ui-toast-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes ui-toast-out {
  to { opacity: 0; transform: translateY(8px); }
}
@media (max-width: 899.98px) {
  .toast-region { right: var(--space-4); bottom: var(--space-4); left: var(--space-4); width: auto; }
}

/* ------------------------------------------------------------- Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-12) var(--space-6);
  color: var(--color-text-muted);
  text-align: center;
}
.empty-state-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-xl);
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
}
.empty-state-icon svg { width: 24px; height: 24px; }
.empty-state-title { margin: 0; color: var(--color-text); font-size: var(--text-md); font-weight: var(--weight-semibold); }
.empty-state-text { max-width: 44ch; margin: 0; }
.empty-state-action { margin-top: var(--space-3); }
.empty-state-compact { padding: var(--space-6) var(--space-4); }
.empty-state-bordered { border: 1px dashed var(--color-border-strong); border-radius: var(--radius-lg); }

/* ------------------------------------------------------------- Skeleton */
.skeleton {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--color-skeleton);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--color-shimmer), transparent);
  transform: translateX(-100%);
  animation: ui-shimmer 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  opacity: 0.8;
}
.skeleton-text { height: 12px; margin: var(--space-2) 0; }
.skeleton-text:last-child:not(:first-child) { width: 60%; }
.skeleton-title { width: 40%; height: 16px; margin-bottom: var(--space-3); }
.skeleton-circle { width: 32px; height: 32px; flex: none; border-radius: 50%; }
.skeleton-block { height: 80px; border-radius: var(--radius-lg); }
.skeleton-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; }
.skeleton-row > .skeleton-text { flex: 1; margin: 0; }
@keyframes ui-shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { display: none; }
}

/* ------------------------------------------------------------- Table */
.table-wrap {
  position: relative; /* keeps .visually-hidden cell text inside the scroll container */
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 36px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--line-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.table td {
  height: var(--row-height);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover { background: var(--color-hover); }
.table-compact th, .table-compact td { padding: var(--space-2) var(--space-3); }
.table .num, .table th.num { text-align: right; }
.table tr[aria-selected="true"] { background: var(--color-accent-subtle); }
.table .col-check { width: 40px; }
.th-sort {
  display: inline-flex;
  min-height: 0;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.th-sort:hover { color: var(--color-text); }
.th-sort svg { width: var(--icon-sm); height: var(--icon-sm); opacity: 0.5; }
th[aria-sort="ascending"] .th-sort svg,
th[aria-sort="descending"] .th-sort svg { opacity: 1; color: var(--color-accent-text); }

/* ------------------------------------------------------------- Progress */
.progress {
  --progress-color: var(--color-accent);
  position: relative;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--color-bg-muted);
}
.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--progress-color);
  transition: width var(--duration-slow) var(--ease-out);
}
.progress-success { --progress-color: var(--color-success); }
.progress-warning { --progress-color: var(--color-warning); }
.progress-danger { --progress-color: var(--color-danger); }
.progress-lg { height: 8px; }
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: 6px;
  font-size: var(--text-xs);
}
.progress-meta-label { color: var(--color-text); font-weight: var(--weight-medium); }
.progress-meta-value { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- Tooltip
   1) data-tooltip="Text" on any focusable element (pair with aria-label).
   2) .tooltip-wrap > trigger[aria-describedby] + .tooltip[role=tooltip]. */
[data-tooltip] { position: relative; }
[data-tooltip]::after,
.tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  z-index: var(--z-tooltip);
  max-width: 280px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-text);
  color: var(--color-bg);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  white-space: nowrap;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%);
  transition: opacity var(--motion-quick) var(--ease-out-soft), visibility var(--motion-quick);
}
[data-tooltip]::after { content: attr(data-tooltip); }
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after,
.tooltip-wrap:hover > .tooltip,
.tooltip-wrap:focus-within > .tooltip {
  opacity: 1;
  visibility: visible;
  transition-delay: 400ms;
}
[data-tooltip-pos="bottom"]::after,
.tooltip-bottom { top: calc(100% + 6px); bottom: auto; }
[data-tooltip-pos="right"]::after,
.tooltip-right { top: 50%; bottom: auto; left: calc(100% + 8px); transform: translateY(-50%); }
[data-tooltip-pos="left"]::after,
.tooltip-left { top: 50%; right: calc(100% + 8px); bottom: auto; left: auto; transform: translateY(-50%); }
[data-tooltip].tooltip-dismissed::after,
.tooltip-wrap.tooltip-dismissed > .tooltip { opacity: 0 !important; visibility: hidden !important; }
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip-wrap > .tooltip { white-space: normal; width: max-content; }

/* ------------------------------------------------------------- Callout (inline message) */
.callout {
  --callout-color: var(--color-info);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--callout-color);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.callout svg { width: 18px; height: 18px; color: var(--callout-text, var(--color-info-text)); }
.callout-success { --callout-color: var(--color-success); --callout-text: var(--color-success-text); }
.callout-warning { --callout-color: var(--color-warning); --callout-text: var(--color-warning-text); }
.callout-error { --callout-color: var(--color-danger); --callout-text: var(--color-danger-text); }

/* ------------------------------------------------------------- Shortcut list */
.shortcut-list { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-6); margin: 0; }
.shortcut-list dt { color: var(--color-text); }
.shortcut-list dd { display: flex; gap: var(--space-1); justify-content: flex-end; margin: 0; }
.shortcut-group-title { margin: var(--space-4) 0 var(--space-2); color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); text-transform: uppercase; letter-spacing: 0.06em; }
.shortcut-group-title:first-child { margin-top: 0; }

/* ------------------------------------------------------------- Theme panels (styleguide) */
.theme-panel { background: var(--color-bg); color: var(--color-text); }

@media print {
  .app-sidebar, .app-topbar, .toast-region, .skip-link { display: none !important; }
  .app { display: block; }
  .app-content { padding: 0; }
}

/* ------------------------------------------------------------------------
   Markdown decorations from core.markdown (comments, chat, meeting notes)
   <span class="mention">@anna</span> · <a class="task-ref">#12 Titel <span class="task-ref-status">In Arbeit</span></a>
   ------------------------------------------------------------------------ */
.mention {
  padding: 0 2px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-subtle);
  color: var(--color-accent-text);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.task-ref {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  max-width: 100%;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.93em;
  font-weight: var(--weight-medium);
  line-height: 1.6;
  text-decoration: none;
  vertical-align: baseline;
}
.task-ref:hover { background: var(--color-bg-subtle); text-decoration: none; }
.task-ref-status { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-regular); }

/* ------------------------------------------------------------------------
   Third-party: FullCalendar (project calendar, team calendar)
   ------------------------------------------------------------------------ */
/* FullCalendar dims days of neighbouring months with opacity .3 (1.5:1 contrast) – use muted text instead (AA). */
.fc .fc-day-other .fc-daygrid-day-top { opacity: 1; }
.fc .fc-day-other .fc-daygrid-day-number { color: var(--color-text-muted); }

/* Shared calendar frame (includes/calendar_toolbar.html) – project and team calendar look the same. */
.calendar-card { min-width: 0; }
.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.calendar-title { margin: 0 0 0 var(--space-2); font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.calendar-team { width: auto; min-width: 160px; }
.calendar-body { padding: var(--space-4) var(--space-5) var(--space-5); }
@media (max-width: 640px) { .calendar-body, .calendar-toolbar { padding-inline: var(--space-3); } }
.fc .fc-col-header-cell { padding: var(--space-1) 0; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); text-transform: uppercase; }
.fc .fc-col-header-cell-cushion { color: inherit; text-decoration: none; }

/* ==========================================================================
   V4 (PLAN_V4 3.8, 4.A) – motion contracts, new components, login
   ========================================================================== */

/* ------------------------------------------------------------- Page transitions (View Transitions API)
   Cross-document transitions in Chromium: a quick cross-fade of the page, the page title and the active
   nav pill glide. Off with reduced motion. HTMX view tabs use hx-swap="… transition:true" (see ui/README.md).
   The opt-in (@view-transition) lives in view-transitions.css, which early.js switches off offline and with the
   profile setting "Bewegung: reduziert". */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--motion-quick);
  animation-timing-function: var(--ease-out-soft);
}
::view-transition-group(page-title),
::view-transition-group(nav-pill) {
  animation-duration: var(--motion-calm);
  animation-timing-function: var(--ease-out-soft);
}
html[data-motion="reduced"] ::view-transition-group(*),
html[data-motion="reduced"] ::view-transition-old(*),
html[data-motion="reduced"] ::view-transition-new(*) { animation: none !important; }

/* ------------------------------------------------------------- Reveal on scroll (UI.reveal)
   Once per element; never in boards and tables. Children are staggered by 40 ms (--reveal-index). */
[data-reveal] > * { opacity: 0; transform: translateY(8px); }
[data-reveal].is-revealed > * {
  opacity: 1;
  transform: none;
  transition: opacity var(--motion-calm) var(--ease-out-soft), transform var(--motion-calm) var(--ease-out-soft);
  transition-delay: calc(min(var(--reveal-index, 0), 12) * 40ms);
}
html[data-motion="reduced"] [data-reveal] > * { transform: none; }
@media (prefers-reduced-motion: reduce) { html:not([data-motion="full"]) [data-reveal] > * { transform: none; } }
@media print { [data-reveal] > * { opacity: 1 !important; transform: none !important; } }

/* ------------------------------------------------------------- Bulk bar (ui/components/bulk_bar.html) */
.ui-bulk-bar {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  z-index: var(--z-dropdown);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  max-width: calc(100vw - 2 * var(--space-4));
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: ui-bulk-in var(--motion-calm) var(--ease-out-soft);
}
.ui-bulk-bar[hidden] { display: none !important; }
.ui-bulk-bar-summary { margin: 0; padding-right: var(--space-3); border-right: 1px solid var(--color-border); font-weight: var(--weight-medium); white-space: nowrap; }
.ui-bulk-bar-count { display: inline-block; min-width: 2ch; color: var(--color-accent-text); font-weight: var(--weight-semibold); text-align: right; }
.ui-bulk-bar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
@keyframes ui-bulk-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translateX(-50%); }
}
.is-selected { outline: 2px solid var(--color-accent); outline-offset: 1px; }
@media (max-width: 639.98px) {
  .ui-bulk-bar { right: var(--space-4); bottom: var(--space-4); left: var(--space-4); max-width: none; transform: none; animation-name: ui-fade-in; }
}

/* ------------------------------------------------------------- Undo toast (UI.undoToast) */
.toast-undo { position: relative; align-items: center; overflow: hidden; }
.toast-undo .toast-icon { margin-top: 0; }
.toast-undo-btn { flex: none; }
.toast-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--color-accent);
  opacity: 0.7;
  transform-origin: left center;
}

/* ------------------------------------------------------------- Keyboard drag (UI.kbdDrag) */
.card--grabbed {
  outline: 2px dashed var(--color-accent);
  outline-offset: 2px;
  box-shadow: var(--shadow-md);
}

/* ------------------------------------------------------------- Celebrate (UI.celebrate) */
.celebrate-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast);
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-canvas) 55%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none; /* never blocks input: clicks reach the page (and close the overlay) – QA V4 Q-4 */
}
.celebrate-card { pointer-events: auto; }
.celebrate-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.celebrate-card {
  position: relative;
  display: grid;
  gap: var(--space-2);
  justify-items: center;
  min-width: min(320px, 100%);
  max-width: 420px;
  padding: var(--space-8) var(--space-10);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-lg);
  text-align: center;
  cursor: default;
}
.celebrate-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-accent-subtle);
  color: var(--color-accent-text);
}
.celebrate-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.celebrate-title { margin: 0; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); letter-spacing: 0.04em; text-transform: uppercase; }
.celebrate-name { margin: 0; font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: var(--line-lg); letter-spacing: -0.018em; }
.celebrate-card .btn { margin-top: var(--space-3); }
.celebrate-hint { margin: var(--space-2) 0 0; color: var(--color-text-muted); font-size: var(--text-xs); }

/* ------------------------------------------------------------- Page header component ({% page_header %}) */
.page-header-crumbs { margin-bottom: var(--space-2); }

/* ------------------------------------------------------------- Empty state with illustration */
.empty-state-illustration { width: min(240px, 70%); margin-bottom: var(--space-2); color: var(--color-text-muted); }
.empty-state-illustration svg { display: block; width: 100%; height: auto; }

/* ------------------------------------------------------------- Illustration (ui/components/illustration.html) */
.illustration { display: inline-block; color: var(--color-text-muted); line-height: 0; }
.illustration svg { display: block; width: 100%; height: auto; overflow: visible; }

/* ------------------------------------------------------------- Cover image (ui/components/cover_image.html) */
.cover {
  --cover-color: var(--color-bg-muted);
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--cover-color);
  aspect-ratio: var(--cover-ratio, 16 / 9);
}
.cover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Images fade in once loaded (motion.js sets .is-loaded); without JS they are simply shown. */
html.js [data-ui-fade] { transition: opacity var(--motion-calm) var(--ease-out-soft); }
html.js [data-ui-fade]:not(.is-loaded) { opacity: 0; }
.cover-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--cover-color) 0%, var(--color-bg-muted) 100%);
  color: var(--color-text);
}
.cover-fallback svg { width: 30%; max-width: 96px; height: auto; opacity: 0.12; stroke-width: 1.5; }

/* ------------------------------------------------------------- Progress ring (ui/components/progress_ring.html) */
.progress-ring { display: inline-flex; flex: none; align-items: center; gap: var(--space-2); vertical-align: middle; }
.progress-ring svg { display: block; transform: rotate(-90deg); }
.progress-ring-track { stroke: var(--color-bg-muted); }
.progress-ring-value {
  stroke: var(--ring-color, var(--color-accent));
  stroke-linecap: round;
  transition: stroke-dashoffset var(--motion-calm) var(--ease-out-soft);
}
.progress-ring-success { --ring-color: var(--color-success); }
.progress-ring-label { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- Stat (ui/components/stat.html) */
.stat { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.stat-value {
  color: var(--color-text);
  font-size: var(--text-2xl);
  font-weight: 650;
  line-height: var(--line-xl);
  letter-spacing: var(--tracking-display);
  font-variant-numeric: tabular-nums;
}
.stat-lg .stat-value { font-size: var(--text-3xl); line-height: var(--line-2xl); }
.stat-label { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: var(--line-xs); }
.stat-hint { color: var(--color-text-muted); font-size: var(--text-xs); }

/* ------------------------------------------------------------- Segmented control (ui/components/segmented.html) */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-md);
  background: var(--color-bg-muted);
  vertical-align: middle;
}
.segmented-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: 30px;
  min-height: 0;
  margin: 0;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--motion-quick) var(--ease-out-soft), color var(--motion-quick), box-shadow var(--motion-quick);
}
.segmented-item svg { width: var(--icon-sm); height: var(--icon-sm); }
.segmented-item:hover { color: var(--color-text); text-decoration: none; }
.segmented-item[aria-checked="true"],
.segmented-item[aria-pressed="true"],
.segmented-item[aria-current],
.segmented input:checked + .segmented-item {
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:focus-visible + .segmented-item { outline: var(--focus-width) solid var(--color-focus); outline-offset: 1px; }
.segmented-sm .segmented-item { height: 24px; padding: 0 var(--space-2); font-size: var(--text-xs); }

/* ------------------------------------------------------------- Keyboard shortcut (ui/components/kbd.html) */
.kbd-combo { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; }
.kbd-combo-sep { color: var(--color-text-muted); font-size: var(--text-xs); }

/* ------------------------------------------------------------- Motion settings (ui/_motion_settings.html) */
.motion-settings { display: grid; gap: var(--space-2); min-width: 0; margin: 0 0 var(--space-5); padding: 0; border: 0; }
.motion-settings > legend { margin-bottom: var(--space-3); padding: 0; font-size: var(--text-body-reading); font-weight: var(--weight-semibold); }
.motion-settings .field { margin-bottom: var(--space-2); }
.motion-settings .segmented { flex-wrap: wrap; }

/* ------------------------------------------------------------- Login (registration/login.html)
   Split layout from 960 px: form left (max 360 px), photo right. Below: form only, photo as a 160-px band. */
.login-page .auth { padding: 0; background: var(--color-bg); }
.login-page .auth > .auth-brand { display: none; }  /* the split layout draws its own brand */
.login-page .auth-content { max-width: none; }
.login {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.login-photo {
  position: relative;
  height: 160px;
  margin: 0;
  overflow: hidden;
  background: var(--login-photo-color, var(--color-bg-subtle));
}
.login-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.login-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10, 14, 21, 0.55) 0%, rgba(10, 14, 21, 0) 45%);
  pointer-events: none;
}
.login-photo-empty { display: grid; place-items: center; background: var(--color-bg-subtle); }
.login-photo-empty::after { display: none; }
.login-photo-empty .illustration { width: min(200px, 60%); color: var(--color-text-muted); }
.login-caption {
  position: absolute;
  right: var(--space-6);
  bottom: var(--space-5);
  left: var(--space-6);
  z-index: 1;
  margin: 0;
  color: var(--color-on-accent); /* white in both themes, on the dark gradient of the photo */
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.login-main {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: var(--space-8) var(--space-6) var(--space-10);
}
.login-panel { width: 100%; max-width: 360px; margin: 0 auto; }
.login-brand { display: inline-flex; margin-bottom: var(--space-10); }
.login-brand .brand-mark { width: 32px; height: 32px; }
.login-title { margin: 0; font-size: var(--text-xl); line-height: var(--line-lg); letter-spacing: -0.018em; }
.login-subtitle { margin: var(--space-2) 0 var(--space-8); color: var(--color-text-muted); }
.login-form .btn-block { height: var(--control-h-lg); margin-top: var(--space-2); }
.login-note { display: flex; gap: var(--space-2); margin: var(--space-6) 0 0; color: var(--color-text-muted); font-size: var(--text-xs); line-height: var(--line-xs); }
.login-note svg { flex: none; margin-top: 1px; }
.login .copyright { margin-top: var(--space-10); text-align: left; }
@media (min-width: 960px) {
  .login { grid-template-columns: minmax(420px, 5fr) 7fr; }
  .login-photo { order: 2; height: auto; min-height: 100dvh; }
  .login-caption { right: var(--space-10); bottom: var(--space-8); left: var(--space-10); }
  .login-main { justify-content: center; padding: var(--space-12) var(--space-16); }
  .login-photo-empty .illustration { width: min(420px, 60%); }
}

/* Other logged-out pages (password reset, invitation) – a calm centered card */
.auth-panel { width: 100%; max-width: 420px; margin: 0 auto; }

.copyright { margin: var(--space-6) 0 0; text-align: center; }

/* ------------------------------------------------------------- Appearance (ui:appearance) */
.appearance-preview { max-width: 640px; }
.appearance-preview .login-photo { height: 240px; border-radius: var(--radius-lg); }

/* Person link ({% person_link %}, accounts app) – usable on every page */
.person-link { display: inline-flex; align-items: center; gap: var(--space-2); color: inherit; text-decoration: none; }
.person-link:hover { text-decoration: underline; }

/* Exam periods as calendar background events (accounts:availability_feed, both calendars). FullCalendar dims
   background events (opacity .3), which also dims their title below WCAG AA – keep the tint, not the text. */
.fc .fc-bg-event.availability-exam { opacity: 1; background: var(--color-warning-subtle); }
.fc .fc-bg-event.availability-exam .fc-event-title { color: var(--color-warning-text); font-style: normal; opacity: 1; }


/* Checkbox/radio groups from ui/components/form_field.html (fieldset + legend, QA V4 Q-2) */
fieldset.field-group { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field-group > legend.field-label { padding: 0; margin-bottom: var(--space-1); }

/* Already seen in this session (UI.reveal, QA V4 Q-5): shown at once, no entrance animation */
[data-reveal].is-static > *, [data-reveal].is-static { transition: none !important; animation: none !important; }

