/* ==========================================================================
   EDFY DESIGN SYSTEM
   - Base reset & typography
   - Design tokens
   - Layout primitives
   - Components (buttons, inputs, cards, tabs, badges, modals)
   - Utilities
   ========================================================================== */

/* ------------------------------ DESIGN TOKENS ----------------------------- */
:root {
  /* Core tone scale: dark to light */
  --color-base-950: #050101;
  --color-base-900: #201212;
  --color-base-850: #2f1d1f;
  --color-base-800: #362525;
  --color-base-750: #493536;
  --color-base-700: #5c4b4b;
  --color-base-600: #7c6465;
  --color-base-500: #a18989;
  --color-base-400: #ad9999;
  --color-base-300: #bfa7a7;
  --color-base-200: #d1b6b6;
  --color-base-150: #f2e7ea;
  --color-base-100: #f3ece8;
  --color-base-75: #f8f3f1;
  --color-base-50: #fdf8f6;
  --color-base-25: #fefcfa;
  --color-base-0: #ffffff;

  /* Semantic palette mapped to the scale */
  --color-bg: var(--color-base-75);
  --color-bg-muted: var(--color-base-50);
  --color-surface: var(--color-base-0);
  --color-surface-alt: var(--color-base-100);
  --color-primary: var(--color-base-300);
  --color-primary-strong: var(--color-base-500);
  --color-secondary: var(--color-base-200);
  --color-accent: var(--color-base-400);
  --color-highlight: var(--color-base-150);
  --color-text: var(--color-base-600);
  --color-text-strong: var(--color-base-850);
  --color-muted: var(--color-base-500);
  --color-border: var(--color-base-950);
  --color-border-light: rgba(47, 29, 31, 0.08);
  --color-success: #3a8f6b;
  --color-warning: #f2b04a;
  --color-danger: #c94848;

  /* Widget foundation: shell -> strip -> content -> card -> group -> control */
  --widget-shell-bg: var(--color-base-25);
  --widget-shell-border-color: rgba(47, 29, 31, 0.06);
  --widget-shell-shadow: 0 24px 48px rgba(92, 75, 75, 0.12);

  --widget-strip-bg: linear-gradient(135deg, var(--color-base-700) 0%, var(--color-base-600) 100%);
  --widget-strip-divider-color: rgba(255, 255, 255, 0.12);
  --widget-strip-highlight: radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 34%);
  --widget-strip-text: var(--color-base-0);
  --widget-strip-meta: rgba(255, 255, 255, 0.82);

  --widget-content-bg: linear-gradient(180deg, var(--color-base-25) 0%, var(--color-base-50) 100%);

  --widget-avatar-bg: rgba(255, 255, 255, 0.68);
  --widget-avatar-border-color: rgba(255, 255, 255, 0.72);
  --widget-avatar-shadow: 0 14px 28px rgba(92, 75, 75, 0.18);
  --widget-avatar-filter: blur(12px);

  --widget-card-bg: rgba(255, 255, 255, 0.58);
  --widget-card-border-color: rgba(255, 255, 255, 0.62);
  --widget-card-shadow: 0 18px 34px rgba(92, 75, 75, 0.1);
  --widget-card-filter: blur(14px);

  --widget-group-bg: rgba(255, 255, 255, 0.46);
  --widget-group-border-color: rgba(255, 255, 255, 0.6);
  --widget-group-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 10px 22px rgba(92, 75, 75, 0.08);
  --widget-group-filter: blur(12px);

  --widget-control-bg: rgba(255, 255, 255, 0.56);
  --widget-control-border-color: rgba(255, 255, 255, 0.72);
  --widget-control-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 8px 18px rgba(92, 75, 75, 0.08);
  --widget-control-filter: blur(12px);
  --widget-control-button-border-color: rgba(47, 29, 31, 0.2);
  --widget-control-button-shadow: 3px 3px 0 var(--widget-control-button-border-color);
  --widget-control-button-filter: none;

  --widget-title-color: var(--color-base-850);
  --widget-copy-color: var(--color-base-850);
  --widget-meta-color: var(--color-base-600);
  --widget-icon-color: var(--color-base-850);
  --widget-accent-color: var(--color-base-700);

  /* Modal foundation aligned with the widget system */
  --modal-overlay-bg: rgba(47, 29, 31, 0.26);
  --modal-shell-bg: var(--widget-shell-bg);
  --modal-shell-border-color: var(--widget-shell-border-color);
  --modal-shell-shadow: var(--widget-shell-shadow);
  --modal-strip-bg: var(--widget-strip-bg);
  --modal-strip-divider-color: var(--widget-strip-divider-color);
  --modal-strip-highlight: var(--widget-strip-highlight);
  --modal-strip-text: var(--widget-strip-text);
  --modal-content-bg: var(--widget-content-bg);
  --modal-group-bg: var(--widget-group-bg);
  --modal-group-border-color: var(--widget-group-border-color);
  --modal-group-shadow: var(--widget-group-shadow);
  --modal-control-bg: var(--widget-control-bg);
  --modal-control-border-color: var(--widget-control-border-color);
  --modal-control-shadow: var(--widget-control-shadow);
  --modal-control-button-border-color: var(--widget-control-button-border-color);
  --modal-control-button-shadow: var(--widget-control-button-shadow);
  --modal-title-color: var(--widget-title-color);
  --modal-copy-color: var(--widget-copy-color);
  --modal-meta-color: var(--widget-meta-color);

  /* Typography */
  --font-heading: 'Arial Rounded MT Bold', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; /* Schriftart 1: Arial Rounded MT Bold */
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica', Arial, sans-serif; /* Schriftart 2: IBM Plex Sans */
  /* Compatibility aliases: these still resolve to the two canonical fonts above. */
  --font-display: var(--font-heading);
  --font-ui: var(--font-body);
  --font-meta: var(--font-body);
  --fs-h0: 2.5rem;      /* 40px */
  --fs-h1: 2rem;        /* 32px */
  --fs-h2: 1.5rem;      /* 24px */
  --fs-h3: 1.25rem;     /* 20px */
  --fs-h4: 1rem;        /* 16px */
  --fs-body-l: 1.25rem; /* 20px */
  --fs-body-m: 1rem;    /* 16px */
  --fs-body-s: 0.75rem; /* 12px */
  --fs-caption: 0.75rem;/* 12px */
  --fs-link: 1rem;      /* 16px */
  --lh-tight: 1.2;
  --lh-normal: 1.3;
  --lh-loose: 1.45;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --font-size-base: 16px;
  --line-height-base: 1.4;

  /* Radii */
  --radius-pill: 999px;
  --radius-lg: 1.75rem;
  --radius-md: 1.25rem;
  --radius-sm: 0.75rem;

  /* Shadows */
  --shadow-xs: 1px 1px 0 rgba(0, 0, 0, 0.4);
  --shadow-sm: 2px 2px 0 #000;
  --shadow-md: 4px 4px 0 #000;
  --shadow-lg: 8px 8px 0 rgba(0, 0, 0, 0.25);

  /* Spacing scale */
  --space-2: 0.125rem;
  --space-4: 0.25rem;
  --space-6: 0.375rem;
  --space-8: 0.5rem;
  --space-10: 0.625rem;
  --space-12: 0.75rem;
  --space-14: 0.875rem;
  --space-16: 1rem;
  --space-18: 1.125rem;
  --space-20: 1.25rem;
  --space-24: 1.5rem;
  --space-32: 2rem;
  --space-40: 2.5rem;
  --space-48: 3rem;

  /* Global spacing primitives for the Matryoshka / Null-Contact system */
  --ui-null-contact-gap: var(--space-8);
  --ui-group-gap: var(--space-12);
  --ui-stack-gap: var(--space-16);
  --ui-group-inset: var(--space-14);
  --ui-group-compact-inset: var(--space-12);
  --ui-panel-inset: var(--space-16);
  --ui-card-inset: var(--space-20);
  --ui-label-inset-inline: var(--space-4);
  --ui-control-inset-y: var(--space-12);
  --ui-control-inset-x: var(--space-20);
  --ui-control-min-block-size: 2.75rem;
  --ui-layer-gap: var(--space-12);
  --ui-shadow-clearance: var(--space-8);
  --ui-select-adornment-divider-color: rgba(47, 29, 31, 0.08);
  --ui-select-adornment-divider-offset-inline: 2.45rem;
  --ui-select-adornment-chevron-offset-inline: 1.1rem;
  --ui-inline-divider-color: rgba(47, 29, 31, 0.08);
  --ui-inline-action-min-inline-size: 2rem;
  --ui-inline-action-pad-inline-start: var(--space-12);
  --ui-inline-action-hover-bg: rgba(47, 29, 31, 0.04);

  /* Layout */
  --container-max: 1200px;
  --transition-base: 0.18s ease;
}

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

