/*!
 * Mailqory design system
 * Structure follows Apple's Human Interface Guidelines (clarity, deference, depth):
 * system UI font, 8pt grid, large titles, inset grouped lists, sidebar app shell,
 * 44px hit targets, light/dark appearance, reduced motion, visible focus.
 * Colours come from the Mailqory brand palette.
 */

/* ---------- Brand font (headlines only) ---------- */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/space-grotesk-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/space-grotesk-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/space-grotesk-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/space-grotesk-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

  /* Brand */
  --mq-red: #E23B2E;
  --mq-red-strong: #C8301F;
  --mq-ink: #14161C;
  --mq-grey: #6B7079;
  --mq-paper: #F4F4F6;

  /* Semantic (light) */
  --bg: #F4F4F6;                 /* grouped background */
  --bg-elevated: #FFFFFF;        /* cards, lists, sheets */
  --bg-secondary: #F9F9FB;
  --label: #14161C;
  --label-2: #5E636C;            /* secondary text, AA on white and paper */
  --label-3: #8A8F98;            /* placeholders, decorative only */
  --separator: rgba(20, 22, 28, 0.12);
  --separator-strong: rgba(20, 22, 28, 0.2);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --tint: #C8301F;               /* buttons, links (AA with white) */
  --tint-brand: #E23B2E;         /* logo, large accents */
  --tint-on: #FFFFFF;
  --tint-soft: rgba(226, 59, 46, 0.1);
  --tint-soft-strong: rgba(226, 59, 46, 0.18);
  --success: #1E7F45;
  --success-soft: rgba(30, 127, 69, 0.12);
  --warning: #9A5B00;
  --warning-soft: rgba(214, 135, 0, 0.14);
  --info: #1F5FBF;
  --info-soft: rgba(31, 95, 191, 0.12);
  --focus-ring: 0 0 0 3px rgba(226, 59, 46, 0.45);
  --material: rgba(255, 255, 255, 0.72);
  --shadow-1: 0 1px 2px rgba(20, 22, 28, 0.06), 0 1px 1px rgba(20, 22, 28, 0.04);
  --shadow-2: 0 8px 24px rgba(20, 22, 28, 0.08), 0 2px 6px rgba(20, 22, 28, 0.05);
  --shadow-3: 0 24px 64px rgba(20, 22, 28, 0.18), 0 4px 16px rgba(20, 22, 28, 0.08);

  /* Type */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-brand: "Space Grotesk", var(--font-ui);
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* 8pt grid */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 22px;
  --r-pill: 999px;

  --hit: 44px;
  --sidebar-w: 264px;
  --content-max: 1080px;

  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --t-fast: 150ms;
  --t-med: 250ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0C0F;
    --bg-elevated: #1A1C22;
    --bg-secondary: #23262D;
    --label: #F4F4F6;
    --label-2: #A6ABB4;
    --label-3: #7A7F88;
    --separator: rgba(244, 244, 246, 0.12);
    --separator-strong: rgba(244, 244, 246, 0.2);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --tint: #FF5A4C;
    --tint-brand: #FF5A4C;
    --tint-on: #14161C;          /* ink on light red keeps AA */
    --tint-soft: rgba(255, 90, 76, 0.16);
    --tint-soft-strong: rgba(255, 90, 76, 0.26);
    --success: #4CD383;
    --success-soft: rgba(76, 211, 131, 0.16);
    --warning: #FFB340;
    --warning-soft: rgba(255, 179, 64, 0.16);
    --info: #6AA8FF;
    --info-soft: rgba(106, 168, 255, 0.16);
    --focus-ring: 0 0 0 3px rgba(255, 90, 76, 0.55);
    --material: rgba(26, 28, 34, 0.72);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-3: 0 24px 64px rgba(0, 0, 0, 0.6);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
  color: var(--label);
  background: var(--bg);
}

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

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

a { color: var(--tint); text-decoration: none; text-underline-offset: 0.18em; }
a:hover { text-decoration: underline; }

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

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

::selection { background: var(--tint-soft-strong); }

[hidden] { display: none !important; }

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

.mq-skip-link {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  z-index: 1000;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--label);
  box-shadow: var(--shadow-2);
  transform: translateY(-200%);
}
.mq-skip-link:focus-visible { transform: none; }

