/* Mensch Creative Apps · shared UI · source: ~/CLAUDE/mensch-design (DESIGN.md is the law)
   Copy this file verbatim into each app. Do not edit it inside an app: change it here,
   then copy it again. App-specific rules and registered exceptions live in the app's own CSS.
   Components are prefixed mx- so they never collide with an app's older class names. */

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  accent-color: #3dd6c4;

  --bg: #0d0f11;
  --surface: #14171a;
  --surface-raised: #1c2025;
  --surface-hover: #22272d;
  --border: #272d34;
  --border-strong: #363e47;
  --border-input: #5f6975;
  --text: #e8eaed;
  --text-muted: #9aa3ad;
  --text-dim: #878f99;

  --accent: #3dd6c4;
  --accent-dim: #1f6f67;
  --accent-ink: #06110f;
  --accent-hover: color-mix(in srgb, var(--accent) 88%, #fff);

  --resolved: #4cc38a;
  --warn: #d9a441;
  --danger: #e5645a;
  --danger-ink: #1a0705;
  --highlight: #f2c14e;
  --suggest: #a98bff;

  --hue-sky: #79c9e8;
  --hue-blue: #5eaaf2;
  --hue-periwinkle: #8b9cf4;
  --hue-violet: #a993f7;
  --hue-orchid: #da8cf9;
  --hue-rose: #ef6a9a;
  --hue-coral: #f0a274;
  --hue-sand: #cdb48a;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-read: 14px;
  --text-lg: 16px;
  --text-xl: 21px;
  --text-2xl: 28px;

  --sp-2: 2px; --sp-4: 4px; --sp-6: 6px; --sp-8: 8px; --sp-10: 10px; --sp-12: 12px;
  --sp-16: 16px; --sp-20: 20px; --sp-24: 24px; --sp-32: 32px; --sp-48: 48px; --sp-64: 64px;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-round: 999px;

  --h-sm: 26px; --h-md: 32px; --h-lg: 38px; --h-touch: 44px;
  --line: 16px; --hang: 26px; --inset: 48px;
  --bar: 52px; --subbar: 48px; --rail: 230px; --drawer: 440px; --column: 1320px; --card: 440px;

  --shadow-pop: 0 12px 32px rgb(0 0 0 / 0.5);
  --shadow-overlay: 0 18px 50px rgb(0 0 0 / 0.55);
  --shadow-side: -16px 0 40px rgb(0 0 0 / 0.5);
  --backdrop: rgb(0 0 0 / 0.6);
  --z-sticky: 20; --z-drawer: 30; --z-pop: 40; --z-toast: 50; --z-dialog: 60; --z-tooltip: 70;

  --dur-hover: 120ms;
  --dur-enter: 140ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- base ---------- */
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--text-base)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--accent);
  scrollbar-color: var(--border-strong) transparent;
}
::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); color: var(--text); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, h4 { text-wrap: balance; }
b, strong, th { font-weight: 600; }
a { color: var(--accent); text-underline-offset: 3px; }
.mx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mx-i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mx-num { font-variant-numeric: tabular-nums; }

/* ---------- type roles ---------- */
.mx-title { margin: 0; font-size: var(--text-xl); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.mx-heading { margin: 0; font-size: var(--text-lg); font-weight: 600; line-height: 1.35; }
.mx-reading { font-size: var(--text-read); line-height: 1.6; max-width: 66ch; text-wrap: pretty; }
.mx-label { margin: 0; font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); }
.mx-meta { font-size: var(--text-sm); color: var(--text-dim); }
.mx-mono { font-family: var(--mono); font-size: var(--text-sm); }

