/*
 * Global stylesheet entry point.
 *
 * The backend inlines the @import rules below into a single bundle served at
 * /_static/gnotus.css.
 *
 * Theme, base and component styles live in cascade layers, so the unlayered
 * layout and page styles always take precedence over them regardless of
 * selector specificity.
 */
@layer theme, base, components;

/* Theme: color palette, light/dark themes and design tokens */

@layer theme {
  :root {
    --spacing: 0.25rem;
    --radius-selector: 0.5rem;
    --radius-field: 0.25rem;
    --radius-box: 0.5rem;
    --border: 1px;
    --border-subtle: 1px solid var(--color-base-300);

    --text-xs: 0.75rem;
    --leading-xs: calc(1 / 0.75);
    --text-sm: 0.875rem;
    --leading-sm: calc(1.25 / 0.875);
    --text-lg: 1.125rem;
    --leading-lg: calc(1.75 / 1.125);
    --text-xl: 1.25rem;
    --leading-xl: calc(1.75 / 1.25);
    --text-2xl: 1.5rem;
    --leading-2xl: calc(2 / 1.5);
    --text-3xl: 1.875rem;
    --leading-3xl: calc(2.25 / 1.875);
    --text-4xl: 2.25rem;
    --leading-4xl: calc(2.5 / 2.25);

    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Secondary text, derived from the text color so it adapts to the theme */
    --color-muted: color-mix(in oklab, var(--color-base-content) 65%, transparent);
    --color-subtle: color-mix(in oklab, var(--color-base-content) 55%, transparent);

    --font-mono:
      ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
      monospace;

    --color-gray-500: oklch(55.1% 0.027 264.364);
    --color-red-500: oklch(63.7% 0.237 25.331);
    --color-green-500: oklch(72.3% 0.219 149.579);
    --color-blue-500: oklch(62.3% 0.214 259.815);
    --color-blue-600: oklch(54.6% 0.245 262.881);
    --color-blue-700: oklch(48.8% 0.243 264.376);

    --color-secondary-content: oklch(94% 0.028 342.258);
    --color-accent: oklch(77% 0.152 181.912);
    --color-accent-content: oklch(38% 0.063 188.416);
    --color-neutral: oklch(14% 0.005 285.823);
    --color-neutral-content: oklch(92% 0.004 286.32);
    --color-info: oklch(74% 0.16 232.661);
    --color-info-content: oklch(29% 0.066 243.157);
    --color-success: oklch(76% 0.177 163.223);
    --color-success-content: oklch(37% 0.077 168.94);
    --color-warning: oklch(82% 0.189 84.429);
    --color-warning-content: oklch(41% 0.112 45.904);
    --color-error: oklch(71% 0.194 13.428);
    --color-error-content: oklch(27% 0.105 12.094);
  }

  :root,
  [data-theme='light'] {
    color-scheme: light;
    --color-base-100: oklch(100% 0 0);
    --color-base-200: oklch(98% 0 0);
    --color-base-300: oklch(95% 0 0);
    --color-base-content: oklch(21% 0.006 285.885);
    --default-primary: oklch(45% 0.24 277.023);
    --default-secondary: oklch(65% 0.241 354.308);
    --color-primary-content: oklch(93% 0.034 272.788);
  }

  [data-theme='dark'] {
    color-scheme: dark;
    --color-base-100: oklch(25.33% 0.016 252.42);
    --color-base-200: oklch(23.26% 0.014 253.1);
    --color-base-300: oklch(21.15% 0.012 254.09);
    --color-base-content: oklch(97.807% 0.029 256.847);
    --default-primary: oklch(58% 0.233 277.117);
    --default-secondary: oklch(65% 0.241 354.308);
    --color-primary-content: oklch(96% 0.018 272.314);
  }

  /* Site colors are configurable and set as --gnotus-* properties on the root element. */
  html {
    --color-primary: var(--gnotus-primary, var(--default-primary));
    --color-secondary: var(--gnotus-secondary, var(--default-secondary));
  }

  html[data-theme='dark'] {
    --color-primary: var(--gnotus-primary-dark, var(--gnotus-primary, var(--default-primary)));
    --color-secondary: var(
      --gnotus-secondary-dark,
      var(--gnotus-secondary, var(--default-secondary))
    );
  }
}

/* Base: element reset and defaults */

@layer base {
  *,
  ::after,
  ::before,
  ::backdrop,
  ::file-selector-button {
    box-sizing: border-box;
    border: 0 solid;
    margin: 0;
    padding: 0;
  }

  html {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
    -webkit-tap-highlight-color: transparent;
    font-family:
      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell,
      'Helvetica Neue', sans-serif;
    font-size: 12pt;
    background-color: var(--color-base-100);
    color: var(--color-base-content);
    scrollbar-color: color-mix(in oklch, currentColor 35%, transparent) transparent;
  }

  @media (max-width: 600px) {
    html {
      font-size: 10pt;
    }
  }

  body {
    line-height: inherit;
  }

  hr {
    height: 0;
    color: inherit;
    border-top-width: 1px;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-size: inherit;
    font-weight: inherit;
  }

  a {
    color: inherit;
    text-decoration: inherit;
  }

  b,
  strong {
    font-weight: bolder;
  }

  code,
  kbd,
  samp,
  pre {
    font-family: var(--font-mono);
    font-size: 1em;
  }

  small {
    font-size: 80%;
  }

  table {
    text-indent: 0;
    border-color: inherit;
    border-collapse: collapse;
  }

  button,
  input,
  select,
  optgroup,
  textarea,
  ::file-selector-button {
    font: inherit;
    font-feature-settings: inherit;
    font-variation-settings: inherit;
    letter-spacing: inherit;
    color: inherit;
    border-radius: 0;
    background-color: transparent;
    opacity: 1;
  }

  ::placeholder {
    opacity: 1;
    color: color-mix(in oklab, currentColor 50%, transparent);
  }

  textarea {
    resize: vertical;
  }

  button,
  input:where([type='button'], [type='reset'], [type='submit']),
  ::file-selector-button {
    appearance: button;
  }

  ol,
  ul,
  menu {
    list-style: none;
  }

  summary {
    display: list-item;
  }

  img,
  svg,
  video,
  canvas,
  audio,
  iframe,
  embed,
  object {
    display: block;
    vertical-align: middle;
  }

  img,
  video {
    max-width: 100%;
    height: auto;
  }

  progress {
    vertical-align: baseline;
  }

  [hidden]:where(:not([hidden='until-found'])) {
    display: none !important;
  }
}

/* Focus outlines (unlayered so they take precedence over component focus styles) */

