/*
  TRA theme tokens v1.0 (2026-09-24)
  Source of truth: P:\Claude\Web Sites\THEME.md
  Light values were pixel-sampled from Theme/reference/m365-plan-finder-reference.png. Do not change them.
  Copy this file into a project, or paste this block at the top of its styles.css.
  Set <html data-theme="light|dark"> before first paint (see THEME.md, "Theme switching").
*/

:root,
[data-theme="light"] {
  color-scheme: light;

  /* Brand bar (app header) */
  --brand-bar: #14817a;                         /* header background, measured #147f79 to #14837b */
  --brand-bar-hover: rgb(255 255 255 / 12%);    /* hover fill for controls sitting on the bar */
  --brand-bar-control: rgb(255 255 255 / 16%);  /* search field + badge fill on the bar (measured #3a7f84 over teal) */
  --brand-bar-control-border: rgb(255 255 255 / 45%);
  --brand-bar-text: #ffffff;
  --brand-bar-text-muted: rgb(255 255 255 / 78%);

  /* Accent (teal) */
  --accent: #14a38c;            /* primary button fill, selected-item left edge, active indicators (measured) */
  --accent-hover: #11907b;
  --accent-active: #0e7c69;
  --accent-text: #0e7c69;       /* teal used AS TEXT on light surfaces (5.2:1 on white) */
  --accent-soft: #e6f4f1;       /* selected list row background (measured) */
  --accent-soft-strong: #def2ef;/* "Included" chip background (measured) */
  --accent-tint: #f3faf8;       /* group bands, code chips, count badges (measured) */
  --text-on-accent: #ffffff;

  /* Surfaces */
  --bg: #ffffff;                /* canvas and main detail column */
  --surface: #ffffff;           /* list column, right panel, cards */
  --surface-rail: #fafafa;      /* left navigation rail (measured) */
  --surface-subtle: #f3faf8;    /* collapsible group header bands (measured) */
  --surface-raised: #ffffff;    /* menus, dialogs, popovers */
  --surface-overlay: rgb(11 18 32 / 45%);

  /* Text */
  --text: #0b1220;              /* titles, row labels (measured) */
  --text-secondary: #33465a;    /* body, subtitles, chip text, breadcrumbs (measured) */
  --text-muted: #5f7284;        /* meta, counts, chevrons, helper copy (measured) */
  --text-placeholder: #757575;  /* measured */
  --text-disabled: #9aa6ae;

  /* Borders */
  --border: #d2e7e2;            /* row dividers, rail/list divider (measured, teal-tinted) */
  --border-strong: #c8dcd7;     /* list/detail column divider (measured) */
  --border-neutral: #c7ccd1;    /* outline buttons, filter pills */
  --border-input: #b5b7bc;      /* text inputs, selects (measured on the outline button) */
  --border-input-hover: #8e969e;

  /* Status */
  --success-text: #0e7c69; --success-bg: #def2ef; --success-border: #b9e2da;   /* = "Included" chip */
  --warning-text: #8a5a00; --warning-bg: #fff4ce; --warning-border: #f1d98a;   /* = "Partial" chip */
  --info-text: #0f5f9f;    --info-bg: #e7f2fc;   --info-border: #b9d8f3;       /* = "Can be added" chip */
  --danger-text: #b42318;  --danger-bg: #fde7e9; --danger-border: #f4b8bd;
  --neutral-text: #33465a; --neutral-bg: #eef1f4; --neutral-border: #d1d8de;   /* = "Read only" chip */

  /* Code / monospace chips */
  --code-bg: #f3faf8; --code-text: #33465a; --code-border: #d2e7e2;

  /* Focus and elevation */
  --focus-ring: #14a38c;        /* on the brand bar use #ffffff instead */
  --shadow-menu: 0 4px 16px rgb(11 18 32 / 14%), 0 0 0 1px #d2e7e2;
  --shadow-dialog: 0 16px 48px rgb(11 18 32 / 22%);
  --scrollbar-thumb: #8b8b8b; --scrollbar-track: #fcfcfc;

  /* Typography */
  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  --fs-2xs: 10px; --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-lg: 14px; --fs-xl: 16px; --fs-2xl: 18px; --fs-3xl: 20px;
  --lh-tight: 1.2; --lh-normal: 1.45;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;

  /* Sizing and spacing (4px grid) */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --header-h: 48px; --rail-w: 220px; --list-w: 340px; --panel-w: 400px;
  --control-h: 32px;            /* buttons, inputs, selects */
  --control-h-sm: 26px;         /* pills, small buttons */
  --row-h: 36px;                /* nav items, compact list rows */
  --radius-xs: 3px; --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-pill: 999px;
  --motion-fast: 120ms; --motion-base: 180ms;
}