/* ---------- app bar ---------- */
.mx-bar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--sp-16);
  min-height: var(--bar); padding: 0 var(--sp-16);
  border-bottom: 1px solid var(--border); background: var(--bg);
  box-sizing: border-box;
}
.mx-bar__start { display: flex; align-items: center; gap: var(--sp-12); min-width: 0; flex: none; }
.mx-bar__middle { display: flex; align-items: center; gap: var(--sp-8); min-width: 0; flex: 1 1 auto; }
.mx-bar__end { display: flex; align-items: center; gap: var(--sp-8); margin-left: auto; flex: none; }
.mx-bar__status { display: inline-flex; align-items: center; gap: var(--sp-8); color: var(--text-dim); font-size: var(--text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mx-brand { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; border-radius: var(--radius-sm); }
.mx-brand svg { display: block; height: 12px; width: auto; fill: currentColor; }
.mx-appname {
  display: inline-flex; align-items: center; gap: var(--sp-8);
  height: 16px; padding-left: var(--sp-12); border-left: 1px solid var(--border-strong);
  color: var(--text); font-size: var(--text-base); font-weight: 500; white-space: nowrap; text-decoration: none;
}
/* The app's own launcher icon, in mint: "you are here", as the current app in the launcher. */
.mx-appname .mx-appname__icon { width: 16px; height: 16px; color: var(--accent); }
button.mx-appname { height: var(--h-md); padding: 0 var(--sp-8) 0 var(--sp-12); border: 0; border-left: 1px solid var(--border-strong); border-radius: 0; background: none; font: inherit; font-weight: 500; color: var(--text); cursor: pointer; }
button.mx-appname:hover { background: var(--surface-hover); }
button.mx-appname .mx-appname__chev { width: 14px; height: 14px; color: var(--text-muted); }
@media (min-width: 1360px) {
  .mx-bar--column { padding-left: max(var(--sp-16), calc((100vw - var(--column)) / 2)); padding-right: max(var(--sp-16), calc((100vw - var(--column)) / 2)); }
}

/* ---------- floating menu (launcher, account, any dropdown) ---------- */
.mx-pop { position: relative; }
.mx-menu {
  position: absolute; right: 0; top: calc(100% + var(--sp-8)); z-index: var(--z-pop);
  min-width: 220px; padding: var(--sp-4); box-sizing: border-box;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface-raised); box-shadow: var(--shadow-pop);
  animation: mx-rise var(--dur-enter) var(--ease);
}
.mx-menu--start { left: 0; right: auto; }
.mx-menu--wide { min-width: 260px; }
.mx-menu[hidden] { display: none; }
@keyframes mx-rise { from { transform: translateY(-4px); opacity: 0; } }
.mx-menu__item {
  display: flex; align-items: center; gap: var(--sp-10); width: 100%; min-height: 30px; box-sizing: border-box;
  padding: var(--sp-6) var(--sp-10); border: 0; border-radius: var(--radius); background: none;
  color: var(--text-muted); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.mx-menu__item:hover, .mx-menu__item:focus-visible { background: var(--surface-hover); color: var(--text); }
.mx-menu__item[aria-current="page"], .mx-menu__item[aria-checked="true"] { color: var(--text); }
.mx-menu__item[aria-current="page"] .mx-i, .mx-menu__item[aria-checked="true"] .mx-i { color: var(--accent); }
.mx-menu__item--danger { color: var(--danger); }
.mx-menu__hint { display: block; color: var(--text-dim); font-size: var(--text-xs); }
.mx-menu__sep { height: 1px; margin: var(--sp-4) 0; background: var(--border); border: 0; }
.mx-menu__head { padding: var(--sp-8) var(--sp-10) var(--sp-6) calc(var(--sp-10) + var(--hang)); }
.mx-menu__name { display: block; color: var(--text); font-weight: 600; }
.mx-menu__email { display: block; color: var(--text-dim); font-size: var(--text-sm); overflow-wrap: anywhere; }

/* launcher */
.mx-launch { width: 280px; }
.mx-launch__apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.mx-launch__app {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-6);
  padding: var(--sp-10) var(--sp-4) var(--sp-8); border-radius: var(--radius);
  color: var(--text-muted); font-size: var(--text-sm); text-decoration: none;
}
.mx-launch__app .mx-i { width: 18px; height: 18px; }
.mx-launch__app:hover, .mx-launch__app:focus-visible { background: var(--surface-hover); color: var(--text); }
.mx-launch__app[aria-current="page"] { color: var(--accent); }

/* account button */
.mx-acct {
  display: inline-flex; align-items: center; gap: var(--sp-8); height: var(--h-md); padding: 0 var(--sp-8) 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--radius); background: none;
  color: var(--text-muted); font: inherit; cursor: pointer;
}
.mx-acct:hover, .mx-acct[aria-expanded="true"] { background: var(--surface-hover); color: var(--text); }
.mx-avatar {
  display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-raised)); color: var(--text);
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase;
}
.mx-avatar--lg { width: 32px; height: 32px; font-size: var(--text-sm); }
.mx-acct__name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.mx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-6);
  height: var(--h-md); padding: 0 var(--sp-12); box-sizing: border-box;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: transparent;
  color: var(--text-muted); font: inherit; font-size: var(--text-base); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: color var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease), background-color var(--dur-hover) var(--ease);
}
.mx-btn .mx-i { width: 14px; height: 14px; }
.mx-btn:hover { color: var(--accent); border-color: var(--accent); }
.mx-btn:active, .mx-btn[aria-pressed="true"] { background: var(--surface-raised); }
.mx-btn--sm { height: var(--h-sm); padding: 0 var(--sp-10); font-size: var(--text-sm); }
.mx-btn--lg { height: var(--h-lg); padding: 0 var(--sp-16); }
.mx-btn--primary { padding: 0 14px; border-color: transparent; background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.mx-btn--primary:hover { background: var(--accent-hover); border-color: transparent; color: var(--accent-ink); }
.mx-btn--quiet { border-color: transparent; }
.mx-btn--quiet:hover { background: var(--surface-hover); border-color: transparent; color: var(--text); }
.mx-btn--positive { color: var(--resolved); }
.mx-btn--positive:hover { color: var(--resolved); border-color: var(--resolved); }
.mx-btn--danger:hover { color: var(--danger); border-color: var(--danger); }
.mx-btn--confirm-danger { border-color: transparent; background: var(--danger); color: var(--danger-ink); font-weight: 500; }
.mx-btn--confirm-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #fff); border-color: transparent; color: var(--danger-ink); }
.mx-btn:disabled, .mx-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.mx-btn[aria-busy="true"] { cursor: progress; }
.mx-btn[aria-busy="true"] .mx-i { display: none; }
.mx-btn[aria-busy="true"]::before { content: ""; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; animation: mx-spin 0.8s linear infinite; }
@keyframes mx-spin { to { transform: rotate(360deg); } }
.mx-icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; flex: none;
  border: 0; border-radius: var(--radius); background: none; color: var(--text-muted); cursor: pointer;
  transition: color var(--dur-hover) var(--ease), background-color var(--dur-hover) var(--ease);
}
.mx-icon-btn:hover, .mx-icon-btn[aria-expanded="true"] { background: var(--surface-hover); color: var(--text); }
.mx-icon-btn[aria-pressed="true"] { color: var(--accent); }