html {
  font-size: var(--font-size-base);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: var(--fs-body-m);
  line-height: var(--lh-loose);
  background: var(--color-bg);
  color: var(--color-text);
  text-transform: lowercase;
  overflow-wrap: anywhere;
  word-break: normal;
}

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

:where(h1, h2, h3, h4, h5, h6, p, li, dt, dd, figcaption, blockquote, label, legend, span, strong, small, a, button, .btn, .input, .textarea, .select) {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
}

:where(.ui-panel, .ui-card, .ui-group, .card, .panel, .modal, .modal-dialog, .modal-content, .modal-shell, .btn, .chip, .badge, .pill, .tag, ul, ol, dl, li) {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
}

:where(pre, code, kbd, samp) {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

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

a:hover {
  text-decoration: underline;
}

h1,
.h1 {
  font-family: var(--font-heading);
  font-size: var(--fs-h1);
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  margin: 0;
}

h2,
.h2 {
  font-family: var(--font-heading);
  font-size: var(--fs-h2);
  line-height: var(--lh-normal);
  font-weight: var(--fw-semibold);
  margin: 0;
}

h3,
.h3 {
  font-family: var(--font-heading);
  font-size: var(--fs-h3);
  line-height: var(--lh-normal);
  font-weight: var(--fw-semibold);
  margin: 0;
}

h4,
.h4 {
  font-family: var(--font-ui);
  font-size: var(--fs-h4);
  line-height: var(--lh-normal);
  font-weight: var(--fw-semibold);
  margin: 0;
}

p,
.body-lg,
.body-md,
.body-sm,
.text-large,
.text-medium,
.text-small,
.hyperlink {
  font-family: var(--font-ui);
  margin: 0;
}

.body-lg,
.text-large {
  font-size: var(--fs-body-l);
  line-height: var(--lh-loose);
  font-weight: var(--fw-regular);
}

p,
.body-md,
.text-medium {
  font-size: var(--fs-body-m);
  line-height: var(--lh-loose);
  font-weight: var(--fw-regular);
}

.body-sm,
.text-small {
  font-size: var(--fs-body-s);
  line-height: var(--lh-loose);
  font-weight: var(--fw-regular);
}

.h0 {
  font-family: var(--font-heading);
  font-size: var(--fs-h0);
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
}

.button-text {
  font-family: var(--font-ui);
  font-size: var(--fs-body-m);
  line-height: var(--lh-tight);
  font-weight: var(--fw-semibold);
}

small,
.caption {
  font-family: var(--font-ui);
  font-size: var(--fs-caption);
  line-height: var(--lh-normal);
  font-weight: var(--fw-regular);
}

a,
.hyperlink {
  font-family: var(--font-ui);
  font-size: var(--fs-link);
  font-weight: var(--fw-semibold);
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

button,
input,
select,
textarea {
  font-family: var(--font-ui);
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ------------------------- UI SPACING PRIMITIVES ------------------------- */
.ui-stack {
  display: flex;
  flex-direction: column;
  gap: var(--ui-stack-gap);
}

.ui-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-group-gap);
}

.ui-flow {
  display: flex;
  flex-direction: column;
  gap: var(--ui-group-gap);
}

.ui-panel {
  padding: var(--ui-panel-inset);
  border-radius: var(--radius-lg);
}

.ui-card {
  padding: var(--ui-card-inset);
  border-radius: var(--radius-lg);
}

.ui-group {
  padding: var(--ui-group-inset);
  border-radius: var(--radius-md);
}

.ui-section-label {
  padding-inline: var(--ui-label-inset-inline);
}

.ui-control-shell {
  padding: var(--ui-control-inset-y) var(--ui-control-inset-x);
  border-radius: var(--radius-pill);
  min-block-size: var(--ui-control-min-block-size);
}

.ui-control-surface {
  padding: var(--ui-control-inset-y) var(--ui-control-inset-x);
  border-radius: var(--radius-pill);
  min-block-size: var(--ui-control-min-block-size);
}

.ui-inline-control-row {
  display: flex;
  align-items: center;
  gap: var(--ui-group-gap);
  padding: var(--ui-control-inset-y) var(--ui-control-inset-x);
  border-radius: var(--radius-pill);
  min-block-size: var(--ui-control-min-block-size);
}

.ui-inline-control__leading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--color-muted);
}

