/* darkmoon design system: tokens and the dm- component classes.
   Source of truth: the Design System artifact (docs/design.md, Links). Roboto Mono
   comes from fonts/fonts.css. Every class is prefixed dm-, states are is-* modifiers. */

/* ---------- tokens ---------- */
:root {
  --surface-chrome: #0d0c10;
  --surface-ground: #131217;
  --surface-panel: #19181e;
  --surface-raised: #201f26;
  --surface-hover: #26252d;
  --border-subtle: #24232a;
  --border: #2e2c35;
  --border-control: #76727f;
  --text: #ecebef;
  --text-muted: #a3a0ab;
  --text-faint: #8f8c99;
  --text-disabled: #55525e;
  --accent: #e94fd1;
  --accent-hover: #f26fdd;
  --accent-active: #d23cba;
  --accent-soft: #e94fd126;
  --on-accent: #16101a;
  --focus-ring: var(--accent);
  --ok: #52e07c;
  --warning: #e0b052;
  --error: #f06b6b;
  --info: #6ea8fe;
  --ok-soft: #52e07c1f;
  --warning-soft: #e0b0521f;
  --error-soft: #f06b6b1f;
  --info-soft: #6ea8fe1f;
  --mode-statweights: #8788ee;
  --class-demonhunter: #a330c9;
  /* chart colors of the three modes (validated for color blindness on the design canvas, D33) */
  --chart-quicksim: #3987e5; --chart-statweights: #d95926; --chart-topgear: #199e70; --chart-droptimizer: #b45fd6;
  /* item quality colors (the game's), for item names in tooltips */
  --quality-0: #9d9d9d; --quality-1: #ecebef; --quality-2: #1eff00; --quality-3: #3f9bff;
  --quality-4: #b65cf5; --quality-5: #ff8000; --quality-6: #e6cc80; --quality-7: #00ccff;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-none: 0px; --radius-sm: 3px; --radius-md: 6px; --radius-full: 999px;
  --shadow-overlay: 0 16px 48px rgba(0, 0, 0, 0.55);
  --shadow-popover: 0 8px 24px rgba(0, 0, 0, 0.45);
  --topbar-height: 48px; --sidebar-width: 232px; --sidebar-collapsed: 56px; --content-max: 1440px;
  --control-height: 32px; --control-height-lg: 40px; --tile-size: 40px;
  --font-mono: "Roboto Mono", ui-monospace, monospace;
}

/* ---------- motion (tokens.json has no motion family; these are the motion tokens) ---------- */
:root {
  --duration-instant: 80ms;   /* press feedback */
  --duration-fast: 120ms;     /* hover, focus, color and border changes, exits */
  --duration-base: 200ms;     /* menus, toasts, sidebar collapse, meters */
  --duration-slow: 320ms;     /* dialogs, page content, bars growing */
  --duration-accent: 500ms;   /* the class color fade of --accent */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
}
@property --accent { syntax: "<color>"; inherits: true; initial-value: #e94fd1; }
:root { transition: --accent var(--duration-accent) var(--ease-standard); }

/* ---------- base ---------- */
.dm-root, .dm-root * { box-sizing: border-box; }
.dm-root {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--surface-ground);
  -webkit-font-smoothing: antialiased;
}
.dm-root :focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.dm-root p { margin: 0; line-height: inherit; }
.dm-label {
  font-size: 11px; line-height: 16px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint);
}
.dm-muted { color: var(--text-muted); }
.dm-faint { color: var(--text-faint); }
.dm-num { font-variant-numeric: tabular-nums; text-align: right; }
.dm-strong { font-weight: 600; }
.dm-stack { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; min-height: 0; }
.dm-scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-control) transparent; }
a.dm-btn, a.dm-seg__item, a.dm-menu__item, a.dm-nav__item { text-decoration: none; }
[role="button"] { cursor: pointer; }
.dm-icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- logo (1:1 with today's DMLogo) ---------- */
.dm-logo { display: inline-flex; align-items: center; white-space: nowrap; user-select: none; text-decoration: none; }
.dm-logo__mark { display: flex; width: 30px; height: 30px; }
.dm-logo__mark svg { width: 30px; height: 30px; }
.dm-logo__mark path { fill: var(--accent); }
.dm-logo__text { color: var(--text); font-size: 26px; font-weight: 700; line-height: 1; margin-left: 1px; }

/* ---------- buttons ---------- */
.dm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-height); padding: 0 var(--space-3);
  font: inherit; font-weight: 500; color: var(--text);
  background: var(--surface-raised); border: 1px solid var(--border-control); border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
}
.dm-btn { transition: background-color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard); }
.dm-btn:active:not(:disabled) { transform: translateY(1px); transition-duration: var(--duration-instant); }
.dm-btn:hover { background: var(--surface-hover); }
.dm-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.dm-btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.dm-btn--primary:active { background: var(--accent-active); border-color: var(--accent-active); }
.dm-btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.dm-btn--ghost:hover { background: var(--surface-hover); color: var(--text); }
.dm-btn--danger { background: transparent; border-color: var(--error); color: var(--error); }
.dm-btn--danger:hover { background: var(--error-soft); }
.dm-btn--lg { height: var(--control-height-lg); padding: 0 var(--space-5); font-size: 14px; letter-spacing: 0.04em; }
.dm-btn--icon { width: var(--control-height); padding: 0; }
.dm-btn:disabled, .dm-btn.is-disabled { background: var(--surface-raised); border-color: var(--border); color: var(--text-disabled); cursor: not-allowed; }

