/* ==========================================================================
   Handboektool — design system
   Warm, calm and precise. Built with plain CSS custom properties so the
   interface can be themed without a build step.
   ========================================================================== */

@font-face {
  font-family: "Manrope";
  src: url("../fonts/Manrope.101877a7a906.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/Fraunces.5d2835174326.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* -- Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  --bg: #f5f2eb;
  --bg-deep: #eee9df;
  --surface: #fffdf9;
  --surface-2: #faf7f0;
  --surface-3: #f2ede2;
  --surface-glass: rgba(255, 253, 249, 0.86);

  --ink: #1d2a24;
  --ink-2: #34433c;
  --muted: #68766f;
  --muted-2: #8a958e;

  --border: #e5e0d4;
  --border-strong: #d3ccbc;

  --brand: #2e5c4d;
  --brand-strong: #22473b;
  --brand-soft: #e7efe9;
  --brand-softer: #f1f6f3;
  --brand-contrast: #ffffff;

  --accent: #a5844f;
  --accent-soft: #f4ecdc;

  --success: #2b6a4d;
  --success-soft: #e4f1e9;
  --warning: #94641c;
  --warning-soft: #fbf0d9;
  --danger: #a13a31;
  --danger-soft: #fbeae6;
  --info: #34617b;
  --info-soft: #e8f1f6;

  --shadow-xs: 0 1px 2px rgba(29, 42, 36, 0.05);
  --shadow-sm: 0 2px 6px rgba(29, 42, 36, 0.06), 0 1px 2px rgba(29, 42, 36, 0.04);
  --shadow-md: 0 10px 30px rgba(29, 42, 36, 0.09), 0 2px 8px rgba(29, 42, 36, 0.05);
  --shadow-lg: 0 24px 70px rgba(18, 30, 24, 0.22), 0 4px 14px rgba(18, 30, 24, 0.08);

  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;

  --container: 1440px;
  --sidebar-width: 306px;
  --topbar-height: 68px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --speed: 160ms;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #101613;
  --bg-deep: #0c110f;
  --surface: #171f1b;
  --surface-2: #1c2521;
  --surface-3: #222d27;
  --surface-glass: rgba(23, 31, 27, 0.86);

  --ink: #eaf0eb;
  --ink-2: #c8d3cc;
  --muted: #96a49c;
  --muted-2: #79877f;

  --border: #2a352f;
  --border-strong: #3a473f;

  --brand: #8fc0aa;
  --brand-strong: #aad5bf;
  --brand-soft: #1d3028;
  --brand-softer: #17251f;
  --brand-contrast: #10201a;

  --accent: #d6b57e;
  --accent-soft: #2d2720;

  --success: #8fd0ae;
  --success-soft: #1b2e25;
  --warning: #e4bc78;
  --warning-soft: #2e271a;
  --danger: #f0a098;
  --danger-soft: #35211f;
  --info: #9ac6dd;
  --info-soft: #1c2a31;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.34);
  --shadow-md: 0 12px 34px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.55);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 24px);
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "kern", "liga", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
}

img, svg {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--brand-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

::selection {
  background: var(--brand);
  color: var(--brand-contrast);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Hidden helpers ----------------------------------------------------------- */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 200;
  padding: 12px 18px;
  background: var(--brand);
  color: var(--brand-contrast);
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: 700;
  transition: top var(--speed) var(--ease);
}

.skip-link:focus {
  top: 0;
  text-decoration: none;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  vertical-align: -3px;
}

.icon--xs {
  width: 14px;
  height: 14px;
}

.icon--rotate-up {
  transform: rotate(180deg);
}

.icon--theme-light,
.icon--show,
.icon--hide {
  display: none;
}

:root[data-theme="dark"] .icon--theme-dark {
  display: none;
}

:root[data-theme="dark"] .icon--theme-light {
  display: block;
}

[data-toggle-password] .icon--show {
  display: block;
}

[data-toggle-password].is-revealed .icon--show {
  display: none;
}

[data-toggle-password].is-revealed .icon--hide {
  display: block;
}

/* -- Typography ------------------------------------------------------------ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.012em;
  color: var(--ink);
}

h1 { font-size: clamp(2rem, 3vw, 2.75rem); }
h2 { font-size: clamp(1.35rem, 1.8vw, 1.6rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

.eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

.eyebrow--light {
  color: rgba(255, 255, 255, 0.72);
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

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

.small {
  font-size: 0.82rem;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

/* -- Layout ---------------------------------------------------------------- */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 28px 32px 80px;
}

#main:focus {
  outline: none;
}

.has-sidebar .page {
  padding-top: 20px;
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.workspace__main {
  min-width: 0;
}

/* -- Top bar --------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--surface-glass);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: var(--container);
  min-height: var(--topbar-height);
  margin: 0 auto;
  padding: 10px 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
  color: var(--ink);
  flex: 0 0 auto;
}

.brand:hover { text-decoration: none; }

.brand__mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: var(--shadow-xs);
  flex: 0 0 auto;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__title {
  font-family: var(--font-display);
  font-size: 1.16rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.brand__sub {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.mainnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
}

.mainnav__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 0.86rem;
  font-weight: 650;
  text-decoration: none;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.mainnav__link .icon {
  color: var(--muted);
}

.mainnav__link:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.mainnav__link.is-active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.mainnav__link.is-active .icon {
  color: var(--brand);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

.search-trigger:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.search-trigger .icon { color: var(--muted); }

.search-trigger__label {
  padding-right: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  text-decoration: none;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease), color var(--speed) var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--ink);
  text-decoration: none;
}

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

.icon-btn--on-dark {
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.18);
}

.icon-btn--on-dark:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.menu-toggle {
  display: none;
}

/* User menu ---------------------------------------------------------------- */
.usermenu {
  position: relative;
}

.usermenu__summary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 4px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  list-style: none;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.usermenu__summary::-webkit-details-marker { display: none; }

.usermenu__summary:hover,
.usermenu[open] .usermenu__summary {
  background: var(--surface-2);
  border-color: var(--border);
}

.usermenu__name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink-2);
}

.usermenu__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 70;
  width: 286px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop-in 140ms var(--ease);
}

.usermenu__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.usermenu__header strong {
  display: block;
  font-size: 0.92rem;
}

.usermenu__header small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usermenu__links {
  display: grid;
  gap: 2px;
  margin: 14px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.usermenu__links a,
.usermenu__links button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
}

.usermenu__links a:hover,
.usermenu__links button:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.usermenu__links .icon { color: var(--muted); }

.usermenu__logout {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Avatars ------------------------------------------------------------------ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  flex: 0 0 auto;
}

.avatar--sm { width: 30px; height: 30px; font-size: 0.64rem; }
.avatar--xs { width: 22px; height: 22px; font-size: 0.56rem; }