.ui-inline-control__input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-height: 0;
  padding: 0;
}

.ui-inline-control__input:focus {
  outline: none;
  border: none;
  box-shadow: none;
}

.ui-inline-control__action {
  margin-left: auto;
  align-self: stretch;
  width: auto;
  min-width: var(--ui-inline-action-min-inline-size);
  padding: 0 0 0 var(--ui-inline-action-pad-inline-start);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-left: 1px solid var(--ui-inline-divider-color);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--color-muted);
}

.ui-inline-control__action:hover,
.ui-inline-control__action:focus-visible {
  background: var(--ui-inline-action-hover-bg);
  color: var(--color-text-strong);
  outline: none;
}

.ui-stack > * + *,
.ui-panel > * + *,
.ui-card > * + *,
.ui-group > * + * {
  margin-top: var(--ui-null-contact-gap);
}

ul,
ol {
  padding: 0;
  margin: 0;
  list-style: none;
}

/* ------------------------------ LAYOUT PRIMS ------------------------------ */
.app-shell {
  min-height: 100vh;
  background: var(--color-bg);
  padding: clamp(var(--space-16), 5vw, var(--space-32));
}

.page-wrapper {
  width: 100%;
  margin: 0;
  padding: 0 clamp(var(--space-24), 6vw, var(--space-48));
  display: flex;
  flex-direction: column;
  gap: var(--space-24);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-12);
  align-items: center;
}