/* ---------- fields ---------- */
.mx-field { display: grid; gap: var(--sp-6); }
.mx-field > label, .mx-field__label { color: var(--text-muted); font-size: var(--text-sm); }
.mx-field__hint { color: var(--text-dim); font-size: var(--text-sm); }
.mx-field__error { color: var(--danger); font-size: var(--text-sm); }
.mx-input, .mx-select, .mx-textarea {
  width: 100%; height: var(--h-md); padding: 0 var(--sp-10); box-sizing: border-box;
  border: 1px solid var(--border-input); border-radius: var(--radius); background: var(--bg);
  color: var(--text); font: inherit; font-size: var(--text-base);
}
.mx-select { appearance: none; padding-right: var(--sp-32); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa3ad' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right var(--sp-10) center; background-size: 16px; cursor: pointer; }
.mx-textarea { height: auto; min-height: 80px; padding: var(--sp-8) var(--sp-10); line-height: 1.5; resize: vertical; }
.mx-input::placeholder, .mx-textarea::placeholder { color: var(--text-dim); }
.mx-input:focus-visible, .mx-select:focus-visible, .mx-textarea:focus-visible,
.mx-input:focus, .mx-select:focus, .mx-textarea:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mx-input[aria-invalid="true"] { border-color: var(--danger); }
.mx-search { position: relative; display: flex; align-items: center; width: 100%; max-width: 560px; }
.mx-search .mx-input { height: 34px; padding-left: 32px; }
.mx-search > .mx-i { position: absolute; left: 10px; color: var(--text-dim); pointer-events: none; }

/* toggle switch */
.mx-toggle {
  position: relative; width: 32px; height: 18px; flex: none; padding: 0; box-sizing: border-box;
  border: 1px solid var(--border-input); border-radius: var(--radius-round); background: var(--surface-raised); cursor: pointer;
  transition: background-color var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.mx-toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-muted); transition: transform var(--dur-hover) var(--ease), background-color var(--dur-hover) var(--ease);
}
.mx-toggle[aria-checked="true"] { background: var(--accent-dim); border-color: var(--accent); }
.mx-toggle[aria-checked="true"]::after { transform: translateX(14px); background: var(--accent); }
.mx-toggle:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- chips ---------- */
.mx-chip, .mx-tag {
  display: inline-flex; align-items: center; gap: var(--sp-6); height: 20px; padding: 0 7px; box-sizing: border-box;
  border-radius: var(--radius); font-size: var(--text-xs); line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.mx-chip { background: var(--surface-raised); color: var(--text-muted); }
.mx-chip::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: currentColor; flex: none; }
.mx-chip--plain::before { display: none; }
.mx-chip--accent { color: var(--accent); }
.mx-chip--resolved { color: var(--resolved); }
.mx-chip--warn { color: var(--warn); }
.mx-chip--danger { color: var(--danger); }
.mx-chip--highlight { color: var(--highlight); }
.mx-chip--suggest { color: var(--suggest); }
.mx-chip--idle { color: var(--text-dim); }
.mx-tag { border: 1px solid var(--border); color: var(--text-muted); }
.mx-filter {
  display: inline-flex; align-items: center; gap: var(--sp-6); height: var(--h-sm); padding: 0 var(--sp-10); box-sizing: border-box;
  border: 1px solid var(--border); border-radius: var(--radius); background: transparent;
  color: var(--text-muted); font: inherit; font-size: var(--text-sm); cursor: pointer;
  transition: color var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease);
}
.mx-filter:hover { border-color: var(--border-strong); color: var(--text); }
.mx-filter[aria-pressed="true"], .mx-filter[aria-checked="true"] { background: var(--surface-raised); border-color: var(--accent-dim); color: var(--accent); }
.mx-filter__count { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.mx-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
  border-radius: var(--radius-round); background: var(--surface-raised); color: var(--text-muted);
  font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums;
}
.mx-count--unread { background: var(--accent); color: var(--accent-ink); }