.person {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* -- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease),
    color var(--speed) var(--ease), box-shadow var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-contrast);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, var(--shadow-xs);
}

.btn--primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink-2);
}

.btn--secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn--ghost:hover { background: var(--surface-2); }

.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn--danger:hover { filter: brightness(0.92); }

.btn--sm {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 0.8rem;
  gap: 6px;
}

.btn--lg {
  min-height: 50px;
  padding: 13px 22px;
  font-size: 0.95rem;
  border-radius: var(--radius);
}

.btn--block { width: 100%; }

.link {
  color: var(--brand-strong);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
}

.link:hover { text-decoration: underline; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-strong);
  font-size: inherit;
  font-weight: 650;
  text-decoration: none;
}

.link-button:hover { text-decoration: underline; text-underline-offset: 3px; }

.link-form { display: inline; }

.link-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--brand-strong);
  font-size: 0.82rem;
  font-weight: 650;
}

.link-label:hover { text-decoration: underline; }

/* -- Badges & status ------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  line-height: 1.5;
  white-space: nowrap;
}

.badge .icon { width: 12px; height: 12px; }

.badge--published { background: var(--success-soft); color: var(--success); }
.badge--draft { background: var(--accent-soft); color: var(--warning); }
.badge--review { background: var(--info-soft); color: var(--info); }
.badge--archived { background: var(--surface-3); color: var(--muted); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--neutral { background: var(--surface-3); color: var(--ink-2); }
.badge--outline { border: 1px solid var(--border-strong); background: transparent; color: var(--muted); }
.badge--ghost { background: transparent; color: var(--muted); padding-left: 0; padding-right: 0; }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--muted-2);
}

.status-dot--published { background: var(--success); }
.status-dot--draft { background: var(--accent); }
.status-dot--review { background: var(--info); }
.status-dot--archived { background: var(--muted-2); }

/* -- Alerts, notices, banners --------------------------------------------- */
.alert,
.notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--brand-softer);
  font-size: 0.86rem;
  line-height: 1.55;
}

.alert .icon,
.notice .icon { margin-top: 2px; color: var(--brand); }

.alert p + p { margin-top: 4px; }

.alert--error {
  border-color: var(--danger-soft);
  border-left-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.alert--error .icon { color: var(--danger); }

.notice--warning {
  border-color: var(--warning-soft);
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.notice--warning .icon { color: var(--warning); }

.notice--info {
  border-color: var(--info-soft);
  border-left-color: var(--info);
  background: var(--info-soft);
}

.notice--info .icon { color: var(--info); }

.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 36px 24px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.86rem;
  line-height: 1.55;
}

.banner .icon { color: var(--muted); flex: 0 0 auto; }
.banner > div { flex: 1; }
.banner strong { color: var(--ink); }

.banner--draft {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.banner--draft .icon { color: var(--warning); }

.banner--warning {
  border-color: var(--warning);
  background: var(--warning-soft);
}

.banner--warning .icon { color: var(--warning); }

.banner form { margin: 0; }

/* -- Cards ----------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.card--wide { grid-column: 1 / -1; }

.card--wide .category-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card__head h2 {
  font-size: 1.18rem;
  margin-bottom: 2px;
}

.card__head p { margin: 0; }

.card__footnote {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* -- Empty states ---------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 36px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state .icon {
  width: 26px;
  height: 26px;
  color: var(--muted-2);
}

.empty-state p { margin: 0; font-size: 0.86rem; }
.empty-state--inline { padding: 22px 12px; }
.empty-state--small { padding: 20px 8px; align-items: flex-start; text-align: left; }
.empty-state--success { color: var(--success); }
.empty-state--success .icon { color: var(--success); }

.empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 64px 24px;
  text-align: center;
}

.empty-hero--card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.empty-hero__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
}

.empty-hero__icon .icon { width: 26px; height: 26px; }
.empty-hero__icon--success { background: var(--success-soft); color: var(--success); }

.empty-hero h1,
.empty-hero h2 {
  margin: 0;
}

.empty-hero p { max-width: 54ch; }

.empty-hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

/* -- Page head ------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 26px;
}

.page-head__text h1 { margin: 4px 0 8px; }
.page-head__lead { max-width: 68ch; color: var(--muted); font-size: 0.95rem; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 9px; flex: 0 0 auto; }
.page-head--compact { margin-bottom: 20px; }

.subpage {
  max-width: 1240px;
  margin: 0 auto;
}

/* The body class is only a layout hint; the inner .subpage is the column. */
body.subpage {
  max-width: none;
  margin: 0;
}

.subpage--narrow {
  max-width: 640px;
}

.subpage .page-head { margin-top: 8px; }

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.breadcrumbs a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs a:hover { color: var(--brand-strong); }
.breadcrumbs .icon { width: 13px; height: 13px; }
.breadcrumbs__current {
  max-width: 46ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}

/* -- Dashboard ------------------------------------------------------------- */
.dashboard {
  max-width: var(--container);
  margin: 0 auto;
}

.dashboard .page-head h1 { font-size: clamp(1.8rem, 2.6vw, 2.4rem); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 152px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.stat__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--brand);
}

.stat__body { display: flex; flex-direction: column; gap: 1px; }

.stat__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat__value small {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.stat__label {
  font-size: 0.8rem;
  font-weight: 750;
  color: var(--ink-2);
}

.stat__hint {
  color: var(--muted);
  font-size: 0.74rem;
}

.stat__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  color: var(--brand-strong);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.stat__link .icon { width: 13px; height: 13px; }
.stat__link--muted { color: var(--muted-2); font-weight: 600; }

.stat--brand {
  background: linear-gradient(150deg, #22473b, #2e5c4d);
  border-color: transparent;
  color: #fff;
}

.stat--brand .stat__icon { background: rgba(255, 255, 255, 0.14); color: #fff; }
.stat--brand .stat__label,
.stat--brand .stat__link { color: #fff; }
.stat--brand .stat__hint { color: rgba(255, 255, 255, 0.72); }

.stat--warning {
  border-color: var(--warning);
  background: linear-gradient(160deg, var(--warning-soft), var(--surface) 75%);
}

.stat--warning .stat__icon { background: var(--warning-soft); color: var(--warning); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.item-list { list-style: none; }

.item-list > li + li { border-top: 1px solid var(--border); }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  transition: background var(--speed) var(--ease);
}

.item:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.item__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.item__title { font-size: 0.88rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__meta { color: var(--muted); font-size: 0.74rem; }
.item__chevron { color: var(--muted-2); width: 15px; height: 15px; }

.item__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--muted);
  flex: 0 0 auto;
}

.item__icon .icon { width: 15px; height: 15px; }
.item__icon--danger { background: var(--danger-soft); color: var(--danger); }
.item__icon--warning { background: var(--warning-soft); color: var(--warning); }
.item__icon--star { background: var(--accent-soft); color: var(--accent); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.category-tile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}

.category-tile:hover {
  background: var(--brand-softer);
  border-color: var(--brand-soft);
  text-decoration: none;
}

.category-tile__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--brand);
  flex: 0 0 auto;
}

.category-tile__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.category-tile__body strong { font-size: 0.82rem; line-height: 1.3; }
.category-tile__body small { color: var(--muted); font-size: 0.7rem; }
.category-tile__chevron { width: 14px; height: 14px; color: var(--muted-2); }

.timeline { list-style: none; }

.timeline__item {
  display: flex;
  gap: 13px;
  padding: 11px 0;
}

.timeline__item + .timeline__item { border-top: 1px solid var(--border); }

.timeline__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--brand);
  flex: 0 0 auto;
}

