/* ============================================================================
   downstage.css — Minimal Nordic Design System
   by Andrea Pollastri
   ----------------------------------------------------------------------------
   A minimal, clean, professional CSS framework. Zero dependencies.
   Built for sites and web apps where content comes before ornament.
   ============================================================================ */

/* ============================================================================
   1. FONT — Space Grotesk (self-hosted)
   ============================================================================ */

@font-face {
  font-family: "Space Grotesk";
  src:
    url("./fonts/SpaceGrotesk-VF.woff2") format("woff2-variations"),
    url("./fonts/SpaceGrotesk-VF.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* Static fallback for browsers that don't support variable fonts */
@font-face {
  font-family: "Space Grotesk Static";
  src: url("./fonts/SpaceGrotesk-Light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk Static";
  src: url("./fonts/SpaceGrotesk-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk Static";
  src: url("./fonts/SpaceGrotesk-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk Static";
  src: url("./fonts/SpaceGrotesk-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* ============================================================================
   2. DESIGN TOKENS
   ----------------------------------------------------------------------------
   Everything is a variable. Change the theme by changing the variables.
   ============================================================================ */

:root {
  /* --- Neutral scale (light) --- */
  --neutral-50: #fffdf7;
  --neutral-100: #e8e6e1;
  --neutral-200: #d3d1cd;
  --neutral-300: #c0beba;
  --neutral-400: #afada9;
  --neutral-500: #9f9d9a;
  --neutral-600: #918f8c;
  --neutral-700: #5a5856;
  --neutral-800: #3a3836;
  --neutral-900: #2a2826;

  /* --- Brand --- */
  --brand-primary: #5a6b5d; /* deep sage */
  --brand-primary-hover: #48574b;
  --brand-secondary: #8a7a68; /* taupe / hazelnut */
  --brand-secondary-hover: #6f6253;

  /* --- Semantic --- */
  --color-success: #6b8266;
  --color-success-soft: #e8ede4;
  --color-danger: #a85a4f;
  --color-danger-soft: #f0e0db;
  --color-warning: #c08a3e;
  --color-warning-soft: #f4e8d2;
  --color-info: #5f7a8a;
  --color-info-soft: #e0e8ed;

  /* --- Semantic roles (these are the ones you actually use in components) --- */
  --bg: var(--neutral-50);
  --bg-elevated: #ffffff; /* card/modal above bg */
  --bg-sunken: var(--neutral-100); /* recessed section */
  --bg-hover: var(--neutral-100);

  --border: var(--neutral-200);
  --border-strong: var(--neutral-300);
  --border-focus: var(--neutral-900);

  --text: var(--neutral-900);
  --text-soft: var(--neutral-700);
  --text-muted: var(--neutral-500);
  --text-subtle: var(--neutral-400);
  --text-invert: var(--neutral-50);

  --link: var(--neutral-900);
  --link-hover: var(--brand-primary);

  /* --- Typography --- */
  --font-sans:
    "Space Grotesk", "Space Grotesk Static", -apple-system, BlinkMacSystemFont,
    "Segoe UI", system-ui, sans-serif;
  --font-mono:
    "Space Grotesk", "Space Grotesk Static", ui-monospace, "SF Mono", Menlo,
    Consolas, monospace;

  --fs-xs: 0.75rem; /* 12px */
  --fs-sm: 0.875rem; /* 14px */
  --fs-base: 1rem; /* 16px */
  --fs-md: 1.125rem; /* 18px */
  --fs-lg: 1.375rem; /* 22px */
  --fs-xl: 1.75rem; /* 28px */
  --fs-2xl: 2.25rem; /* 36px */
  --fs-3xl: 3rem; /* 48px */

  --lh-tight: 1.2;
  --lh-snug: 1.4;
  --lh-base: 1.6;
  --lh-loose: 1.8;

  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-bold: 700;

  /* --- Spacing (rem scale, base 4px) --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* --- Radius --- */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-full: 9999px;

  /* --- Shadows (used sparingly — nordic style) --- */
  --shadow-sm: 0 1px 2px rgba(42, 40, 38, 0.04);
  --shadow: 0 2px 8px rgba(42, 40, 38, 0.06);
  --shadow-lg: 0 8px 32px rgba(42, 40, 38, 0.08);

  /* --- Layout --- */
  --container-narrow: 640px;
  --container: 960px;
  --container-wide: 1200px;

  /* --- Motion --- */
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --duration-fast: 120ms;
  --duration: 200ms;
  --duration-slow: 320ms;

  /* --- Z-index scale --- */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 800;
  --z-modal: 900;
  --z-toast: 1000;
}

/* ============================================================================
   3. DARK THEME
   ----------------------------------------------------------------------------
   Activated with [data-theme="dark"] on <html> or via prefers-color-scheme
   when [data-theme="auto"] (or no attribute).
   ============================================================================ */

[data-theme="dark"] {
  --neutral-50: #1a1917;
  --neutral-100: #232220;
  --neutral-200: #2d2c29;
  --neutral-300: #3a3834;
  --neutral-400: #5a5854;
  --neutral-500: #7a7874;
  --neutral-600: #9a9893;
  --neutral-700: #b8b6b1;
  --neutral-800: #d8d6d1;
  --neutral-900: #f0ede6;

  --brand-primary: #8aa088;
  --brand-primary-hover: #a3b8a1;
  --brand-secondary: #b59c84;
  --brand-secondary-hover: #c9b39d;

  --color-success: #8aa088;
  --color-success-soft: #232c25;
  --color-danger: #c47a70;
  --color-danger-soft: #2e1f1d;
  --color-warning: #d4a460;
  --color-warning-soft: #2c2418;
  --color-info: #8298a8;
  --color-info-soft: #1d262c;

  --bg: var(--neutral-50);
  --bg-elevated: var(--neutral-100);
  --bg-sunken: #131210;
  --bg-hover: var(--neutral-200);

  --border: var(--neutral-300);
  --border-strong: var(--neutral-400);
  --border-focus: var(--neutral-800);

  --text: var(--neutral-900);
  --text-soft: var(--neutral-700);
  --text-muted: var(--neutral-500);
  --text-subtle: var(--neutral-400);
  --text-invert: var(--neutral-50);

  --link: var(--neutral-900);
  --link-hover: var(--brand-primary);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Auto: follows the operating system preference */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --neutral-50: #1a1917;
    --neutral-100: #232220;
    --neutral-200: #2d2c29;
    --neutral-300: #3a3834;
    --neutral-400: #5a5854;
    --neutral-500: #7a7874;
    --neutral-600: #9a9893;
    --neutral-700: #b8b6b1;
    --neutral-800: #d8d6d1;
    --neutral-900: #f0ede6;

    --brand-primary: #8aa088;
    --brand-primary-hover: #a3b8a1;
    --brand-secondary: #b59c84;
    --brand-secondary-hover: #c9b39d;

    --color-success: #8aa088;
    --color-success-soft: #232c25;
    --color-danger: #c47a70;
    --color-danger-soft: #2e1f1d;
    --color-warning: #d4a460;
    --color-warning-soft: #2c2418;
    --color-info: #8298a8;
    --color-info-soft: #1d262c;

    --bg: var(--neutral-50);
    --bg-elevated: var(--neutral-100);
    --bg-sunken: #131210;
    --bg-hover: var(--neutral-200);

    --border: var(--neutral-300);
    --border-strong: var(--neutral-400);
    --border-focus: var(--neutral-800);

    --text: var(--neutral-900);
    --text-soft: var(--neutral-700);
    --text-muted: var(--neutral-500);
    --text-subtle: var(--neutral-400);
    --text-invert: var(--neutral-50);
  }
}

/* ============================================================================
   4. RESET & BASE
   ============================================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "ss01", "ss02";
  transition:
    background-color var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

/* Text selection */
::selection {
  background: var(--neutral-900);
  color: var(--neutral-50);
}

/* Base element reset */
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}
ul,
ol {
  margin: 0;
  padding: 0;
}
img,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================================
   5. TYPOGRAPHY
   ============================================================================ */

h1,
.h1 {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
}
h2,
.h2 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
}
h3,
.h3 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: -0.01em;
}
h4,
.h4 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
}
h5,
.h5 {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
}
h6,
.h6 {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
}

p {
  line-height: var(--lh-base);
}

small,
.text-sm {
  font-size: var(--fs-sm);
}
.text-xs {
  font-size: var(--fs-xs);
}
.text-muted {
  color: var(--text-muted);
}
.text-soft {
  color: var(--text-soft);
}
.text-subtle {
  color: var(--text-subtle);
  font-size: var(--fs-sm);
}

.text-mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  transition:
    color var(--duration-fast) var(--ease),
    text-decoration-color var(--duration-fast) var(--ease);
}
a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-sunken);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

pre {
  font-family: var(--font-mono);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: var(--lh-snug);
}
pre code {
  background: none;
  border: 0;
  padding: 0;
}

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

blockquote {
  border-left: 2px solid var(--border-strong);
  padding-left: var(--space-4);
  color: var(--text-soft);
  font-style: italic;
}

/* “H7” — no native element; use paragraph + class (e.g. rich-text editor) */
.ds-h7 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================================
   HTML editor — toolbar + contenteditable (see downstage.js [data-html-editor])
   ============================================================================ */

.html-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
  position: relative;
}

.html-editor-mode-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}

.html-editor-mode-bar .switch {
  flex-shrink: 0;
}

.html-editor-pane {
  position: relative;
}

.html-editor-raw {
  display: block;
  width: 100%;
  min-height: 12rem;
  max-height: 24rem;
  margin: 0;
  border: 0;
  border-radius: 0;
  resize: vertical;
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}

.html-editor-raw:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--text-muted);
}

.html-editor.is-raw-mode .html-editor-content {
  display: none;
}

.html-editor.is-raw-mode .html-editor-raw {
  display: block;
}

.html-editor:not(.is-raw-mode) .html-editor-raw {
  display: none !important;
}