.grid {
  display: grid;
  gap: var(--space-16);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.app-card-grid {
  display: grid;
  gap: var(--space-20);
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-12);
}

.section-title,
.section-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-4) var(--space-16);
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-border);
  background: var(--color-highlight);
  color: var(--color-text-strong);
  text-transform: lowercase;
  font-family: var(--font-ui);
  font-size: var(--fs-body-m);
  font-weight: var(--fw-semibold);
}

/* -------------------------------- CARDS ---------------------------------- */
.card {
  background: var(--color-surface);
  border: 3px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-24);
}

.card--compact {
  padding: var(--space-16);
}

.card header h2 {
  margin: 0;
  color: var(--color-text-strong);
}

.card .muted {
  color: var(--color-muted);
}

/* -------------------------------- BUTTONS -------------------------------- */
/* -------------------------------- BUTTONS -------------------------------- */

.btn {
  --btn-bg: var(--color-surface);
  --btn-bg-hover: var(--color-highlight);
  --btn-bg-active: var(--color-highlight);
  --btn-color: var(--color-text-strong);
  --btn-border: var(--color-border);
  --btn-min-height: calc(var(--fs-body-m) * var(--lh-tight) + (var(--space-12) * 2));
  --btn-pad-y: var(--space-12);
  --btn-pad-x: var(--space-20);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  padding: var(--btn-pad-y) var(--btn-pad-x);
  border-radius: var(--radius-pill);
  border: 1px solid var(--btn-border);
  font-family: var(--font-ui);
  font-size: var(--fs-body-m);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  background: var(--btn-bg);
  color: var(--btn-color);
  cursor: pointer;
  min-height: var(--btn-min-height);
  min-width: 0;
  max-width: 100%;
  width: auto;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: background var(--transition-base), color var(--transition-base), transform var(--transition-base), border-color var(--transition-base);
}

.btn:not(.btn-block):not(.btn-icon) {
  width: auto !important;
  max-width: 100%;
}

.btn:hover:not([disabled]):not(.is-loading) {
  transform: scale(1.02);
}

.btn:active:not([disabled]):not(.is-loading) {
  transform: scale(1);
}

.btn[disabled],
.btn[aria-disabled='true'],
.btn.is-loading {
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  background: #e9dedf;
  color: #7f7474;
  border-color: #cdbcbc;
}



.btn-primary {
  --btn-bg: #ad9999;
  --btn-bg-hover: #ad9999;
  --btn-bg-active: #ad9999;
  --btn-color: #fff;
  --btn-border: #918181;
}

.btn-secondary {
  --btn-bg: #f2e7ea;
  --btn-bg-hover: #f2e7ea;
  --btn-bg-active: #f2e7ea;
  --btn-color: var(--color-text-strong);
  --btn-border: #918181;
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-bg-hover: transparent;
  --btn-bg-active: transparent;
  --btn-color: var(--color-text-strong);
  --btn-border: #918181;
}