.timeline__icon .icon { width: 14px; height: 14px; }
.timeline__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.timeline__title { font-size: 0.84rem; font-weight: 600; }
.timeline__meta { color: var(--muted); font-size: 0.73rem; }

/* -- Sidebar --------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
  max-height: calc(100vh - var(--topbar-height) - 40px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.sidebar__inner {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--topbar-height) - 42px);
}

.sidebar__head {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar__mobile-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.sidebar__mobile-title {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.searchbox {
  position: relative;
  display: flex;
  align-items: center;
}

.searchbox > .icon {
  position: absolute;
  left: 12px;
  color: var(--muted-2);
  pointer-events: none;
}

.searchbox input {
  width: 100%;
  height: 42px;
  padding: 0 34px 0 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.84rem;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease), background var(--speed) var(--ease);
}

.searchbox input::placeholder { color: var(--muted-2); }

.searchbox input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.searchbox__spinner {
  position: absolute;
  right: 11px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.sidebar__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.sidebar__meta .muted { font-size: 0.72rem; }

.sidebar__filter { margin: 0; }

.select {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
}

.select > .icon { width: 14px; height: 14px; }

.select select {
  height: 34px;
  padding: 0 20px 0 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.76rem;
  font-weight: 650;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 4px center, right 8px center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.select select:focus { outline: none; }

.select--compact { padding: 0 8px; }
.select--compact select { height: 30px; font-size: 0.72rem; }

.tree {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tree__favorites {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.tree__label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.tree__label .icon { width: 12px; height: 12px; color: var(--accent); }

.tree__group { margin-bottom: 2px; }

.tree__summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-xs);
  color: var(--ink-2);
  font-size: 0.79rem;
  font-weight: 750;
  cursor: pointer;
  list-style: none;
  transition: background var(--speed) var(--ease);
}

.tree__summary::-webkit-details-marker { display: none; }

.tree__summary:hover { background: var(--surface-2); }

.tree__caret {
  display: inline-flex;
  color: var(--muted-2);
  transition: transform var(--speed) var(--ease);
}

.tree__caret .icon { width: 13px; height: 13px; }

.tree__group[open] > .tree__summary .tree__caret { transform: rotate(90deg); }

.tree__name { flex: 1; }

.tree__items { padding: 2px 0 4px 8px; }

.nav {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  margin: 1px 0;
  border-radius: var(--radius-xs);
  color: var(--ink-2);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.nav:hover {
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.nav.active {
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: 650;
  box-shadow: var(--shadow-xs);
}

.nav.active:hover { background: var(--brand-strong); }
.nav.active .status-dot { border: 1px solid rgba(255, 255, 255, 0.75); }
.nav.active .nav__star { color: rgba(255, 255, 255, 0.9); }

.nav .status-dot { margin-top: 5px; }

.nav__title { flex: 1; min-width: 0; }

.nav__star {
  width: 11px;
  height: 11px;
  margin-top: 4px;
  color: var(--accent);
}

.nav--favorite {
  font-weight: 600;
}

.sidebar__tools {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.sidebar__tools-links {
  display: grid;
  gap: 2px;
  margin-top: 8px;
}

.sidebar__tools-links a,
.sidebar__tools-links .link-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.sidebar__tools-links a:hover,
.sidebar__tools-links .link-label:hover {
  background: var(--surface-3);
  color: var(--ink-2);
  text-decoration: none;
}

.sidebar__tools-links .icon { width: 14px; height: 14px; }

.sidebar__foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
}

.sidebar__foot .link-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.sidebar__foot .icon { width: 13px; height: 13px; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(12, 20, 16, 0.45);
  backdrop-filter: blur(2px);
}

/* -- Article reader -------------------------------------------------------- */
.article {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.article--empty { padding: 20px; }

.article__topbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.article__topbar .breadcrumbs { margin: 0; }
.article__topbar .breadcrumbs__current { max-width: 32ch; }

.article__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.article__actions form { margin: 0; }

.favorite { color: var(--muted); }
.favorite:hover { color: var(--accent); background: var(--accent-soft); }
.favorite.is-active { color: var(--accent); background: var(--accent-soft); }
.favorite.is-active:hover { color: var(--accent); }

.menu { position: relative; }

.menu > summary {
  list-style: none;
  cursor: pointer;
}

.menu > summary::-webkit-details-marker { display: none; }

.menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: 250px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: pop-in 140ms var(--ease);
}

.menu__panel a,
.menu__panel button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-2);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
}

.menu__panel a:hover,
.menu__panel button:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.menu__panel form { margin: 0; }
.menu__panel hr { margin: 5px 0; }
.menu__panel .icon { color: var(--muted); }
.menu__danger, .menu__danger .icon { color: var(--danger) !important; }
.menu__danger:hover { background: var(--danger-soft) !important; }

.article__header {
  padding: 28px 36px 24px;
}

.article__badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.article__header h1 {
  max-width: 24ch;
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 2.6vw, 2.5rem);
  line-height: 1.12;
  text-wrap: balance;
}

.article__summary {
  max-width: 68ch;
  margin-bottom: 18px;
  color: var(--ink-2);
  font-size: 1.02rem;
  line-height: 1.6;
}

.article__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.article__meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.article__meta-item dt {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.article__meta-item dd {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink-2);
}

.article__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  gap: 34px;
  padding: 0 36px 36px;
}

.article__main { min-width: 0; }

.article__content {
  margin-bottom: 8px;
}