.html-editor-toolbar--disabled {
  pointer-events: none;
  opacity: 0.48;
}

.html-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}

.html-editor-toolbar-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}

.html-editor-toolbar-group + .html-editor-toolbar-group::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1.25rem;
  margin-inline: var(--space-2);
  background: var(--border-strong);
  align-self: center;
}

.html-editor-btn {
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  padding: var(--space-2) var(--space-2);
  min-width: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  line-height: 1.2;
  text-align: center;
  transition:
    background-color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease);
}

.html-editor-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.html-editor-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.html-editor-btn-u {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.html-editor-content {
  min-height: 12rem;
  max-height: 24rem;
  overflow-y: auto;
  padding: var(--space-4);
  outline: none;
  line-height: var(--lh-base);
}

.html-editor-content:focus {
  box-shadow: inset 0 0 0 1px var(--text-muted);
}

.html-editor-content > * + * {
  margin-top: var(--space-3);
}

.html-editor-content blockquote {
  margin: 0;
}

/* Link dialog (nested in .html-editor) */
.html-editor-link-modal {
  z-index: calc(var(--z-modal) + 1);
}

.modal.html-editor-link-panel {
  max-width: 460px;
  position: relative;
  padding: var(--space-5) var(--space-6) var(--space-6);
}

.modal.html-editor-link-panel .modal-title.html-editor-link-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-right: var(--space-10);
  margin-bottom: var(--space-2);
}

.html-editor-link-lede {
  margin: 0 0 var(--space-5) 0;
  line-height: var(--lh-snug);
  max-width: 42em;
}

.modal.html-editor-link-panel .modal-body.html-editor-link-fields {
  margin-bottom: 0;
}

.modal.html-editor-link-panel .check {
  margin-top: var(--space-1);
  align-items: flex-start;
  gap: var(--space-3);
}

.modal.html-editor-link-panel .modal-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.html-editor-link-close {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 1;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  border-radius: var(--radius);
}

/* ============================================================================
   6. LAYOUT — Container & Grid
   ============================================================================ */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-6);
}
.container-narrow {
  max-width: var(--container-narrow);
}
.container-wide {
  max-width: var(--container-wide);
}

/* Stack — utility for vertical stacking with consistent gap */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

/* Cluster — horizontal flex that wraps */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* Grid — simple system based on CSS Grid */
.grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(12, 1fr);
}
.grid-2 {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(2, 1fr);
}
.grid-3 {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(3, 1fr);
}
.grid-4 {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(4, 1fr);
}

/* Auto-fit: adapts automatically */
.grid-auto {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* Span helpers for .grid (12 col) */
.col-1 {
  grid-column: span 1;
}
.col-2 {
  grid-column: span 2;
}
.col-3 {
  grid-column: span 3;
}
.col-4 {
  grid-column: span 4;
}
.col-5 {
  grid-column: span 5;
}
.col-6 {
  grid-column: span 6;
}
.col-7 {
  grid-column: span 7;
}
.col-8 {
  grid-column: span 8;
}
.col-9 {
  grid-column: span 9;
}
.col-10 {
  grid-column: span 10;
}
.col-11 {
  grid-column: span 11;
}
.col-12 {
  grid-column: span 12;
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  [class*="col-"] {
    grid-column: 1 / -1;
  }
}

/* Sections */
.section {
  padding-block: var(--space-16);
}
.section-sm {
  padding-block: var(--space-8);
}
.section-lg {
  padding-block: var(--space-24);
}

/* ============================================================================
   7. BUTTONS
   ----------------------------------------------------------------------------
   Philosophy: buttons with thin border. The "primary" state is simply
   an inversion (dark background, light text), as in the reference site.
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-regular);
  line-height: 1;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none !important; /* protects from a:hover */
  user-select: none;
  white-space: nowrap;
  transition:
    background-color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
}
a.btn {
  color: var(--text);
} /* override for the a {} selector */
a.btn:hover {
  color: var(--text);
  text-decoration: none;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary = inversion (like Whilst).
   The selectors below are intentionally "armored" (including !important on color)
   because the global `a:hover {}` selector has specificity (0,1,1) and
   would override `.btn-primary` (0,1,0), turning the text sage green
   on a black background = terrible contrast. */
.btn-primary,
a.btn-primary,
a.btn-primary:hover,
a.btn-primary:focus,
a.btn-primary:active,
a.btn-primary:visited {
  text-decoration: none !important;
}
.btn-primary,
a.btn-primary {
  background: var(--text);
  color: var(--text-invert) !important;
  border-color: var(--text);
}
.btn-primary:hover,
a.btn-primary:hover {
  background: var(--neutral-700);
  color: var(--text-invert) !important;
  border-color: var(--neutral-700);
}

/* Secondary = border, no fill */
.btn-secondary {
  background: transparent;
  border-color: var(--border-strong);
}

/* Ghost = text only */
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: transparent;
}

/* Danger = red border + text (see "Delete my account") */
.btn-danger {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
}

.btn-danger-solid,
a.btn-danger-solid,
a.btn-danger-solid:hover {
  text-decoration: none !important;
}
.btn-danger-solid,
a.btn-danger-solid {
  background: var(--color-danger);
  color: #fff !important;
  border-color: var(--color-danger);
}
.btn-danger-solid:hover,
a.btn-danger-solid:hover {
  background: #8a463c;
  color: #fff !important;
  border-color: #8a463c;
}

/* Success */
.btn-success,
a.btn-success,
a.btn-success:hover {
  text-decoration: none !important;
}
.btn-success,
a.btn-success {
  background: var(--color-success);
  color: #fff !important;
  border-color: var(--color-success);
}
.btn-success:hover,
a.btn-success:hover {
  background: #556b51;
  color: #fff !important;
  border-color: #556b51;
}

/* Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-xs);
}
.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--fs-base);
}
.btn-block {
  display: flex;
  width: 100%;
}

/* Button groups (tab-style like in Whilst) */
.btn-group {
  display: inline-flex;
  gap: var(--space-3);
}

/* ============================================================================
   8. FORM ELEMENTS
   ============================================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: var(--fw-regular);
}

.input,
.textarea,
.select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition:
    border-color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
  outline: none;
}
.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--border-strong);
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--text);
  background: var(--bg-elevated);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-subtle);
}

.textarea {
  resize: vertical;
  min-height: 6rem;
  line-height: var(--lh-base);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%239f9d9a' stroke-width='1.5' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
}

.help {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.error {
  font-size: var(--fs-xs);
  color: var(--color-danger);
}

/* Error state */
.field.has-error .input,
.field.has-error .textarea,
.field.has-error .select {
  border-color: var(--color-danger);
}

.field.has-error .input-affix {
  border-color: var(--color-danger);
}

/* Input with prefix / suffix (URL, currency, units) */
.input-affix {
  display: flex;
  width: 100%;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
  transition:
    border-color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}
.input-affix:focus-within {
  border-color: var(--text);
}
.input-affix .input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.input-affix .input:focus {
  background: transparent;
}
.input-affix__prefix,
.input-affix__suffix {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  background: color-mix(in srgb, var(--border) 40%, transparent);
  white-space: nowrap;
  user-select: none;
}
.input-affix__prefix {
  border-right: 1px solid var(--border);
}
.input-affix__suffix {
  border-left: 1px solid var(--border);
}

/* Minimal underline — no box, only bottom border; matches page surface (--bg) */
.input.input-minimal,
.textarea.textarea-minimal,
.select.select-minimal {
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: var(--space-3) 0 var(--space-2);
  box-shadow: none;
}

.input.input-minimal:hover,
.textarea.textarea-minimal:hover,
.select.select-minimal:hover {
  border-bottom-color: var(--border-strong);
  background: var(--bg);
}

.input.input-minimal:focus,
.textarea.textarea-minimal:focus,
.select.select-minimal:focus {
  border-bottom-color: var(--border-focus);
  background: var(--bg);
  box-shadow: none;
}

.select.select-minimal {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%239f9d9a' stroke-width='1.5' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: var(--space-8);
}

.textarea.textarea-minimal {
  min-height: 4.5rem;
}

.field.has-error .input.input-minimal,
.field.has-error .textarea.textarea-minimal,
.field.has-error .select.select-minimal {
  border-color: transparent;
  border-bottom-color: var(--color-danger);
}

/* Password field + show/hide toggle (downstage.js wraps input[type=password]) */
.input-password-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.input-password-wrap .input {
  padding-right: var(--space-10);
}
.input-password-wrap-minimal .input.input-minimal {
  padding-right: var(--space-10);
}
.input-password-toggle {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1);
  margin: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  line-height: 0;
}
.input-password-toggle:hover {
  color: var(--text);
}
.input-password-toggle:focus {
  outline: none;
}
.input-password-toggle:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Copy button beside readonly / disabled fields (downstage.js — .input-copy-wrap) */
.input-copy-wrap {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: var(--space-2);
  width: 100%;
}
.input-copy-wrap:has(> input) {
  align-items: center;
}
.input-copy-wrap > .input,
.input-copy-wrap > .textarea {
  flex: 1;
  min-width: 0;
}
.input-copy-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.2;
  transition:
    color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}
.input-copy-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.input-copy-btn:focus {
  outline: none;
}
.input-copy-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
.input-copy-wrap-minimal .input-copy-btn {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: var(--space-2) 0 var(--space-1);
}
.input-copy-wrap-minimal .input-copy-btn:hover {
  border-bottom-color: var(--border-strong);
  background: transparent;
}

/* Drag-and-drop file upload (pairs with [data-upload-drop] in downstage.js) */
.upload-drop {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.upload-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6);
  text-align: center;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  transition:
    border-color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
  cursor: pointer;
}

.upload-drop-zone:hover {
  border-color: var(--border-strong);
}

.upload-drop-zone.is-dragover {
  border-color: var(--border-focus);
  border-style: solid;
  background: var(--bg-hover);
}

.upload-drop-zone:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.upload-drop-text {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  line-height: var(--lh-snug);
}