/* ---------- fields ---------- */
.dm-field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.dm-field__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 20px; }
/* small text switch in a label row ("armory", "simc string") */
.dm-switch { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; font: inherit; font-size: 12px; color: var(--text-muted); cursor: pointer; transition: color var(--duration-fast) var(--ease-standard); }
.dm-switch:hover, .dm-switch:focus-visible { color: var(--accent); outline: none; }
.dm-switch .dm-icon { width: 14px; height: 14px; }
.dm-switch:disabled { opacity: 0.5; cursor: default; }
.dm-field__hint { font-size: 12px; line-height: 16px; color: var(--text-faint); }
.dm-field__error { font-size: 12px; line-height: 16px; color: var(--error); }
.dm-input, .dm-select, .dm-textarea {
  width: 100%; height: var(--control-height); padding: 0 var(--space-3);
  font: inherit; color: var(--text);
  background: var(--surface-raised); border: 1px solid var(--border-control); border-radius: var(--radius-sm);
}
.dm-input, .dm-select, .dm-textarea { transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
.dm-input::placeholder, .dm-textarea::placeholder { color: var(--text-faint); }
.dm-input:focus, .dm-select:focus, .dm-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dm-input.is-invalid, .dm-textarea.is-invalid { border-color: var(--error); background: var(--error-soft); }
.dm-input.is-invalid:focus, .dm-textarea.is-invalid:focus { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
/* read by screen readers only (an error a red field and its mark show) */
.dm-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.dm-input-wrap { position: relative; display: flex; align-items: center; }
.dm-input-wrap .dm-input { padding-right: 36px; }
.dm-input-wrap__end { position: absolute; right: var(--space-3); display: flex; align-items: center; }
.dm-select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a3a0ab' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.dm-textarea { height: auto; min-height: 140px; padding: var(--space-3); resize: vertical; line-height: 20px; }
.dm-menu {
  margin-top: var(--space-1); padding: var(--space-1) 0; list-style: none;
  background: var(--surface-panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-popover);
}
.dm-menu__item { display: flex; justify-content: space-between; padding: 6px var(--space-3); color: var(--text); cursor: pointer; }
.dm-menu__item:hover, .dm-menu__item.is-active { background: var(--surface-hover); }
.dm-menu { animation: dm-drop-in var(--duration-base) var(--ease-out); }
.dm-menu__item mark { background: none; color: var(--accent); }

/* ---------- segmented control and stepper ---------- */
.dm-seg { display: inline-flex; height: var(--control-height); border: 1px solid var(--border-control); border-radius: var(--radius-sm); overflow: hidden; }
.dm-seg__item {
  display: flex; flex: 1 1 auto; align-items: center; justify-content: center; padding: 0 var(--space-3);
  font: inherit; color: var(--text-muted); background: var(--surface-raised);
  border: 0; border-right: 1px solid var(--border); cursor: pointer;
}
.dm-seg__item:last-child { border-right: 0; }
.dm-seg__item { transition: color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard); }
.dm-seg__item:hover { color: var(--text); background: var(--surface-hover); }
.dm-seg__item.is-selected { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.dm-stepper { display: inline-flex; align-items: center; height: var(--control-height); border: 1px solid var(--border-control); border-radius: var(--radius-sm); background: var(--surface-raised); }
.dm-stepper button { width: 30px; height: 100%; font: inherit; color: var(--text-muted); background: none; border: 0; cursor: pointer; }
.dm-stepper button:hover { color: var(--accent); background: var(--surface-hover); }
.dm-stepper__value { min-width: 72px; text-align: center; border-left: 1px solid var(--border); border-right: 1px solid var(--border); line-height: 30px; }

/* ---------- checkbox and toggle ---------- */
.dm-check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.dm-check input {
  appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0;
  border: 1px solid var(--border-control); border-radius: var(--radius-sm); background: var(--surface-raised);
  display: grid; place-content: center;
}
.dm-check input:checked { background: var(--accent); border-color: var(--accent); }
.dm-check input:checked::after { content: ""; width: 8px; height: 4px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: rotate(-45deg) translate(1px, -1px); }
.dm-toggle { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.dm-toggle input {
  appearance: none; -webkit-appearance: none; position: relative; width: 32px; height: 18px; margin: 0;
  border: 1px solid var(--border-control); border-radius: var(--radius-full); background: var(--surface-raised);
}
.dm-toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: var(--radius-full); background: var(--text-muted); }
.dm-toggle input:checked { background: var(--accent); border-color: var(--accent); }
.dm-toggle input:checked::after { left: 16px; background: var(--on-accent); }

/* ---------- app frame: topbar, sidebar, content ---------- */
.dm-app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: var(--topbar-height) minmax(0, 1fr); min-height: 100%; }
.dm-app { transition: grid-template-columns var(--duration-base) var(--ease-standard); }
.dm-app.is-collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
.dm-topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-4);
  height: var(--topbar-height); padding: 0 var(--space-4);
  background: var(--surface-chrome); border-bottom: 1px solid var(--border);
}
.dm-topbar__spacer { flex: 1; }
.dm-topbar__user { display: inline-flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2); height: 32px; color: var(--text-muted); border-radius: var(--radius-sm); text-decoration: none; }
.dm-topbar__user:hover { background: var(--surface-hover); color: var(--text); }
.dm-avatar { display: grid; place-content: center; width: 24px; height: 24px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; }
.dm-sidebar { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-3) var(--space-2); background: var(--surface-chrome); border-right: 1px solid var(--border); overflow-y: auto; }
.dm-nav { display: flex; flex-direction: column; gap: 2px; }
.dm-nav__title { padding: 0 var(--space-3) var(--space-1); }
.dm-nav__item {
  display: flex; align-items: center; gap: var(--space-3); height: 36px; padding: 0 var(--space-3);
  color: var(--text-muted); text-decoration: none; border-radius: var(--radius-sm); position: relative;
}
.dm-nav__item { transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard); }
.dm-nav__item:hover { background: var(--surface-hover); color: var(--text); }
.dm-nav__item.is-active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.dm-nav__item.is-active .dm-icon { color: var(--accent); }
.dm-nav__item.is-soon { color: var(--text-faint); cursor: default; }
.dm-nav__item .dm-badge { margin-left: auto; }
.dm-sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.dm-app.is-collapsed .dm-nav__item span, .dm-app.is-collapsed .dm-nav__title, .dm-app.is-collapsed .dm-nav__item .dm-badge { display: none; }
/* collapsed: a line between the groups stands in for their titles */
.dm-app.is-collapsed .dm-nav + .dm-nav { padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.dm-app.is-collapsed .dm-nav__item { justify-content: center; padding-left: 0; padding-right: 0; }
.dm-content { padding: var(--space-5); overflow: auto; container: content / inline-size; }
.dm-content__inner { max-width: var(--content-max); display: flex; flex-direction: column; gap: var(--space-4); animation: dm-fade-in var(--duration-slow) var(--ease-out); }

/* ---------- workbench (direction G): run panel, character, right column ---------- */
.dm-wb { display: grid; grid-template-columns: 320px 540px minmax(0, 1fr); gap: var(--space-4); flex: 1; min-height: 0; }
/* too narrow for three columns: the result keeps its width. The middle
   column (.dm-wb__char: character sheet and sim info) folds into the left
   one: the sheet under the run panel, the sim info where recent was (recent
   is hidden). A purely visual column (.dm-wb__aside, the profile's "later")
   goes */
@container content (max-width: 1500px) {
  .dm-wb { grid-template-columns: 320px minmax(0, 1fr); }
  .dm-wb > .dm-wb__aside { display: none; }
  .dm-wb:has(> .dm-wb__char) { grid-template-rows: auto minmax(300px, 1fr) auto; }
  .dm-wb:has(> .dm-wb__char) > .dm-stack:first-child { display: contents; }
  .dm-wb:has(> .dm-wb__char) > .dm-stack:first-child > :first-child { grid-column: 1; grid-row: 1; }
  .dm-wb:has(> .dm-wb__char) > .dm-stack:first-child > :not(:first-child) { display: none; }
  .dm-wb > .dm-wb__char { display: contents; }
  .dm-wb > .dm-wb__char > :first-child { grid-column: 1; grid-row: 2; }
  .dm-wb > .dm-wb__char > :last-child { grid-column: 1; grid-row: 3; }
  .dm-wb:has(> .dm-wb__char) > :last-child { grid-column: 2; grid-row: 1 / -1; }
}
.dm-wb__row2 { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--space-2); }
.dm-or { display: flex; align-items: center; gap: var(--space-3); color: var(--text-faint); font-size: 12px; }
.dm-or::before, .dm-or::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }
.dm-btn.is-wide { width: 100%; justify-content: center; }
.dm-field__hint.is-ok { color: var(--ok); }
.dm-loading-note { display: flex; gap: var(--space-2); align-items: center; padding: var(--space-3) var(--space-4); }