.prose {
  max-width: 74ch;
  color: var(--ink-2);
  font-size: 0.98rem;
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.prose > * + * { margin-top: 1em; }

.prose p { margin: 0; }

.prose h2, .prose h3, .prose h4 {
  margin-top: 1.7em;
  margin-bottom: 0.35em;
}

.prose h2 { font-size: 1.5rem; }
.prose h3 { font-size: 1.2rem; }
.prose h4 { font-size: 1rem; }

.prose strong { color: var(--ink); font-weight: 700; }

.prose ul, .prose ol {
  padding-left: 1.4em;
}

.prose li + li { margin-top: 0.3em; }
.prose li::marker { color: var(--brand); }

.prose blockquote {
  margin: 1.2em 0;
  padding: 10px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-2);
  font-style: italic;
}

.prose hr {
  margin: 2em 0;
  border-top: 1px solid var(--border);
}

.prose code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.86em;
}

.prose--plain {
  white-space: pre-wrap;
  line-height: 1.85;
}

.article__footnote {
  margin-top: 30px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
}

/* Sections ----------------------------------------------------------------- */
.section {
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 3px;
  font-size: 1.18rem;
}

.section__title .icon { color: var(--brand); width: 17px; height: 17px; }

.section__hint { color: var(--muted); font-size: 0.78rem; }

.section__count {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

.progress {
  width: 100%;
  height: 7px;
  margin-bottom: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.progress__bar {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--success));
  transition: width 320ms var(--ease);
}

.checklist { display: flex; flex-direction: column; }

.checklist__item { margin: 0; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--speed) var(--ease);
}

.checklist__item:last-child .check { border-bottom: 0; }

.check:hover { background: var(--surface-2); }

.check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.check__box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  margin-top: 2px;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: transparent;
  flex: 0 0 auto;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease), color var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.check__box .icon { width: 13px; height: 13px; stroke-width: 3; }

.check input:checked + .check__box {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.check input:focus-visible + .check__box {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.check input:checked ~ .check__text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
}

.check__text { font-size: 0.88rem; line-height: 1.55; }

/* Model texts -------------------------------------------------------------- */
.modelblock {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}

.modelblock__head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 16px 10px;
}

.modelblock__head h3 {
  margin: 0;
  font-size: 1rem;
}

.modelblock__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.modelblock__actions form { margin: 0; }

.modeltext {
  margin: 0 16px 14px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.9rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  user-select: text;
}

.modeltext p { margin: 0 0 10px; }
.modeltext p:last-child { margin-bottom: 0; }
.modeltext ul, .modeltext ol { padding-left: 22px; margin: 8px 0; }
.modeltext blockquote {
  margin: 10px 0;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.modeltext hr { margin: 14px 0; }

.copyhint {
  min-height: 1.2em;
  margin: 0;
  padding: 0 16px 14px;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Documents ---------------------------------------------------------------- */
.doc {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--border);
}

.doc:last-of-type { border-bottom: 0; }

.doc__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  flex: 0 0 auto;
}

.doc__icon--pdf { background: var(--danger-soft); color: var(--danger); }
.doc__icon--doc, .doc__icon--docx, .doc__icon--odt, .doc__icon--rtf { background: var(--info-soft); color: var(--info); }
.doc__icon--xls, .doc__icon--xlsx, .doc__icon--ods, .doc__icon--csv { background: var(--success-soft); color: var(--success); }
.doc__icon--png, .doc__icon--jpg, .doc__icon--jpeg, .doc__icon--gif, .doc__icon--webp { background: var(--accent-soft); color: var(--accent); }

.doc__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }

.doc__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 650;
}

.doc__meta { color: var(--muted); font-size: 0.72rem; }

.doc__actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.doc__actions form { margin: 0; }

.upload-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}

.upload-zone.is-dragover {
  border-color: var(--brand);
  background: var(--brand-softer);
}

.upload-zone__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--brand);
  flex: 0 0 auto;
}

.upload-zone > div { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.upload-zone strong { font-size: 0.84rem; }
.upload-zone .muted { font-size: 0.73rem; }
.upload-zone__files { color: var(--brand-strong); font-size: 0.73rem; font-weight: 650; }

/* Article rail ------------------------------------------------------------- */
.article__rail {
  position: sticky;
  top: calc(var(--topbar-height) + 72px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: start;
}

.panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.panel__title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel__title .icon { width: 13px; height: 13px; color: var(--muted); }
.panel__actions { display: grid; gap: 6px; }
.panel--accent { background: var(--brand-softer); border-color: var(--brand-soft); }
.panel--muted { background: transparent; border-style: dashed; }
.panel--muted p { font-size: 0.76rem; line-height: 1.6; }

.detail-list { display: flex; flex-direction: column; gap: 8px; }

.detail-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.78rem;
}

.detail-list dt { color: var(--muted); flex: 0 0 auto; }
.detail-list dd { text-align: right; font-weight: 600; color: var(--ink-2); }

.detail-list--grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.detail-list--grid > div { flex-direction: column; align-items: flex-start; gap: 1px; }
.detail-list--grid dd { text-align: left; }

.toc { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.toc__item a {
  display: block;
  padding: 4px 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: none;
  line-height: 1.4;
}
.toc__item a:hover { color: var(--brand-strong); }
.toc__item--2 { padding-left: 10px; }
.toc__item--3 { padding-left: 20px; }
.toc__item--4 { padding-left: 30px; }

.version-list { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }

.version-list a {
  display: flex;
  gap: 9px;
  padding: 7px;
  border-radius: var(--radius-xs);
  color: var(--ink-2);
  text-decoration: none;
}

.version-list a:hover { background: var(--surface-3); text-decoration: none; }

.version-list__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 22px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
}

.version-list strong { display: block; font-size: 0.75rem; font-weight: 650; }
.version-list small { display: block; color: var(--muted); font-size: 0.68rem; line-height: 1.35; }

/* -- Quick links ----------------------------------------------------------- */
.quick-links {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.quick-link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.quick-link:hover {
  background: var(--surface-2);
  border-color: var(--border);
  text-decoration: none;
}

.quick-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: var(--brand-soft);
  color: var(--brand);
  flex: 0 0 auto;
}

.quick-link__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.quick-link__body strong { font-size: 0.84rem; }
.quick-link__body small { color: var(--muted); font-size: 0.72rem; }
.quick-link > .icon { color: var(--muted-2); width: 14px; height: 14px; }

/* -- Category manager ------------------------------------------------------ */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
  list-style: none;
}

.category-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.category-row__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--brand);
  flex: 0 0 auto;
}

.category-row__body { flex: 1; min-width: 0; }
.category-row__body strong { display: block; font-size: 0.86rem; line-height: 1.35; }
.category-row__body small { color: var(--muted); font-size: 0.72rem; }
.category-row__actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.category-row__actions form { margin: 0; }