.mq-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mq-icon--sm { width: 16px; height: 16px; }
.mq-icon--lg { width: 28px; height: 28px; }

/* ---------- Typography (HIG text styles) ---------- */
.mq-large-title { font-size: 34px; line-height: 1.2; font-weight: 700; letter-spacing: -0.022em; }
.mq-title-1 { font-size: 28px; line-height: 1.21; font-weight: 700; letter-spacing: -0.02em; }
.mq-title-2 { font-size: 22px; line-height: 1.27; font-weight: 700; letter-spacing: -0.017em; }
.mq-title-3 { font-size: 20px; line-height: 1.25; font-weight: 600; letter-spacing: -0.015em; }
.mq-headline { font-size: 17px; line-height: 1.29; font-weight: 600; }
.mq-body { font-size: 17px; line-height: 1.47; }
.mq-callout { font-size: 16px; line-height: 1.38; }
.mq-subheadline { font-size: 15px; line-height: 1.33; }
.mq-footnote { font-size: 13px; line-height: 1.38; letter-spacing: -0.006em; }
.mq-caption { font-size: 12px; line-height: 1.33; letter-spacing: 0; }
.mq-brand-type { font-family: var(--font-brand); letter-spacing: -0.03em; }
.mq-secondary { color: var(--label-2); }
.mq-mono { font-family: var(--font-mono); font-size: 0.88em; }

.mq-display {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

/* ---------- Layout primitives ---------- */
.mq-container { width: 100%; max-width: var(--content-max); margin-inline: auto; padding-inline: var(--s-5); }
@media (min-width: 768px) { .mq-container { padding-inline: var(--s-8); } }

.mq-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.mq-stack--sm { gap: var(--s-2); }
.mq-stack--lg { gap: var(--s-8); }
.mq-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.mq-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }

/* ---------- Top bar (translucent material) ---------- */
.mq-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}
.mq-topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: 56px; }
.mq-topbar__brand { display: inline-flex; align-items: center; border-radius: var(--r-sm); }
.mq-topbar__brand:hover { text-decoration: none; }
.mq-logo { height: 26px; width: auto; }
.mq-logo--lg { height: 40px; }
.mq-topbar__actions { display: flex; align-items: center; gap: var(--s-2); }

/* Logo swaps for appearance */
.mq-logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .mq-logo-light { display: none; }
  .mq-logo-dark { display: block; }
}

/* ---------- Footer ---------- */
.mq-footer { padding-block: var(--s-8); border-top: 1px solid var(--separator); color: var(--label-2); }
.mq-footer__inner { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: center; justify-content: space-between; }

/* ---------- Language switcher ---------- */
.mq-lang { display: inline-flex; align-items: center; gap: var(--s-2); }
select.mq-select.mq-lang__select {
  width: auto;
  min-height: 32px;
  padding: 4px 32px 4px 12px;
  border-color: transparent;
  border-radius: var(--r-sm);
  background-color: var(--fill);
  background-position: right 10px center;
  font-size: 15px;
  font-weight: 500;
}
select.mq-select.mq-lang__select:hover { border-color: transparent; background-color: var(--fill-strong); }

/* ---------- Buttons ---------- */
.mq-btn {
  --btn-bg: var(--fill);
  --btn-fg: var(--tint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--hit);
  padding: 0 var(--s-5);
  border: 0;
  border-radius: var(--r-lg);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.mq-btn:hover { text-decoration: none; opacity: 0.88; }
.mq-btn:active { transform: scale(0.98); opacity: 0.75; }
.mq-btn:focus-visible { border-radius: var(--r-lg); }
.mq-btn[disabled], .mq-btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; transform: none; }

.mq-btn--filled { --btn-bg: var(--tint); --btn-fg: var(--tint-on); }
.mq-btn--tinted { --btn-bg: var(--tint-soft); --btn-fg: var(--tint); }
.mq-btn--gray { --btn-bg: var(--fill); --btn-fg: var(--label); }
.mq-btn--plain { --btn-bg: transparent; --btn-fg: var(--tint); padding-inline: var(--s-2); font-weight: 400; }
.mq-btn--destructive { --btn-bg: var(--tint-soft); --btn-fg: var(--tint); }
.mq-btn--small { min-height: 32px; padding-inline: var(--s-3); font-size: 15px; border-radius: var(--r-md); }
.mq-btn--large { min-height: 52px; padding-inline: var(--s-6); border-radius: var(--r-xl); }
.mq-btn--block { width: 100%; }
.mq-btn--icon { width: var(--hit); padding: 0; }
.mq-btn--small.mq-btn--icon { width: 32px; }