[data-theme="dark"] {
  color-scheme: dark;
  --brand-bar: #0e6a63;
  --brand-bar-hover: rgb(255 255 255 / 10%);
  --brand-bar-control: rgb(255 255 255 / 12%);
  --brand-bar-control-border: rgb(255 255 255 / 35%);
  --brand-bar-text: #ffffff;
  --brand-bar-text-muted: rgb(255 255 255 / 78%);   /* v1.0: was 72%; 78% reaches 4.5:1 on the bar */

  --accent: #1aa88f;
  --accent-hover: #24b89d;
  --accent-active: #15927c;
  --accent-text: #5ad2bb;
  --accent-soft: #14302c;
  --accent-soft-strong: #173a35;
  --accent-tint: #182124;
  --text-on-accent: #0b1220;    /* v1.0: was #ffffff (2.98:1); dark text reads 4.8:1 or better on every accent state */

  --bg: #111618;
  --surface: #161c1e;
  --surface-rail: #131a1c;
  --surface-subtle: #1a2325;
  --surface-raised: #1e2729;
  --surface-overlay: rgb(0 0 0 / 55%);

  --text: #e9eef0;
  --text-secondary: #b6c2c7;
  --text-muted: #8a989e;
  --text-placeholder: #89959b;  /* v1.0: was #75838a; now 4.5:1 on every surface */
  --text-disabled: #5c6a70;

  --border: #263237;
  --border-strong: #34444a;
  --border-neutral: #3a474d;
  --border-input: #60737c;      /* v1.0: was #4a585f; field boundary now 3:1 on every surface */
  --border-input-hover: #798b93;/* v1.0: was #64747c; kept one clear step above --border-input */

  --success-text: #5fd3b0; --success-bg: #123c33; --success-border: #1d5548;
  --warning-text: #f2c55c; --warning-bg: #3d2f0f; --warning-border: #5a4614;
  --info-text: #7cc0f5;    --info-bg: #12304a;   --info-border: #1e4a6e;
  --danger-text: #ff8f85;  --danger-bg: #421d1b; --danger-border: #67302c;
  --neutral-text: #b6c2c7; --neutral-bg: #222c30; --neutral-border: #34444a;

  --code-bg: #1f2a2e; --code-text: #c5d1d6; --code-border: #34444a;

  --focus-ring: #5ad2bb;
  --shadow-menu: 0 4px 16px rgb(0 0 0 / 50%), 0 0 0 1px #34444a;
  --shadow-dialog: 0 16px 48px rgb(0 0 0 / 60%);
  --scrollbar-thumb: #4a585f; --scrollbar-track: #161c1e;
}

/* ==========================================================================
   TRA naming tool: application styles
   Everything below uses only the tokens above for color.
   ========================================================================== */

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

html {
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
code, kbd { font-family: var(--font-mono); }
ul, ol { margin: 0; padding: 0; list-style: none; }

svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: var(--space-2);
  left: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--accent-text);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  box-shadow: var(--shadow-menu);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.app-header :focus-visible { outline-color: var(--brand-bar-text); outline-offset: -2px; }
.app-header .menu :focus-visible,
.app-header .search-results :focus-visible { outline-color: var(--focus-ring); }

/* Thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { border-radius: var(--radius-sm); background: var(--scrollbar-thumb); }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border: 1px solid var(--border-neutral);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-2xs);
  line-height: 1;
  vertical-align: 1px;
}

/* ---------- App header (brand bar) ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, 360px) minmax(max-content, 1fr);
  align-items: center;
  column-gap: var(--space-4);
  padding: 0 var(--space-1) 0 var(--space-3);
  background: var(--brand-bar);
  color: var(--brand-bar-text);
}

.brand-group { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 15px; white-space: nowrap; }
.brand-icon { width: 20px; height: 20px; }
.brand-name { font-size: 15px; font-weight: var(--fw-regular); line-height: var(--lh-tight); }
.brand-org { font-size: 15px; font-weight: var(--fw-regular); }
.brand-name strong { font-size: 15px; font-weight: var(--fw-semibold); }

.brand-badge {
  padding: 1px var(--space-2);
  border: 1px solid var(--brand-bar-control-border);
  border-radius: var(--radius-sm);
  background: var(--brand-bar-control);
  color: var(--brand-bar-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 16px;
  white-space: nowrap;
}

.header-search { position: relative; width: 100%; min-width: 0; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 28px;
  border: 1px solid var(--brand-bar-control-border);
  border-radius: var(--radius-md);
  background: var(--brand-bar-control);
  color: var(--brand-bar-text);
  transition: background-color var(--motion-fast) ease;
}
.search-box:hover { background: var(--brand-bar-hover); }
.search-box:focus-within { outline: 2px solid var(--brand-bar-text); outline-offset: 1px; }
.search-box > svg {
  position: absolute;
  left: var(--space-2);
  width: 16px;
  height: 16px;
  color: var(--brand-bar-text-muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 0 30px 0 30px;
  border: 0;
  background: transparent;
  color: var(--brand-bar-text);
  font-size: var(--fs-md);
  outline: none;
}
.search-box input:focus-visible { outline: none; }
.search-box input::placeholder { color: var(--brand-bar-text-muted); opacity: 1; }
.search-kbd {
  position: absolute;
  right: 6px;
  border-color: var(--brand-bar-control-border);
  background: transparent;
  color: var(--brand-bar-text-muted);
  pointer-events: none;
}

.search-results {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 320px;
  max-height: min(440px, calc(100dvh - 80px));
  overflow-y: auto;
  padding: var(--space-1) 0;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-menu);
}
.search-results[hidden] { display: none; }
.search-group + .search-group { margin-top: var(--space-1); padding-top: var(--space-1); border-top: 1px solid var(--border); }
.search-group-label {
  padding: var(--space-2) var(--space-3) var(--space-1);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.search-group-label span { color: var(--text-muted); font-weight: var(--fw-regular); letter-spacing: 0; }
.search-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--row-h);
  padding: 6px var(--space-3);
  cursor: pointer;
}
.search-option > svg { width: 18px; height: 18px; color: var(--text-muted); }
.search-option-text { display: grid; min-width: 0; }
.search-option-label { overflow: hidden; color: var(--text); font-size: var(--fs-md); text-overflow: ellipsis; white-space: nowrap; }
.search-option-label.is-mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.search-option-detail { overflow: hidden; color: var(--text-muted); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.search-option.is-active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.search-option.is-active > svg { color: var(--accent-text); }
.search-empty { padding: var(--space-3); color: var(--text-muted); font-size: var(--fs-sm); }

.header-actions { display: flex; align-items: stretch; justify-self: end; height: 100%; }

.bar-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--brand-bar-text);
  font-size: var(--fs-md);
  white-space: nowrap;
  transition: background-color var(--motion-fast) ease;
}
.bar-tab:hover { background: var(--brand-bar-hover); }
.bar-tab-icon { display: none; }
.bar-tab-label { display: inline-grid; }
.bar-tab-label::after {
  content: attr(data-label);
  content: attr(data-label) / "";
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-weight: var(--fw-semibold);
}
.bar-tab.is-active { font-weight: var(--fw-semibold); }
.bar-tab.is-active::after {
  content: "";
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: 7px;
  height: 2px;
  border-radius: 1px;
  background: var(--brand-bar-text);
}
.bar-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--brand-bar-control-border);
  border-radius: var(--radius-pill);
  background: var(--brand-bar-control);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  line-height: 1;
}

.bar-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-bar-text);
  transition: background-color var(--motion-fast) ease;
}
.bar-icon-btn:hover { background: var(--brand-bar-hover); }
.search-open, .search-close { display: none; }

.export-wrap { position: relative; display: flex; }
.menu {
  position: absolute;
  z-index: 60;
  top: calc(100% - 4px);
  right: 0;
  width: 248px;
  padding: var(--space-1) 0;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-menu);
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  text-align: left;
  white-space: nowrap;
}
.menu-item svg { width: 16px; height: 16px; color: var(--text-muted); }
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-tint); }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-note { padding: 2px var(--space-3) var(--space-2) 38px; color: var(--text-muted); font-size: var(--fs-xs); }
.menu-separator { height: 1px; margin: var(--space-1) 0; background: var(--border); }
.menu-item.is-danger, .menu-item.is-danger svg { color: var(--danger-text); }
.menu-item.is-danger:hover, .menu-item.is-danger:focus-visible { background: var(--danger-bg); }

/* ---------- Shell: rail / list / detail / panel ---------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--rail-w) var(--list-w) minmax(0, 1fr) var(--panel-w);
  grid-template-areas: "rail list detail panel";
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
}
.app-shell[data-history="closed"] {
  grid-template-columns: var(--rail-w) var(--list-w) minmax(0, 1fr);
  grid-template-areas: "rail list detail";
}
.app-shell[data-history="closed"] .history-panel { display: none; }

/* Left rail */
.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-2) 0 var(--space-4);
  border-right: 1px solid var(--border);
  background: var(--surface-rail);
}
.rail-items { display: flex; flex-direction: column; }
.rail-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  height: var(--row-h);
  padding: 0 var(--space-5);
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--motion-fast) ease;
}
.rail-item svg { color: var(--text-secondary); }
.rail-item:hover { background: var(--accent-tint); }
.rail-item.is-selected { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); font-weight: var(--fw-medium); }
.rail-item.is-selected svg { color: var(--accent-text); }
.rail-item:focus-visible { outline-offset: -2px; }
.rail-short { display: none; }
.rail-help { margin: var(--space-4) var(--space-3) 0; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.4; }
.rail-help strong { color: var(--text-secondary); font-weight: var(--fw-semibold); }
.rail-reset { align-self: flex-start; margin: var(--space-3) var(--space-2) 0; }