.upload-drop-browse {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.upload-drop-browse:hover {
  color: var(--link-hover);
}

.upload-drop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.upload-drop-list li {
  padding: var(--space-1) 0;
  word-break: break-word;
}

/* Checkbox & Radio */
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.check input[type="checkbox"],
.check input[type="radio"] {
  appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  flex-shrink: 0;
}
.check input[type="radio"] {
  border-radius: var(--radius-full);
}

.check input[type="checkbox"]::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  background: var(--text-invert);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease);
}
.check input[type="radio"]::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--text-invert);
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease);
}

.check input[type="checkbox"]:checked,
.check input[type="radio"]:checked {
  background: var(--text);
  border-color: var(--text);
}
.check input[type="checkbox"]:checked::before,
.check input[type="radio"]:checked::before {
  transform: scale(1);
}

/* Switch (toggle) */
.switch {
  position: relative;
  display: inline-block;
  width: 2.5rem;
  height: 1.4rem;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  transition: background var(--duration) var(--ease);
}
.switch-slider::before {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  left: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  border-radius: 50%;
  transition: transform var(--duration) var(--ease);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-slider {
  background: var(--text);
}
.switch input:checked + .switch-slider::before {
  transform: translate(1.1rem, -50%);
}

/* ============================================================================
   9. CARD
   ============================================================================ */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card-sm {
  padding: var(--space-4);
}
.card-lg {
  padding: var(--space-8);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ============================================================================
   10. ALERT
   ============================================================================ */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  font-size: var(--fs-sm);
}
.alert-success {
  background: var(--color-success-soft);
  border-color: var(--color-success);
  color: var(--color-success);
}
.alert-danger {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
  color: var(--color-danger);
}
.alert-warning {
  background: var(--color-warning-soft);
  border-color: var(--color-warning);
  color: var(--color-warning);
}
.alert-info {
  background: var(--color-info-soft);
  border-color: var(--color-info);
  color: var(--color-info);
}

/* ============================================================================
   11. BADGE
   ============================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem var(--space-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  background: var(--bg-sunken);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.badge-success {
  background: var(--color-success-soft);
  color: var(--color-success);
  border-color: var(--color-success);
}
.badge-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.badge-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border-color: var(--color-warning);
}
.badge-info {
  background: var(--color-info-soft);
  color: var(--color-info);
  border-color: var(--color-info);
}

/* ============================================================================
   12. TABLE
   ============================================================================ */

/* Wrap .table to allow horizontal scroll when the grid is wider than the viewport */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.table-wrap .table {
  width: max-content;
  min-width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th,
.table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.table th {
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tbody tr {
  transition: background var(--duration-fast) var(--ease);
}
.table tbody tr:hover {
  background: var(--bg-hover);
}

/* Variants — combine with .table (e.g. class="table table-minimal") */
.table.table-minimal {
  background: transparent;
}

.table.table-minimal th,
.table.table-minimal td {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-2) var(--space-3) 0;
}

.table.table-minimal th:last-child,
.table.table-minimal td:last-child {
  padding-right: 0;
}

.table.table-minimal thead th {
  border-bottom-color: var(--border-strong);
}

.table.table-minimal tbody tr {
  transition: border-color var(--duration-fast) var(--ease);
}

.table.table-minimal tbody tr:hover {
  background: transparent;
}

.table.table-minimal tbody tr:hover td {
  border-bottom-color: var(--border-strong);
}

.table.table-compact th,
.table.table-compact td {
  padding: var(--space-2) var(--space-3);
}

.table.table-compact.table-minimal th,
.table.table-compact.table-minimal td {
  padding: var(--space-2) var(--space-2) var(--space-2) 0;
}

.table.table-striped tbody tr:nth-child(even) {
  background: var(--bg-sunken);
}

.table.table-striped tbody tr:hover {
  background: var(--bg-hover);
}

.table.table-striped.table-minimal tbody tr:nth-child(even) {
  background: transparent;
}

.table.table-striped.table-minimal tbody tr:hover {
  background: transparent;
}

/* ============================================================================
   13. MODAL / DIALOG
   ============================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 40, 38, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: var(--z-modal);
  animation: fadeIn var(--duration) var(--ease);
}
[data-theme="dark"] .modal-overlay,
[data-theme="auto"] .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--duration) var(--ease);
}
.modal-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  margin-bottom: var(--space-3);
}
.modal-body {
  color: var(--text-soft);
  margin-bottom: var(--space-6);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Slide-over panel (e.g. quick edit from screen edge) */
.slideover-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
  background: rgba(42, 40, 38, 0.4);
  animation: fadeIn var(--duration) var(--ease);
}
[data-theme="dark"] .slideover-overlay,
[data-theme="auto"] .slideover-overlay {
  background: rgba(0, 0, 0, 0.55);
}
.slideover-panel {
  display: flex;
  flex-direction: column;
  width: min(100vw - var(--space-4), 28rem);
  max-height: 100%;
  margin: var(--space-3) var(--space-3) var(--space-3) 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideoverIn var(--duration) var(--ease);
  overflow: hidden;
}
.slideover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.slideover-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
}
.slideover-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-5);
  color: var(--text-soft);
}
.slideover-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}
@keyframes slideoverIn {
  from {
    opacity: 0.85;
    transform: translateX(1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================================================
   14a. NAVBAR (top navigation with mobile hamburger)
   ----------------------------------------------------------------------------
   Reference markup:

   <nav class="navbar">
     <div class="navbar-inner">
       <a class="navbar-brand" href="/">brand</a>
       <button class="navbar-toggle" aria-label="Menu" aria-expanded="false">
         <span></span><span></span><span></span>
       </button>
       <div class="navbar-menu">
         <a href="#" class="navbar-link active">Home</a>
         <a href="#" class="navbar-link">About</a>
         <a href="#" class="navbar-link">Docs</a>
         <div class="navbar-actions">
           <a href="#" class="btn btn-sm">Sign in</a>
           <a href="#" class="btn btn-sm btn-primary">Sign up</a>
         </div>
       </div>
     </div>
   </nav>

   The toggle is activated via JS by adding .is-open to .navbar.
   ============================================================================ */

.navbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  max-width: var(--container-wide);
  margin-inline: auto;
  padding: var(--space-4) var(--space-6);
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.navbar-brand:hover {
  color: var(--text);
}

.navbar-menu {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex: 1;
  justify-content: flex-end;
}

/* Wrapper for mobile scroll — display:contents keeps desktop navbar layout unchanged */
.navbar-menu-scroll {
  display: contents;
}

.navbar-link {
  position: relative;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-2) 0;
  transition: color var(--duration-fast) var(--ease);
}
.navbar-link:hover {
  color: var(--text);
}
.navbar-link.active {
  color: var(--text);
}
.navbar-link.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--text);
}

/* Components mega-dropdown (uses <details> — no extra JS) */
.navbar-dropdown {
  position: relative;
}

.navbar-dropdown summary {
  list-style: none;
}

.navbar-dropdown summary::-webkit-details-marker {
  display: none;
}

.navbar-dropdown-summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: var(--space-2) 0;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease);
  user-select: none;
}

.navbar-dropdown-summary:hover {
  color: var(--text);
}

.navbar-dropdown-chevron {
  flex-shrink: 0;
  opacity: 0.75;
  transition: transform var(--duration-fast) var(--ease);
}

.navbar-dropdown[open] .navbar-dropdown-chevron {
  transform: rotate(180deg);
}

.navbar-dropdown-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  margin: 0;
}

.navbar-dropdown-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: var(--space-3) 0 0;
  border-top: 1px solid var(--border);
}

.navbar-dropdown-group:first-child {
  padding-top: 0;
  border-top: none;
}

.navbar-dropdown-group-title {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0 var(--space-4) var(--space-1);
}

.navbar-dropdown-link {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  transition:
    background-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease);
}

.navbar-dropdown-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

@media (min-width: 769px) {
  .navbar-dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 14rem;
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: calc(var(--z-sticky) + 5);
  }

  .navbar-dropdown-panel.navbar-dropdown-panel--grouped {
    min-width: 15.5rem;
    max-height: min(70vh, 28rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .navbar-dropdown-panel.navbar-dropdown-panel--grouped .navbar-dropdown-group {
    padding-top: var(--space-3);
  }

  .navbar-dropdown-panel.navbar-dropdown-panel--grouped .navbar-dropdown-group:first-child {
    padding-top: 0;
  }

  .navbar-dropdown-panel.navbar-dropdown-panel--grouped .navbar-dropdown-group-title {
    padding-bottom: var(--space-2);
  }
}

.navbar-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: var(--space-4);
  padding-left: var(--space-6);
  border-left: 1px solid var(--border);
}

/* Hamburger toggle — visible only on mobile */
.navbar-toggle {
  display: none;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  flex-direction: column;
  gap: 5px;
  transition: border-color var(--duration-fast) var(--ease);
}
.navbar-toggle:hover {
  border-color: var(--text);
}

.navbar-toggle span {
  display: block;
  width: 1.05rem;
  height: 1.5px;
  background: var(--text);
  border-radius: 1px;
  transition:
    transform var(--duration) var(--ease),
    opacity var(--duration-fast) var(--ease);
  transform-origin: center;
}