/* ---------- page header ---------- */
.dm-pagehead { display: flex; align-items: flex-end; gap: var(--space-4); padding-bottom: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.dm-pagehead__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.dm-crumbs { display: flex; gap: var(--space-2); font-size: 12px; line-height: 16px; color: var(--text-faint); }
.dm-crumbs a { color: var(--text-muted); text-decoration: none; }
.dm-crumbs a:hover { color: var(--text); }
.dm-pagehead__title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; }
.dm-pagehead__meta { color: var(--text-muted); }
.dm-pagehead__actions { display: flex; gap: var(--space-2); }

/* ---------- panel ---------- */
.dm-panel { background: var(--surface-panel); border: 1px solid var(--border); border-radius: var(--radius-md); }
.dm-panel__head { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.dm-panel__title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; flex: 1; }
.dm-panel__body { padding: var(--space-4); }
.dm-panel__body.is-flush { padding: 0; }

.dm-panel__head:has(.dm-metric__caption) { padding-top: 18px; padding-bottom: 18px; }

/* ---------- table ---------- */
.dm-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 20px; }
.dm-table th {
  position: sticky; top: 0; height: 36px; padding: 0 var(--space-3); text-align: left;
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint);
  background: var(--surface-raised); border-bottom: 1px solid var(--border);
}
.dm-table td { height: 40px; padding: 0 var(--space-3); border-bottom: 1px solid var(--border-subtle); }
.dm-table tr:last-child td { border-bottom: 0; }
.dm-table td { transition: background-color var(--duration-fast) var(--ease-standard); }
.dm-table tbody tr:hover td { background: var(--surface-hover); }
.dm-table tr.is-selected td { background: var(--accent-soft); }
.dm-table .num, .dm-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dm-table .strong { font-weight: 600; }
.dm-table th:first-child, .dm-table td:first-child { padding-left: var(--space-4); }
.dm-table th:last-child, .dm-table td:last-child { padding-right: var(--space-4); }
.dm-table td.num { white-space: nowrap; }
.dm-table td.num .dm-badge { margin-left: 6px; vertical-align: middle; }
.dm-table th.is-sorted { color: var(--text); }
.dm-cell-name { display: flex; align-items: center; gap: var(--space-3); }
.dm-cell-name img { width: 24px; height: 24px; border-radius: var(--radius-sm); }
.dm-bar { display: block; position: relative; height: 4px; min-width: 80px; background: var(--surface-raised); border-radius: var(--radius-full); overflow: hidden; }
.dm-bar__fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: var(--radius-full); transform-origin: left center; animation: dm-bar-grow var(--duration-slow) var(--ease-out) both; }
.dm-table tr:nth-child(2) .dm-bar__fill { animation-delay: 20ms; }
.dm-table tr:nth-child(3) .dm-bar__fill { animation-delay: 40ms; }
.dm-table tr:nth-child(4) .dm-bar__fill { animation-delay: 60ms; }
.dm-table tr:nth-child(5) .dm-bar__fill { animation-delay: 80ms; }
.dm-table tr:nth-child(n+6) .dm-bar__fill { animation-delay: 100ms; }
.dm-bar.is-muted .dm-bar__fill { background: var(--text-faint); }