/* Column headings (Presets, History) */
.column-head { min-height: 58px; padding: var(--space-3) var(--space-4) var(--space-2); border-bottom: 1px solid var(--border); }
.column-head h2 { color: var(--text); font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
.column-head p { margin-top: 3px; color: var(--text-muted); font-size: var(--fs-sm); }

/* Presets list column */
.list-column {
  grid-area: list;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border-strong);
  background: var(--surface);
}
.list-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-2);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  letter-spacing: 0;
}

.preset-rows { border-top: 1px solid var(--border); }
.preset-row { position: relative; border-bottom: 1px solid var(--border); }
.preset-select {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 58px;
  padding: 9px 44px 9px var(--space-4);
  border: 0;
  background: transparent;
  text-align: left;
  transition: background-color var(--motion-fast) ease;
}
.preset-row.is-custom .preset-select { padding-right: 76px; }
.preset-select:hover { background: var(--accent-tint); }
.preset-select:focus-visible { outline-offset: -2px; }
.preset-row.is-selected .preset-select { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
/* Titles stay on one line, so rows keep their height; the row tooltip starts with the full label. */
.preset-title { overflow: hidden; color: var(--text); font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: 20px; text-overflow: ellipsis; white-space: nowrap; }
.preset-sub,
.search-option-detail.is-pattern { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; color: var(--text-muted); font-size: var(--fs-sm); line-height: 18px; white-space: nowrap; }
.preset-area, .preset-note, .preset-dot { flex: none; }
/* What the preset sets ("Entra ID · Security") keeps its width up to a cap; the pattern chip truncates first. */
.preset-values { flex: 0 0 auto; max-width: 64%; overflow: hidden; text-overflow: ellipsis; }
.preset-sub .code-chip,
.search-option-detail.is-pattern .code-chip {
  display: inline-block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
}
.row-chevron { position: absolute; top: 11px; right: var(--space-4); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.preset-delete { position: absolute; top: 50%; right: 40px; margin-top: -14px; }

.code-chip {
  padding: 1px 6px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-xs);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 16px;
  overflow-wrap: anywhere;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.modified-hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: var(--fs-sm);
  text-align: left;
}
.modified-hint > svg { width: 16px; height: 16px; }
.modified-hint > span { flex: 1 1 auto; }
.modified-hint strong { font-weight: var(--fw-semibold); }
.modified-hint:focus-visible { outline-offset: -2px; }
.list-empty { padding: 0 var(--space-4) var(--space-4); color: var(--text-muted); font-size: var(--fs-sm); }

/* Detail column (builder) */
.detail-column {
  grid-area: detail;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  container-type: inline-size;
}
.detail-column:focus { outline: none; }
.detail-head {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: var(--space-3) var(--space-4) var(--space-2);
  border-bottom: 1px solid var(--border);
}
.detail-head h1 { color: var(--text); font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
.detail-head p { margin-top: 3px; color: var(--text-muted); font-size: var(--fs-sm); }
.detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.toolbar-customize { margin-left: auto; }
.detail-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: var(--control-h-sm);
  padding: 0 10px 0 8px;
  border: 1px solid var(--border-neutral);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  white-space: nowrap;
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease;
}
.pill svg { width: 14px; height: 14px; }
.pill:hover { border-color: var(--border-input-hover); background: var(--accent-tint); }
.pill.is-on { border-color: var(--success-border); background: var(--success-bg); color: var(--success-text); font-weight: var(--fw-medium); }
.pill.is-on:hover { border-color: var(--success-text); }

/* Generated name block (styled like the reference "SKU" block) */
.name-block { border-bottom: 1px solid var(--border); }
.name-body { padding: var(--space-4) var(--space-4) var(--space-3); }
.block-label { color: var(--text-secondary); font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: .06em; text-transform: uppercase; }
.generated-name {
  margin-top: var(--space-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.generated-name.is-empty { color: var(--text-placeholder); font-family: var(--font-ui); font-size: var(--fs-lg); font-weight: var(--fw-regular); }
.name-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px var(--space-3);
  margin-top: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}
.name-meta-format { color: var(--text-muted); }
.segment-list { display: flex; flex-wrap: wrap; gap: 6px var(--space-3); margin-top: var(--space-3); }
.segment { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-muted); font-size: var(--fs-xs); }
.callouts { display: grid; gap: 6px; margin-top: var(--space-3); }
.callouts:empty { display: none; }
.callout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 6px 10px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.callout svg { width: 16px; height: 16px; margin-top: 1px; }
.callout.is-error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
.name-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
}