/* Open state: hamburger → X */
.navbar.is-open .navbar-toggle span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.navbar.is-open .navbar-toggle span:nth-child(2) {
  opacity: 0;
}
.navbar.is-open .navbar-toggle span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* --- Mobile breakpoint --- */
@media (max-width: 768px) {
  .navbar-toggle {
    display: flex;
  }

  .navbar-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0;
    /* Open animation — scroll lives in .navbar-menu-scroll (iOS needs inner scroller) */
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition:
      max-height var(--duration-slow) var(--ease),
      opacity var(--duration) var(--ease),
      visibility 0s linear var(--duration-slow);
  }

  .navbar.is-open .navbar-menu {
    display: flex;
    flex-direction: column;
    max-height: min(88vh, calc(100dvh - 3rem));
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    transition:
      max-height var(--duration-slow) var(--ease),
      opacity var(--duration) var(--ease),
      visibility 0s linear 0s;
  }

  .navbar-menu-scroll {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding: var(--space-2) var(--space-6) var(--space-6);
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  }

  .navbar-link {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-base);
  }
  .navbar-link.active::after {
    display: none;
  }
  .navbar-link.active {
    color: var(--text);
    font-weight: var(--fw-medium);
  }

  .navbar-dropdown {
    width: 100%;
    border-bottom: 1px solid var(--border);
  }

  .navbar-dropdown-summary {
    width: 100%;
    padding: var(--space-4) 0;
    font-size: var(--fs-base);
    justify-content: space-between;
  }

  .navbar-dropdown-panel {
    padding: 0 0 var(--space-2) var(--space-3);
    border-left: 1px solid var(--border);
    margin: 0 0 var(--space-2) var(--space-2);
  }

  .navbar-dropdown-panel.navbar-dropdown-panel--grouped {
    max-height: none;
    overflow: visible;
  }

  .navbar-dropdown-group {
    padding-top: var(--space-2);
    border-top: none;
  }

  .navbar-dropdown-group:first-child {
    padding-top: 0;
  }

  .navbar-dropdown-group + .navbar-dropdown-group {
    margin-top: var(--space-1);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
  }

  .navbar-dropdown-group-title {
    padding: 0 0 var(--space-2);
    font-size: var(--fs-sm);
    letter-spacing: 0.06em;
  }

  .navbar-dropdown-link {
    padding: var(--space-3) 0;
    font-size: var(--fs-base);
    border-radius: 0;
  }

  .navbar-dropdown-link:hover {
    background: transparent;
  }

  .navbar-actions {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    margin-top: var(--space-4);
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }
  .navbar-actions .btn {
    justify-content: center;
    width: 100%;
  }
}

/* ============================================================================
   14b. NAVIGATION (vertical sidebar, Whilst settings style)
   ============================================================================ */

.nav-vertical {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.nav-vertical a {
  display: block;
  padding: var(--space-2) var(--space-4);
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: var(--fs-sm);
  transition: all var(--duration-fast) var(--ease);
}
.nav-vertical a:hover {
  color: var(--text);
}
.nav-vertical a.active {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

/* ============================================================================
   15. UTILITIES (le minime indispensabili)
   ============================================================================ */

/* Display */
.hidden {
  display: none !important;
}
.flex {
  display: flex;
}
.inline-flex {
  display: inline-flex;
}
.block {
  display: block;
}

/* Flex */
.items-center {
  align-items: center;
}
.items-start {
  align-items: flex-start;
}
.items-end {
  align-items: flex-end;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.justify-end {
  justify-content: flex-end;
}
.flex-1 {
  flex: 1;
}
.flex-col {
  flex-direction: column;
}

/* Gap */
.gap-1 {
  gap: var(--space-1);
}
.gap-2 {
  gap: var(--space-2);
}
.gap-3 {
  gap: var(--space-3);
}
.gap-4 {
  gap: var(--space-4);
}
.gap-6 {
  gap: var(--space-6);
}
.gap-8 {
  gap: var(--space-8);
}

/* Text align */
.text-left {
  text-align: left;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}

/* Margin top utilities (most commonly used) */
.mt-0 {
  margin-top: 0;
}
.mt-2 {
  margin-top: var(--space-2);
}
.mt-4 {
  margin-top: var(--space-4);
}
.mt-6 {
  margin-top: var(--space-6);
}
.mt-8 {
  margin-top: var(--space-8);
}
.mt-10 {
  margin-top: var(--space-10);
}
.mt-12 {
  margin-top: var(--space-12);
}
.mt-16 {
  margin-top: var(--space-16);
}

/* Margin bottom utilities */
.mb-0 {
  margin-bottom: 0;
}
.mb-2 {
  margin-bottom: var(--space-2);
}
.mb-4 {
  margin-bottom: var(--space-4);
}
.mb-6 {
  margin-bottom: var(--space-6);
}
.mb-8 {
  margin-bottom: var(--space-8);
}

/* Width */
.w-full {
  width: 100%;
}
.max-w-narrow {
  max-width: var(--container-narrow);
  margin-inline: auto;
}

/* Border */
.border-t {
  border-top: 1px solid var(--border);
}
.border-b {
  border-bottom: 1px solid var(--border);
}

/* ============================================================================
   16. ACCESSIBILITY
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

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

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

/* ============================================================================
   17. ICON SYSTEM
   ----------------------------------------------------------------------------
   Icons are inline SVGs or loaded via <use href="downstage-icons.svg#name"/>.
   All use `currentColor` so they inherit the text color.
   Add .rotate to .icon for a loading spinner (pairs with #refresh, etc.).
   ============================================================================ */

.icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.18em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-sm {
  width: 0.9em;
  height: 0.9em;
}
.icon-lg {
  width: 1.5em;
  height: 1.5em;
}
.icon-xl {
  width: 2em;
  height: 2em;
}
.icon-2xl {
  width: 3rem;
  height: 3rem;
}

/* Continuous rotation — use with circular / radial glyphs (e.g. #refresh) as loading indicators */
@keyframes ds-icon-spin {
  to {
    transform: rotate(360deg);
  }
}

.icon.rotate {
  animation: ds-icon-spin 0.75s linear infinite;
  transform-origin: center;
}

@media (prefers-reduced-motion: reduce) {
  .icon.rotate {
    animation-duration: 1.5s;
  }
}

/* ============================================================================
   18. TABS
   ============================================================================ */

.tabs {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.tabs-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  padding: 0;
  margin: 0;
  list-style: none;
}

.tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition:
    color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease);
}
.tab:hover {
  color: var(--text);
}
.tab[aria-selected="true"],
.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-panel {
  display: none;
  animation: tabFadeIn var(--duration) var(--ease);
}
.tab-panel.active,
.tab-panel[aria-hidden="false"] {
  display: block;
}

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

/* ============================================================================
   18b. WIZARD (stepper)
   ============================================================================ */

.wizard {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  background: var(--surface);
}

.wizard-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.wizard-nav-item {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    background var(--duration-fast) var(--ease);
}
.wizard-nav-item:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-muted);
}
.wizard-nav-item.is-active {
  color: var(--text);
  border-color: var(--brand-primary);
  background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
}
.wizard-nav-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wizard-nav-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  background: var(--border);
  color: var(--text-muted);
}
.wizard-nav-item.is-active .wizard-nav-num {
  background: var(--brand-primary);
  color: var(--surface);
}

.wizard-panels {
  min-height: 0;
}

.wizard-panel {
  display: none;
  animation: tabFadeIn var(--duration) var(--ease);
}
.wizard-panel.is-active {
  display: block;
}

.wizard-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.wizard-meta {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.wizard--vertical {
  display: grid;
  grid-template-columns: minmax(10rem, 12rem) 1fr;
  grid-template-areas:
    "nav panels"
    "nav footer";
  gap: var(--space-6);
  align-items: start;
}
@media (max-width: 48rem) {
  .wizard--vertical {
    grid-template-columns: 1fr;
    grid-template-areas:
      "nav"
      "panels"
      "footer";
  }
}
.wizard--vertical .wizard-nav {
  grid-area: nav;
  flex-direction: column;
}
.wizard--vertical .wizard-panels {
  grid-area: panels;
}
.wizard--vertical .wizard-footer {
  grid-area: footer;
}

.wizard-nav--dots .wizard-nav-item {
  position: relative;
  padding: var(--space-2);
  border-radius: 999px;
  border: 0;
  background: transparent;
}
.wizard-nav--dots .wizard-nav-item .wizard-nav-num {
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  font-size: 0;
  background: var(--border);
}
.wizard-nav--dots .wizard-nav-item.is-active .wizard-nav-num {
  background: var(--brand-primary);
  transform: scale(1.25);
}
.wizard-nav--dots .wizard-nav-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
   19. ACCORDION
   ============================================================================ */

.accordion {
  border-top: 1px solid var(--border);
}
.accordion-item {
  border-bottom: 1px solid var(--border);
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-5) 0;
  background: transparent;
  border: 0;
  text-align: left;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease);
}
.accordion-header:hover {
  color: var(--brand-primary);
}

.accordion-header .accordion-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  transition: transform var(--duration) var(--ease);
}
.accordion-item.is-open .accordion-icon {
  transform: rotate(45deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-slow) var(--ease);
}
.accordion-item.is-open .accordion-content {
  max-height: 1000px; /* high limit, animation on real height */
}
.accordion-body {
  padding: 0 0 var(--space-5);
  color: var(--text-soft);
  line-height: var(--lh-base);
}

/* ============================================================================
   20. BREADCRUMB
   ============================================================================ */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  margin: 0;
  list-style: none;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}
.breadcrumb a:hover {
  color: var(--text);
}
.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.breadcrumb li + li::before {
  content: "/";
  color: var(--text-subtle);
  font-family: var(--font-mono);
}
.breadcrumb li:last-child {
  color: var(--text);
}

/* ============================================================================
   21. IMAGE FRAME
   ----------------------------------------------------------------------------
   Wrapper for images with thin border, optional caption and fixed ratio.
   ============================================================================ */

.image-frame {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 0;
}
.image-frame img,
.image-frame video {
  display: block;
  width: 100%;
  height: auto;
}
.image-frame.is-square > .image-media,
.image-frame.is-4-5 > .image-media,
.image-frame.is-16-9 > .image-media,
.image-frame.is-3-2 > .image-media {
  position: relative;
  width: 100%;
  overflow: hidden;
}
.image-frame.is-square > .image-media {
  aspect-ratio: 1 / 1;
}
.image-frame.is-4-5 > .image-media {
  aspect-ratio: 4 / 5;
}
.image-frame.is-16-9 > .image-media {
  aspect-ratio: 16 / 9;
}
.image-frame.is-3-2 > .image-media {
  aspect-ratio: 3 / 2;
}
.image-frame .image-media img,
.image-frame .image-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-caption {
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
}