/* ---------- rail ---------- */
.mx-rail {
  position: sticky; top: var(--bar); align-self: start; height: calc(100vh - var(--bar)); overflow-y: auto; box-sizing: border-box;
  width: var(--rail); padding: var(--sp-16); display: flex; flex-direction: column; gap: var(--sp-2);
  border-right: 1px solid var(--border); background: var(--surface);
}
.mx-rail__head { margin: var(--sp-20) 0 var(--sp-6); padding: 0 var(--sp-10) 0 calc(var(--sp-10) + var(--hang)); }
/* One Line Rule: an item without an icon still starts on the label line. */
.mx-rail__item:not(:has(> .mx-i)) { padding-left: calc(var(--sp-10) + var(--hang)); }
.mx-rail__head:first-child { margin-top: 0; }
.mx-rail__item {
  display: flex; align-items: center; gap: var(--sp-10); min-height: var(--h-md); padding: 0 var(--sp-10); box-sizing: border-box;
  border: 0; border-radius: var(--radius); background: none; color: var(--text-muted);
  font: inherit; text-align: left; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
}
.mx-rail__item:hover { background: var(--surface-hover); color: var(--text); }
.mx-rail__item[aria-current="page"], .mx-rail__item[aria-selected="true"] { background: var(--surface-raised); color: var(--text); font-weight: 500; }
.mx-rail__item[aria-current="page"] .mx-i, .mx-rail__item[aria-selected="true"] .mx-i { color: var(--accent); }
.mx-rail__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-rail__count { color: var(--text-dim); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.mx-rail__count--hot { color: var(--warn); }
.mx-rail__count--bad { color: var(--danger); }

/* ---------- segmented control + underline tabs ---------- */
.mx-seg { display: inline-flex; gap: var(--sp-2); padding: var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.mx-seg__item {
  display: inline-flex; align-items: center; gap: var(--sp-6); height: 28px; padding: 0 var(--sp-10); box-sizing: border-box;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-muted); font: inherit; cursor: pointer;
}
.mx-seg__item .mx-i { width: 14px; height: 14px; }
.mx-seg__item:hover { color: var(--text); }
.mx-seg__item[aria-checked="true"], .mx-seg__item[aria-pressed="true"], .mx-seg__item[aria-selected="true"] { background: var(--surface-raised); color: var(--text); }
.mx-tabs { display: flex; gap: var(--sp-16); border-bottom: 1px solid var(--border); }
.mx-tabs__tab {
  height: var(--h-md); padding: 0; border: 0; background: none; color: var(--text-muted); font: inherit; cursor: pointer;
  box-shadow: inset 0 -2px 0 transparent; transition: color var(--dur-hover) var(--ease), box-shadow var(--dur-hover) var(--ease);
}
.mx-tabs__tab:hover { color: var(--text); }
.mx-tabs__tab[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

/* ---------- rows, tables, stats ---------- */
.mx-rows { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.mx-row {
  display: flex; align-items: center; gap: var(--sp-12); min-height: 44px; padding: var(--sp-8) var(--sp-12); box-sizing: border-box;
  border-bottom: 1px solid var(--border); color: inherit; text-decoration: none;
  transition: background-color var(--dur-hover) var(--ease);
}
a.mx-row:hover, button.mx-row:hover, .mx-row--link:hover { background: var(--surface-hover); }
.mx-row[aria-selected="true"], .mx-row[aria-current="page"] { background: var(--surface-raised); box-shadow: inset 2px 0 0 var(--accent); }
.mx-row:focus-visible { outline-offset: -2px; }
.mx-row__title { font-weight: 600; }
.mx-row__meta { color: var(--text-dim); font-size: var(--text-sm); }
.mx-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.mx-table th { padding: var(--sp-8); border-bottom: 1px solid var(--border); color: var(--text-dim); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; text-align: left; }
.mx-table td { padding: var(--sp-8); border-bottom: 1px solid var(--border); vertical-align: top; }
.mx-table .mx-num, .mx-table td.num, .mx-table th.num { text-align: right; }
/* hairlines drawn by a 1px gap over the border colour, so wrapped rows stay ruled */
.mx-stats { display: flex; flex-wrap: wrap; gap: 1px; background: var(--border); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.mx-stats > * { flex: 1 1 140px; } /* a short last row widens instead of leaving empty ruled cells */
.mx-stat { padding: var(--sp-12) var(--sp-16); border: 0; background: var(--bg); text-align: left; color: inherit; font: inherit; }
.mx-stat__n { display: block; font-size: var(--text-2xl); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mx-stat__k { display: block; color: var(--text-dim); font-size: var(--text-sm); }
button.mx-stat { cursor: pointer; }
button.mx-stat:hover { background: var(--surface); }
button.mx-stat:focus-visible { outline-offset: -2px; }

/* One Line Rule helpers: a list whose rows start with an icon. The text sits on the
   page's line; the icon hangs in the margin (the page keeps --inset of air for it). */
.mx-hang { margin-left: calc(-1 * var(--hang)); }
.mx-table-wrap { max-width: 100%; overflow-x: auto; }

/* ---------- containers ---------- */
.mx-card { padding: var(--sp-16); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); transition: border-color var(--dur-hover) var(--ease); }
.mx-card:hover { border-color: var(--border-strong); }
.mx-notice { display: flex; gap: var(--sp-10); padding: var(--sp-12) var(--sp-16); border: 1px solid var(--accent-dim); border-radius: var(--radius-lg); }
.mx-notice > .mx-i { margin-top: 2px; }
.mx-notice--warn { border-color: var(--warn); }
.mx-notice--warn > .mx-i { color: var(--warn); }
.mx-notice--danger { border-color: var(--danger); }
.mx-notice--danger > .mx-i { color: var(--danger); }
.mx-stale { position: sticky; top: var(--bar); z-index: var(--z-sticky); margin: 0; padding: var(--sp-10) var(--sp-16); background: color-mix(in srgb, var(--danger) 10%, var(--bg)); box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--danger) 50%, transparent); text-align: center; }

/* ---------- dialog ---------- */
.mx-dialog {
  width: min(440px, calc(100vw - 32px)); padding: var(--sp-20); box-sizing: border-box;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-overlay);
}
.mx-dialog[open] { animation: mx-dialog-in var(--dur-enter) var(--ease); }
.mx-dialog::backdrop { background: var(--backdrop); }
@keyframes mx-dialog-in { from { transform: translateY(6px) scale(0.99); opacity: 0; } }
.mx-dialog__title { margin: 0 0 var(--sp-8); color: var(--text); font-size: var(--text-lg); font-weight: 600; line-height: 1.35; letter-spacing: normal; text-transform: none; }
.mx-dialog__body { margin: 0 0 var(--sp-16); color: var(--text-muted); }
.mx-dialog__actions { display: flex; justify-content: flex-end; gap: var(--sp-8); margin-top: var(--sp-20); }

/* ---------- drawer ---------- */
.mx-drawer {
  position: sticky; top: var(--bar); align-self: start; width: var(--drawer); max-width: 100vw; height: calc(100vh - var(--bar)); overflow-y: auto; box-sizing: border-box;
  padding: var(--sp-20); border-left: 1px solid var(--border); background: var(--surface);
  animation: mx-drawer-in var(--dur-enter) var(--ease);
}
@keyframes mx-drawer-in { from { transform: translateX(8px); opacity: 0; } }
.mx-facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-6) var(--sp-16); margin: 0; }
.mx-facts dt { color: var(--text-dim); font-size: var(--text-sm); }
.mx-facts dd { margin: 0; }