/* Collapsible group bands */
.group-heading { margin: 0; font: inherit; }
.group-band {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: var(--row-h);
  padding: 0 var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  text-align: left;
  transition: background-color var(--motion-fast) ease;
}
.group-band:hover { background: var(--accent-soft); }
.group-band:focus-visible { outline-offset: -2px; }
.group-band svg { width: 16px; height: 16px; color: var(--text-muted); transition: transform var(--motion-fast) ease; }
.group-band[aria-expanded="false"] svg { transform: rotate(-90deg); }
.group-count { margin-left: auto; color: var(--text-muted); font-size: var(--fs-sm); font-weight: var(--fw-regular); }
.group-body { padding: var(--space-4); border-bottom: 1px solid var(--border); }
.group-body[hidden] { display: none; }

/* Fields and inputs */
.field-grid, .format-grid, .doc-grid, .format-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
/* Spaces gets the widest column: its longest option, "Use separator (Service-desk)", needs about 200px. */
.format-grid, .format-options { grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 3fr); }
.field { display: grid; align-content: start; gap: 4px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-2); color: var(--text-secondary); font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.field-off, .field-optional { color: var(--text-muted); font-size: var(--fs-xs); font-weight: var(--fw-regular); }
.field.is-off .input { border-style: dashed; }
.field-counter { justify-self: end; color: var(--text-muted); font-size: var(--fs-xs); }
.format-pattern { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); color: var(--text-muted); font-size: var(--fs-sm); }