/* ============================================================================
   22. GALLERY
   ============================================================================ */

.gallery {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.gallery-2 {
  grid-template-columns: repeat(2, 1fr);
}
.gallery-3 {
  grid-template-columns: repeat(3, 1fr);
}
.gallery-4 {
  grid-template-columns: repeat(4, 1fr);
}

.gallery-item {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  cursor: zoom-in;
  transition:
    border-color var(--duration-fast) var(--ease),
    transform var(--duration) var(--ease);
}
.gallery-item:hover {
  border-color: var(--text);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease);
}
.gallery-item:hover img {
  transform: scale(1.04);
}

@media (max-width: 640px) {
  .gallery-3,
  .gallery-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================================
   23. LIGHTBOX
   ============================================================================ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(20, 18, 16, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--duration) var(--ease),
    visibility 0s linear var(--duration);
}
.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  transition:
    opacity var(--duration) var(--ease),
    visibility 0s linear 0s;
}

.lightbox-img {
  max-width: min(90vw, 1200px);
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.lightbox-btn {
  position: absolute;
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 253, 247, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 253, 247, 0.2);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease);
  backdrop-filter: blur(8px);
}
.lightbox-btn:hover {
  background: rgba(255, 253, 247, 0.15);
  border-color: rgba(255, 253, 247, 0.4);
}
.lightbox-close {
  top: var(--space-6);
  right: var(--space-6);
}
.lightbox-prev {
  left: var(--space-6);
  top: 50%;
  transform: translateY(-50%);
}
.lightbox-next {
  right: var(--space-6);
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-counter {
  position: absolute;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 253, 247, 0.7);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
}

/* ============================================================================
   24. FILE CARD
   ============================================================================ */

.file-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none !important;
  color: var(--text);
  transition:
    border-color var(--duration-fast) var(--ease),
    background var(--duration-fast) var(--ease);
}
.file-card:hover {
  border-color: var(--text);
  background: var(--bg-hover);
}
.file-card-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.file-card-body {
  flex: 1;
  min-width: 0;
}
.file-card-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* ============================================================================
   25. FOOTER
   ============================================================================ */

.footer {
  border-top: 1px solid var(--border);
  padding-block: var(--space-12);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.footer-inner {
  max-width: var(--container-wide);
  margin-inline: auto;
  padding-inline: var(--space-6);
}
.footer-grid {
  display: grid;
  gap: var(--space-8);
  grid-template-columns: 2fr repeat(3, 1fr);
}
@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 480px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

.footer-brand {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-2);
}
.footer-tagline {
  color: var(--text-muted);
  max-width: 32ch;
  line-height: var(--lh-base);
}

.footer-title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  margin-bottom: var(--space-4);
  font-weight: var(--fw-medium);
}
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}
.footer-links a:hover {
  color: var(--text);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}
.footer-social {
  display: inline-flex;
  gap: var(--space-3);
}
.footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease);
}
.footer-social a:hover {
  color: var(--text);
  border-color: var(--text);
}

/* ============================================================================
   26. KBD (keyboard keys)
   ============================================================================ */

kbd {
  display: inline-block;
  padding: 0.1em 0.4em;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

/* ============================================================================
   27. SLIDER / CAROUSEL
   ----------------------------------------------------------------------------
   <div class="slider" data-slider>
     <div class="slider-track">
       <div class="slider-slide">...</div>
     </div>
     <button class="slider-prev">...</button>
     <button class="slider-next">...</button>
     <div class="slider-dots"></div>
   </div>
   ============================================================================ */

.slider {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
}

.slider-track {
  display: flex;
  transition: transform var(--duration-slow) var(--ease);
  will-change: transform;
}

.slider-slide {
  min-width: 100%;
  position: relative;
}
.slider-slide img,
.slider-slide video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slider-hero .slider-slide {
  min-height: 420px;
}
@media (max-width: 768px) {
  .slider-hero .slider-slide {
    min-height: 300px;
  }
}

.slider-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(20, 18, 16, 0.7) 0%,
    transparent 60%
  );
  display: flex;
  align-items: flex-end;
  padding: var(--space-8);
}
.slider-hero-content {
  color: #fffdf7;
  max-width: 540px;
}
.slider-hero-content h2 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-3);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.slider-hero-content p {
  font-size: var(--fs-sm);
  opacity: 0.85;
  line-height: var(--lh-base);
}

.slider-prev,
.slider-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 253, 247, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 253, 247, 0.25);
  border-radius: var(--radius-full);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition:
    background var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease);
  z-index: 2;
}
.slider-prev:hover,
.slider-next:hover {
  background: rgba(255, 253, 247, 0.22);
  border-color: rgba(255, 253, 247, 0.45);
}
.slider-prev {
  left: var(--space-4);
}
.slider-next {
  right: var(--space-4);
}

.slider-dots {
  position: absolute;
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-2);
  z-index: 2;
}
.slider-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 253, 247, 0.5);
  background: rgba(255, 253, 247, 0.2);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  padding: 0;
}
.slider-dot.active,
.slider-dot:hover {
  background: #fffdf7;
  border-color: #fffdf7;
}

.slider-bordered {
  border: 1px solid var(--border);
}
.slider-bordered .slider-prev,
.slider-bordered .slider-next {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-strong);
  backdrop-filter: none;
}
.slider-bordered .slider-prev:hover,
.slider-bordered .slider-next:hover {
  border-color: var(--text);
}
.slider-bordered .slider-dots {
  bottom: var(--space-3);
}
.slider-bordered .slider-dot {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}
.slider-bordered .slider-dot.active,
.slider-bordered .slider-dot:hover {
  background: var(--text);
  border-color: var(--text);
}

/* ============================================================================
   28. VIDEO PLAYER
   ============================================================================ */

.video-player {
  position: relative;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.video-player video {
  display: block;
  width: 100%;
}
.video-player-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: rgba(20, 18, 16, 0.85);
  backdrop-filter: blur(8px);
  color: #fffdf7;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
}
.video-player-controls .icon {
  width: 1.1em;
  height: 1.1em;
}

.video-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: 1px solid rgba(255, 253, 247, 0.2);
  border-radius: var(--radius);
  color: #fffdf7;
  cursor: pointer;
  padding: 0;
  transition: all var(--duration-fast) var(--ease);
}
.video-btn:hover {
  background: rgba(255, 253, 247, 0.1);
  border-color: rgba(255, 253, 247, 0.4);
}

.video-progress {
  flex: 1;
  height: 4px;
  background: rgba(255, 253, 247, 0.15);
  border-radius: var(--radius-full);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.video-progress-bar {
  height: 100%;
  background: #fffdf7;
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 100ms linear;
}

.video-time {
  white-space: nowrap;
  min-width: 6ch;
}

.video-overlay-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 18, 16, 0.3);
  cursor: pointer;
  z-index: 1;
  transition: opacity var(--duration) var(--ease);
}
.video-overlay-play .icon {
  width: 3rem;
  height: 3rem;
  color: #fffdf7;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}
.video-player.is-playing .video-overlay-play {
  opacity: 0;
  pointer-events: none;
}

/* Fullscreen: fill viewport, keep controls at bottom */
.video-player:fullscreen,
.video-player:-webkit-full-screen {
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: none;
  background: #000;
}

.video-player:fullscreen video,
.video-player:-webkit-full-screen video {
  flex: 1;
  min-height: 0;
  object-fit: contain;
}

.video-player:fullscreen .video-player-controls,
.video-player:-webkit-full-screen .video-player-controls {
  flex-shrink: 0;
}

/* ============================================================================
   29. AUDIO PLAYER
   ============================================================================ */

.audio-player {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--text);
  color: var(--text-invert);
  border: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition:
    background var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
}
.audio-btn:hover {
  background: var(--neutral-700);
}
.audio-btn:active {
  transform: scale(0.95);
}
.audio-btn .icon {
  width: 1.1em;
  height: 1.1em;
}

.audio-info {
  flex: 1;
  min-width: 0;
}
.audio-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-artist {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.audio-progress {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}
.audio-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-sunken);
  border-radius: var(--radius-full);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.audio-progress-fill {
  height: 100%;
  background: var(--text);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 100ms linear;
}
.audio-times {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.audio-volume {
  width: 60px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.audio-volume-bar {
  flex: 1;
  height: 3px;
  background: var(--bg-sunken);
  border-radius: var(--radius-full);
  position: relative;
  overflow: hidden;
}
.audio-volume-fill {
  height: 100%;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  width: 70%;
}

@media (max-width: 640px) {
  .audio-volume {
    display: none;
  }
  .audio-player {
    flex-wrap: wrap;
  }
}

/* ============================================================================
   30. DOCS LAYOUT (technical documentation)
   ============================================================================ */

.docs-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-8);
  align-items: start;
}
@media (max-width: 768px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
}

.docs-sidebar {
  position: sticky;
  top: calc(var(--space-16) + 56px);
}
.docs-sidebar-title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  margin-bottom: var(--space-3);
  font-weight: var(--fw-medium);
}
.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 1px solid var(--border);
}
.docs-nav a {
  display: block;
  padding: var(--space-2) var(--space-4);
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease);
}
.docs-nav a:hover {
  color: var(--text);
}
.docs-nav a.active {
  color: var(--text);
  border-left-color: var(--text);
  font-weight: var(--fw-medium);
}

.docs-content {
  min-width: 0;
}
.docs-chapter {
  padding-bottom: var(--space-10);
  margin-bottom: var(--space-10);
  border-bottom: 1px solid var(--border);
}
.docs-chapter:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}
.docs-chapter h3 {
  margin-bottom: var(--space-4);
}
.docs-chapter p {
  color: var(--text-soft);
  line-height: var(--lh-loose);
  margin-bottom: var(--space-4);
}
.docs-chapter p:last-child {
  margin-bottom: 0;
}
.docs-chapter pre {
  margin-bottom: var(--space-4);
}
.docs-chapter ul,
.docs-chapter ol {
  color: var(--text-soft);
  line-height: var(--lh-loose);
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
  list-style: disc;
}
.docs-chapter ol {
  list-style: decimal;
}