.mq-btn[aria-busy="true"] { pointer-events: none; }
.mq-btn[aria-busy="true"] .mq-btn__label { opacity: 0.5; }

/* ---------- Spinner (activity indicator) ---------- */
.mq-spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  opacity: 0.8;
  animation: mq-spin 0.8s linear infinite;
}
@keyframes mq-spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
.mq-field { display: flex; flex-direction: column; gap: 6px; }
.mq-label { font-size: 13px; font-weight: 600; color: var(--label-2); letter-spacing: 0; padding-inline: var(--s-1); }
.mq-help { font-size: 13px; color: var(--label-2); padding-inline: var(--s-1); }
.mq-error-text { font-size: 13px; color: var(--tint); padding-inline: var(--s-1); display: flex; gap: 6px; align-items: center; }

.mq-input, .mq-select, .mq-textarea {
  width: 100%;
  min-height: var(--hit);
  padding: 10px var(--s-3);
  border: 1px solid var(--separator-strong);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--label);
  font-size: 17px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.mq-input::placeholder, .mq-textarea::placeholder { color: var(--label-3); }
.mq-input:hover, .mq-select:hover, .mq-textarea:hover { border-color: var(--label-3); }
.mq-input:focus-visible, .mq-select:focus-visible, .mq-textarea:focus-visible { border-color: var(--tint); box-shadow: var(--focus-ring); border-radius: var(--r-md); }
.mq-input[aria-invalid="true"], .mq-textarea[aria-invalid="true"] { border-color: var(--tint); }
.mq-input:disabled, .mq-select:disabled, .mq-textarea:disabled { opacity: 0.5; cursor: not-allowed; }
.mq-textarea { min-height: 112px; resize: vertical; line-height: 1.4; }

.mq-select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238A8F98' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}

.mq-search { position: relative; }
.mq-search .mq-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--label-3); pointer-events: none; width: 18px; height: 18px; }
.mq-search .mq-input { padding-left: 36px; background: var(--fill); border-color: transparent; border-radius: var(--r-md); }
.mq-search .mq-input:focus-visible { background: var(--bg-elevated); }

/* Checkbox */
.mq-check { display: inline-flex; align-items: center; gap: var(--s-3); min-height: var(--hit); cursor: pointer; }
.mq-check input {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; margin: 0;
  border: 1.5px solid var(--separator-strong);
  border-radius: 6px;
  background: var(--bg-elevated);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.mq-check input::after {
  content: "";
  width: 6px; height: 11px;
  border: solid var(--tint-on);
  border-width: 0 2.2px 2.2px 0;
  transform: rotate(45deg) translate(-1px, -1px) scale(0);
  transition: transform var(--t-fast) var(--ease-spring);
}
.mq-check input:checked { background: var(--tint); border-color: var(--tint); }
.mq-check input:checked::after { transform: rotate(45deg) translate(-1px, -1px) scale(1); }
.mq-check input:focus-visible { box-shadow: var(--focus-ring); }

/* Switch (UISwitch) */
.mq-switch {
  appearance: none; -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 51px; height: 31px; margin: 0;
  border-radius: var(--r-pill);
  background: var(--fill-strong);
  cursor: pointer;
  transition: background-color var(--t-med) var(--ease);
}
.mq-switch::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 3px 1px rgba(0, 0, 0, 0.06);
  transition: transform var(--t-med) var(--ease-spring);
}
.mq-switch:checked { background: var(--success); }
.mq-switch:checked::before { transform: translateX(20px); }
.mq-switch:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-pill); }
.mq-switch:disabled { opacity: 0.4; cursor: not-allowed; }