.input {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--space-2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
  outline: none;
  transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
.input:hover { border-color: var(--border-input-hover); }
.input:focus, .input:focus-visible { border-color: var(--focus-ring); box-shadow: 0 0 0 1px var(--focus-ring); outline: none; }
.input::placeholder { color: var(--text-placeholder); opacity: 1; }
textarea.input { height: auto; min-height: 72px; padding: 6px var(--space-2); line-height: var(--lh-normal); resize: vertical; }
input[type="search"].input::-webkit-search-cancel-button { cursor: pointer; }

.select-wrap { position: relative; display: block; min-width: 0; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer; text-overflow: ellipsis; }
.select-chevron { position: absolute; top: 50%; right: var(--space-2); width: 16px; height: 16px; margin-top: -8px; color: var(--text-muted); pointer-events: none; }
select option { background: var(--surface-raised); color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--text-on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }
.btn-outline { border-color: var(--border-input); background: var(--surface); color: var(--text); font-weight: var(--fw-medium); }
.btn-outline:hover { border-color: var(--border-input-hover); background: var(--accent-tint); }

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.btn-text svg { width: 16px; height: 16px; }
.btn-text:hover { background: var(--accent-tint); }
.btn-text.is-danger { color: var(--danger-text); }
.btn-text.is-danger:hover { background: var(--danger-bg); }
.btn-text:disabled, .btn-text:disabled:hover { background: transparent; color: var(--text-disabled); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  transition: background-color var(--motion-fast) ease, color var(--motion-fast) ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn-md { width: 32px; height: 32px; }
.icon-btn-md svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--accent-tint); color: var(--text); }
.icon-btn.is-danger:hover { background: var(--danger-bg); color: var(--danger-text); }
.icon-btn:disabled, .icon-btn:disabled:hover { background: transparent; color: var(--text-disabled); }

/* Status chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 var(--space-2);
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip-sm { height: 20px; padding: 0 6px; font-size: var(--fs-xs); }
.chip-success { border-color: var(--success-border); background: var(--success-bg); color: var(--success-text); }
.chip-warning { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning-text); }
.chip-info { border-color: var(--info-border); background: var(--info-bg); color: var(--info-text); }
.chip-danger { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
.chip-neutral { border-color: var(--neutral-border); background: var(--neutral-bg); color: var(--neutral-text); }

/* History panel (right) */
.history-panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 58px;
  padding: var(--space-3) var(--space-2) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { color: var(--text); font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
.panel-head p { margin-top: 3px; color: var(--text-muted); font-size: var(--fs-sm); }
.panel-tools { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4) var(--space-1); }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; color: var(--text-secondary); font-size: var(--fs-sm); }
.breadcrumb-sep { color: var(--text-muted); }
.panel-tool-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: var(--space-2); }
.search-input { position: relative; display: block; min-width: 0; }
.search-input > svg { position: absolute; top: 50%; left: var(--space-2); width: 16px; height: 16px; margin-top: -8px; color: var(--text-muted); pointer-events: none; }
.search-input .input { padding-left: 30px; }
.panel-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 var(--space-4) var(--space-4); }
.history-group .section-label { padding: var(--space-3) 0 var(--space-2); }
.history-rows { border-top: 1px solid var(--border); }
.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px var(--space-2);
  padding: var(--space-2) 0 var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--border);
}
.history-name { grid-column: 1; color: var(--text); font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.45; overflow-wrap: anywhere; }
.history-meta { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); color: var(--text-muted); font-size: var(--fs-sm); }
.history-desc { grid-column: 1; color: var(--text-secondary); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.history-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: flex-start; gap: 2px; }
.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-4);
  border-top: 1px solid var(--border);
}
.panel-foot-note { color: var(--text-muted); font-size: var(--fs-sm); }
.empty-state { display: grid; justify-items: center; gap: 4px; padding: var(--space-8) var(--space-4); color: var(--text-muted); font-size: var(--fs-sm); text-align: center; }
.empty-state > svg { width: 28px; height: 28px; margin-bottom: var(--space-1); }
.empty-title { color: var(--text-secondary); font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.history-backdrop { display: none; }

/* Format dialog */
.format-dialog {
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-dialog);
  overflow: hidden;
}
.format-dialog::backdrop { background: var(--surface-overlay); }
.dialog-shell { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-3) var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 { color: var(--text); font-size: var(--fs-3xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
.dialog-head p { margin-top: var(--space-1); color: var(--text-muted); font-size: var(--fs-sm); }
.dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--space-4) var(--space-5) var(--space-5); }
.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}
.dialog-section-title { display: block; margin: var(--space-5) 0 var(--space-1); padding: 0; color: var(--text); font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.token-editor { min-width: 0; margin: var(--space-5) 0 0; padding: 0; border: 0; }
.token-editor > legend.dialog-section-title { margin-top: 0; }
.dialog-hint { color: var(--text-muted); font-size: var(--fs-sm); }
.dialog-preview { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0; color: var(--text-muted); font-size: var(--fs-sm); }
.dialog-callouts { margin: 0 0 var(--space-2); }
.token-editor-list { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 40px;
  padding: 2px var(--space-2) 2px var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}
.token-row:last-child { border-bottom: 0; }
.token-row label { display: flex; flex: 1 1 auto; align-items: center; gap: 10px; min-height: 32px; font-size: var(--fs-md); cursor: pointer; }
.token-row.is-off label { color: var(--text-muted); }
.token-row input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.token-move { display: flex; gap: 2px; }
.save-preset-row { display: flex; gap: var(--space-2); }
.save-preset-row .input { flex: 1 1 auto; min-width: 0; }
.custom-preset-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: 40px; padding: var(--space-1) 0; border-top: 1px solid var(--border); font-size: var(--fs-md); }
.custom-preset-name { flex: 1 1 auto; font-weight: var(--fw-medium); }