/* ---------- metric ---------- */
.dm-metric { display: flex; flex-direction: column; gap: 2px; }
.dm-metric__value { font-size: 40px; line-height: 44px; font-weight: 700; letter-spacing: -0.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.dm-metric.is-secondary .dm-metric__value { font-size: 28px; line-height: 34px; color: var(--text); }
.dm-metric__caption { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.dm-delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.dm-delta.is-up { color: var(--ok); }
.dm-delta.is-down { color: var(--error); }

/* ---------- item tile ---------- */
.dm-tile {
  position: relative; display: block; width: var(--tile-size); height: var(--tile-size);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-raised); overflow: hidden; cursor: pointer;
}
.dm-tile { transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
.dm-tile img { width: 100%; height: 100%; display: block; transition: opacity var(--duration-fast) var(--ease-standard); }
.dm-tile__ilvl { position: absolute; right: 1px; bottom: 0; padding: 0 2px; font-size: 10px; line-height: 13px; font-weight: 700; color: var(--text); background: rgba(13, 12, 16, 0.82); border-radius: 2px; }
.dm-tile.is-worn::before { content: ""; position: absolute; left: 0; top: 0; border-top: 10px solid var(--text-muted); border-right: 10px solid transparent; z-index: 1; }
.dm-tile.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dm-tile.is-off img { opacity: 0.35; }
.dm-tile.is-warned { border-color: var(--warning); }
.dm-tile__up { position: absolute; left: 1px; bottom: 0; font-size: 10px; line-height: 13px; font-weight: 700; color: var(--ok); }
.dm-tiles { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.dm-tiles__sep { width: 1px; align-self: stretch; margin: 0 var(--space-1); background: var(--border); }
.dm-slot { display: flex; flex-direction: column; gap: var(--space-1); }

/* ---------- profile summary ---------- */
.dm-profile { display: flex; gap: var(--space-4); align-items: center; }
.dm-profile__render { width: 88px; height: 88px; flex: none; border-radius: var(--radius-sm); background: var(--surface-raised); border: 1px solid var(--border); object-fit: cover; object-position: center top; }
.dm-profile__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.dm-profile__head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dm-profile__name { font-size: 20px; line-height: 28px; font-weight: 600; }
.dm-profile__line { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-profile__gear { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.dm-profile__gear .dm-tile { width: 28px; height: 28px; }
.dm-profile__ilvl { text-align: right; }

/* ---------- badge and dot ---------- */
.dm-badge {
  display: inline-flex; align-items: center; gap: var(--space-1); height: 20px; padding: 0 6px;
  font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  border-radius: var(--radius-sm); border: 1px solid var(--border-control); color: var(--text-muted);
}
.dm-badge.is-accent { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.dm-badge.is-ok { color: var(--ok); border-color: transparent; background: var(--ok-soft); }
.dm-badge.is-warning { color: var(--warning); border-color: transparent; background: var(--warning-soft); }
.dm-badge.is-error { color: var(--error); border-color: transparent; background: var(--error-soft); }
.dm-badge.is-info { color: var(--info); border-color: transparent; background: var(--info-soft); }
.dm-dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--text-faint); flex: none; }
.dm-dot.is-ok { background: var(--ok); }
.dm-dot.is-warning { background: var(--warning); }
.dm-dot.is-error { background: var(--error); }

/* ---------- status banner ---------- */
.dm-banner { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid transparent; }
.dm-banner__text { flex: 1; }
.dm-banner__title { font-weight: 600; }
.dm-banner.is-warning { background: var(--warning-soft); border-color: var(--warning); }
.dm-banner.is-warning .dm-icon { color: var(--warning); }
.dm-banner.is-error { background: var(--error-soft); border-color: var(--error); }
.dm-banner.is-error .dm-icon { color: var(--error); }
.dm-banner.is-info { background: var(--info-soft); border-color: var(--info); }
.dm-banner.is-info .dm-icon { color: var(--info); }

/* ---------- toast ---------- */
.dm-toast {
  display: flex; align-items: center; gap: var(--space-3); width: 360px; padding: var(--space-3) var(--space-4);
  background: var(--surface-panel); border: 1px solid var(--border); border-left-width: 1px; border-radius: var(--radius-md); box-shadow: var(--shadow-popover);
}
.dm-toast__text { flex: 1; }
.dm-toast { animation: dm-toast-in var(--duration-base) var(--ease-out); }
.dm-toast.is-leaving { animation: dm-fade-out var(--duration-fast) var(--ease-in) forwards; }
.dm-toast.is-ok .dm-icon { color: var(--ok); }
.dm-toast.is-warning .dm-icon { color: var(--warning); }
.dm-toast.is-error .dm-icon { color: var(--error); }

/* ---------- sim progress ---------- */
.dm-progress { display: flex; flex-direction: column; gap: var(--space-3); }
.dm-steps { display: flex; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.dm-steps li { display: flex; align-items: center; gap: var(--space-2); color: var(--text-faint); }
.dm-steps li.is-done { color: var(--text-muted); }
.dm-steps li.is-current { color: var(--text); font-weight: 600; }
.dm-steps li + li::before { content: ""; width: 24px; height: 1px; background: var(--border-control); }
.dm-meter { height: 4px; background: var(--surface-raised); border-radius: var(--radius-full); overflow: hidden; }
.dm-meter__fill { height: 100%; background: var(--accent); transition: width var(--duration-base) linear; }
.dm-log { margin: 0; padding: var(--space-3); max-height: 160px; overflow: auto; font-size: 12px; line-height: 18px; color: var(--text-muted); background: var(--surface-chrome); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); white-space: pre-wrap; }

/* ---------- dialog ---------- */
.dm-backdrop { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8, 7, 10, 0.72); }
.dm-backdrop { animation: dm-fade-in var(--duration-base) var(--ease-out); }
.dm-dialog { animation: dm-dialog-in var(--duration-slow) var(--ease-out); }
.dm-dialog { width: min(560px, calc(100% - 32px)); background: var(--surface-panel); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-overlay); }
.dm-dialog__head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); }
.dm-dialog__title { margin: 0; flex: 1; font-size: 15px; line-height: 22px; font-weight: 600; }
.dm-dialog__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.dm-dialog__foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-subtle); }