/* Segmented control */
.mq-segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  border: 0;
  margin: 0;
  border-radius: var(--r-md);
  background: var(--fill);
  max-width: 100%;
  align-self: flex-start;
  justify-self: start;
}
.mq-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.mq-segmented label {
  display: flex; align-items: center; justify-content: center;
  min-height: 32px;
  padding: 0 var(--s-4);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--label);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.mq-segmented input:checked + label { background: var(--bg-elevated); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .mq-segmented input:checked + label { background: #5A5D66; } }
.mq-segmented input:focus-visible + label { box-shadow: var(--focus-ring); }

/* ---------- Cards & grouped lists ---------- */
.mq-card {
  background: var(--bg-elevated);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  box-shadow: var(--shadow-1);
}
.mq-card--flat { box-shadow: none; }
.mq-card--raised { box-shadow: var(--shadow-2); }

.mq-section { display: flex; flex-direction: column; gap: var(--s-2); }
.mq-section__header { padding-inline: var(--s-4); font-size: 13px; font-weight: 400; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.02em; }
.mq-section__footer { padding-inline: var(--s-4); font-size: 13px; color: var(--label-2); }

.mq-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.mq-list__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--hit);
  padding: 10px var(--s-4);
  color: var(--label);
}
a.mq-list__row:hover { text-decoration: none; background: var(--fill); }
a.mq-list__row:active { background: var(--fill-strong); }
a.mq-list__row:focus-visible { border-radius: 0; box-shadow: inset var(--focus-ring); }
.mq-list > li + li > .mq-list__row::before,
.mq-list > .mq-list__row + .mq-list__row::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--row-inset, var(--s-4));
  right: 0;
  border-top: 1px solid var(--separator);
}
.mq-list--icons { --row-inset: 60px; }
.mq-list__icon {
  width: 30px; height: 30px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--tint-brand);
  color: #FFFFFF;
}
.mq-list__icon .mq-icon { width: 18px; height: 18px; }
.mq-list__icon--ink { background: var(--mq-ink); }
.mq-list__icon--grey { background: var(--mq-grey); }
.mq-list__icon--green { background: #34A853; }
.mq-list__icon--blue { background: #2F7BEA; }
@media (prefers-color-scheme: dark) { .mq-list__icon--ink { background: #3A3D45; } }
.mq-list__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mq-list__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mq-list__subtitle { font-size: 13px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mq-list__detail { color: var(--label-2); flex: none; }
.mq-list__chevron { color: var(--label-3); flex: none; width: 14px; height: 14px; }

/* ---------- Badges ---------- */
.mq-badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; letter-spacing: 0;
  background: var(--fill); color: var(--label-2);
}
.mq-badge--tint { background: var(--tint-soft); color: var(--tint); }
.mq-badge--success { background: var(--success-soft); color: var(--success); }
.mq-badge--warning { background: var(--warning-soft); color: var(--warning); }
.mq-badge--info { background: var(--info-soft); color: var(--info); }
.mq-badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Banners (inline notices) ---------- */
.mq-banner {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-4);
  border-radius: var(--r-lg);
  background: var(--info-soft);
  color: var(--label);
}
.mq-banner .mq-icon { color: var(--info); margin-top: 2px; }
.mq-banner--success { background: var(--success-soft); }
.mq-banner--success .mq-icon { color: var(--success); }
.mq-banner--warning { background: var(--warning-soft); }
.mq-banner--warning .mq-icon { color: var(--warning); }
.mq-banner--error { background: var(--tint-soft); }
.mq-banner--error .mq-icon { color: var(--tint); }
.mq-banner__title { font-weight: 600; }

/* ---------- Progress ---------- */
.mq-progress {
  width: 100%; height: 6px;
  border: 0; border-radius: var(--r-pill);
  background: var(--fill);
  overflow: hidden;
  appearance: none; -webkit-appearance: none;
}
.mq-progress::-webkit-progress-bar { background: var(--fill); border-radius: var(--r-pill); }
.mq-progress::-webkit-progress-value { background: var(--tint); border-radius: var(--r-pill); }
.mq-progress::-moz-progress-bar { background: var(--tint); border-radius: var(--r-pill); }

/* ---------- Stat tiles (reporting) ---------- */
.mq-stat { background: var(--bg-elevated); border-radius: var(--r-xl); padding: var(--s-5); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: var(--s-1); }
.mq-stat__label { font-size: 13px; font-weight: 600; color: var(--label-2); }
.mq-stat__value { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.mq-stat__delta { font-size: 13px; font-weight: 600; color: var(--success); }
.mq-stat__delta--down { color: var(--tint); }

/* ---------- Empty state ---------- */
.mq-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3); padding: var(--s-12) var(--s-6); }
.mq-empty__icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--fill); color: var(--label-2); margin-bottom: var(--s-2); }
.mq-empty__icon .mq-icon { width: 30px; height: 30px; }
.mq-empty__text { max-width: 36ch; color: var(--label-2); }