/* Toast */
.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: max-content; /* left: 50% would otherwise cap the width at half the viewport */
  max-width: calc(100vw - 32px);
  padding: 10px var(--space-4) 10px var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-menu);
  font-size: var(--fs-md);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity var(--motion-base) ease, transform var(--motion-base) ease;
}
.toast::before { content: ""; align-self: stretch; width: 3px; flex: none; border-radius: 2px; background: var(--accent); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

/* Narrow builder column: stack the field grids */
@container (max-width: 520px) {
  .field-grid, .format-grid, .doc-grid { grid-template-columns: minmax(0, 1fr); }
  .field-wide { grid-column: auto; }
}

/* ---------- Responsive contract ---------- */

/* 1180 to 1599: side columns scale so the builder keeps room for a full name; 340 / 400 from 1600 up */
@media (max-width: 1599px) {
  .app-shell { --list-w: clamp(280px, 21vw, 340px); --panel-w: clamp(320px, 26vw, 400px); }
}

/* 900 to 1179: history becomes a slide-over from the right */
@media (max-width: 1179px) {
  .app-shell, .app-shell[data-history="closed"] {
    grid-template-columns: var(--rail-w) var(--list-w) minmax(0, 1fr);
    grid-template-areas: "rail list detail";
  }
  .app-shell[data-history="closed"] .history-panel { display: flex; }
  .history-panel {
    position: fixed;
    z-index: 70;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    width: min(400px, 100vw);
    border-left: 1px solid var(--border-strong);
    box-shadow: var(--shadow-dialog);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform var(--motion-base) ease, visibility 0s linear var(--motion-base);
  }
  .history-panel.is-open { transform: none; visibility: visible; transition: transform var(--motion-base) ease, visibility 0s; }
  .history-backdrop { position: fixed; z-index: 65; inset: var(--header-h) 0 0 0; display: block; background: var(--surface-overlay); }
  .history-backdrop[hidden] { display: none; }
}

/* 700 to 899: presets become a horizontal strip above the builder; rail 200 */
@media (max-width: 899px) {
  .app-shell, .app-shell[data-history="closed"] {
    --rail-w: 200px;
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "rail list" "rail detail";
  }
  .list-column { border-right: 0; border-bottom: 1px solid var(--border-strong); }
  .list-column .column-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-2); min-height: 0; padding: var(--space-2) var(--space-4) var(--space-1); border-bottom: 0; }
  .list-column .column-head h2 { font-size: var(--fs-lg); }
  .list-scroll {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--space-1) var(--space-4) var(--space-3);
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--space-4);
    overscroll-behavior-x: contain;
  }
  .list-section, .preset-rows { display: contents; }
  .list-section .section-label, .list-empty, .row-chevron { display: none; }
  .preset-row { flex: 0 0 auto; width: 236px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; scroll-snap-align: start; }
  .preset-row.is-selected { border-color: var(--accent); }
  .preset-select { height: 100%; min-height: 56px; padding: var(--space-2) var(--space-3); }
  .preset-row.is-custom .preset-select { padding-right: 44px; }
  .preset-delete { top: 6px; right: 6px; margin-top: 0; }
  .modified-hint { flex: 0 0 auto; width: 210px; border: 1px solid var(--warning-border); border-radius: var(--radius-sm); }
}