.inline-panel {
  margin: 6px 0 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.inline-panel--accent {
  margin-bottom: 0;
  border-color: var(--brand-soft);
  background: var(--brand-softer);
}

.inline-panel h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.inline-panel h3 .icon { color: var(--brand); width: 14px; height: 14px; }

/* -- Forms ----------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field__label {
  font-size: 0.76rem;
  font-weight: 750;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

.field__required { color: var(--danger); margin-left: 2px; }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field input[type="search"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

.field textarea {
  min-height: 120px;
  line-height: 1.65;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.field input::placeholder,
.field textarea::placeholder { color: var(--muted-2); }

.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
  cursor: pointer;
}

.field input[type="file"] {
  padding: 8px 10px;
  font-size: 0.8rem;
}

.field input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 650;
  cursor: pointer;
}

.field__help {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.field__error {
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 600;
}

.field--invalid input,
.field--invalid textarea,
.field--invalid select {
  border-color: var(--danger);
}

.field--invalid input:focus,
.field--invalid textarea:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.field__group {
  position: relative;
  display: flex;
  align-items: center;
}

.field__group input { padding-right: 44px; }

.field__reveal {
  position: absolute;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
}

.field__reveal:hover { background: var(--surface-2); }

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  cursor: pointer;
}

.checkbox input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
}

.checkbox--small { font-size: 0.78rem; color: var(--muted); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}

.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid__full { grid-column: 1 / -1; }

.form-section {
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.form-section:last-of-type { border-bottom: 0; }

.form-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.form-section__title {
  margin: 0 0 8px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-hint {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.55;
}

.form-hint .icon { margin-top: 2px; width: 13px; height: 13px; }

.form-disclaimer {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
}

.form-card { max-width: 620px; }

.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.mini-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.mini-list li { display: flex; align-items: center; gap: 7px; font-size: 0.78rem; }
.mini-list .icon { width: 13px; height: 13px; color: var(--muted); }

/* Editor helpers ----------------------------------------------------------- */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
}

.editor-toolbar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 28px;
  height: 27px;
  padding: 0 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
}

.editor-toolbar__btn:hover { background: var(--surface); color: var(--ink); }
.editor-toolbar__btn .icon { width: 13px; height: 13px; }

.editor-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.7rem;
}

.editor-meta code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-3);
}

.preview {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.88rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.preview p { margin: 0 0 10px; }
.preview p:last-child { margin-bottom: 0; }
.preview ul, .preview ol { padding-left: 22px; margin: 8px 0; }
.preview--editor { margin-top: 12px; background: var(--surface); }
.preview--document { background: var(--surface); padding: 24px 26px; }

.editor-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.editor-split__pane--preview {
  position: sticky;
  top: 0;
}

/* -- Dialogs & modals ------------------------------------------------------ */
dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(12, 20, 16, 0.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal {
  width: min(680px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 48px);
}

.modal--sm { width: min(460px, calc(100vw - 32px)); }
.modal--lg { width: min(840px, calc(100vw - 32px)); }
.modal--xl { width: min(1040px, calc(100vw - 32px)); }
.modal--preview { width: min(900px, calc(100vw - 32px)); }

.modal__panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 200ms var(--ease);
}

.modal__header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal__header > div { flex: 1; min-width: 0; }
.modal__header h2 { margin: 0 0 2px; font-size: 1.32rem; }
.modal__header p { margin: 0; font-size: 0.8rem; }

.modal__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  flex: 0 0 auto;
}

.modal__icon--brand { background: var(--brand-soft); color: var(--brand); }
.modal__icon--warning { background: var(--warning-soft); color: var(--warning); }

.modal__close { margin-left: auto; flex: 0 0 auto; }

.modal__body {
  flex: 1;
  padding: 20px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal__body--preview { padding: 0; background: var(--surface-2); text-align: center; }
.modal__body--preview img { max-height: 66vh; margin: 0 auto; object-fit: contain; }

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.modal__footer-note {
  margin-right: auto;
  color: var(--warning);
  font-size: 0.74rem;
  font-weight: 650;
}

/* Command palette ---------------------------------------------------------- */
.cmdk {
  width: min(740px, calc(100vw - 32px));
  margin-top: 10vh;
  vertical-align: top;
}

.cmdk__panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 160ms var(--ease);
}

.cmdk__field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.cmdk__field > .icon { width: 20px; height: 20px; color: var(--muted); }

.cmdk__field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 1.02rem;
  font-weight: 500;
}

.cmdk__field input:focus { outline: none; }

.cmdk__field input::placeholder { color: var(--muted-2); }

.cmdk__results {
  max-height: min(58vh, 470px);
  overflow-y: auto;
  padding: 8px;
}

.cmdk__group {
  padding: 10px 12px 5px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cmdk__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.cmdk__item:hover,
.cmdk__item.is-active {
  background: var(--brand-soft);
  text-decoration: none;
}

.cmdk__item .icon { color: var(--muted); }

.cmdk__item-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.cmdk__item-title { font-size: 0.88rem; font-weight: 650; }
.cmdk__item-title mark { background: transparent; color: var(--brand-strong); font-weight: 800; }
.cmdk__item-meta { overflow: hidden; color: var(--muted); font-size: 0.73rem; text-overflow: ellipsis; white-space: nowrap; }
.cmdk__item-meta mark { background: var(--accent-soft); color: var(--warning); font-weight: 700; }
.cmdk__item-chevron { color: var(--muted-2); width: 15px; height: 15px; }

.cmdk__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 0.84rem;
}

.cmdk__empty .icon { width: 26px; height: 26px; color: var(--muted-2); }

.cmdk__footer {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
}

.cmdk__footer span { display: inline-flex; align-items: center; gap: 5px; }
.cmdk__footer .kbd { height: 19px; min-width: 20px; font-size: 0.6rem; }

/* -- Toasts ---------------------------------------------------------------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(390px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 0.82rem;
  line-height: 1.5;
  pointer-events: auto;
  animation: toast-in 220ms var(--ease);
}

.toast.is-leaving { animation: toast-out 180ms var(--ease) forwards; }

.toast--success { border-left-color: var(--success); }
.toast--success .toast__icon { color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--error .toast__icon { color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--info { border-left-color: var(--info); }
.toast--info .toast__icon { color: var(--info); }

.toast__icon { margin-top: 1px; }
.toast__text { flex: 1; }
.toast__close {
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted-2);
}
.toast__close:hover { background: var(--surface-2); color: var(--ink); }
.toast__close .icon { width: 14px; height: 14px; }

/* -- Help ------------------------------------------------------------------ */
.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.help-block h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 750;
}

.help-block h3 .icon { color: var(--brand); }
.help-block p { color: var(--muted); font-size: 0.82rem; line-height: 1.65; }
.help-block p + p { margin-top: 7px; }