/* ---------- Sheet / modal (native <dialog>) ---------- */
.mq-sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  padding: 0;
  border: 0;
  border-radius: var(--r-2xl);
  background: var(--bg-elevated);
  color: var(--label);
  box-shadow: var(--shadow-3);
  overflow: auto;
}
.mq-sheet::backdrop { background: rgba(0, 0, 0, 0.32); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.mq-sheet[open] { animation: mq-sheet-in var(--t-med) var(--ease-spring); }
.mq-sheet[open]::backdrop { animation: mq-fade-in var(--t-med) var(--ease); }
.mq-sheet__header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-4) var(--s-2) var(--s-6); }
.mq-sheet__body { padding: var(--s-2) var(--s-6) var(--s-4); display: flex; flex-direction: column; gap: var(--s-4); }
.mq-sheet__footer { display: flex; gap: var(--s-3); justify-content: flex-end; padding: var(--s-4) var(--s-6) var(--s-6); }
@keyframes mq-sheet-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes mq-fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 599px) {
  .mq-sheet {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mq-sheet__footer { flex-direction: column-reverse; }
  .mq-sheet__footer .mq-btn { width: 100%; }
}

/* ---------- Toasts ---------- */
.mq-toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--s-6) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.mq-toast {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-pill);
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow-2);
  font-size: 15px; font-weight: 500;
  pointer-events: auto;
  animation: mq-toast-in var(--t-med) var(--ease-spring);
}
.mq-toast .mq-icon { color: var(--success); }
.mq-toast--leaving { animation: mq-toast-out var(--t-fast) var(--ease) forwards; }
@keyframes mq-toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes mq-toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ---------- App shell (sidebar + content) ---------- */
.mq-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.mq-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-4) var(--s-3);
  background: var(--bg-secondary);
  border-right: 1px solid var(--separator);
  overflow-y: auto;
}
.mq-sidebar__brand { display: flex; align-items: center; padding: var(--s-2) var(--s-3) var(--s-3); }
.mq-sidebar__group { display: flex; flex-direction: column; gap: 2px; }
.mq-sidebar__heading { padding: var(--s-3) var(--s-3) var(--s-1); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--label-2); }
.mq-sidebar__item {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 36px;
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  color: var(--label);
  font-size: 15px;
}
.mq-sidebar__item .mq-icon { color: var(--tint); width: 18px; height: 18px; }
.mq-sidebar__item:hover { text-decoration: none; background: var(--fill); }
.mq-sidebar__item[aria-current="page"], .mq-sidebar__item[aria-current="true"] { background: var(--tint-soft); color: var(--tint); font-weight: 600; }
.mq-sidebar__footer { margin-top: auto; padding: var(--s-2) var(--s-3); }

.mq-main { min-width: 0; display: flex; flex-direction: column; }
.mq-main__bar { display: none; }
.mq-main__content { width: 100%; max-width: var(--content-max); margin-inline: auto; padding: var(--s-8) var(--s-8) var(--s-16); display: flex; flex-direction: column; gap: var(--s-8); }
.mq-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4); }
.mq-page-header__text { display: flex; flex-direction: column; gap: var(--s-1); }

.mq-scrim { display: none; }

@media (max-width: 899px) {
  .mq-shell { grid-template-columns: minmax(0, 1fr); }
  .mq-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 120;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-105%);
    transition: transform var(--t-med) var(--ease-spring);
    box-shadow: var(--shadow-3);
  }
  .mq-shell[data-sidebar="open"] .mq-sidebar { transform: none; }
  .mq-shell[data-sidebar="open"] .mq-scrim { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(0, 0, 0, 0.32); }
  .mq-main__bar {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
    position: sticky; top: 0; z-index: 50;
    min-height: 52px;
    padding: 0 var(--s-2);
    background: var(--material);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--separator);
  }
  .mq-main__content { padding: var(--s-5) var(--s-4) var(--s-12); gap: var(--s-6); }
}