.btn-plain {
  border-color: transparent;
  box-shadow: none;
  background: none;
  padding-inline: 0;
}

.btn-pill {
  border-radius: var(--radius-pill);
}

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 50%;
  min-height: 0;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  --btn-pad-y: var(--space-12);
  --btn-pad-x: var(--space-20);
  padding: var(--btn-pad-y) var(--btn-pad-x);
  font-size: var(--fs-body-s);
  min-height: var(--btn-min-height);
}

/* -------------------------------- FORMS ---------------------------------- */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  font-size: var(--fs-body-m);
  color: var(--color-text-strong);
  text-transform: lowercase;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: var(--space-12) var(--space-20);
  font-size: var(--fs-body-m);
  line-height: var(--lh-normal);
  background: var(--color-surface);
  box-shadow: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  text-transform: lowercase;
}

.textarea {
  border-radius: var(--radius-lg);
  min-height: 110px;
  resize: vertical;
}

.select {
  cursor: pointer;
  border-color: rgba(47, 29, 31, 0.14);
}

@supports selector(.form-field:has(> .select)) {
  .form-field:has(> .select),
  .ui-select-field {
    --ui-select-control-height: 46.2px;
    position: relative;
  }

  .ui-select-field {
    width: fit-content;
    max-width: 100%;
  }

  .form-field:has(> .select--compact),
  .ui-select-field:has(> .select--compact) {
    --ui-select-control-height: 44px;
  }

  .form-field:has(> .select) > .select,
  .ui-select-field > .select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: auto;
    max-width: 100%;
    min-height: var(--ui-select-control-height);
    padding-right: 3.65rem;
    background-image:
      linear-gradient(var(--ui-select-adornment-divider-color), var(--ui-select-adornment-divider-color)),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9' fill='none'%3E%3Cpath d='M1 1.5L7 7.5L13 1.5' stroke='%232F1D1F' stroke-opacity='0.58' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-position:
      right var(--ui-select-adornment-divider-offset-inline) center,
      right var(--ui-select-adornment-chevron-offset-inline) center;
    background-size:
      1px 1.2rem,
      0.82rem 0.56rem;
    background-repeat: no-repeat;
  }

  .form-field:has(> .select)::before,
  .form-field:has(> .select)::after,
  .ui-select-field::before,
  .ui-select-field::after {
    content: none;
    position: absolute;
    pointer-events: none;
  }

  .form-field:has(> .select)::before,
  .ui-select-field::before {
    right: var(--ui-select-adornment-divider-offset-inline);
    bottom: calc((var(--ui-select-control-height) - 1.2rem) / 2);
    width: 1px;
    height: 1.2rem;
    background: var(--ui-select-adornment-divider-color);
  }

  .form-field:has(> .select)::after,
  .ui-select-field::after {
    right: var(--ui-select-adornment-chevron-offset-inline);
    bottom: calc((var(--ui-select-control-height) - 0.56rem) / 2);
    width: 0.82rem;
    height: 0.56rem;
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9' fill='none'%3E%3Cpath d='M1 1.5L7 7.5L13 1.5' stroke='%232F1D1F' stroke-opacity='0.58' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
      center / contain no-repeat;
  }
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(201, 152, 167, 0.35);
}

input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  display: inline-grid;
  place-content: center;
  flex: 0 0 1.25rem;
  border: 2px solid #000;
  border-radius: 0.35rem;
  background: #fff;
  cursor: pointer;
  transition: background-color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}

input[type='checkbox']::after {
  content: '';
  width: 0.72rem;
  height: 0.72rem;
  transform: scale(0);
  transition: transform var(--transition-base);
  background: #000;
  clip-path: polygon(14% 44%, 0 59%, 42% 100%, 100% 20%, 84% 6%, 42% 68%);
}

input[type='checkbox']:checked::after {
  transform: scale(1);
}

input[type='checkbox']:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.28);
  outline-offset: 2px;
}

input[type='checkbox']:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --------------------------- DISPLAY OPTIONS ---------------------------- */
.display-options {
  display: grid;
  gap: var(--space-12);
}

.display-options__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
}

.display-options__title {
  margin: 0;
  font-size: var(--fs-body-m);
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  color: var(--widget-title-color, var(--color-text-strong));
  letter-spacing: 0;
  text-transform: lowercase;
}