.help-shortcuts {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.help-shortcuts h3 {
  margin-bottom: 10px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.help-shortcuts dl { display: grid; gap: 7px; }
.help-shortcuts dl > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.help-shortcuts dt { display: flex; gap: 4px; }
.help-shortcuts dd { color: var(--muted); font-size: 0.78rem; }

.help-disclaimer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  line-height: 1.6;
}

/* -- History --------------------------------------------------------------- */
.history-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.history-list { position: sticky; top: calc(var(--topbar-height) + 20px); padding: 16px; }

.version-timeline { list-style: none; position: relative; }

.version-timeline::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 17px;
  width: 1px;
  background: var(--border);
}

.version-timeline li { position: relative; }

.version-timeline a {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
}

.version-timeline a:hover { background: var(--surface-2); text-decoration: none; }

.version-timeline li.is-active a { background: var(--brand-soft); }

.version-timeline__marker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  flex: 0 0 auto;
}

.version-timeline li.is-active .version-timeline__marker {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-contrast);
}

.version-timeline__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.version-timeline__body strong { font-size: 0.76rem; font-weight: 650; }
.version-timeline__body small { color: var(--muted); font-size: 0.68rem; }
.version-timeline__note { font-style: italic; }

.history-detail { padding: 22px; }

.changed-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 0.76rem;
}

.diff {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 0.78rem;
}

.diff__head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.diff__body { max-height: 60vh; overflow: auto; }

.diff__line {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  padding: 3px 10px;
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  line-height: 1.6;
}

.diff__line:last-child { border-bottom: 0; }
.diff__line--add { background: var(--success-soft); }
.diff__line--del { background: var(--danger-soft); }
.diff__line--same { color: var(--muted); }

.diff__sign { color: var(--muted-2); font-weight: 700; user-select: none; }
.diff__line--add .diff__sign { color: var(--success); }
.diff__line--del .diff__sign { color: var(--danger); }
.diff__code { white-space: pre-wrap; overflow-wrap: anywhere; }
.diff__empty { padding: 18px; text-align: center; }

.history-detail__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.history-detail__footer form { margin: 0; }

/* -- Tables & management --------------------------------------------------- */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--surface-2); }
.table__num { text-align: right; font-variant-numeric: tabular-nums; }
.table__nowrap { white-space: nowrap; }
.table__actions { text-align: right; white-space: nowrap; }
.table__actions .link { margin-left: 10px; font-size: 0.76rem; }
.table--log td { font-size: 0.78rem; }

.audit-action { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.audit-action .icon { width: 14px; height: 14px; color: var(--brand); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.pagination__status { color: var(--muted); font-size: 0.76rem; }

.status-bars { display: flex; flex-direction: column; gap: 11px; }

.status-bar {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
}

.status-bar__label { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); }

.status-bar__track {
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.status-bar__fill {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
}

.status-bar__fill--published { background: var(--success); }
.status-bar__fill--draft { background: var(--accent); }
.status-bar__fill--review { background: var(--info); }
.status-bar__fill--archived { background: var(--muted-2); }
.status-bar__value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }

.backup-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.backup-actions .btn { margin-bottom: 2px; }
.rule { margin: 18px 0; }

.import-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.import-form .field { width: 100%; margin-bottom: 0; }

.filter-form { display: flex; align-items: center; gap: 8px; }
.filter-form .select select { height: 40px; }

.form-card { padding: 28px; }

/* -- Workspaces ------------------------------------------------------------ */
.workspace-switcher {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
}

.workspace-switcher__summary {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 278px;
  padding: 5px 9px 5px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}

.workspace-switcher__summary::-webkit-details-marker { display: none; }
.workspace-switcher__summary:hover { border-color: var(--border-strong); background: var(--surface-2); }
.workspace-switcher__summary > .icon { color: var(--muted-2); }

.workspace-switcher__mark,
.workspace-option__mark,
.workspace-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-contrast);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.workspace-switcher__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.workspace-switcher__label { color: var(--muted); font-size: 0.58rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.workspace-switcher__name { overflow: hidden; color: var(--ink-2); font-size: 0.76rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

.workspace-switcher__panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 70;
  width: 310px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop-in 140ms var(--ease);
}

.workspace-switcher__heading {
  padding: 7px 9px 5px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.workspace-switcher__panel form { margin: 0; }

.workspace-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-2);
  text-align: left;
}

.workspace-option:hover,
.workspace-option.is-active { background: var(--brand-softer); }
.workspace-option.is-active { color: var(--brand-strong); }
.workspace-option > .icon { color: var(--brand); width: 14px; height: 14px; }
.workspace-option__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.workspace-option__body strong { overflow: hidden; font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
.workspace-option__body small { color: var(--muted); font-size: 0.68rem; }

.workspace-switcher__links {
  display: grid;
  gap: 1px;
  margin-top: 6px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
}

.workspace-switcher__links a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius-xs);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  text-decoration: none;
}

.workspace-switcher__links a:hover { background: var(--surface-2); color: var(--ink-2); }
.workspace-switcher__links .icon { width: 14px; height: 14px; }

/* Workspace overview */
.workspace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.workspace-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.workspace-card.is-active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.workspace-card__top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 4px; }
.workspace-card__top .badge { margin-left: auto; }
.workspace-card__top .badge + .badge { margin-left: 0; }
.workspace-card h2 { font-size: 1.22rem; margin-top: 2px; }
.workspace-card p { font-size: 0.8rem; line-height: 1.55; flex: 1; }
.workspace-card__meta { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.72rem; }
.workspace-card__meta span { display: inline-flex; align-items: center; gap: 5px; }
.workspace-card__meta .icon { width: 13px; height: 13px; }
.workspace-card__actions { display: flex; gap: 6px; margin-top: 4px; }
.workspace-card__actions form { margin: 0; }
.workspace-list__note { max-width: 74ch; margin: 20px auto 0; text-align: center; font-size: 0.76rem; }
.workspace-mark--large { width: 42px; height: 42px; font-size: 1.05rem; border-radius: 12px; }

.workspace-card--new {
  align-items: flex-start;
  justify-content: center;
  border-style: dashed;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
}

.workspace-card--new:hover {
  border-color: var(--brand);
  background: var(--brand-softer);
  text-decoration: none;
}

.workspace-card--new h2 { margin: 2px 0 0; }
.workspace-card--new p { flex: 0 0 auto; }

.workspace-card__new-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--brand);
}