/* ---------- empty state and skeleton ---------- */
.dm-empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-4); text-align: center; color: var(--text-muted); }
.dm-empty .dm-icon { width: 24px; height: 24px; color: var(--text-faint); }
.dm-empty__title { color: var(--text); font-weight: 600; }
.dm-skel { display: block; height: 12px; border-radius: var(--radius-sm); background: var(--surface-hover); animation: dm-pulse 1.6s ease-in-out infinite; }
/* Blazor's reconnect dialog (App.razor): blazor sets components-reconnect-show,
   -failed or -rejected on #components-reconnect-modal */
#components-reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: block; }
/* a slim bar at the top center in the toast's look; the layer under it is clear and only holds the clicks back */
.dm-reconnect { position: fixed; inset: 0; z-index: 9999; display: flex; justify-content: center; align-items: flex-start; padding: var(--space-4); cursor: progress; }
.dm-reconnect__bar {
  display: flex; align-items: center; gap: var(--space-3); max-width: min(560px, 100%); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); min-height: 44px; box-sizing: border-box;
  background: var(--surface-panel); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-popover); cursor: default;
  animation: dm-toast-in var(--duration-base) var(--ease-out);
}
.dm-reconnect__text { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--space-2); min-width: 0; padding-right: var(--space-2); font-size: 12px; color: var(--text-muted); }
.dm-reconnect__text b { font-size: 13px; font-weight: 600; color: var(--text); }
.dm-reconnect__spin { flex: none; }
.dm-reconnect__dot { display: none; flex: none; background: var(--error); }
.dm-reconnect__msg.is-failed, .dm-reconnect__msg.is-rejected, .dm-reconnect__reload { display: none; }
.components-reconnect-failed .dm-reconnect__msg.is-retrying, .components-reconnect-rejected .dm-reconnect__msg.is-retrying { display: none; }
.components-reconnect-failed .dm-reconnect__msg.is-failed, .components-reconnect-rejected .dm-reconnect__msg.is-rejected { display: inline; }
.components-reconnect-failed .dm-reconnect__reload { display: inline-flex; flex: none; }
.components-reconnect-failed .dm-reconnect__spin { display: none; }
.components-reconnect-failed .dm-reconnect__dot { display: inline-block; }
.components-reconnect-failed .dm-reconnect__bar { border-color: var(--error); }