a:focus-visible,
button:focus-visible,
label:has(input[type='file']:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

label input[type='file']:focus-visible {
  outline: none;
}

input:focus-visible,
input[type='color']:focus-within,
textarea:focus-visible,
select:focus-visible,
select:focus-within {
  outline: 2px solid var(--color-primary);
  outline-offset: 0px;
}

summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Buttons */

@layer components {
  .btn {
    --size: calc(var(--spacing) * 10);
    --fontsize: 0.875rem;
    --btn-p: 1rem;
    --btn-bg: var(--btn-color, var(--color-base-200));
    --btn-fg: var(--color-base-content);
    --btn-border: color-mix(in oklab, var(--btn-bg), #000 5%);
    --btn-shadow:
      0 3px 2px -2px color-mix(in oklab, var(--btn-bg) 30%, transparent),
      0 4px 3px -2px color-mix(in oklab, var(--btn-bg) 30%, transparent);
    display: inline-flex;
    flex-shrink: 0;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: var(--size);
    padding-inline: var(--btn-p);
    border: var(--border) solid var(--btn-border);
    border-radius: var(--radius-field);
    background-color: var(--btn-bg);
    color: var(--btn-fg);
    box-shadow:
      0 0.5px 0 0.5px oklch(100% 0 0 / 6%) inset,
      var(--btn-shadow);
    text-shadow: 0 0.5px oklch(100% 0 0 / 0.15);
    font-size: var(--fontsize);
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    outline-color: var(--btn-color, var(--color-base-content));
    outline-offset: 2px;
    transition-property: color, background-color, border-color, box-shadow;
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }

  @media (hover: hover) {
    .btn:hover {
      --btn-bg: color-mix(in oklab, var(--btn-color, var(--color-base-200)), #000 7%);
    }
  }

  .btn:focus-visible {
    outline-width: 2px;
    outline-style: solid;
    isolation: isolate;
  }

  .btn:active {
    --btn-bg: color-mix(in oklab, var(--btn-color, var(--color-base-200)), #000 5%);
    --btn-border: color-mix(in oklab, var(--btn-color, var(--color-base-200)), #000 7%);
    --btn-shadow: 0 0 0 0 transparent;
    translate: 0 0.5px;
  }

  .btn-primary {
    --btn-color: var(--color-primary);
    --btn-fg: var(--color-primary-content);
  }

  .btn-secondary {
    --btn-color: var(--color-secondary);
    --btn-fg: var(--color-secondary-content);
  }

  .btn-accent {
    --btn-color: var(--color-accent);
    --btn-fg: var(--color-accent-content);
  }

  .btn-error {
    --btn-color: var(--color-error);
    --btn-fg: var(--color-error-content);
  }

  .btn-ghost:not(:hover, :active:focus, :focus-visible) {
    --btn-shadow: 0 0 0 0 transparent;
    --btn-bg: transparent;
    --btn-border: transparent;
    box-shadow: none;
  }

  .btn-ghost:not(:hover, :active:focus, :focus-visible):not(:disabled) {
    --btn-fg: var(--btn-color, currentColor);
    outline-color: currentColor;
  }

  .btn:disabled,
  .btn[disabled] {
    --btn-border: transparent;
    --btn-fg: color-mix(in oklch, var(--color-base-content) 20%, transparent);
    pointer-events: none;
  }

  .btn:disabled:not(.btn-ghost),
  .btn[disabled]:not(.btn-ghost) {
    background-color: color-mix(in oklab, var(--color-base-content) 10%, transparent);
    box-shadow: none;
  }

  .btn-xs {
    --fontsize: 0.6875rem;
    --btn-p: 0.5rem;
    --size: calc(var(--spacing) * 6);
  }

  .btn-sm {
    --fontsize: 0.75rem;
    --btn-p: 0.75rem;
    --size: calc(var(--spacing) * 8);
  }

  .btn-square {
    width: var(--size);
    height: var(--size);
    padding-inline: 0;
  }

  .btn-circle {
    width: var(--size);
    height: var(--size);
    padding-inline: 0;
    border-radius: 3.40282e38px;
  }
}

/* Form controls: inputs, selects, textareas, file inputs, toggles, fieldsets and labels */

@layer components {
  /* Form fields */
  .input,
  .select,
  .textarea,
  .file-input {
    --size: calc(var(--spacing) * 10);
    --input-color: color-mix(in oklab, var(--color-base-content) 20%, transparent);
    width: clamp(3rem, 20rem, 100%);
    border: var(--border) solid var(--input-color);
    border-radius: var(--radius-field);
    background-color: var(--color-base-100);
    box-shadow:
      0 1px color-mix(in oklab, var(--input-color) 10%, transparent) inset,
      0 -1px oklch(100% 0 0 / 0.1) inset;
    font-size: 0.875rem;
    vertical-align: middle;
    appearance: none;
    touch-action: manipulation;
  }

  .input,
  .select,
  .file-input {
    display: inline-flex;
    align-items: center;
    height: var(--size);
  }

  .input {
    position: relative;
    flex-shrink: 1;
    gap: 0.5rem;
    padding-inline: 0.75rem;
    white-space: nowrap;
    cursor: text;
  }

  .select {
    position: relative;
    flex-shrink: 1;
    gap: 0.375rem;
    padding-inline: 0.75rem 1.75rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    background-image:
      linear-gradient(45deg, transparent 50%, currentColor 50%),
      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position:
      calc(100% - 20px) calc(1px + 50%),
      calc(100% - 16.1px) calc(1px + 50%);
    background-size:
      4px 4px,
      4px 4px;
    background-repeat: no-repeat;
  }

  /* Styled dropdowns in browsers that support customizable selects */
  @supports (appearance: base-select) {
    .select {
      appearance: base-select;
    }
  }

  .select::picker(select) {
    appearance: base-select;
    max-height: min(24rem, 70dvh);
    margin: 0.5rem;
    padding: 0.5rem;
    border: var(--border) solid var(--color-base-200);
    border-radius: var(--radius-box);
    background-color: inherit;
    color: inherit;
    box-shadow:
      0 20px 25px -5px rgb(0 0 0 / 0.1),
      0 8px 10px -6px rgb(0 0 0 / 0.1);
    translate: -0.5rem;
  }

  .select::picker-icon {
    display: none;
  }

  .select option {
    padding-block: 0.375rem;
    padding-inline: 0.75rem;
    border-radius: var(--radius-field);
    white-space: normal;
    transition-property: color, background-color;
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }

  .select option:not(:disabled):is(:hover, :focus-visible) {
    background-color: color-mix(in oklab, var(--color-base-content) 10%, transparent);
    outline-style: none;
    cursor: pointer;
  }

  .select option:not(:disabled):active {
    background-color: var(--color-neutral);
    color: var(--color-neutral-content);
  }

  .select-sm {
    --size: calc(var(--spacing) * 8);
    font-size: 0.75rem;
  }

  .select-sm option {
    padding-block: 0.25rem;
    padding-inline: 0.625rem;
  }

  .textarea {
    flex-shrink: 1;
    min-height: 5rem;
    padding-block: 0.5rem;
    padding-inline: 0.75rem;
  }

  .input:focus,
  .input:focus-within,
  .select:focus,
  .select:focus-within,
  .textarea:focus,
  .textarea:focus-within,
  .file-input:focus {
    --input-color: var(--color-base-content);
    box-shadow: 0 1px color-mix(in oklab, var(--input-color) 10%, transparent);
    outline: 2px solid var(--input-color);
    outline-offset: 2px;
    isolation: isolate;
  }

  .input:disabled,
  .select:disabled,
  .textarea:disabled,
  .file-input:disabled {
    cursor: not-allowed;
    border-color: var(--color-base-200);
    background-color: var(--color-base-200);
    color: color-mix(in oklab, var(--color-base-content) 40%, transparent);
    box-shadow: none;
  }

  .input:disabled::placeholder,
  .textarea:disabled::placeholder {
    color: color-mix(in oklab, var(--color-base-content) 20%, transparent);
  }

  .file-input {
    --btn-bg: var(--btn-color, var(--color-base-200));
    --btn-fg: var(--color-base-content);
    padding-inline-end: 0.75rem;
    line-height: 2;
    cursor: pointer;
    user-select: none;
  }

  .file-input::file-selector-button {
    height: calc(100% + var(--border) * 2);
    margin-block: calc(var(--border) * -1);
    margin-inline: calc(var(--border) * -1) 1rem;
    padding-inline: 1rem;
    border: var(--border) solid color-mix(in oklab, var(--btn-bg), #000 5%);
    border-start-start-radius: var(--radius-field);
    border-end-start-radius: var(--radius-field);
    background-color: var(--btn-bg);
    color: var(--btn-fg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
  }

  .file-input-secondary {
    --btn-color: var(--color-secondary);
    --btn-fg: var(--color-secondary-content);
    --input-color: var(--color-secondary);
  }

  .file-input-secondary:focus {
    --input-color: var(--color-secondary);
  }

  /* Toggle switch */
  .toggle {
    --size: calc(var(--spacing) * 6);
    --toggle-p: calc(var(--size) * 0.125);
    --input-color: color-mix(in oklab, var(--color-base-content) 50%, transparent);
    position: relative;
    display: inline-grid;
    flex-shrink: 0;
    grid-template-columns: 0fr 1fr 1fr;
    place-content: center;
    width: calc((var(--size) * 2) - (var(--border) + var(--toggle-p)) * 2);
    height: var(--size);
    padding: var(--toggle-p);
    border: var(--border) solid currentColor;
    border-radius: calc(var(--radius-selector) + var(--toggle-p) + var(--border));
    color: var(--input-color);
    box-shadow: 0 1px color-mix(in oklab, currentColor 10%, transparent) inset;
    vertical-align: middle;
    cursor: pointer;
    appearance: none;
    user-select: none;
    transition:
      color 0.3s,
      grid-template-columns 0.2s;
  }

  .toggle::before {
    content: '';
    position: relative;
    grid-row-start: 1;
    grid-column-start: 2;
    width: 100%;
    height: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-selector);
    background-color: currentColor;
    box-shadow:
      0 -1px oklch(0% 0 0 / 0.1) inset,
      0 8px 0 -4px oklch(100% 0 0 / 0.1) inset,
      0 1px color-mix(in oklab, currentColor 10%, transparent);
    transition:
      background-color 0.1s,
      translate 0.2s;
  }

  .toggle:focus-visible {
    outline: 2px solid;
    outline-offset: 2px;
  }

  .toggle:checked {
    --input-color: var(--color-base-content);
    grid-template-columns: 1fr 1fr 0fr;
    background-color: var(--color-base-100);
  }

  .toggle:disabled {
    cursor: not-allowed;
    opacity: 0.3;
  }

  .toggle:disabled::before {
    border: var(--border) solid currentColor;
    background-color: transparent;
  }

  .toggle-primary:checked {
    --input-color: var(--color-primary);
  }

  .fieldset {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: max-content;
    gap: 0.375rem;
    padding-block: 0.25rem;
    font-size: 0.75rem;
  }

  .fieldset > :is(.input, .select, .textarea, .file-input) {
    width: 100%;
  }

  .fieldset-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: -0.25rem;
    padding-block: 0.5rem;
    color: var(--color-base-content);
    font-weight: 600;
  }

  .label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: color-mix(in oklab, currentColor 60%, transparent);
    white-space: nowrap;
  }

  .label:has(input) {
    cursor: pointer;
  }
}

/* Cards and dividers */

@layer components {
  /* Cards */
  .card {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-box);
    outline: 0 solid transparent;
    outline-offset: 2px;
    transition: outline 0.2s ease-in-out;
  }

  .card:focus-visible {
    outline: 2px solid currentColor;
  }

  .card-border {
    border: var(--border) solid var(--color-base-200);
  }

  .card-body {
    display: flex;
    flex: auto;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.5rem;
    font-size: 0.875rem;
  }

  .card-body :where(p) {
    flex-grow: 1;
  }

  .card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
  }

  .card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .divider {
    display: flex;
    flex-direction: row;
    align-self: stretch;
    align-items: center;
    height: 1rem;
    margin: 1rem 0;
    white-space: nowrap;
  }

  .divider::before,
  .divider::after {
    content: '';
    flex-grow: 1;
    width: 100%;
    height: 0.125rem;
    background-color: color-mix(in oklab, var(--color-base-content) 10%, transparent);
  }
}

/* Feedback: alerts, badges, tooltips and loading indicators */

@layer components {
  /* Alerts */
  .alert {
    --alert-color: var(--color-base-200);
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: auto;
    justify-content: start;
    place-items: center start;
    gap: 1rem;
    padding-block: 0.75rem;
    padding-inline: 1rem;
    border: var(--border) solid var(--alert-color);
    border-radius: var(--radius-box);
    background-color: var(--alert-color);
    color: var(--color-base-content);
    box-shadow:
      0 3px 0 -2px oklch(100% 0 0 / 0.08) inset,
      0 1px color-mix(in oklab, color-mix(in oklab, #000 20%, var(--alert-color)) 20%, transparent),
      0 4px 3px -2px oklch(0% 0 0 / 0.08);
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-align: start;
  }

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

  .alert-success {
    --alert-color: var(--color-success);
    color: var(--color-success-content);
  }

  .alert-warning {
    --alert-color: var(--color-warning);
    color: var(--color-warning-content);
  }

  /* Badges */
  .badge {
    --size: calc(var(--spacing) * 6);
    --badge-bg: var(--badge-color, var(--color-base-100));
    --badge-fg: var(--color-base-content);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: fit-content;
    height: var(--size);
    padding-inline: calc(var(--size) / 2 - var(--border));
    border: var(--border) solid var(--badge-color, var(--color-base-200));
    border-radius: var(--radius-selector);
    background-color: var(--badge-bg);
    color: var(--badge-fg);
    font-size: 0.875rem;
    vertical-align: middle;
  }

  .badge-sm {
    --size: calc(var(--spacing) * 5);
    font-size: 0.75rem;
  }

  .badge-lg {
    --size: calc(var(--spacing) * 7);
    font-size: 1rem;
  }

  .badge-primary {
    --badge-color: var(--color-primary);
    --badge-fg: var(--color-primary-content);
  }

  .badge-secondary {
    --badge-color: var(--color-secondary);
    --badge-fg: var(--color-secondary-content);
  }

  .badge-accent {
    --badge-color: var(--color-accent);
    --badge-fg: var(--color-accent-content);
  }

  .badge-info {
    --badge-color: var(--color-info);
    --badge-fg: var(--color-info-content);
  }

  .badge-success {
    --badge-color: var(--color-success);
    --badge-fg: var(--color-success-content);
  }

  .badge-warning {
    --badge-color: var(--color-warning);
    --badge-fg: var(--color-warning-content);
  }

  .badge-error {
    --badge-color: var(--color-error);
    --badge-fg: var(--color-error-content);
  }

  /* Tooltips */
  .tooltip {
    position: relative;
    display: inline-block;
  }

  .tooltip[data-tip]::before {
    content: attr(data-tip);
    position: absolute;
    z-index: 2;
    width: max-content;
    max-width: 20rem;
    padding-block: 0.25rem;
    padding-inline: 0.5rem;
    border-radius: var(--radius-field);
    background-color: var(--color-neutral);
    color: var(--color-neutral-content);
    font-size: 0.875rem;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1) 75ms;
  }

  .tooltip-top-end[data-tip]::before {
    inset: auto 0 calc(100% + 0.5rem) auto;
  }

  .tooltip[data-tip]:not([data-tip='']):is(.tooltip-open, :hover, :has(:focus-visible))::before {
    opacity: 1;
  }

  /* Progress bar */
  .progress {
    position: relative;
    width: 100%;
    height: 0.5rem;
    overflow: hidden;
    border-radius: var(--radius-box);
    background-color: color-mix(in oklab, currentColor 20%, transparent);
    color: var(--color-base-content);
    appearance: none;
  }

  .progress::-webkit-progress-bar {
    border-radius: var(--radius-box);
    background-color: transparent;
  }

  .progress::-webkit-progress-value {
    border-radius: var(--radius-box);
    background-color: currentColor;
  }

  .progress::-moz-progress-bar {
    border-radius: var(--radius-box);
    background-color: currentColor;
  }

  .progress:indeterminate {
    background-image: repeating-linear-gradient(90deg, currentColor -1% 10%, transparent 10% 90%);
    background-position-x: 15%;
    background-size: 200%;
  }

  .progress:indeterminate::-moz-progress-bar {
    background-color: transparent;
  }

  @media (prefers-reduced-motion: no-preference) {
    .progress:indeterminate {
      animation: progress 5s ease-in-out infinite;
    }
  }

  @keyframes progress {
    50% {
      background-position-x: -115%;
    }
  }

  .progress-primary {
    color: var(--color-primary);
  }

  /* Loading indicators */
  .loading {
    display: inline-block;
    width: calc(var(--spacing) * 6);
    aspect-ratio: 1;
    background-color: currentColor;
    vertical-align: middle;
    pointer-events: none;
    mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='black' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform-origin='center'%3E%3Ccircle cx='12' cy='12' r='9.5' fill='none' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='2s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dasharray' values='0,150;42,150;42,150' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dashoffset' values='0;-16;-59' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
    mask-position: 50%;
    mask-size: 100%;
    mask-repeat: no-repeat;
  }

  .loading-sm {
    width: calc(var(--spacing) * 5);
  }
}

/* Navigation: links, navbar, menus, breadcrumbs and tabs */

@layer components {
  /* Links */
  .link {
    text-decoration-line: underline;
    cursor: pointer;
  }

  .link:focus-visible {
    outline: 2px solid;
    outline-offset: 2px;
  }

  .link-primary {
    color: var(--color-primary);
  }

  @media (hover: hover) {
    .link-primary:hover {
      color: color-mix(in oklab, var(--color-primary) 80%, #000);
    }
  }

  /* Navigation bar */
  .navbar {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 4rem;
    padding: 0.5rem;
  }

  /* Menus */
  .menu {
    --menu-active-fg: var(--color-base-content);
    --menu-active-bg: var(--color-base-300);
    display: flex;
    flex-flow: column wrap;
    width: fit-content;
    padding: 0.5rem;
    font-size: 0.875rem;
  }

  .menu :where(li) {
    position: relative;
    display: flex;
    flex-flow: column wrap;
    flex-shrink: 0;
    align-items: stretch;
  }

  .menu :where(li ul) {
    position: relative;
    margin-inline-start: 1rem;
    padding-inline-start: 0.5rem;
    white-space: nowrap;
  }

  .menu :where(li ul)::before {
    content: '';
    position: absolute;
    top: 0.75rem;
    bottom: 0.75rem;
    inset-inline-start: 0;
    width: var(--border);
    background-color: var(--color-base-content);
    opacity: 0.1;
  }

  .menu :where(li > :not(ul)) {
    display: grid;
    grid-auto-columns: minmax(auto, max-content) auto max-content;
    grid-auto-flow: column;
    align-content: flex-start;
    align-items: center;
    gap: 0.5rem;
    padding-block: 0.375rem;
    padding-inline: 0.75rem;
    border-radius: var(--radius-field);
    text-align: start;
    text-wrap: balance;
    user-select: none;
    transition-property: color, background-color, box-shadow;
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }

  .menu :where(li > :not(ul):not(:active):hover),
  .menu :where(li > :not(ul):not(:active):focus-visible) {
    background-color: color-mix(in oklab, var(--color-base-content) 10%, transparent);
    cursor: pointer;
    outline-style: none;
  }

  .menu :where(li > :not(ul):active) {
    background-color: var(--menu-active-bg);
    color: var(--menu-active-fg);
    outline-style: none;
  }

  /* Breadcrumbs */
  .breadcrumbs {
    max-width: 100%;
    padding-block: 0.5rem;
    overflow-x: auto;
  }

  .breadcrumbs > ul {
    display: flex;
    align-items: center;
    min-height: min-content;
    white-space: nowrap;
  }

  .breadcrumbs > ul > li {
    display: flex;
    align-items: center;
  }

  .breadcrumbs > ul > li > * {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
  }

  @media (hover: hover) {
    .breadcrumbs > ul > li > *:hover {
      text-decoration-line: underline;
    }
  }

  .breadcrumbs > ul > li + li::before {
    content: '';
    display: block;
    width: 0.375rem;
    height: 0.375rem;
    margin-inline: 0.5rem 0.75rem;
    border-top: 1px solid;
    border-right: 1px solid;
    opacity: 0.4;
    rotate: 45deg;
  }

  /* Tabs */
  .tabs {
    display: flex;
    flex-wrap: wrap;
  }

  .tab {
    position: relative;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    height: calc(var(--spacing) * 10);
    padding-inline: 0.75rem;
    border-color: transparent;
    font-size: 0.875rem;
    text-align: center;
    cursor: pointer;
    appearance: none;
    user-select: none;
  }

  .tab:is(input[type='radio']) {
    min-width: fit-content;
  }

  .tab:is(input[type='radio'])::after {
    content: attr(aria-label);
  }

  .tab:not(:checked, :hover) {
    color: color-mix(in oklab, var(--color-base-content) 50%, transparent);
  }

  .tab:focus-visible {
    outline: 2px solid;
    outline-offset: -5px;
  }

  .tab-content {
    display: none;
    order: 1;
    width: 100%;
  }

  .tab:checked + .tab-content {
    display: block;
  }

  .tabs-border > .tab {
    border-radius: var(--radius-field);
  }

  .tabs-border > .tab::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 3px;
    border-radius: var(--radius-field);
  }

  .tabs-border > .tab:checked::before {
    border-top: 3px solid currentColor;
    background-color: currentColor;
  }
}

/* Modal dialogs */

@layer components {
  /* Modals */
  .modal {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: grid;
    place-items: center;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: clip;
    overscroll-behavior: contain;
    background-color: transparent;
    color: inherit;
    visibility: hidden;
    pointer-events: none;
    transition:
      visibility 0.3s allow-discrete,
      background-color 0.3s ease-out,
      opacity 0.1s ease-out;
  }

  .modal::backdrop {
    display: none;
  }

  .modal[open] {
    background-color: oklch(0% 0 0 / 0.4);
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transition:
      visibility 0s allow-discrete,
      background-color 0.3s ease-out,
      opacity 0.1s ease-out;
  }

  @starting-style {
    .modal[open] {
      opacity: 0;
    }
  }

  .modal-box {
    grid-row-start: 1;
    grid-column-start: 1;
    width: 91.6667%;
    max-width: 32rem;
    max-height: 100vh;
    padding: 1.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: var(--radius-box);
    background-color: var(--color-base-100);
    box-shadow: 0 25px 50px -12px oklch(0% 0 0 / 0.25);
    opacity: 0;
    scale: 95%;
    transition:
      translate 0.3s ease-out,
      scale 0.3s ease-out,
      opacity 0.2s ease-out 50ms,
      box-shadow 0.3s ease-out;
  }

  .modal[open] .modal-box {
    opacity: 1;
    scale: 1;
  }

  .modal-title {
    margin-bottom: 1rem;
    font-size: 1.125rem;
    line-height: calc(1.75 / 1.125);
    font-weight: 700;
  }

  .modal-action {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
  }

  .modal-backdrop {
    z-index: -1;
    display: grid;
    grid-row-start: 1;
    grid-column-start: 1;
    place-self: stretch;
    color: transparent;
  }

  .modal-backdrop button {
    cursor: pointer;
  }
}

/* Drawer (slide-in sidebar on narrow screens) */

@layer components {
  /* Drawer (used on narrow screens for the sidebar) */
  .drawer {
    position: relative;
    display: grid;
    grid-auto-columns: max-content auto;
    width: 100%;
  }

  .drawer-content {
    grid-row-start: 1;
    grid-column-start: 2;
    min-width: 0;
  }

  .drawer-toggle {
    position: fixed;
    width: 0;
    height: 0;
    opacity: 0;
    appearance: none;
  }

  .drawer-side {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    z-index: 10;
    display: grid;
    grid-template-rows: repeat(1, minmax(0, 1fr));
    grid-template-columns: repeat(1, minmax(0, 1fr));
    grid-row-start: 1;
    grid-column-start: 1;
    place-items: flex-start start;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: contain;
    background-color: transparent;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transition:
      opacity 0.2s ease-out 0.1s allow-discrete,
      visibility 0.3s ease-out 0.1s allow-discrete;
  }

  .drawer-side > * {
    grid-row-start: 1;
    grid-column-start: 1;
  }

  .drawer-side > .drawer-overlay {
    position: sticky;
    top: 0;
    place-self: stretch;
    background-color: oklch(0% 0 0 / 0.4);
    cursor: pointer;
  }

  .drawer-side > :not(.drawer-overlay) {
    translate: -100%;
    transition:
      translate 0.3s ease-out,
      width 0.2s ease-out;
  }

  .drawer-toggle:checked ~ .drawer-side {
    overflow-y: auto;
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
  }

  .drawer-toggle:checked ~ .drawer-side > :not(.drawer-overlay) {
    translate: 0%;
  }
}

/* Tables */

@layer components {
  /* Tables */
  .table {
    position: relative;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--radius-box);
    font-size: 0.875rem;
    text-align: left;
  }

  .table :where(th, td) {
    padding-block: 0.75rem;
    padding-inline: 1rem;
    vertical-align: middle;
  }

  .table :where(thead) {
    color: color-mix(in oklab, var(--color-base-content) 60%, transparent);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
  }

  .table :where(thead tr :is(td, th), tbody tr:not(:last-child) :is(td, th)) {
    border-bottom: var(--border) solid
      color-mix(in oklch, var(--color-base-content) 5%, transparent);
  }
}

/* Patterns shared by several pages */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border-width: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Full-height area used for loading and error states */
.page-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  height: 100%;
}

.page-spinner {
  color: var(--color-primary);
  animation: spin 1s linear infinite;
}

.page-heading {
  font-size: var(--text-2xl);
  line-height: var(--leading-2xl);
}

/* Error message shown below a form */
.form-error {
  box-shadow: var(--shadow-lg);
}

.modal-box > .form-error {
  margin-top: 1rem;
}

/* Administration pages (users, uploads, settings) */
.admin-page {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  margin: 1rem;
  overflow-y: auto;
}

.admin-page > .breadcrumbs {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.admin-panel {
  border: var(--border-subtle);
  background-color: var(--color-base-200);
  box-shadow: var(--shadow-lg);
}

.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.admin-table-wrapper {
  max-height: 50rem;
  overflow-x: auto;
}

.admin-table {
  table-layout: fixed;
}

.admin-table-empty {
  color: var(--color-subtle);
  text-align: center;
}

/* Buttons that show a spinner instead of their label while busy */
.btn-spinner {
  display: none;
}

.is-busy > .btn-label {
  display: none;
}

.is-busy > .btn-spinner {
  display: inline-block;
}

/* Rendered Markdown document content */

/* Adapted from MVP.css v1.17.2 - https://github.com/andybrewer/mvp */
/* MIT License

Copyright (c) 2025 Andy Brewer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */

/* Note: this only needs to cover content that may be produced from Markdown. */

.gnotus-content {
  --active-brightness: 0.85;
  --border-radius: 5px;
  --hover-brightness: 1.2;
  line-height: 1.5;
  scroll-behavior: smooth;
  font-size: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  .gnotus-content {
    scroll-behavior: auto;
  }
}

/* Layout */
.gnotus-content *,
.gnotus-content *::before,
.gnotus-content *::after {
  box-sizing: border-box;
}

.gnotus-content footer,
.gnotus-content header,
.gnotus-content main {
  margin: 0 auto;
  padding: 3rem 1rem;
}

.gnotus-content hr {
  background-color: var(--color-base-300);
  border: none;
  height: 1px;
  margin: 1rem 0;
  width: 100%;
}

.gnotus-content sup {
  font-size: 0.75rem;
  vertical-align: super;
}

.gnotus-content sub {
  font-size: 0.75rem;
  vertical-align: sub;
}

/* Summaries */
.gnotus-content details {
  margin: 1.3rem 0;
}

.gnotus-content details summary {
  font-weight: bold;
  cursor: pointer;
}

.gnotus-content details summary:focus-visible {
  outline: 2px solid var(--color-blue-500);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Headings */
.gnotus-content h1,
.gnotus-content h2,
.gnotus-content h3,
.gnotus-content h4,
.gnotus-content h5,
.gnotus-content h6 {
  text-wrap: balance;
  font-weight: bold;
}

.gnotus-content h1 {
  font-size: 2rem;
  margin: 1.25rem 0 0.5rem;
}
.gnotus-content h2 {
  font-size: 1.75rem;
  margin: 1rem 0 0.5rem;
}
.gnotus-content h3 {
  font-size: 1.375rem;
  margin: 0.75rem 0 0.5rem;
}
.gnotus-content h4 {
  font-size: 1.25rem;
  margin: 0.5rem 0;
}
.gnotus-content h5 {
  font-size: 1.125rem;
  margin: 0.5rem 0;
}
.gnotus-content h6 {
  font-size: 1rem;
  margin: 0.5rem 0;
}

.gnotus-content mark {
  padding: 0.1rem;
}

.gnotus-content .heading-anchor {
  color: var(--color-subtle);
  font-size: 1rem;
  margin-left: 0.5rem;
  opacity: 0.5;
  text-decoration: none;
  transition: opacity 0.2s ease-in-out;
}

.gnotus-content .heading-anchor:hover {
  opacity: 1;
  color: var(--color-primary);
}

.gnotus-content .heading-anchor:focus-visible {
  outline: 2px solid var(--color-blue-500);
  outline-offset: 2px;
  border-radius: 2px;
}

.gnotus-home-content .heading-anchor {
  display: none;
}

.gnotus-home-content h1 {
  color: var(--color-primary);
}

/* Lists */
.gnotus-content ol,
.gnotus-content ul {
  margin: 0.5rem 0;
  padding: 0.5rem 1rem 0.5rem 2rem;
}
.gnotus-content ol ol,
.gnotus-content ol ul,
.gnotus-content ul ol,
.gnotus-content ul ul {
  margin: 0.25rem 0;
  padding-left: 1.5rem;
}

.gnotus-content ol {
  list-style-type: decimal;
}

.gnotus-content ul {
  list-style-type: disc;
}

.gnotus-content ol li,
.gnotus-content ul li {
  padding: 0.2rem 0;
}

.gnotus-content ol li > *:first-child:not(ul):not(ol),
.gnotus-content ul li > *:first-child:not(ul):not(ol) {
  display: inline;
}

.gnotus-content p {
  margin: 0.75rem 0;
}

/* Code */
.gnotus-content pre {
  margin: 1rem 0;
  padding: 1rem;
  background-color: var(--color-base-200);
  color: var(--color-base-content);
  white-space: pre;
  overflow-x: auto;
  border: var(--border-subtle);
  border-radius: var(--border-radius);
}

.gnotus-content code,
.gnotus-content samp {
  color: var(--color-secondary);
  background-color: var(--color-base-300);
  border-radius: var(--border-radius);
  margin: 0 0.1rem;
  padding: 0.1rem 0.3rem;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.gnotus-content pre code {
  background-color: transparent;
  margin: 0;
  padding: 0;
}

/* Links */
.gnotus-content a {
  color: var(--color-blue-500);
  font-weight: bold;
  text-decoration: underline;
}

.gnotus-content a:hover {
  color: var(--color-blue-600);
}

.gnotus-content a:active {
  color: var(--color-blue-700);
}

.gnotus-content a:focus-visible {
  outline: 2px solid var(--color-blue-500);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Images */
.gnotus-content img {
  display: inline-block;
  max-width: 100%;
}

/* Checkboxes */
.gnotus-content input[type='checkbox'],
.gnotus-content input[type='radio'] {
  display: inline-block;
}

.gnotus-content input[type='checkbox'] + label,
.gnotus-content input[type='radio'] + label {
  display: inline-block;
  font-weight: normal;
  position: relative;
  top: 1px;
}

.gnotus-content label {
  font-weight: bold;
  margin-bottom: 0.2rem;
}

/* Tables */
.gnotus-content table {
  border: var(--border-subtle);
  border-radius: var(--border-radius);
  border-spacing: 0;
  table-layout: fixed;
}

.gnotus-content table td,
.gnotus-content table th {
  padding: 0.4rem 0.8rem;
  text-align: center;
  word-break: break-word;
}

.gnotus-content table thead {
  background-color: var(--color-secondary);
  color: var(--color-base-100);
}

.gnotus-content table thead tr:first-child th:first-child {
  border-top-left-radius: var(--border-radius);
}

.gnotus-content table thead tr:first-child th:last-child {
  border-top-right-radius: var(--border-radius);
}

.gnotus-content table thead th:first-child,
.gnotus-content table tr td:first-child {
  text-align: left;
}

.gnotus-content table tbody tr:nth-child(even) {
  background-color: var(--color-base-200);
}

/* Quotes */
.gnotus-content blockquote {
  margin: 1rem auto;
  padding: 0.5rem 1rem;
  background-color: var(--color-base-200);
  border-left: 4px solid var(--color-secondary);
  box-shadow: 1px 1px 5px var(--color-base-300);
  border-radius: var(--border-radius);
}

/* Scrollbars */
.gnotus-content * {
  scrollbar-width: thin;
  scrollbar-color: var(--color-base-content) transparent;
}

.gnotus-content *::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.gnotus-content *::-webkit-scrollbar-track {
  background: transparent;
}

.gnotus-content *::-webkit-scrollbar-thumb {
  background-color: var(--color-base-content);
  border-radius: 10px;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background-color: var(--color-base-100);
}

.app-body {
  display: flex;
  flex-direction: row;
  flex-grow: 1;
  overflow-y: hidden;
}

.app-sidebar.drawer-side {
  z-index: 30;
}

.app-sidebar-content {
  height: 100%;
  background-color: var(--color-base-200);
}

.app-main {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

@media print {
  .app {
    height: auto;
  }

  .app-sidebar {
    display: none;
  }
}

.app-header {
  z-index: 20;
  min-height: 3rem;
  width: 100vw;
  max-width: 100vw;
  padding: 0.25rem;
  background-color: var(--color-base-300);
  box-shadow: var(--shadow-md);
}

.app-header-menu {
  margin-inline-end: 0.5rem;
}

.app-header-bar {
  display: flex;
  flex-grow: 1;
  align-items: center;
  gap: 0.5rem;
}

.app-header-home {
  display: flex;
  flex-shrink: 0;
}

.app-header-logo {
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.5rem;
  object-fit: contain;
}

.app-header-title {
  margin-inline-end: auto;
  overflow: hidden;
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .app-header-logo {
    width: 2rem;
    height: 2rem;
  }

  .app-header-title {
    font-size: var(--text-xl);
    line-height: var(--leading-xl);
  }
}

@media print {
  .app-header {
    display: none;
  }
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 16rem;
  height: 100%;
  padding: 0.5rem;
  overflow-y: auto;
}

.sidebar-menu {
  width: 100%;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
}

.sidebar-item:has(a.active) {
  background-color: var(--color-base-100);
}

.sidebar-toggle {
  padding: 0.5rem 0.25rem;
  cursor: pointer;
}

@media (hover: hover) {
  .sidebar-toggle:hover {
    color: var(--color-secondary);
  }
}

.sidebar-toggle-icon {
  width: 1rem;
  height: 1rem;
  transition: rotate 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-toggle-icon.open {
  rotate: 90deg;
}

.sidebar-link {
  display: flex;
  flex-grow: 1;
  align-items: center;
  height: 2rem;
}

.sidebar-link-leaf {
  padding-left: 1.5rem;
}

.sidebar-link.active,
.sidebar-action.active {
  color: var(--color-primary);
}

.sidebar-action {
  opacity: 0.75;
}

.sidebar-action.active:not(:hover) {
  background-color: var(--color-base-100);
}

.sidebar-children {
  width: auto;
  margin-left: 0.75rem;
  padding: 0 0 0 0.5rem;
  overflow-y: hidden;
  border-left: var(--border-subtle);
}

.sidebar-children:not([hidden]) {
  display: block;
}

.sidebar-children::before {
  display: none;
}

.sidebar-spacer {
  flex-grow: 1;
}

.sidebar-footer {
  color: var(--color-subtle);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.search-trigger-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--color-subtle);
}

.search-modal {
  align-items: start;
}

.search-box {
  margin: 1rem;
  padding: 0;
  border-radius: var(--radius-box);
}

.search-field {
  position: relative;
  margin: 1rem 1rem 0;
  box-shadow: var(--shadow-lg);
}

.search-spinner {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  color: var(--color-secondary);
}

.search-field-icon {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  width: 1rem;
  height: 1rem;
  color: var(--color-subtle);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding-inline: 2.5rem;
}

.search-clear {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  color: var(--color-subtle);
  cursor: pointer;
}

.search-clear svg {
  width: 1rem;
  height: 1rem;
}

@media (hover: hover) {
  .search-clear:hover {
    color: var(--color-base-content);
  }
}

.search-results {
  max-height: 25rem;
  padding: 0.5rem 0.25rem 0.5rem 1rem;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background-color: var(--color-base-100);
}

.search-message {
  color: var(--color-subtle);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  text-align: center;
}

.search-error {
  color: var(--color-error);
}

.search-result {
  margin-block: 0.25rem;
  padding: 0.5rem;
  border: var(--border-subtle);
  border-radius: var(--radius-box);
}

@media (hover: hover) {
  .search-result:hover {
    background-color: var(--color-base-200);
  }
}

.search-result-header {
  display: flex;
}

.search-result-badge {
  margin-left: auto;
  color: var(--color-base-content);
}

.search-result-text {
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.search-results .search-highlight {
  color: var(--color-primary);
  padding: 1px;
  border-radius: 2px;
  font-weight: bold;
  font-style: normal;
}

/* Server-rendered app shell */

#main:focus {
  outline: none;
}

/*
 * The sidebar is a drawer on narrow screens and docked on wide ones, where
 * <body data-sidebar> controls whether it is expanded.
 */
@media (min-width: 751px) {
  .app-sidebar-auto.drawer-side {
    position: static;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 16rem;
    height: auto;
    overflow: hidden;
    border-right: var(--border-subtle);
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transition: width 0.3s ease-out;
  }

  body[data-sidebar='closed'] .app-sidebar-auto.drawer-side {
    width: 0;
  }

  .app-sidebar-auto.drawer-side > .drawer-overlay {
    display: none;
  }

  .app-sidebar-auto.drawer-side > :not(.drawer-overlay) {
    translate: none;
  }
}

/* Collapsible outline nodes */
.sidebar-node {
  display: block;
  padding: 0;
  background-color: transparent;
  color: inherit;
}

.sidebar-node > summary.sidebar-item {
  border-radius: var(--radius-field);
  list-style: none;
}

.sidebar-node > summary.sidebar-item::-webkit-details-marker {
  display: none;
}

@media (hover: hover) {
  .sidebar-node > summary.sidebar-item:hover {
    background-color: color-mix(in oklab, var(--color-base-content) 10%, transparent);
  }
}

.sidebar-node[open] > summary .sidebar-toggle-icon {
  rotate: 90deg;
}

/* Progress bar shown while a page is loading */
.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 0;
  height: 3px;
  background-color: var(--color-primary);
  opacity: 0;
  pointer-events: none;
}

html.is-loading .page-progress {
  width: 80%;
  opacity: 1;
  transition:
    width 8s cubic-bezier(0.1, 0.7, 0.2, 1),
    opacity 0.2s ease-out;
}

/* Smooth scrolling to in-page anchors */
@media (prefers-reduced-motion: no-preference) {
  [data-scroll] {
    scroll-behavior: smooth;
  }
}

.doc-layout {
  display: flex;
  flex-grow: 1;
  align-items: flex-start;
  overflow: hidden;
}

.doc-scroll {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 100%;
  min-height: 100%;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.doc-article {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 50rem;
  margin-inline: auto;
  padding: 0.5rem 1rem 2rem;
}

.doc-article-shared {
  max-width: 43.75rem;
}

@media (min-width: 768px) {
  .doc-article {
    padding-inline: 2rem;
  }
}

@media (min-width: 1024px) {
  .doc-article {
    padding-inline: 3rem;
  }
}

.doc-shared-notice {
  margin-bottom: 0.5rem;
}

.doc-breadcrumbs {
  flex-shrink: 0;
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.doc-breadcrumbs > ul {
  flex-wrap: wrap;
}

.doc-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-block: 0.5rem;
  color: var(--color-primary);
  font-size: var(--text-3xl);
  line-height: var(--leading-3xl);
  font-weight: 700;
}

.doc-title-text {
  margin-inline-end: auto;
}

.doc-visibility {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.doc-title-action {
  margin-left: 0.5rem;
}

.doc-title-action svg {
  width: 1.25rem;
  height: 1.25rem;
}

.doc-share-button,
.doc-copy-button {
  cursor: pointer;
}

.doc-share-copied,
.doc-copy-copied {
  color: var(--color-success);
}

.doc-share-button .doc-share-copied,
.doc-share-button.is-copied .doc-share-icon,
.doc-copy-button .doc-copy-copied,
.doc-copy-button.is-copied .doc-copy-icon {
  display: none;
}

.doc-share-button.is-copied .doc-share-copied,
.doc-copy-button.is-copied .doc-copy-copied {
  display: block;
}

.doc-contents {
  margin-inline: 1rem;
}

.doc-contents-heading {
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
}

.doc-contents-list {
  padding-left: 1.5rem;
  color: var(--color-primary);
  font-weight: 600;
  list-style-type: disc;
}

.doc-spacer {
  flex-grow: 1;
}

.doc-dates {
  margin-top: 0.5rem;
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.doc-toc {
  display: none;
  flex-shrink: 0;
  width: 12.5rem;
  max-height: 100%;
  padding-block: 1rem;
  padding-inline-start: 0.5rem;
  overflow-y: auto;
  scrollbar-gutter: stable;
  border-left: var(--border-subtle);
}

@media (min-width: 1024px) {
  .doc-toc {
    display: block;
  }
}

.doc-toc-heading {
  margin-bottom: 0.5rem;
  color: var(--color-secondary);
  font-weight: 600;
}

.doc-toc-list {
  padding-left: 0.75rem;
  color: var(--color-subtle);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.page-message {
  max-width: 28rem;
}

.page-message-actions {
  display: flex;
  gap: 0.5rem;
}

@media print {
  .doc-article {
    padding-inline: 1rem;
  }

  .doc-toc {
    display: none;
  }
}

.home-page {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1rem;
  overflow-y: auto;
}

.home-intro {
  max-width: 50rem;
  text-align: center;
}

.home-title {
  font-size: var(--text-4xl);
  line-height: var(--leading-4xl);
  font-weight: 700;
  text-align: center;
}

.home-sections {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 1rem;
}

.home-section-list {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  max-width: 30rem;
  color: var(--color-primary);
  font-weight: 600;
}

.home-section {
  margin: 0.25rem;
  border: var(--border-subtle);
  border-radius: var(--radius-box);
  background-color: var(--color-base-200);
}

@media (hover: hover) {
  .home-section:hover {
    background-color: var(--color-base-300);
  }
}

.home-section-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  overflow: hidden;
  text-wrap: wrap;
}

.home-section-chevron {
  margin-left: auto;
}

.home-edit {
  margin-top: 1rem;
}

.home-edit svg {
  width: 1rem;
  height: 1rem;
}

.share-dialog {
  max-width: 32rem;
}

.share-dialog .btn svg {
  width: 1rem;
  height: 1rem;
}

.share-dialog-error {
  margin-bottom: 1rem;
}

.share-dialog-section {
  margin-bottom: 1rem;
}

.share-dialog-heading {
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.share-dialog-create {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.share-dialog-expiration {
  flex: 1;
}

.share-dialog-loading {
  display: flex;
  justify-content: center;
  padding-block: 1rem;
}

.share-dialog-loading svg {
  width: 1.5rem;
  height: 1.5rem;
}

.share-dialog-empty {
  padding-block: 1rem;
  color: var(--color-subtle);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  text-align: center;
}

.share-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.share-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border-radius: var(--radius-box);
  background-color: var(--color-base-200);
}

.share-link-expired {
  opacity: 0.5;
}

.share-link-info {
  flex: 1;
  min-width: 0;
}

.share-link-token {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-link-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
  color: var(--color-subtle);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
}

.share-link-expiry-expired {
  color: var(--color-error);
}

.share-link-actions {
  display: flex;
  gap: 0.25rem;
}

.share-link-copied {
  color: var(--color-success);
}

.share-link-actions .share-link-copied,
.share-link-actions .is-copied .share-link-copy {
  display: none;
}

.share-link-actions .is-copied .share-link-copied {
  display: block;
}

.share-link-delete {
  color: var(--color-error);
}

/* Login and logout pages */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.auth-card {
  flex-grow: 1;
  max-width: 25rem;
  background-color: var(--color-base-200);
  box-shadow: var(--shadow-lg);
}

.auth-actions {
  justify-content: flex-end;
}

.auth-submit {
  width: 6.25rem;
}

.logout-status {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  align-items: center;
  gap: 1rem;
  max-width: 25rem;
}

.admin-home {
  width: 100%;
  max-width: 50rem;
  margin-inline: auto;
  padding: 1.5rem 1rem;
}

.admin-home-title {
  margin-bottom: 1.5rem;
  color: var(--color-primary);
  font-size: var(--text-3xl);
  line-height: var(--leading-3xl);
  font-weight: 700;
}

.admin-home-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .admin-home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.admin-home-card {
  background-color: var(--color-base-200);
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (hover: hover) {
  .admin-home-card:hover {
    background-color: var(--color-base-300);
  }
}

.admin-home-card-body {
  flex-direction: row;
  align-items: center;
  gap: 1rem;
}

.admin-home-card-body > svg {
  width: 2rem;
  height: 2rem;
}

.admin-home-card-description {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  opacity: 0.7;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-size {
  width: 5rem;
}

.pagination-label {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.users-actions-column {
  width: 12.5rem;
  text-align: center;
}

.users-actions {
  text-align: right;
  white-space: nowrap;
}

.users-actions > .btn + .btn {
  margin-left: 0.25rem;
}

.user-inactive {
  opacity: 0.5;
}

.user-status-inactive {
  background-color: var(--color-gray-500);
}

.users-dialog .modal-title {
  margin-bottom: 0.5rem;
  font-size: var(--text-xl);
  line-height: var(--leading-xl);
}

.users-password-for {
  margin-bottom: 0.5rem;
  color: var(--color-muted);
}

.uploads-document-column {
  width: 7.5rem;
}

.uploads-public-column {
  width: 6.25rem;
}

.uploads-size-column {
  width: 6.25rem;
  text-align: center;
}

.uploads-actions-column {
  width: 12.5rem;
  text-align: center;
}

.uploads-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  text-wrap: nowrap;
}

.uploads-doc-link {
  gap: 0.25rem;
}

.uploads-doc-link svg {
  width: 0.75rem;
  height: 0.75rem;
}

.uploads-doc-title {
  max-width: 5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uploads-no-doc {
  color: var(--color-subtle);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
}

.uploads-size {
  text-align: right;
}

.uploads-actions {
  text-align: center;
  white-space: nowrap;
}

.uploads-actions > .btn + .btn {
  margin-left: 0.5rem;
}

.uploads-inherited-hint {
  margin-left: 0.5rem;
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
}

.uploads-dialog-submit {
  width: 5rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-icon-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.settings-icon-preview {
  padding: 0.5rem;
  border: var(--border-subtle);
  border-radius: var(--radius-box);
  background-color: var(--color-base-100);
}

.settings-icon-image {
  width: 3rem;
  height: 3rem;
  object-fit: contain;
}

.settings-icon-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-hint {
  margin-top: 0.25rem;
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
}

.settings-colors {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .settings-colors {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.settings-color-row {
  display: flex;
  gap: 0.5rem;
}

.settings-color-swatch {
  width: 3.5rem;
  height: 2.5rem;
  padding: 0.25rem;
}

.settings-color-value {
  flex: 1;
}

.settings-actions {
  margin-top: 0.5rem;
}

.search-index-stats {
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: center;
  gap: 0.5rem 1.5rem;
}

.search-index-stats dt {
  color: var(--color-muted);
}

.revisions-page {
  max-height: 100%;
  overflow-y: auto;
}

.revisions-card {
  margin: 1rem;
  background-color: var(--color-base-200);
  box-shadow: var(--shadow-lg);
}

.revisions-doc-link {
  margin-left: 0.25rem;
}

.revisions-table {
  margin-top: 1rem;
}

.revisions-actions-column {
  width: 8.75rem;
  text-align: center;
}

.revision-dialog {
  max-width: 48rem;
}

.revision-dialog-title {
  margin-bottom: 0;
}

.revision-dialog-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.revision-meta,
.revision-tabs {
  margin-top: 0.5rem;
}

.revision-pane {
  width: 90vw;
  height: 70vh;
  padding: 1rem;
}

.revision-pane-content,
.revision-pane-diff {
  overflow: auto;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-box);
}

.revision-pane-content {
  background-color: var(--color-base-100);
}

.revision-pane-diff {
  background-color: var(--color-base-200);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
}

.revision-diff {
  white-space: pre-wrap;
}

.diff-added {
  background-color: var(--color-green-500);
}

.diff-removed {
  background-color: var(--color-red-500);
}

.revision-loading {
  display: flex;
  justify-content: center;
  padding: 2rem;
}

.new-doc-page {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-inline: 1rem;
  overflow-y: auto;
}

.new-doc-card {
  width: 100%;
  max-width: 37.5rem;
  max-height: 100%;
  margin: 1rem auto;
  overflow-y: auto;
  background-color: var(--color-base-200);
  box-shadow: var(--shadow-lg);
}

.new-doc-form {
  gap: 1rem;
}

.editor-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1rem;
  overflow: hidden;
}

.editor-form {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

/* Header with title, actions and document metadata */
.editor-meta {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-box);
  background-color: var(--color-base-200);
  box-shadow: var(--shadow-sm);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-toolbar .btn-square svg {
  width: 1.25rem;
  height: 1.25rem;
}

.editor-heading {
  font-size: var(--text-xl);
  line-height: var(--leading-xl);
  font-weight: 700;
}

.editor-toolbar-spacer {
  flex-grow: 1;
}

.editor-history {
  color: var(--color-primary);
}

.editor-move {
  color: var(--color-secondary);
}

.editor-delete {
  color: var(--color-error);
}

.editor-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.editor-field {
  flex: 1;
  min-width: 12rem;
}

.editor-field > :is(.input, .select) {
  width: 100%;
}

.editor-field-label,
.editor-public-toggle > span {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.editor-public-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  cursor: pointer;
}

/* Side-by-side Markdown editor and preview */
.editor-panes {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
  min-height: 0;
}

@media (min-width: 768px) {
  .editor-panes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.editor-pane {
  display: flex;
  flex-direction: column;
  min-height: 16rem;
}

.editor-pane-label {
  padding-block: 0.25rem;
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: 500;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  resize: none;
}

.editor-upload-progress {
  margin-top: 0.5rem;
}

.editor-preview {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  overflow: auto;
  border: var(--border-subtle);
  border-radius: var(--radius-box);
  background-color: var(--color-base-100);
}

/* Attachments */
.editor-attachments {
  border-radius: var(--radius-box);
  background-color: var(--color-base-200);
  box-shadow: var(--shadow-sm);
}

.editor-attachments-summary {
  padding: 0.75rem;
  border-radius: var(--radius-box);
  font-weight: 500;
  cursor: pointer;
}

.editor-attachments-body {
  padding: 0.75rem;
  border-top: var(--border-subtle);
}

.editor-attachments-empty {
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.editor-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.editor-attachment {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-box);
  background-color: var(--color-base-100);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.editor-attachment .btn svg {
  width: 0.75rem;
  height: 0.75rem;
}

.editor-attachment-name {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-attachment-delete {
  color: var(--color-error);
}

.editor-attachment-upload {
  margin-top: 0.75rem;
}

/* Visually hidden but still focusable through its label */
.editor-attachment-input {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