/* Members */
.members-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.members-aside { display: flex; flex-direction: column; gap: 18px; }
.members-table td { vertical-align: middle; }
.person { display: inline-flex; align-items: center; gap: 9px; }
.person__body { display: flex; flex-direction: column; min-width: 0; }
.person__body strong { display: flex; align-items: center; gap: 6px; font-size: 0.84rem; }
.person__body small { color: var(--muted); font-size: 0.72rem; }
.role-form { display: flex; align-items: center; gap: 5px; margin: 0; }
.role-form select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-size: 0.78rem;
}
.invite-form .field { margin-bottom: 12px; }
.invite-row { padding: 12px 0; border-top: 1px solid var(--border); }
.invite-row:first-of-type { border-top: 0; }
.invite-row__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.invite-row__head strong { font-size: 0.82rem; overflow-wrap: anywhere; }
.invite-row__badges { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.invite-row p { margin: 2px 0 8px; font-size: 0.72rem; }
.copy-field { display: flex; gap: 5px; margin-bottom: 6px; }
.copy-field input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.7rem;
}
.copy-field .btn { flex: 0 0 auto; }
.badge--owner { background: var(--brand-soft); color: var(--brand-strong); }
.badge--admin { background: var(--info-soft); color: var(--info); }
.badge--editor { background: var(--accent-soft); color: var(--accent); }
.badge--member { background: var(--surface-3); color: var(--ink-2); }
.badge--viewer { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.item--static { cursor: default; }
.item--static:hover { background: transparent; }

/* Invitation and danger zones */
.invitation-card { max-width: 640px; margin: 4vh auto 0; padding: 32px; }
.invitation-card__top { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; }
.invitation-card__top .badge { margin-left: auto; }
.invitation-card h1 { margin: 6px 0 10px; font-size: clamp(1.8rem, 3vw, 2.4rem); }
.invitation-card__lead { max-width: 54ch; color: var(--muted); font-size: 0.92rem; line-height: 1.65; }
.invitation-card__details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.invitation-card__details span { display: block; color: var(--muted); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.invitation-card__details strong { display: block; margin-top: 2px; font-size: 0.82rem; overflow-wrap: anywhere; }
.stacked-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.workspace-danger { margin-top: 18px; }
.danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.danger-row:first-of-type { border-top: 0; }
.danger-row p { margin-top: 2px; max-width: 52ch; font-size: 0.75rem; }
.danger-row form { margin: 0; flex: 0 0 auto; }

/* -- Auth ------------------------------------------------------------------ */
.auth {
  background: var(--bg);
}

.auth__layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
}

.auth__brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px clamp(28px, 5vw, 72px);
  background:
    radial-gradient(circle at 85% 10%, rgba(165, 132, 79, 0.28), transparent 42%),
    radial-gradient(circle at 10% 85%, rgba(255, 255, 255, 0.08), transparent 46%),
    linear-gradient(155deg, #24473b 0%, #1a352c 55%, #142a23 100%);
  color: #fff;
  overflow: hidden;
}

.auth__brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.14) 0.6px, transparent 0.6px);
  background-size: 18px 18px;
  opacity: 0.3;
  pointer-events: none;
}

.auth__brand-top,
.auth__brand-body,
.auth__brand-foot { position: relative; z-index: 1; }

.auth__brand-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.auth__logo-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.auth__logo-link:hover { text-decoration: none; }

.auth__mark {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.auth__wordmark {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: #fff;
}

.auth__brand-body { max-width: 540px; margin: 48px 0; }

.auth__brand-body h1 {
  margin: 10px 0 18px;
  color: #fff;
  font-size: clamp(2.2rem, 3.6vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.auth__brand-body h1 em {
  color: #e6cf9f;
  font-style: italic;
}

.auth__lead {
  max-width: 44ch;
  color: rgba(255, 255, 255, 0.78);
  font-size: 1rem;
  line-height: 1.7;
}

.auth__features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 30px;
  padding: 0;
  list-style: none;
}

.auth__features li {
  display: flex;
  align-items: center;
  gap: 11px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.86rem;
}

.auth__features .icon {
  width: 17px;
  height: 17px;
  color: #e6cf9f;
}

.auth__brand-foot {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.auth__panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 40px clamp(22px, 5vw, 72px);
  background: var(--bg);
}

.auth__panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 460px;
  width: 100%;
  margin: 0 auto;
}

.auth__card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.auth__intro { margin-bottom: 22px; }
.auth__intro h2 { margin: 5px 0 6px; font-size: 1.7rem; }
.auth__intro p { font-size: 0.86rem; }
.auth__intro--center { text-align: center; }
.auth__intro--center p { margin-left: auto; margin-right: auto; }

.auth__form { display: flex; flex-direction: column; }
.auth__form .field { margin-bottom: 15px; }
.auth__form .btn--lg { margin-top: 6px; }

.auth__form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.auth__help {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.auth__help .muted { margin-bottom: 10px; margin-top: 10px; font-size: 0.78rem; line-height: 1.6; }
.auth__help--center { text-align: center; }
.auth__help--center .btn { margin-bottom: 10px; }

.auth__foot {
  max-width: 460px;
  width: 100%;
  margin: 0 auto;
  color: var(--muted-2);
  font-size: 0.7rem;
  line-height: 1.6;
  text-align: center;
}

.auth__success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}

.auth__success-icon .icon { width: 26px; height: 26px; }

/* -- Error pages ----------------------------------------------------------- */
.error-page {
  max-width: 560px;
  margin: 8vh auto 0;
  text-align: center;
}

.error-page__mark {
  font-family: var(--font-display);
  font-size: clamp(5rem, 12vw, 8rem);
  font-weight: 600;
  line-height: 0.9;
  color: var(--brand-soft);
  letter-spacing: -0.04em;
  margin-bottom: -8px;
}

.error-page h1 { margin: 8px 0 10px; }
.error-page .muted { max-width: 46ch; margin: 0 auto 22px; }
.error-page__actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }

/* -- Footer ---------------------------------------------------------------- */
.sitefooter {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.sitefooter__inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 26px;
  max-width: var(--container);
  margin: 0 auto;
  padding: 22px 32px;
}

.sitefooter__brand { display: flex; align-items: center; gap: 11px; font-size: 0.8rem; }
.sitefooter__brand small { color: var(--muted); font-size: 0.7rem; }

.sitefooter__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--brand);
  color: var(--brand-contrast);
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 700;
}

.sitefooter__note {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.6;
}

.sitefooter__links { display: flex; gap: 14px; font-size: 0.74rem; }
.sitefooter__links a,
.sitefooter__links .link-button { color: var(--muted); font-weight: 600; }

/* -- Animations ------------------------------------------------------------ */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(14px); }
}