/* ============================================================================
   31. DASHBOARD
   ============================================================================ */

.dashboard-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.stat-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-medium);
  letter-spacing: -0.02em;
  line-height: 1;
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}
.stat-change {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.stat-change.is-up {
  color: var(--color-success);
}
.stat-change.is-down {
  color: var(--color-danger);
}

.chart-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.chart-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.chart-subtitle {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.chart-canvas {
  width: 100%;
  height: 200px;
  position: relative;
}

/* Canvas chart libs (e.g. Chart.js): parent sets height; chart fills width */
.chart-canvas.chart-canvas--chartjs {
  height: 260px;
  min-height: 200px;
}
.chart-canvas.chart-canvas--chartjs canvas {
  max-width: 100%;
}

.chart-bar-group {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  height: 100%;
  padding-top: var(--space-4);
}
.chart-bar {
  flex: 1;
  background: var(--text);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  transition:
    background var(--duration-fast) var(--ease),
    opacity var(--duration-fast) var(--ease);
  opacity: 0.7;
  position: relative;
}
.chart-bar:hover {
  opacity: 1;
}
.chart-bar.is-accent {
  background: var(--brand-primary);
  opacity: 1;
}

.chart-bar-label {
  position: absolute;
  bottom: calc(-1 * var(--space-5));
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.chart-line-svg {
  width: 100%;
  height: 100%;
}
.chart-line-path {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-line-area {
  fill: var(--text);
  opacity: 0.06;
}
.chart-line-dot {
  fill: var(--bg-elevated);
  stroke: var(--text);
  stroke-width: 1.5;
}
.chart-line-path.is-accent {
  stroke: var(--brand-primary);
}
.chart-line-area.is-accent {
  fill: var(--brand-primary);
  opacity: 0.1;
}
.chart-line-dot.is-accent {
  stroke: var(--brand-primary);
}

.chart-donut-svg {
  width: 100%;
  height: 100%;
}
.chart-donut-ring {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}
.chart-donut-center {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: var(--fw-medium);
  fill: var(--text);
  text-anchor: middle;
  dominant-baseline: central;
}
.chart-donut-label {
  font-size: var(--fs-xs);
  fill: var(--text-muted);
  text-anchor: middle;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-4);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* ============================================================================
   32. PORTFOLIO — project grid
   ============================================================================ */

.portfolio {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.portfolio--dense {
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.portfolio-item {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

a.portfolio-item {
  text-decoration: none;
  color: inherit;
}

.portfolio-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.portfolio-item:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.portfolio-media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-sunken);
}

.portfolio-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease);
}

.portfolio-item:hover .portfolio-media img {
  transform: scale(1.04);
}

.portfolio-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.portfolio-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.portfolio-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: -0.02em;
  margin: 0;
}

.portfolio-desc {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  line-height: var(--lh-base);
  margin: 0;
}

.portfolio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.portfolio-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.portfolio-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.portfolio-item--featured .portfolio-media {
  aspect-ratio: 21 / 9;
}

@media (min-width: 900px) {
  .portfolio-item--featured {
    grid-column: span 2;
  }
}

/* Minimal — underline rows on --bg (like .table-minimal / .input-minimal) */
.portfolio.portfolio--minimal {
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 42rem;
}

.portfolio.portfolio--minimal .portfolio-item--featured {
  grid-column: auto;
}

@media (min-width: 900px) {
  .portfolio.portfolio--minimal .portfolio-item--featured {
    grid-column: auto;
  }
}

.portfolio-item.portfolio-item--minimal {
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  box-shadow: none;
}

.portfolio-item.portfolio-item--minimal:first-child {
  border-top: 1px solid var(--border);
}

.portfolio-item.portfolio-item--minimal:hover {
  box-shadow: none;
  border-color: var(--border-strong);
}

.portfolio-item.portfolio-item--minimal .portfolio-footer {
  border-top: none;
  background: transparent;
}

@media (min-width: 640px) {
  .portfolio-item.portfolio-item--minimal {
    display: grid;
    grid-template-columns: 10.5rem 1fr;
    grid-template-rows: auto auto;
    align-items: start;
  }

  .portfolio-item.portfolio-item--minimal .portfolio-media {
    grid-row: 1 / span 2;
    aspect-ratio: 1;
  }

  .portfolio-item.portfolio-item--minimal .portfolio-body {
    grid-column: 2;
    padding-bottom: 0;
  }

  .portfolio-item.portfolio-item--minimal .portfolio-footer {
    grid-column: 2;
    padding: 0 var(--space-5) var(--space-5);
  }
}

/* ============================================================================
   33. BLOG — article list & post cards
   ============================================================================ */

.blog-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.blog-list--grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.blog-list--narrow {
  max-width: var(--container-narrow);
}

.blog-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

a.blog-card {
  text-decoration: none;
  color: inherit;
}

.blog-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.blog-card:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.blog-card-media {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-sunken);
}

.blog-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease);
}

.blog-card:hover .blog-card-media img {
  transform: scale(1.03);
}

.blog-card-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}

.blog-card-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
}

.blog-card-meta time {
  white-space: nowrap;
}

.blog-card-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: -0.02em;
  margin: 0;
}

.blog-card--compact .blog-card-title {
  font-size: var(--fs-lg);
}

.blog-card-excerpt {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  line-height: var(--lh-base);
  margin: 0;
}

.blog-card-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.blog-read-more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.blog-list.blog-list--minimal {
  gap: 0;
  max-width: 42rem;
}

.blog-list.blog-list--minimal.blog-list--grid {
  display: flex;
  flex-direction: column;
}

.blog-card.blog-card--minimal {
  flex-direction: row;
  align-items: stretch;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  box-shadow: none;
  overflow: visible;
}

.blog-card.blog-card--minimal:first-child {
  border-top: 1px solid var(--border);
}

.blog-card.blog-card--minimal:hover {
  box-shadow: none;
  border-color: var(--border-strong);
}

.blog-card.blog-card--minimal .blog-card-media {
  flex-shrink: 0;
  width: 7.5rem;
  aspect-ratio: 1;
}

.blog-card.blog-card--minimal .blog-card-body {
  padding: var(--space-4) var(--space-5);
  min-width: 0;
}

.blog-card.blog-card--minimal .blog-card-footer {
  border-top: none;
  padding-top: 0;
}

@media (max-width: 639px) {
  .blog-card.blog-card--minimal {
    flex-direction: column;
  }

  .blog-card.blog-card--minimal .blog-card-media {
    width: 100%;
    aspect-ratio: 16 / 9;
  }
}

/* ============================================================================
   34. LINK LIST — link-in-bio / resources
   ============================================================================ */

.link-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 28rem;
}

.link-list--wide {
  max-width: 36rem;
}

.link-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

a.link-item {
  text-decoration: none;
  color: inherit;
}

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

.link-item:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.link-item-icon {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
}

.link-item-icon .icon {
  width: 1.35rem;
  height: 1.35rem;
}

.link-item-body {
  flex: 1;
  min-width: 0;
}

.link-item-title {
  font-weight: var(--fw-medium);
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
}

.link-item-desc {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.link-item-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
}

.link-item:hover .link-item-arrow {
  color: var(--text);
}

/* ============================================================================
   35. ABOUT — profile block
   ============================================================================ */

.about {
  display: grid;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 768px) {
  .about {
    grid-template-columns: minmax(200px, 280px) 1fr;
  }
}

.about-media {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1;
  background: var(--bg-sunken);
}

.about-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.about-name {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  margin: 0;
}

.about-role {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: 0;
}

.about-bio {
  font-size: var(--fs-base);
  color: var(--text-soft);
  line-height: var(--lh-base);
  margin: 0;
  max-width: 42rem;
}

.about-social {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.about-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  transition:
    border-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}

.about-social a:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--bg-hover);
}

.about-social .icon {
  width: 1.15rem;
  height: 1.15rem;
}

/* ============================================================================
   36. TEAM — member grid
   ============================================================================ */

.team-grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.team-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-6) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

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

.team-avatar {
  width: 7.5rem;
  height: 7.5rem;
  margin: 0 0 var(--space-4);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg-sunken);
  flex-shrink: 0;
}

.team-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.team-name {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: -0.02em;
  margin: 0;
}

.team-role {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: var(--space-2) 0 0;
}

.team-bio {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  line-height: var(--lh-base);
  margin: var(--space-3) 0 0;
}

.team-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.team-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  transition:
    border-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}

.team-links a:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--bg-hover);
}

.team-links .icon {
  width: 1rem;
  height: 1rem;
}

/* ============================================================================
   37. PROFILE — account & security (demo blocks)
   ============================================================================ */

.profile-shell {
  max-width: 36rem;
  display: flex;
  flex-direction: column;
}

.profile-block {
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--border);
}

.profile-block:first-child {
  padding-top: 0;
}

.profile-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.profile-block-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-4);
}

.profile-block-lead {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  line-height: var(--lh-base);
  margin: calc(var(--space-2) * -1) 0 var(--space-4);
}

/* ============================================================================
   38. TIMELINE — vertical events / changelog
   ============================================================================ */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.5rem;
  position: relative;
  max-width: 42rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0.3125rem;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 1px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-8);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -1.5rem;
  top: 0.4rem;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.0625rem;
  border-radius: var(--radius-full);
  background: var(--text);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border);
  z-index: 1;
}

.timeline-content {
  padding-top: 0.05rem;
}

.timeline-date {
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.timeline-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-2);
}

.timeline-desc {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  line-height: var(--lh-base);
  margin: 0;
}

.timeline-badge {
  display: inline-flex;
  margin-top: var(--space-3);
}

.timeline--compact .timeline-item {
  padding-bottom: var(--space-5);
}

.timeline--compact .timeline-title {
  font-size: var(--fs-base);
}