/* < 700: rail becomes a tab strip, single column, 40px touch targets */
@media (max-width: 699px) {
  .app-header { grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-2); padding: 0 0 0 var(--space-3); }
  .brand-badge, .search-kbd, .header-search { display: none; }
  .app-header.is-search-open .header-search {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0 0 0 var(--space-2);
    background: var(--brand-bar);
  }
  .app-header.is-search-open .search-box { flex: 1 1 auto; height: 36px; }
  .search-close { display: inline-grid; flex: none; width: 44px; height: var(--header-h); }
  .search-open { display: inline-grid; }
  .search-results { position: fixed; top: calc(var(--header-h) + 4px); left: var(--space-2); right: var(--space-2); min-width: 0; max-height: calc(100dvh - var(--header-h) - 16px); }
  .bar-tab { justify-content: center; width: 44px; padding: 0; }
  .bar-tab-icon { display: block; }
  .bar-tab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .bar-count { position: absolute; top: 5px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; }
  .bar-tab.is-active::after { left: 10px; right: 10px; bottom: 4px; }
  .bar-icon-btn { width: 44px; }

  .app-shell, .app-shell[data-history="closed"] { display: block; height: auto; }
  .rail {
    position: sticky;
    z-index: 30;
    top: var(--header-h);
    display: block;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail-items { flex-direction: row; width: max-content; min-width: 100%; }
  .rail-item { width: auto; height: 44px; padding: 0 var(--space-3); gap: var(--space-2); }
  .rail-item.is-selected { background: transparent; box-shadow: inset 0 -2px 0 var(--accent); }
  .rail-label, .rail-help, .rail-reset { display: none; }
  .rail-short { display: inline; }
  .detail-column { display: block; }
  .detail-scroll { overflow: visible; }
  .detail-head { min-height: 0; padding: var(--space-3) var(--space-4); }
  .field-grid, .format-grid, .doc-grid, .format-options, .panel-tool-row { grid-template-columns: minmax(0, 1fr); }
  .field-wide { grid-column: auto; }

  .input { height: 40px; font-size: var(--fs-xl); }
  textarea.input { height: auto; }
  .btn, .btn-text { min-height: 40px; }
  .pill { height: 40px; padding: 0 var(--space-3) 0 10px; }
  .icon-btn, .icon-btn-md { width: 40px; height: 40px; }
  .group-band { height: 44px; }
  .toolbar-customize { flex: 1 1 100%; }
  .name-actions .btn { flex: 1 1 0; }
  .preset-select { min-height: 60px; }
  .preset-row.is-custom .preset-select { padding-right: 48px; }
  .preset-delete { top: 4px; right: 4px; margin-top: 0; }
  .modified-hint { min-height: 60px; }
  .menu-item, .search-option { min-height: 44px; }
  .history-panel { width: 100%; }
  .history-row { padding-left: 0; }
  .token-row { min-height: 48px; }
  .token-row label { min-height: 40px; }
  .dialog-head, .dialog-body, .dialog-foot { padding-left: var(--space-4); padding-right: var(--space-4); }
  .dialog-foot { flex-direction: column-reverse; align-items: stretch; }
  .dialog-foot .btn { width: 100%; }
}

@media (forced-colors: active) {
  .rail-item.is-selected, .preset-row.is-selected .preset-select, .search-option.is-active { outline: 2px solid CanvasText; outline-offset: -2px; }
  .bar-tab.is-active::after { background: CanvasText; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  .app-header, .rail, .list-column, .history-panel, .history-backdrop, .detail-toolbar, .name-actions, .toast, .skip-link, .field-counter, .group-band svg { display: none !important; }
  html, body { overflow: visible; }
  .app-shell, .app-shell[data-history="closed"] { display: block; height: auto; }
  .detail-column, .detail-scroll { display: block; overflow: visible; }
  .group-body[hidden] { display: block; }
  .group-band { background: none; }
}