/* -- Responsive ------------------------------------------------------------ */
@media (max-width: 1240px) {
  .workspace { grid-template-columns: 272px minmax(0, 1fr); }
  .workspace-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .members-layout { grid-template-columns: minmax(0, 1fr) 310px; }
  .workspace-switcher__text { display: none; }
  .workspace-switcher__summary { padding: 4px; }
  .article__grid { grid-template-columns: minmax(0, 1fr) 250px; gap: 26px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-layout { grid-template-columns: 260px minmax(0, 1fr); }
}

@media (max-width: 1080px) {
  .card--wide .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .members-layout { grid-template-columns: minmax(0, 1fr); }
  .members-aside { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article__grid { grid-template-columns: minmax(0, 1fr); }
  .article__rail { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article__rail .panel--muted { grid-column: 1 / -1; }
  .brand__text { display: none; }
  .usermenu__name { display: none; }
}

@media (max-width: 900px) {
  .topbar__inner { padding: 9px 18px; gap: 10px; }
  .page { padding: 20px 18px 60px; }
  .mainnav { display: none; }
  .menu-toggle { display: inline-flex; }
  [data-sidebar-toggle][aria-expanded="true"] { display: none; }

  .workspace { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    width: min(340px, 88vw);
    max-height: none;
    border-radius: 0;
    border: 0;
    transform: translateX(-102%);
    transition: transform 220ms var(--ease);
    box-shadow: var(--shadow-lg);
  }

  .sidebar__inner { max-height: 100vh; height: 100%; }
  .sidebar__mobile-head { display: flex; }

  .sidebar.is-open { transform: translateX(0); }
  .scrim[hidden] { display: none; }

  .article__topbar { top: 68px; padding: 10px 16px; }
  .article__header { padding: 22px 20px 18px; }
  .article__grid { padding: 0 20px 24px; gap: 24px; }
  .banner { margin-left: 20px; margin-right: 20px; }
  .article__rail { grid-template-columns: minmax(0, 1fr); }
  .article__meta { gap: 12px 22px; }
  .article__actions .btn span { display: none; }
  .article__actions .btn { padding: 9px 11px; }

  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .card--wide { grid-column: auto; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .stats { gap: 10px; }

  .auth__layout { grid-template-columns: minmax(0, 1fr); }
  .auth__brand { min-height: 300px; padding: 26px; }
  .auth__brand-body { margin: 26px 0 10px; }
  .auth__brand-body h1 { font-size: 2rem; }
  .auth__features { display: none; }
  .auth__mark { width: 46px; height: 46px; }
  .auth__wordmark { font-size: 1.18rem; }
  .auth__panel { padding: 26px 20px 40px; }
  .auth__card { padding: 24px; }

  .history-layout { grid-template-columns: minmax(0, 1fr); }
  .history-list { position: static; }

  .sitefooter__inner { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 20px 18px; }
  .sitefooter__links { justify-content: flex-start; }

  .help-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-split { grid-template-columns: minmax(0, 1fr); }
  .editor-split__pane--preview { position: static; }

  .search-trigger__label { display: none; }
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
  .search-trigger .kbd { display: none; }

  .status-bar { grid-template-columns: 120px minmax(0, 1fr) 28px; }
}

@media (max-width: 640px) {
  :root { --topbar-height: 60px; }

  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .members-aside { grid-template-columns: minmax(0, 1fr); }
  .invitation-card { padding: 22px; margin-top: 2vh; }
  .invitation-card__details { grid-template-columns: minmax(0, 1fr); }
  .danger-row { flex-direction: column; align-items: flex-start; }
  .danger-row form, .danger-row .btn { width: 100%; }
  .role-form { flex-wrap: wrap; }
  .role-form select { flex: 1; }
  .workspace-switcher__panel { position: fixed; top: 66px; left: 12px; right: 12px; width: auto; }


  .brand__mark { width: 38px; height: 38px; }
  .topbar__inner { min-height: var(--topbar-height); }
  .usermenu__summary { padding: 3px; }
  .usermenu__summary > .icon { display: none; }

  .page { padding: 16px 12px 48px; }
  .article { border-radius: var(--radius); }
  .article__topbar { top: var(--topbar-height); padding: 8px 12px; flex-wrap: wrap; }
  .article__topbar .breadcrumbs__current { max-width: 20ch; }
  .article__header { padding: 18px 16px 14px; }
  .article__header h1 { font-size: 1.7rem; }
  .article__grid { padding: 0 16px 20px; }
  .article__meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .banner { margin-left: 16px; margin-right: 16px; flex-wrap: wrap; }

  .card__head { flex-wrap: wrap; }
  .card__head .link { white-space: nowrap; }
  .item .badge { display: none; }
  .item__title { white-space: normal; }
  .dashboard .page-head h1 { font-size: 1.6rem; }
  .eyebrow__workspace { display: none; }
  .section__head { flex-direction: column; gap: 8px; }
  .modelblock__head { flex-direction: column; }
  .doc { flex-wrap: wrap; }
  .doc__actions { width: 100%; justify-content: flex-end; }

  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat { min-height: 0; }
  .category-grid,
  .card--wide .category-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .status-bar { grid-template-columns: 110px minmax(0, 1fr) 28px; font-size: 0.72rem; }
  .detail-list--grid { grid-template-columns: minmax(0, 1fr); }

  .modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .modal__panel { max-height: calc(100vh - 16px); border-radius: var(--radius-lg); }
  .modal__header { padding: 16px; }
  .modal__body { padding: 16px; }
  .modal__footer { padding: 12px 16px; flex-wrap: wrap; }
  .modal__footer .btn { flex: 1; }
  .cmdk { margin-top: 4vh; width: calc(100vw - 16px); }

  .toasts { right: 12px; bottom: 12px; left: 12px; width: auto; }
  .sitefooter__inner { padding: 18px 12px; }
  .history-detail { padding: 16px; }
  .history-detail__footer { flex-direction: column; align-items: stretch; }
  .history-detail__footer .btn { width: 100%; }
  .upload-zone { flex-direction: column; align-items: flex-start; }
  .upload-zone .btn { width: 100%; }
  .auth__card { padding: 20px; border-radius: var(--radius-lg); }
  .auth__form-row { flex-direction: column; align-items: flex-start; }
  .auth__panel-top { padding: 0 4px; }
}

@media (max-width: 420px) {
  .mainnav { display: none; }
  .icon-btn { width: 36px; height: 36px; }
  .search-trigger { width: 36px; height: 36px; }
  .brand__mark { width: 34px; height: 34px; }
}

/* -- Motion preferences ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* -- Print (article page in the app) --------------------------------------- */
@media print {
  .topbar,
  .sidebar,
  .article__topbar,
  .article__rail,
  .sitefooter,
  .toasts,
  .scrim,
  .article__actions,
  .upload-zone {
    display: none !important;
  }

  body { background: #fff; color: #000; }
  .page { padding: 0; max-width: none; }
  .workspace { display: block; }
  .article { border: 0; box-shadow: none; }
  .article__grid { display: block; padding: 0; }
  .article__header { padding: 0 0 16px; }
  .banner { display: none; }
  a { color: inherit; text-decoration: none; }
  .section { break-inside: avoid; }
}