@keyframes dm-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ---------- keyframes ---------- */
@keyframes dm-alert { 0%, 100% { box-shadow: 0 0 0 1px var(--error); } 50% { box-shadow: 0 0 0 1px var(--error), 0 0 18px 2px color-mix(in srgb, var(--error) 45%, transparent); } }
@keyframes dm-rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes dm-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dm-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes dm-drop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes dm-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes dm-dialog-in { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes dm-bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes dm-spin { to { transform: rotate(360deg); } }
.dm-spinner { width: 16px; height: 16px; border: 2px solid var(--border-control); border-top-color: var(--accent); border-radius: var(--radius-full); animation: dm-spin 800ms linear infinite; }

/* ---------- reduced motion: no movement, only short fades ---------- */
@media (prefers-reduced-motion: reduce) {
  :root { transition: none; }
  .dm-skel, .dm-bar__fill, .dm-content__inner, .dm-menu, .dm-toast, .dm-dialog { animation: none; }
  .dm-backdrop, .dm-toast { animation-duration: var(--duration-fast); }
  .dm-btn:active:not(:disabled) { transform: none; }
  .dm-app { transition: none; }
  .dm-spinner { animation-duration: 2400ms; }
}

/* ---------- item tooltip (tooltip.js shows one floating box; Components/Core/DMItemTooltips renders the contents) ---------- */
.dm-tt-store { display: none; }
.dm-tt {
  position: fixed; z-index: 9000; left: 0; top: 0; width: 300px; max-width: calc(100vw - 16px); padding: var(--space-3) var(--space-4);
  background: var(--surface-chrome); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-popover);
  font-family: var(--font-mono); font-size: 12px; line-height: 18px; color: var(--text); pointer-events: none;
}
.dm-tt[hidden] { display: none; }
.dm-tt__name { font-size: 13px; line-height: 19px; font-weight: 600; margin-bottom: 2px; }
.dm-tt__name.q0 { color: var(--quality-0); } .dm-tt__name.q1 { color: var(--quality-1); } .dm-tt__name.q2 { color: var(--quality-2); }
.dm-tt__name.q3 { color: var(--quality-3); } .dm-tt__name.q4 { color: var(--quality-4); } .dm-tt__name.q5 { color: var(--quality-5); }
.dm-tt__name.q6 { color: var(--quality-6); } .dm-tt__name.q7 { color: var(--quality-7); }
.dm-tt__level { color: var(--warning); }
/* the upgrade step: its own line, track in the track's color, a mark per step */
.dm-tt__track { display: flex; align-items: center; gap: var(--space-2); margin: 2px 0 4px; color: var(--track); --track: var(--text-muted); }
.dm-tt__track.is-explorer { --track: var(--quality-0); }
.dm-tt__track.is-adventurer { --track: var(--quality-1); }
.dm-tt__track.is-veteran { --track: var(--quality-2); }
.dm-tt__track.is-champion { --track: var(--quality-3); }
.dm-tt__track.is-hero { --track: var(--quality-4); }
.dm-tt__track.is-myth { --track: var(--quality-5); }
.dm-tt__track-name { font-weight: 600; }
.dm-tt__steps { display: inline-flex; gap: 3px; }
.dm-tt__steps i { width: 10px; height: 6px; border-radius: 1px; border: 1px solid var(--track); opacity: 0.45; }
.dm-tt__steps i.is-on { background: var(--track); opacity: 1; }
.dm-tt__row { display: flex; justify-content: space-between; gap: var(--space-3); }
.dm-tt__muted { color: var(--text-muted); }
.dm-tt__faint { color: var(--text-faint); }
.dm-tt__sec { color: var(--ok); }
.dm-tt__group { margin-top: var(--space-2); }
.dm-tt__set { color: var(--warning); }
.dm-tt__piece { padding-left: var(--space-3); color: var(--text-faint); }
.dm-tt__piece.is-worn { color: var(--text); }
.dm-tt__desc { color: var(--warning); white-space: pre-line; }
.dm-tt__bonus { margin-top: 2px; color: var(--text-faint); white-space: pre-line; }
.dm-tt__bonus.is-active { color: var(--ok); }
.dm-tt__group .dm-tt__sec { white-space: pre-line; }