/* ============================================================================
   39. SHOP — list, product detail, cart, checkout
   ============================================================================ */

.shop-grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.shop-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow: hidden;
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

a.shop-card-hit {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  text-decoration: none;
  color: inherit;
}

a.shop-card-hit:hover .shop-card-title {
  color: var(--link-hover);
}

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

.shop-card-media {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-sunken);
}

.shop-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shop-card-badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
}

.shop-card-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.shop-card-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  margin: 0;
}

.shop-card-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.shop-price {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

.shop-price-old {
  font-size: var(--fs-sm);
  font-weight: var(--fw-regular);
  color: var(--text-muted);
  text-decoration: line-through;
  margin-left: var(--space-2);
}

.shop-card-footer {
  margin-top: auto;
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
}

.shop-grid.shop-grid--minimal {
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 42rem;
}

.shop-card.shop-card--minimal {
  flex-direction: row;
  align-items: stretch;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  box-shadow: none;
}

.shop-card.shop-card--minimal:first-child {
  border-top: 1px solid var(--border);
}

.shop-card.shop-card--minimal:hover {
  box-shadow: none;
  border-color: var(--border-strong);
}

.shop-card.shop-card--minimal a.shop-card-hit {
  flex-direction: row;
  flex: 1;
  min-width: 0;
}

.shop-card.shop-card--minimal .shop-card-media {
  width: 5.5rem;
  flex-shrink: 0;
  aspect-ratio: 1;
}

.shop-card.shop-card--minimal .shop-card-body {
  flex: 1;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
}

.shop-card.shop-card--minimal .shop-card-footer {
  flex-shrink: 0;
  margin-top: 0;
  padding: var(--space-3) var(--space-4);
  border-top: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: var(--space-2);
  width: auto;
  min-width: 5.5rem;
}

@media (max-width: 479px) {
  .shop-card.shop-card--minimal {
    flex-direction: column;
  }

  .shop-card.shop-card--minimal a.shop-card-hit {
    flex-direction: column;
  }

  .shop-card.shop-card--minimal .shop-card-media {
    width: 100%;
    aspect-ratio: 16 / 10;
  }

  .shop-card.shop-card--minimal .shop-card-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
  }
}

/* Product detail */
.product-detail {
  display: grid;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 900px) {
  .product-detail {
    grid-template-columns: 1fr 1fr;
  }
}

.product-gallery {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1;
  max-width: 480px;
  background: var(--bg-sunken);
}

.product-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.product-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  margin: 0;
}

.product-lead {
  font-size: var(--fs-md);
  color: var(--text-soft);
  line-height: var(--lh-base);
  margin: 0;
}

.product-price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
}

.product-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.shop-qty-input {
  width: 4rem;
  text-align: center;
}

/* Cart */
.cart {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
}

.cart-header {
  display: none;
}

.cart-row {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.cart-row:last-child {
  border-bottom: none;
}

.cart-thumb {
  width: 5rem;
  height: 5rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sunken);
  flex-shrink: 0;
}

.cart-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-line-title {
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  margin: 0 0 0.15rem;
}

.cart-line-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.cart-line-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.cart-line-price {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cart-line-qty {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

@media (max-width: 640px) {
  .cart-row {
    grid-template-columns: 4rem 1fr;
    grid-template-rows: auto auto;
  }

  .cart-thumb {
    grid-row: 1 / 3;
    align-self: start;
  }

  .cart-line-main {
    grid-column: 2;
    grid-row: 1;
  }

  .cart-line-end {
    grid-column: 2;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }
}

.cart-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  background: var(--bg-elevated);
}

.cart-summary-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 var(--space-4);
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--fs-sm);
  padding: var(--space-2) 0;
}

.cart-summary-row--total {
  margin-top: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

/* Checkout */
.checkout-layout {
  display: grid;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 900px) {
  .checkout-layout {
    grid-template-columns: 1fr minmax(280px, 360px);
  }
}

.payment-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  background: var(--bg-elevated);
}

.payment-panel-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  margin: 0 0 var(--space-5);
}

.payment-card-row {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr 1fr;
}

.order-recap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  background: var(--bg-sunken);
  font-size: var(--fs-sm);
}

.order-recap-title {
  font-weight: var(--fw-medium);
  margin: 0 0 var(--space-4);
  font-size: var(--fs-base);
}

.order-recap-item {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.order-recap-item:last-of-type {
  border-bottom: none;
}

.order-recap-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   40. IMAGE FILTERS
   ============================================================================ */

.img-bw {
  filter: grayscale(100%);
}
.img-sepia {
  filter: sepia(80%) saturate(60%);
}
.img-muted {
  filter: grayscale(30%) brightness(0.95);
}
.img-warm {
  filter: sepia(20%) saturate(110%) brightness(1.02);
}

.img-bw-hover {
  transition: filter var(--duration-slow) var(--ease);
}
.img-bw-hover:hover {
  filter: grayscale(0);
}
.img-sepia-hover {
  transition: filter var(--duration-slow) var(--ease);
}
.img-sepia-hover:hover {
  filter: sepia(0);
}

/* ============================================================================
   41. AUTH — sign in / sign up / recovery / 2FA (layout + form shell)
   ============================================================================ */

.auth-shell {
  display: flex;
  min-height: min(70vh, 720px);
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow);
}

.auth-card-wide {
  max-width: 32rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.auth-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-medium);
  margin: 0 0 var(--space-2);
  text-align: center;
}

.auth-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 var(--space-6);
  line-height: var(--lh-snug);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-form .field {
  margin: 0;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.auth-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: center;
}

.auth-footer a {
  color: var(--link);
  text-decoration: none;
}

.auth-footer a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.auth-links-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--fs-sm);
}

.auth-links-row a {
  color: var(--link);
  text-decoration: none;
}

.auth-links-row a:hover {
  text-decoration: underline;
}

.auth-otp {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
}

.auth-otp .input {
  width: 2.75rem;
  text-align: center;
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
  padding-inline: var(--space-2);
}

/* ============================================================================
   42. COMBOBOX — autocomplete select (local or remote)
   ============================================================================ */

.combobox {
  position: relative;
  width: 100%;
}

.combobox-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.combobox-input-wrap .icon {
  position: absolute;
  left: var(--space-3);
  width: 1.1rem;
  height: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.combobox-input-wrap .icon + .combobox-input {
  padding-left: var(--space-10);
}

.combobox-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition:
    border-color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}

.combobox-input:hover {
  border-color: var(--border-strong);
}

.combobox-input:focus {
  border-color: var(--text);
}

.combobox.is-open .combobox-input {
  border-color: var(--text);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.combobox-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: calc(var(--z-modal) - 1);
  max-height: 14rem;
  overflow-y: auto;
  margin: 0;
  padding: var(--space-1) 0;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}

.combobox-option {
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-sm);
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.combobox-option:hover,
.combobox-option[aria-selected="true"] {
  background: var(--bg-hover);
}

.combobox-option.is-active {
  background: var(--bg-sunken);
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}

.combobox-empty {
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.combobox-loading {
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.field.has-error .combobox-input {
  border-color: var(--color-danger);
}

/* Search variant: full-width with icon */
.combobox--search .combobox-input {
  padding-block: var(--space-3);
}

/* Create-new option in input-autocomplete */
.combobox-create {
  font-style: italic;
  color: var(--text-soft, var(--text-muted));
  border-top: 1px solid var(--border);
}

.combobox-create:hover,
.combobox-create[aria-selected="true"] {
  background: var(--bg-hover);
}

.combobox-create-error {
  color: var(--color-danger, #c0392b);
}

/* Input autocomplete wrapper */
.input-autocomplete {
  max-width: 26rem;
}

/* Tag input — multi-value tag field with autocomplete */
.tag-input {
  position: relative;
  width: 100%;
  max-width: 32rem;
}

.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  min-height: 2.625rem;
  padding: var(--space-1) var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: text;
  transition:
    border-color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}

.tag-input-wrap:hover {
  border-color: var(--border-strong);
}

.tag-input-wrap:focus-within {
  border-color: var(--text);
}

.tag-input.is-open .tag-input-wrap {
  border-color: var(--text);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.tag-input-pills {
  display: contents;
}

.tag-input-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.15rem var(--space-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  background: var(--bg-sunken);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  line-height: 1.5;
}

.tag-input-pill-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}

.tag-input-pill-remove:hover {
  color: var(--color-danger);
  background: var(--color-danger-soft, rgba(192, 57, 43, 0.1));
}

.tag-input-field {
  flex: 1 1 6rem;
  min-width: 6rem;
  padding: var(--space-1) var(--space-1);
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text);
}

.tag-input-field::placeholder {
  color: var(--text-muted);
}

.tag-input .combobox-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: calc(var(--z-modal) - 1);
  max-height: 14rem;
  overflow-y: auto;
  margin: 0;
  padding: var(--space-1) 0;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}

.field.has-error .tag-input-wrap {
  border-color: var(--color-danger);
}

/* ============================================================================
   43. SEARCH — standalone search field with autocomplete (uses .combobox)
   ============================================================================ */

.search-autocomplete {
  width: 100%;
  max-width: 26rem;
}

.search-autocomplete--wide {
  max-width: none;
}

/* ============================================================================
   44. KANBAN
   ============================================================================ */

.kanban-board {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scroll-snap-type: x mandatory;
}

.kanban-column {
  flex: 0 0 min(18rem, 85vw);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 560px);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kanban-count {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: var(--fw-regular);
  font-variant-numeric: tabular-nums;
}

.kanban-column-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  cursor: grab;
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

.kanban-card:active {
  cursor: grabbing;
}

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

.kanban-card.is-dragging {
  opacity: 0.65;
  box-shadow: var(--shadow);
}

.kanban-card-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  margin: 0 0 var(--space-1);
}

.kanban-card-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.kanban-column.is-drop-target {
  outline: 2px dashed var(--border-focus);
  outline-offset: 2px;
}

.kanban-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.kanban-empty {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-6);
}

.kanban-loading {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: var(--space-4);
}