/* ---------- toast ---------- */
.mx-toast {
  position: fixed; left: 50%; bottom: var(--sp-24); z-index: var(--z-toast); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--sp-12); max-width: min(520px, calc(100vw - 32px)); box-sizing: border-box;
  padding: var(--sp-10) 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-pop);
  animation: mx-toast-in var(--dur-enter) var(--ease);
}
.mx-toast[hidden] { display: none; }
.mx-toast--bad { border-color: color-mix(in srgb, var(--danger) 70%, var(--border-strong)); }
.mx-toast__action { margin-left: auto; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 500; cursor: pointer; }
@keyframes mx-toast-in { from { transform: translate(-50%, 6px); opacity: 0; } }

/* ---------- states, footer ---------- */
.mx-empty { margin: var(--sp-24) 0; color: var(--text-muted); }
.mx-empty__hint { display: block; margin-top: var(--sp-4); color: var(--text-dim); font-size: var(--text-sm); }
.mx-error { color: var(--danger); }
.mx-skeleton { border-radius: var(--radius); background: var(--surface-raised); animation: mx-pulse 1.4s ease-in-out infinite; }
@keyframes mx-pulse { 50% { opacity: 0.5; } }
.mx-legal { margin: var(--sp-48) 0 0; padding: var(--sp-16) 0 var(--sp-24); color: var(--text-dim); font-size: var(--text-sm); }
.mx-legal a { color: var(--text-dim); text-decoration: none; }
.mx-legal a:hover { color: var(--text); text-decoration: underline; }