/* ---------- Auth layout ---------- */
.mq-auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.mq-auth__card { width: min(420px, 100%); display: flex; flex-direction: column; gap: var(--s-6); }
.mq-auth__brand { display: flex; justify-content: center; }

/* ---------- Landing (home) ---------- */
.mq-hero { padding-block: var(--s-16) var(--s-12); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s-5); }
@media (min-width: 768px) { .mq-hero { padding-block: var(--s-20) var(--s-16); } }
.mq-hero__mark { width: 88px; height: 88px; filter: drop-shadow(0 12px 24px rgba(226, 59, 46, 0.28)); }
.mq-hero__slogan { max-width: 14ch; }
.mq-hero__slogan em { font-style: normal; color: var(--tint-brand); }
.mq-hero__lead { max-width: 40ch; font-size: clamp(19px, 2.2vw, 22px); line-height: 1.4; color: var(--label-2); letter-spacing: -0.015em; }
.mq-hero__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); margin-top: var(--s-2); }

.mq-features { padding-bottom: var(--s-16); }
.mq-feature { display: flex; flex-direction: column; gap: var(--s-3); }
.mq-feature__icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--tint-soft); color: var(--tint); }
.mq-feature__icon .mq-icon { width: 22px; height: 22px; }

/* ---------- Error pages ---------- */
.mq-error { min-height: calc(100vh - 160px); display: grid; place-items: center; padding: var(--s-12) var(--s-4); text-align: center; }
.mq-error__inner { display: flex; flex-direction: column; align-items: center; gap: var(--s-4); max-width: 480px; }
.mq-error__code { font-family: var(--font-brand); font-weight: 700; font-size: clamp(64px, 12vw, 112px); line-height: 1; letter-spacing: -0.05em; color: var(--tint-brand); }

/* ---------- Style guide helpers ---------- */
.mq-swatch { display: flex; flex-direction: column; gap: var(--s-2); }
.mq-swatch__chip { height: 64px; border-radius: var(--r-lg); border: 1px solid var(--separator); }
.mq-swatch__chip--red { background: #E23B2E; }
.mq-swatch__chip--red-strong { background: #C8301F; }
.mq-swatch__chip--red-dark { background: #FF5A4C; }
.mq-swatch__chip--ink { background: #14161C; }
.mq-swatch__chip--grey { background: #6B7079; }
.mq-swatch__chip--paper { background: #F4F4F6; }
.mq-type-sample { display: flex; flex-direction: column; gap: var(--s-3); }
.mq-type-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.mq-demo-stack { display: flex; flex-direction: column; gap: var(--s-5); }
.mq-spacing-row { display: flex; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap; }
.mq-spacing-row span { display: block; background: var(--tint-soft-strong); border-radius: 3px; }
.mq-spacing-row .s1 { width: 4px; height: 4px; }
.mq-spacing-row .s2 { width: 8px; height: 8px; }
.mq-spacing-row .s3 { width: 12px; height: 12px; }
.mq-spacing-row .s4 { width: 16px; height: 16px; }
.mq-spacing-row .s6 { width: 24px; height: 24px; }
.mq-spacing-row .s8 { width: 32px; height: 32px; }
.mq-spacing-row .s12 { width: 48px; height: 48px; }
.mq-spacing-row .s16 { width: 64px; height: 64px; }
.mq-grid--swatches { grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); }
.mq-toc { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ---------- Motion & accessibility preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
@media (prefers-contrast: more) {
  :root { --separator: rgba(20, 22, 28, 0.35); --separator-strong: rgba(20, 22, 28, 0.55); --label-2: #3E434B; }
}
@media (forced-colors: active) {
  .mq-btn, .mq-input, .mq-select, .mq-textarea, .mq-switch, .mq-card, .mq-list { border: 1px solid CanvasText; }
  :focus-visible { outline: 2px solid Highlight; }
}

@media print {
  .mq-topbar, .mq-sidebar, .mq-main__bar, .mq-toasts, .mq-footer { display: none !important; }
  body { background: #FFFFFF; color: #000000; }
}