.display-options__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-12) var(--space-16);
  margin: 0;
  padding: var(--ui-group-inset);
  border-radius: var(--radius-lg);
  border: 1px solid var(--widget-group-border-color);
  background: var(--widget-group-bg);
  box-shadow: var(--widget-group-shadow);
  min-width: 0;
  max-width: 100%;
}

.display-options__controls .checkbox {
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--widget-copy-color, var(--color-text-strong));
  line-height: var(--lh-tight);
}

.display-options__controls[hidden] {
  display: none !important;
}

/* -------------------------------- BADGES --------------------------------- */
.badge,
.tag,
.pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-4) var(--space-12);
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-border);
  font-family: var(--font-ui);
  font-size: var(--fs-body-m);
  font-weight: var(--fw-semibold);
  background: var(--color-surface);
  color: var(--color-text-strong);
  box-shadow: var(--shadow-xs);
}

.chip {
  min-width: 0;
  max-width: 100%;
  border-width: 1px;
  border-color: var(--widget-control-border-color);
  border-radius: var(--radius-lg);
  background: var(--widget-control-bg);
  box-shadow: var(--widget-control-shadow);
  overflow-wrap: anywhere;
}

.badge--muted {
  background: var(--color-highlight);
}

/* --------------------------------- TABS ---------------------------------- */
.tab-list {
  display: inline-flex;
  gap: var(--space-8);
  padding: var(--space-8);
  background: var(--color-surface);
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-border);
}

.tab {
  border-radius: var(--radius-pill);
  padding: var(--space-8) var(--space-20);
  font-family: var(--font-ui);
  font-size: var(--fs-body-m);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  background: transparent;
}

.tab.is-active {
  background: var(--color-primary);
  color: #fff;
}

/* --------------------------------- MODAL --------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-24);
  z-index: 2000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--modal-shell-bg);
  border: 1px solid var(--modal-shell-border-color);
  border-radius: calc(var(--radius-lg) + 6px);
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: hidden;
  padding: 0;
  box-shadow: var(--modal-shell-shadow);
}

.modal-content > form {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.modal-content--wide {
  width: min(1100px, 100%);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 20;
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-20) var(--space-24);
  background: var(--modal-strip-bg);
  border-bottom: 1px solid var(--modal-strip-divider-color);
  color: var(--modal-strip-text);
}

.modal-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--modal-strip-highlight);
  pointer-events: none;
}

.modal-header > * {
  position: relative;
  z-index: 1;
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--fs-h3);
  line-height: 1;
  font-weight: var(--fw-bold);
  text-transform: lowercase;
  color: inherit;
}

.modal-header-actions,
.modal-actions {
  display: flex;
  gap: var(--space-10);
  align-items: center;
  flex-wrap: wrap;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--modal-content-bg);
  padding: var(--space-20) var(--space-24) var(--space-24);
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  overflow: auto;
  color: var(--modal-copy-color);
}

.modal-content > .modal-actions,
.modal-content > form > .modal-actions {
  flex: 0 0 auto;
  padding: var(--space-16) var(--space-24) var(--space-20);
  background: var(--modal-content-bg);
  border-top: 1px solid var(--modal-strip-divider-color);
}

.modal-content :is(.input, .textarea, .select) {
  border: 1px solid var(--modal-control-border-color);
  background: var(--modal-control-bg);
  box-shadow: var(--modal-control-shadow);
}

.modal-content :is(.input, .textarea, .select):focus {
  box-shadow:
    var(--modal-control-shadow),
    0 0 0 3px rgba(201, 152, 167, 0.24);
}

.modal-content .btn-ghost.btn-icon,
.modal-content .close-modal {
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(47, 29, 31, 0.14);
  box-shadow: 0 10px 24px rgba(47, 29, 31, 0.12);
  color: var(--modal-copy-color);
}

.help-modal-template {
  --help-modal-width: 520px;
  --help-modal-content-width: 34ch;
  width: min(var(--help-modal-width), 92vw) !important;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.help-modal-template .help-modal-template__body,
.help-modal-template .modal-header,
.help-modal-template .modal-body {
  width: min(var(--help-modal-content-width), 100%);
  max-width: 100%;
}

.help-modal-template .help-modal-template__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  padding: var(--space-24);
  background: var(--modal-content-bg);
  color: var(--modal-copy-color);
}

.help-modal-template .help-modal-template__body > h3,
.help-modal-template .help-modal-template__body > p {
  margin: 0;
}

.help-modal-template .modal-actions,
.help-modal-template .classroom-entry-warning-actions {
  justify-content: flex-end;
}

/* -------------------------------- UTILITIES ------------------------------ */
.text-center { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--color-muted); }
.text-strong  { color: var(--color-text-strong); }