/* ============================================================================
   45. DATA TABLE — toolbar + sortable + pagination
   ============================================================================ */

.data-table-wrap {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: hidden;
}

.data-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.data-table-toolbar .input {
  max-width: 16rem;
}

.data-table-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.data-table-scroll {
  overflow-x: auto;
}

.data-table-scroll .table {
  margin: 0;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th.sortable:hover {
  color: var(--text);
}

.data-table th .sort-indicator {
  display: inline-block;
  margin-left: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.data-table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  font-size: var(--fs-sm);
}

.data-table-pagination {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.data-table-page-info {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  min-width: 5rem;
  text-align: center;
}

.data-table.is-loading {
  opacity: 0.65;
  pointer-events: none;
}

/* ============================================================================
   46. DATE PICKER & DATE RANGE
   ============================================================================ */

/* Native date / datetime-local inputs already inherit .input styles.
   These additions handle the range wrapper layout. */

.date-range {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.date-range-from,
.date-range-to {
  flex: 1 1 0;
  min-width: 0;
}

.date-range-sep {
  display: flex;
  align-items: center;
  padding-bottom: var(--space-3);
  font-size: var(--fs-base);
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}

/* Ensure native date inputs match .input sizing */
input[type="date"].input,
input[type="datetime-local"].input {
  min-height: 2.75rem;
}

input[type="date"].input-minimal,
input[type="datetime-local"].input-minimal {
  min-height: 2.5rem;
}

@media (max-width: 480px) {
  .date-range {
    flex-direction: column;
    align-items: stretch;
  }
  .date-range-sep {
    display: none;
  }
}

/* ============================================================================
   47. CALENDAR — month / week / day / resource timeline (Gantt)
   ============================================================================ */

.cal-root {
  width: 100%;
}

.cal-root.is-loading .cal-body {
  opacity: 0.55;
  pointer-events: none;
}

/* -- toolbar -- */

.cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.cal-toolbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cal-toolbar-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text);
  text-transform: capitalize;
}

.cal-view-group .btn {
  font-size: var(--fs-xs);
}

/* -- loading / empty -- */

.cal-loading,
.cal-empty {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-8);
}

/* -- event chip (shared) -- */

.cal-event {
  font-size: var(--fs-xs);
  line-height: var(--lh-tight);
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--cal-event-color, var(--brand-primary));
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}

.cal-event-more {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  padding: 1px var(--space-1);
}

/* ============================================================================
   46a. MONTH VIEW
   ============================================================================ */

.cal-month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}

.cal-month-wday {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-2) 0;
  text-transform: capitalize;
}

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 1px solid var(--border);
}

.cal-month-cell {
  min-height: 5.5rem;
  padding: var(--space-1) var(--space-2);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow: hidden;
}

.cal-month-cell.cal-other-month {
  background: var(--bg-sunken);
}

.cal-month-cell.cal-other-month .cal-month-day-num {
  color: var(--text-subtle);
}

.cal-month-cell.cal-today {
  background: var(--color-info-soft);
}

.cal-month-day-num {
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-soft);
  margin-bottom: var(--space-1);
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   46b. WEEK / DAY VIEW — time grid
   ============================================================================ */

.cal-time-grid {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
}

.cal-time-gutter {
  flex: 0 0 3.5rem;
  border-right: 1px solid var(--border);
  background: var(--bg-sunken);
}

.cal-time-gutter-corner {
  height: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.cal-time-label {
  height: 3.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 2px var(--space-2) 0 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--border);
}

.cal-day-col {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--border);
}

.cal-day-col:last-child {
  border-right: none;
}

.cal-day-col-full {
  flex: 1;
}

.cal-day-col-header {
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-soft);
  text-transform: capitalize;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}

.cal-day-col.cal-today .cal-day-col-header {
  background: var(--color-info-soft);
  color: var(--text);
}

.cal-day-slots {
  position: relative;
}

.cal-time-slot {
  height: 3.5rem;
  border-bottom: 1px solid var(--border);
}

.cal-time-slot:last-child {
  border-bottom: none;
}

.cal-event-abs {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 1;
  border-radius: var(--radius-sm);
  padding: var(--space-1);
  font-size: var(--fs-xs);
  line-height: var(--lh-tight);
  overflow: hidden;
}

/* ============================================================================
   46c. TIMELINE / GANTT VIEW
   ============================================================================ */

.cal-tl-header {
  display: grid;
  grid-template-columns: 9rem repeat(var(--cal-tl-cols, 7), 1fr);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--bg-sunken);
}

.cal-tl-corner {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}

.cal-tl-day-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-soft);
  text-transform: capitalize;
  border-right: 1px solid var(--border);
}

.cal-tl-day-header:last-child {
  border-right: none;
}

.cal-tl-day-header.cal-today {
  background: var(--color-info-soft);
  color: var(--text);
}

.cal-tl-rows {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

.cal-tl-row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  min-height: 3rem;
  border-bottom: 1px solid var(--border);
}

.cal-tl-row:last-child {
  border-bottom: none;
}

.cal-tl-res-label {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-tl-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cal-tl-cols, 7), 1fr);
  min-height: 3rem;
}

.cal-tl-cell {
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
}

.cal-tl-cell:last-child {
  border-right: none;
}

.cal-tl-cell.cal-today {
  background: var(--color-info-soft);
}

.cal-tl-bar {
  position: absolute;
  top: 4px;
  bottom: 4px;
  grid-column: calc(var(--cal-tl-bar-start, 0) + 1) / span var(--cal-tl-bar-span, 1);
  left: calc((var(--cal-tl-bar-start, 0) / var(--cal-tl-cols, 7)) * 100% + 3px);
  width: calc((var(--cal-tl-bar-span, 1) / var(--cal-tl-cols, 7)) * 100% - 6px);
  background: var(--cal-event-color, var(--brand-primary));
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  line-height: var(--lh-tight);
  padding: var(--space-1) var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 1;
  display: flex;
  align-items: center;
}

/* -- responsive -- */

@media (max-width: 640px) {
  .cal-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .cal-toolbar-title {
    text-align: center;
  }
  .cal-view-group {
    justify-content: center;
  }
  .cal-month-cell {
    min-height: 3.5rem;
    padding: 2px;
  }
  .cal-time-gutter {
    flex: 0 0 2.5rem;
  }
  .cal-tl-header,
  .cal-tl-row {
    grid-template-columns: 5rem 1fr;
  }
  .cal-tl-header {
    grid-template-columns: 5rem repeat(var(--cal-tl-cols, 7), 1fr);
  }
}

/* ============================================================================
   45b. INPUT AUTOCOMPLETE — create-via-modal enhancement
   ============================================================================ */

.iac-create-modal-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--brand-primary);
  font-weight: var(--fw-medium);
  border-top: 1px solid var(--border);
}

.iac-create-modal {
  z-index: calc(var(--z-modal) + 1);
}

.iac-create-modal .modal {
  max-width: 520px;
  position: relative;
}

.iac-modal-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  font-size: var(--fs-lg);
  line-height: 1;
}

.iac-create-modal .is-invalid {
  border-color: var(--state-danger);
  box-shadow: 0 0 0 2px rgba(var(--state-danger-rgb, 220, 53, 69), 0.18);
}

/* ============================================================================
   46. ORDER LIST — search-to-add item list with qty, sorting, JSON output
   ============================================================================ */

.order-list-wrap {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: hidden;
}

.order-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.order-list-search {
  flex: 1 1 auto;
  min-width: 10rem;
}

.order-list-sort-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.order-list-scroll {
  overflow-x: auto;
}

.order-list-scroll .table {
  margin: 0;
}

.order-list-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.order-list-table th.sortable:hover {
  color: var(--text);
}

.order-list-table th .sort-indicator {
  display: inline-block;
  margin-left: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* drag handle column — hidden by default, shown in manual sort mode */
.order-list-th-drag,
.order-list-td-drag {
  display: none;
  width: 2.5rem;
  text-align: center;
  padding: var(--space-2) var(--space-2);
}

.order-list-manual-sort .order-list-th-drag,
.order-list-manual-sort .order-list-td-drag {
  display: table-cell;
}

.order-list-drag-handle {
  cursor: grab;
  font-size: var(--fs-lg);
  color: var(--text-muted);
  user-select: none;
  line-height: 1;
}

.order-list-drag-handle:hover {
  color: var(--text);
}

.order-list-table tr.is-dragging {
  opacity: 0.4;
  background: var(--bg-sunken);
}

/* qty cell */
.order-list-td-qty {
  white-space: nowrap;
}

.order-list-qty-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.order-list-qty-input {
  width: 3.5rem;
  text-align: center;
  -moz-appearance: textfield;
}

.order-list-qty-input::-webkit-inner-spin-button,
.order-list-qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* actions cell */
.order-list-th-actions,
.order-list-td-actions {
  width: 2.5rem;
  text-align: center;
}

.order-list-remove {
  font-size: var(--fs-lg);
  line-height: 1;
  padding: var(--space-1) var(--space-2);
}

/* footer */
.order-list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  font-size: var(--fs-sm);
}

.order-list-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* create-new option in search dropdown */
.order-list-create-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--brand-primary);
  font-weight: var(--fw-medium);
  border-top: 1px solid var(--border);
}

/* create modal */
.order-list-create-modal {
  z-index: calc(var(--z-modal) + 1);
}

.order-list-create-modal .modal {
  max-width: 520px;
}

.order-list-modal-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  font-size: var(--fs-lg);
  line-height: 1;
}

.order-list-create-modal .modal {
  position: relative;
}

.order-list-create-error {
  margin-top: var(--space-3);
}

.order-list-create-modal .is-invalid {
  border-color: var(--state-danger);
  box-shadow: 0 0 0 2px rgba(var(--state-danger-rgb, 220, 53, 69), 0.18);
}

/* responsive */
@media (max-width: 640px) {
  .order-list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .order-list-sort-toggle {
    align-self: flex-end;
  }
}

/* End of downstage.css */