/* ---------- small screens and touch ---------- */
@media (max-width: 560px) {
  .mx-bar { gap: var(--sp-8); padding: 0 var(--sp-12); }
  .mx-brand svg { height: 10px; }
  .mx-bar__status { display: none; }
  .mx-appname { padding-left: var(--sp-8); }
  .mx-appname__label { display: none; }
}
@media (max-width: 760px) {
  .mx-acct__name { display: none; }
  /* One Line Rule: on phones nothing hangs (no room for air to the screen edge) */
  :root { --inset: var(--sp-16); }
  .mx-hang { margin-left: 0; }
  /* menus never leave the screen on phones */
  .mx-menu { max-width: calc(100vw - 16px); }
  .mx-menu--start { position: fixed; left: 8px; right: auto; top: calc(var(--bar) + 4px); }
  .mx-menu:not(.mx-menu--start) { position: fixed; right: 8px; left: auto; top: calc(var(--bar) + 4px); }
  /* the bar's middle (search) takes its own row under the brand and buttons */
  .mx-bar { flex-wrap: wrap; row-gap: 0; }
  .mx-bar__middle:not(:empty) { order: 3; flex-basis: 100%; padding-bottom: var(--sp-8); }
  .mx-search { max-width: none; }
}
@media (max-width: 760px), (pointer: coarse) {
  .mx-btn, .mx-btn--sm, .mx-btn--lg, .mx-filter, .mx-rail__item, .mx-seg__item, .mx-tabs__tab, .mx-menu__item, .mx-acct { min-height: var(--h-touch); }
  .mx-icon-btn { width: var(--h-touch); height: var(--h-touch); }
  .mx-input, .mx-select, .mx-search .mx-input { height: var(--h-touch); font-size: 16px; }
  .mx-toggle { position: relative; }
  .mx-toggle::before { content: ""; position: absolute; inset: -13px -6px; }
}
@media (max-width: 860px) {
  .mx-rail { position: static; width: auto; height: auto; flex-direction: row; overflow-x: auto; padding: var(--sp-8) var(--sp-16); border-right: 0; border-bottom: 1px solid var(--border); }
  .mx-rail__head { display: none; }
  .mx-rail__item { flex: none; }
  .mx-drawer { position: fixed; right: 0; top: var(--bar); z-index: var(--z-drawer); width: 100vw; box-shadow: var(--shadow-side); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