.mt-8  { margin-top: var(--space-8); }
.mt-16 { margin-top: var(--space-16); }
.mt-24 { margin-top: var(--space-24); }
.mt-32 { margin-top: var(--space-32); }

.mb-8  { margin-bottom: var(--space-8); }
.mb-16 { margin-bottom: var(--space-16); }
.mb-24 { margin-bottom: var(--space-24); }
.mb-32 { margin-bottom: var(--space-32); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { justify-content: center; align-items: center; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-8 { gap: var(--space-8); }
.gap-12 { gap: var(--space-12); }
.gap-16 { gap: var(--space-16); }
.gap-24 { gap: var(--space-24); }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* Landing layout */
.landing-page {
  background: #f8f4f3;
  color: var(--color-text-strong);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem clamp(1rem, 4vw, 4rem);
  
  background: #fff;
  
  top: 0;
  z-index: 2;
}

.site-header .logo {
  font-weight: 700;
  text-transform: lowercase;
  font-size: var(--fs-h3);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--color-text-muted);
  text-transform: lowercase;
}

.site-actions {
  display: flex;
  gap: 0.75rem;
}

.landing-content {
  flex: 1;
  padding: 3rem clamp(1rem, 8vw, 8rem);
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.landing-content--minimal {
  justify-content: center;
  padding: clamp(2rem, 8vw, 6rem);
}

.landing-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(var(--space-24), 5vw, var(--space-48));
  align-items: center;
}

.landing-hero__title {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.landing-hero__features {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.hero-mark {
  font-family: var(--font-heading);
  font-size: var(--fs-h0);
  line-height: var(--lh-tight);
  text-transform: lowercase;
  margin: 0;
  color: var(--color-text-strong);
}

.hero-subtitle {
  font-family: var(--font-ui);
  font-size: var(--fs-body-l);
  margin: 0;
  color: var(--color-text);
}

.feature-pill {
  border: 2px solid #918181;
  border-radius: var(--radius-pill);
  padding: var(--space-16) var(--space-20);
  font-family: var(--font-ui);
  font-size: var(--fs-body-m);
  text-transform: lowercase;
  background: #fff;
  color: var(--color-text-strong);
  display: flex;
  align-items: center;
  gap: var(--space-12);
}

.feature-pill__icon {
  width: clamp(32px, 5vw, 54px);
  height: clamp(32px, 5vw, 54px);
  object-fit: contain;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  align-items: center;
}

.hero-copy h1 {
  font-size: var(--fs-h1);
  margin: 0.4rem 0;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-preview .preview-card {
  border: 2px solid var(--color-border);
  border-radius: 1.5rem;
  padding: 2rem;
  background: #fff;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.1);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  border: 2px solid var(--color-border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  background: #fff;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.08);
}

.planner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  align-items: center;
}

.planner-visual {
  border: 2px dashed var(--color-border);
  border-radius: 1.5rem;
  padding: 2rem;
  text-align: center;
  font-size: var(--fs-h1);
  background: #fff;
}

.site-footer {
  padding: 1rem;
  text-align: center;
  border-top: none;
  background: #fff;
}

.auth-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.auth-modal.hidden {
  display: none;
}

.auth-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.auth-modal__card {
  position: relative;
  width: min(420px, 90vw);
  background: #fff;
  padding: 2rem;
  border-radius: 1.5rem;
  border: 3px solid var(--color-border);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.15);
  z-index: 6;
}

.auth-modal .close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.section-divider {
  height: 2px;
  width: 100%;
  background: var(--color-border-light);
}

.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;
}

@media (max-width: 600px) {
  .site-header {
    flex-wrap: wrap;
    gap: var(--space-12);
    padding: var(--space-16) var(--space-12);
  }

  .site-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8);
  }

  .site-nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    text-align: center;
    overflow-wrap: normal;
    word-break: keep-all;
  }

  .landing-content {
    padding: var(--space-24) var(--space-12);
    gap: var(--space-24);
  }

  .landing-content .feature-card {
    padding: var(--space-20);
  }

  .app-shell {
    padding: var(--space-16);
  }

  .card {
    padding: var(--space-16);
  }

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