/* nghiem-ui v1 — bản gốc: chemistry_lab/src/nghiem. Không sửa ở lab khác; sửa ở gốc rồi chạy npm run nghiem:sync. */

/* ── Core theme tokens (light) ───────────────────────────── */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --surface-3: #e3e9f1;
  --border: #d7dee8;
  --border-strong: #b6c3d4;
  --text: #0f1b2d;
  --text-muted: #4a5b72;
  --text-subtle: #56657a;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --success: #15803d;
  --success-bg: #dcfce7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.06), 0 4px 12px rgba(15, 27, 45, 0.06);
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --elev-1: 0 2px 8px rgba(15, 27, 45, 0.08), 0 1px 2px rgba(15, 27, 45, 0.06);
  --elev-2: 0 8px 24px rgba(15, 27, 45, 0.1), 0 2px 6px rgba(15, 27, 45, 0.06);
  --control-h: 44px;
  --state-hover: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
  --state-press: color-mix(in srgb, var(--accent) 14%, var(--surface-3));
  --ring: 0 0 0 2px var(--accent), 0 0 0 4px var(--surface);
  --font-sans: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --z-raised: 10;
  --z-sticky: 100;
  --z-drawer: 1000;
  --z-overlay: 2000;
  --z-modal: 3000;
  --z-toast: 4000;
  --z-drag: 5000;
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --dur-slow: 300ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --tap-min: 44px;
  --nl-measure-body-max: min(32vh, 220px);
  --brand-mark: #3B82F6;
  --hdr-line: 1px;
  --hdr-clear: transparent;
  --hdr-zero: 0;
  --hdr-icon: 20px;
  --hdr-mark: 32px;
  --hdr-mark-small: 18px;
  --hdr-lab-mark: 28px;
  --hdr-lab-hero: 32px;
  --hdr-mobile-logo: 20px;
  --hdr-title: 20px;
  --hdr-title-hero: 22px;
  --hdr-mobile-title: 14px;
  --hdr-weight: 600;
  --hdr-bold: 700;
  --hdr-regular: 500;
  --hdr-leading: 1.25;
  --hdr-focus-offset: 2px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #121a2b;
    --surface-2: #1a2438;
    --surface-3: #223049;
    --border: #26334a;
    --border-strong: #36476a;
    --text: #e6edf7;
    --text-muted: #a3b3c9;
    --text-subtle: #7d8ca3;
    --accent: #60a5fa;
    --accent-strong: #93c5fd;
    --accent-soft: #172a4a;
    --success: #4ade80;
    --success-bg: #0f2e1d;
    --danger: #f87171;
    --danger-bg: #3a1414;
    --warn: #fbbf24;
    --warn-bg: #3a2a08;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    --elev-1: 0 2px 10px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    --elev-2: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
    --state-hover: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
    --state-press: color-mix(in srgb, var(--accent) 18%, var(--surface-3));
    --ring: 0 0 0 2px var(--accent), 0 0 0 4px var(--bg);
    --brand-mark: #60A5FA;
    color-scheme: dark;
  }
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121a2b;
  --surface-2: #1a2438;
  --surface-3: #223049;
  --border: #26334a;
  --border-strong: #36476a;
  --text: #e6edf7;
  --text-muted: #a3b3c9;
  --text-subtle: #7d8ca3;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: #172a4a;
  --success: #4ade80;
  --success-bg: #0f2e1d;
  --danger: #f87171;
  --danger-bg: #3a1414;
  --warn: #fbbf24;
  --warn-bg: #3a2a08;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  --radius-sm: 8px;
  --radius-lg: 14px;
  --elev-1: 0 2px 10px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --elev-2: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --control-h: 44px;
  --state-hover: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  --state-press: color-mix(in srgb, var(--accent) 18%, var(--surface-3));
  --ring: 0 0 0 2px var(--accent), 0 0 0 4px var(--bg);
  --brand-mark: #60A5FA;
  color-scheme: dark;
}

/* ── Global a11y & touch ─────────────────────────────────── */
:where(button, a, [role="tab"], input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: var(--ring);
}

@media (forced-colors: active) {
  :where(button, a, [role="tab"], input, select, textarea, [tabindex]):focus-visible {
    outline-color: Highlight;
  }
}

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

button {
  touch-action: manipulation;
}

/* Themed scrollbars (color-scheme above also keeps native scrollbars dark in dark mode). */
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* Form controls don't inherit the page font by default (browsers fall back to Arial / system UI).
   :where keeps specificity 0 so any lab rule still wins. */
:where(button, input, select, textarea) {
  font-family: inherit;
}

/* Vietnamese stacks diacritics (ệ, ở) — running text needs more leading than `normal`. */
:where(p) {
  line-height: 1.5;
}

/* ── Action buttons ──────────────────────────────────────── */
.action-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  transition: all var(--dur-base) var(--ease-out);
  font-family: var(--font-sans);
}

.action-btn:has(> svg) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-btn > svg {
  flex-shrink: 0;
}

.action-btn:hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: var(--surface-3);
  transform: translateY(-1px);
}

.action-btn:active:where(:not(:disabled, [aria-disabled="true"])) {
  transform: translateY(0);
}

.action-btn--danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* Hover danger: text #b91c1c on bg ~rgb(248,210,210) light; #f87171 on ~rgb(73,27,27) dark — ≥4.5:1 */
.action-btn--danger:hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: color-mix(in srgb, var(--danger) 8%, var(--danger-bg));
}

.action-btn--success {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

/* Hover success: light text ~rgb(20,103,57) on bg ~rgb(204,242,217); dark ~rgb(113,226,158) on ~rgb(20,60,37) — ≥4.5:1 */
.action-btn--success:hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: color-mix(in srgb, var(--success) 8%, var(--success-bg));
  color: color-mix(in srgb, var(--success) 75%, var(--text));
}

.action-btn--primary {
  font-weight: 700;
  border-width: 1px;
}

.action-btn--primary:disabled,
.action-btn--primary[aria-disabled="true"] {
  opacity: 0.45;
  filter: none;
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.action-btn--quiet-danger {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--danger);
}

.action-btn--quiet-danger:hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: var(--danger-bg);
}

.action-btn--quiet-danger svg {
  color: var(--danger);
}

.action-btn--ghost {
  background: transparent;
  border-color: transparent;
}

.action-btn--ghost:hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: var(--state-hover);
}

.action-btn--active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.action-btn:disabled,
.action-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.action-btn:disabled:hover,
.action-btn:disabled:active,
.action-btn[aria-disabled="true"]:hover,
.action-btn[aria-disabled="true"]:active {
  transform: none;
}

.action-btn--quiet-danger:disabled,
.action-btn--quiet-danger[aria-disabled="true"] {
  color: var(--text-subtle);
  background: var(--surface);
}

.action-btn--quiet-danger:disabled:hover,
.action-btn--quiet-danger[aria-disabled="true"]:hover {
  background: var(--surface);
}

.action-btn--quiet-danger:disabled svg,
.action-btn--quiet-danger[aria-disabled="true"] svg {
  color: var(--text-subtle);
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  box-sizing: border-box;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: var(--hdr-regular) var(--fs-sm) / var(--hdr-leading) var(--font-sans);
  cursor: pointer;
  touch-action: manipulation;
}

.header-icon-btn:hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: var(--state-hover);
}

.header-icon-btn:active:where(:not(:disabled, [aria-disabled="true"])) {
  background: var(--state-press);
}

.header-icon-btn:disabled,
.header-icon-btn[aria-disabled="true"] {
  color: var(--text-subtle);
  cursor: not-allowed;
}

.nl-header-actions .action-btn.header-icon-btn:not(.nl-header-cta) {
  border: 0;
  background: transparent;
  transform: none;
}

.nl-header-actions .action-btn.header-icon-btn:not(.nl-header-cta):hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: var(--state-hover);
  transform: none;
}

.nl-header-actions .action-btn.header-icon-btn:not(.nl-header-cta):active:where(:not(:disabled, [aria-disabled="true"])) {
  background: var(--state-press);
  transform: none;
}

.nl-header-actions .action-btn.header-icon-btn.nl-header-cta {
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding-inline: var(--space-4);
}

.nl-header-actions .action-btn.header-icon-btn.nl-header-cta:hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: color-mix(in srgb, var(--accent) 12%, var(--accent-soft));
  transform: none;
}

.nl-header-actions .action-btn.header-icon-btn.nl-header-cta:active:where(:not(:disabled, [aria-disabled="true"])) {
  background: color-mix(in srgb, var(--accent) 18%, var(--accent-soft));
  transform: none;
}

/* ── Header shell (option C) ───────────────────────────── */
.nl-header {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: var(--space-7);
  flex-shrink: 0;
  padding: var(--space-5) var(--space-6);
  background: var(--surface);
  color: var(--text);
  border-bottom: var(--hdr-line) solid var(--accent);
  font-family: var(--font-sans);
}

.nl-header-brand {
  min-width: 0;
  flex: 1 1 auto;
}

.nl-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  flex-wrap: nowrap;
  margin-inline-start: auto;
}

.nl-header-actions .header-btn-label {
  white-space: nowrap;
}

.nl-header-cta {
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding-inline: var(--space-4);
}

.nl-header-cta:hover:where(:not(:disabled, [aria-disabled="true"])) {
  background: color-mix(in srgb, var(--accent) 12%, var(--accent-soft));
}

@media (max-width: 599px) {
  .nl-header-cta {
    background: transparent;
    padding-inline: var(--space-2);
  }
}

.nl-metric {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline-end: var(--space-3);
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

.nl-metric:hover:where(:not(:disabled)) {
  background: var(--state-hover);
}

.nl-metric:focus-visible {
  outline: 2px solid transparent;
  box-shadow: var(--ring);
}

.nl-metric > svg {
  display: block;
  width: var(--hdr-icon);
  height: var(--hdr-icon);
  flex-shrink: 0;
}

.nl-metric-value {
  font-size: var(--fs-lg);
  font-weight: var(--hdr-weight);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.nl-metric--running .nl-metric-value {
  color: var(--success);
}

/* ── Brand lockup (option C) ───────────────────────────── */
.nl-brand {
  display: grid;
  grid-template-columns: var(--hdr-lab-hero) minmax(0, 1fr);
  column-gap: var(--space-3);
  row-gap: var(--space-1);
  align-items: center;
  min-width: 0;
  margin: 0;
}

.nl-brand-logo {
  grid-column: 1;
  grid-row: 1 / 3;
  width: var(--hdr-lab-hero);
  height: var(--hdr-lab-hero);
  display: block;
  flex: none;
  object-fit: contain;
}

.nl-brand-title {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--hdr-title-hero);
  font-weight: var(--hdr-bold);
  line-height: var(--hdr-leading);
  color: var(--text);
}

.nl-brand-endorse {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  min-width: 0;
  font-size: var(--fs-xs);
  line-height: var(--hdr-leading);
  color: var(--text-muted);
}

.nl-brand-endorse-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: 4px;
}

.nl-brand-endorse-link:hover .nl-brand-parent {
  color: var(--accent-strong);
}

.nl-brand-mark {
  color: var(--brand-mark);
  flex: none;
}

.nl-brand-parent {
  font-weight: var(--hdr-regular);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 599px) {
  .nl-brand {
    grid-template-columns: var(--hdr-lab-mark) minmax(0, 1fr);
    column-gap: var(--space-2);
  }

  .nl-brand-logo {
    width: var(--hdr-lab-mark);
    height: var(--hdr-lab-mark);
  }

  .nl-brand-title {
    font-size: var(--hdr-mobile-title);
  }
}

@media (max-width: 379px) {
  .nl-brand-title {
    font-size: var(--hdr-mobile-title);
  }
}


/* ── Shared nl-* components (from approved design) ── */
/* Toolbar: nhóm nút cuối DOM kết thúc bằng quiet-danger. */
.nl-bench-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:var(--space-2); padding:var(--space-3) 0; color:var(--text); }
.nl-bench-title { margin:0; margin-inline-end:auto; font:700 var(--fs-lg)/1.4 var(--font-sans); }
/* Bàn trống: nội dung tự xuống dòng, không đặt chiều cao cố định. */
.nl-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); font-family:var(--font-sans); }
.nl-empty > svg { display:block; flex:none; width:40px; height:40px; color:var(--text-subtle); }
.nl-empty-title { margin:0; font-size:var(--fs-lg); line-height:1.4; font-weight:600; color:var(--text); }
.nl-empty-sub { max-width:42ch; margin:0; margin-inline:auto; color:var(--text-muted); font-size:var(--fs-md); line-height:1.6; }
/* The empty state sits on the bench and is usually positioned over it; keep it above bench layers
   (grid/surface SVG) and let only its buttons take clicks so drops still reach the bench. */
.nl-empty { z-index:var(--z-raised); }
.nl-empty-actions { display:flex; justify-content:center; flex-wrap:wrap; gap:var(--space-2); margin-top:var(--space-2); pointer-events:auto; }
/* Các điều khiển chia sẻ hit area, icon và phản hồi. */
.nl-pill-btn,.nl-chip,.nl-card,.nl-tab,.nl-dialog-close { box-sizing:border-box; min-height:var(--tap-min); min-width:var(--tap-min); font-family:var(--font-sans); font-size:var(--fs-sm); cursor:pointer; touch-action:manipulation; transition:transform var(--dur-fast) var(--ease-out),opacity var(--dur-base) var(--ease-out); }
.nl-pill-btn { display:inline-flex; justify-content:center; align-items:center; gap:var(--space-2); padding:var(--space-2) var(--space-4); border:1px solid var(--accent); border-radius:var(--space-8); background:var(--surface); color:var(--accent-strong); line-height:1.4; font-weight:600; }
.nl-pill-btn > svg,.nl-chip > svg,.nl-tab > svg,.nl-panel-hint > svg,.nl-dialog-close > svg { display:block; width:var(--space-5); height:var(--space-5); flex:none; }
/* Bộ lọc một hàng; mask chỉ báo phần còn cuộn, không phải gradient trang trí. */
.nl-chip-row { display:flex; gap:var(--space-2); overflow-x:auto; padding:var(--space-2); scroll-padding-inline:var(--space-2); scrollbar-width:thin; }
.nl-chip-row[data-fade-start] { mask-image:linear-gradient(to right,transparent,currentColor var(--space-4)); }
.nl-chip-row[data-fade-end] { mask-image:linear-gradient(to left,transparent,currentColor var(--space-4)); }
.nl-chip-row[data-fade-start][data-fade-end] { mask-image:linear-gradient(to right,transparent,currentColor var(--space-4),currentColor calc(100% - var(--space-4)),transparent); }
.nl-chip { display:inline-flex; align-items:center; gap:var(--space-2); flex:none; padding:var(--space-2) var(--space-3); border:1px solid var(--border-strong); border-radius:var(--space-8); background:var(--surface); color:var(--text-muted); white-space:nowrap; }
.nl-chip-count { font-size:var(--fs-xs); font-variant-numeric:tabular-nums; color:var(--text-muted); }
.nl-chip[aria-selected="true"],.nl-chip[aria-pressed="true"] { color:var(--text); background:var(--accent-soft); border-color:var(--accent); font-weight:700; }
/* Hợp đồng slot dùng chung cho thẻ một dòng, nhiều dòng và tile. */
.nl-card { display:flex; align-items:center; gap:var(--space-3); min-height:44px; width:100%; padding:var(--space-3); border:1px solid var(--border-strong); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); text-align:start; line-height:1.4; }
.nl-card-media { width:32px; height:32px; display:grid; place-items:center; flex:none; }
.nl-card-media--item { width:56px; height:56px; }
.nl-card-media--sm { width:20px; height:20px; }
.nl-card-media > svg,.nl-card-media > img { display:block; width:100%; height:100%; object-fit:contain; }
.nl-card-body { flex:1; min-width:0; display:flex; flex-direction:column; gap:var(--space-1); }
.nl-card-title { display:flex; align-items:center; gap:var(--space-2); min-width:0; margin:0; font-weight:600; line-height:1.3; }
.nl-card-title > span { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; overflow:hidden; overflow-wrap:anywhere; min-width:0; }
.nl-card-meta { display:flex; align-items:center; flex-wrap:wrap; gap:var(--space-1); min-width:0; }
.nl-card-check { margin-left:auto; width:16px; height:16px; display:block; flex:none; }
.nl-card--tile { flex-direction:column; justify-content:center; align-items:center; text-align:center; min-height:104px; }
.nl-card--tile > .nl-card-body { flex:none; width:100%; }
.nl-card--tile .nl-card-title { justify-content:center; min-height:2.6em; }
.nl-card[aria-pressed="true"] { border-color:var(--accent); background:var(--accent-soft); }
.nl-card[data-dragging="true"] { border-style:dashed; border-color:var(--accent); box-shadow:var(--elev-1); opacity:.7; transform:translateY(calc(-1 * var(--space-1))); cursor:grabbing; }
/* Panel: details/summary giữ hành vi bàn phím native. */
.nl-panel-title { margin:0; font-size:var(--fs-xs); font-weight:700; letter-spacing:0.06em; text-transform:uppercase; color:var(--text-muted); font-family:var(--font-sans); line-height:1.5; }
.nl-panel-hint { display:flex; align-items:center; gap:var(--space-2); margin:var(--space-2) 0 var(--space-4); color:var(--text-muted); font:400 var(--fs-sm)/1.6 var(--font-sans); }
.nl-panel-section { padding-block:var(--space-3); border-bottom:1px solid var(--border); color:var(--text); }
.nl-panel-section > summary { display:flex; align-items:center; justify-content:space-between; gap:var(--space-2); min-height:var(--tap-min); cursor:pointer; list-style:none; border-radius:var(--radius-sm); }
.nl-panel-section > summary::-webkit-details-marker { display:none; }
.nl-panel-section > summary > svg { width:var(--space-4); height:var(--space-4); transition:transform var(--dur-base) var(--ease-out); }
.nl-panel-section[open] > summary > svg { transform:rotate(180deg); }
/* Tabbar nằm trong shell; shell dùng hàng cuối để không đè nội dung. */
.nl-tabbar { display:flex; min-height:56px; padding-bottom:env(safe-area-inset-bottom,0px); background:var(--surface); border-top:1px solid var(--border-strong); z-index:var(--z-sticky); }
.nl-tabbar .nl-tab > svg { width:20px; height:20px; }
.nl-tab { display:flex; flex:1 1 0; flex-direction:column; align-items:center; justify-content:center; gap:var(--space-1); padding:var(--space-1); border:0; border-top:2px solid transparent; background:transparent; color:var(--text-muted); text-decoration:none; font-size:var(--fs-xs); line-height:1.4; }
.nl-tab[aria-current="page"] { color:var(--accent-strong); border-top-color:var(--accent); background:var(--accent-soft); font-weight:600; }
.nl-tabbar .nl-tab[aria-current="page"] { border-top-width:3px; }
/* Dialog native: top-layer, body cuộn, footer luôn truy cập được. */
.nl-dialog { box-sizing:border-box; width:min(36rem,calc(100% - var(--space-6))); max-height:calc(100dvh - var(--space-8)); margin:auto; padding:0; border:1px solid var(--border-strong); border-radius:var(--radius-lg); background:var(--surface); color:var(--text); box-shadow:var(--elev-2); font:400 var(--fs-md)/1.6 var(--font-sans); z-index:var(--z-modal); }
.nl-dialog[open] { display:flex; flex-direction:column; }
.nl-dialog::backdrop { background:color-mix(in srgb,var(--bg) 75%,transparent); }
.nl-dialog-header { display:flex; align-items:center; justify-content:space-between; gap:var(--space-3); padding:var(--space-3) var(--space-4); border-bottom:1px solid var(--border); }
.nl-dialog-title { margin:0; font-size:var(--fs-xl); line-height:1.4; }
.nl-dialog-close { display:grid; place-items:center; flex:none; padding:var(--space-2); border:1px solid transparent; border-radius:var(--radius-sm); background:transparent; color:var(--text-muted); }
.nl-dialog-body { padding:var(--space-4); overflow:auto; min-height:0; }
.nl-dialog-footer { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:var(--space-2); padding:var(--space-3) var(--space-4); border-top:1px solid var(--border); }
/* Focus thật và trạng thái mẫu dùng chung; data-preview chỉ dành cho catalogue. */
.nl-pill-btn:focus-visible,.nl-chip:focus-visible,.nl-card:focus-visible,.nl-tab:focus-visible,.nl-dialog-close:focus-visible,.nl-panel-section > summary:focus-visible,.nl-brand-title:focus-visible,.nl-card[data-preview="focus"] { outline:2px solid transparent; box-shadow:var(--ring); }
@media (hover:hover) {
 .nl-pill-btn:hover:not(:disabled),.nl-chip:hover:not(:disabled),.nl-card:hover:not(:disabled),.nl-tab:hover:not(:disabled),.nl-dialog-close:hover { background:var(--state-hover); }
}
.nl-card[data-preview="hover"] { background:var(--state-hover); }
.nl-pill-btn:active:not(:disabled),.nl-chip:active:not(:disabled),.nl-card:active:not(:disabled),.nl-tab:active:not(:disabled),.nl-dialog-close:active,.nl-card[data-preview="active"] { background:var(--state-press); transform:translateY(1px); }
.nl-pill-btn:disabled,.nl-chip:disabled,.nl-card:disabled,.nl-tab:disabled,.nl-dialog-close:disabled { opacity:.45; cursor:not-allowed; transform:none; }
@media (prefers-reduced-motion:reduce) {
 .nl-pill-btn,.nl-chip,.nl-card,.nl-tab,.nl-dialog-close,.nl-panel-section > summary > svg { transition:none; }
 .nl-pill-btn:active,.nl-chip:active,.nl-card:active,.nl-tab:active,.nl-dialog-close:active,.nl-card[data-dragging],.nl-card[data-preview="active"] { transform:none; }
}

@media (max-width:599px) {
 .nl-empty-actions { flex-direction:column; align-items:center; width:100%; }
 .nl-empty-actions .nl-pill-btn { width:100%; max-width:320px; }
}


/* Module header: brand + switch trong .nl-module-heading; actions là sibling cuối. */
.nl-module-header { display:flex; align-items:center; gap:16px; padding:12px 16px; background:var(--surface); border-bottom:1px solid var(--border); }
.nl-module-heading { display:flex; align-items:center; gap:16px; min-width:0; }
.nl-module-heading > .nl-brand { flex:none; }
.nl-module-switch { position:relative; display:flex; flex:none; align-items:stretch; box-sizing:border-box; min-height:var(--tap-min); gap:var(--space-1); background:transparent; }
.nl-module-switch > button { position:relative; display:flex; align-items:center; justify-content:center; gap:var(--space-2); box-sizing:border-box; min-height:var(--tap-min); min-width:var(--tap-min); padding:0 var(--space-3); border:0; border-radius:var(--hdr-zero); border-bottom:var(--hdr-focus-offset) solid var(--hdr-clear); background:transparent; color:var(--text-muted); font:var(--hdr-regular) var(--fs-sm)/1.4 var(--font-sans); white-space:nowrap; cursor:pointer; touch-action:manipulation; }
.nl-module-switch > button[aria-pressed="true"] { color:var(--accent-strong); font-weight:var(--hdr-weight); border-bottom-color:var(--accent); background:var(--hdr-clear); }
.nl-module-switch > button > svg { display:block; width:16px; height:16px; flex:none; }
.nl-module-switch > button:focus-visible { outline:2px solid transparent; box-shadow:var(--ring); }
.nl-module-header > .nl-module-actions { display:flex; align-items:center; gap:8px; margin-inline-start:auto; flex:none; }
@media (600px <= width < 900px) {
 .nl-module-heading { flex:1; flex-wrap:wrap; gap:12px 16px; }
}
@media (width < 600px) {
 .nl-module-header { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px 8px; }
 .nl-module-heading { display:contents; }
 .nl-module-heading > .nl-brand { grid-column:1; grid-row:1; }
 .nl-module-header > .nl-module-actions { grid-column:2; grid-row:1; }
 .nl-module-switch { grid-column:1 / -1; grid-row:2; width:100%; }
 .nl-module-switch > button { flex:1 1 0; min-width:0; padding-inline:4px; }
}
.header-menu-wrap {
 position:relative;
}
.header-overflow-menu {
 position:absolute;
 right:0;
 top:calc(100% + 4px);
 z-index:60;
 min-width:min(92vw, 280px);
 background:var(--surface);
 border:1px solid var(--border-strong);
 border-radius:10px;
 box-shadow:var(--shadow);
 padding:8px;
 display:flex;
 flex-direction:column;
 gap:4px;
}
.header-overflow-item {
 display:flex;
 align-items:center;
 gap:8px;
 width:100%;
 border:none;
 background:var(--surface-2);
 color:var(--text);
 border-radius:8px;
 padding:8px 10px;
 font-size:13px;
 cursor:pointer;
 text-align:left;
}
.header-overflow-item select {
 margin-left:auto;
 max-width:140px;
 font-size:13px;
}
.header-overflow-timer {
 font-family:var(--font-mono);
 justify-content:flex-start;
}

/* Measure dock: one title row when collapsed; open body shrinks in the column flow. */
.nl-measure-dock {
 display:flex;
 flex-direction:column;
 flex:0 0 auto;
 min-height:0;
 margin-top:var(--space-2);
 background:var(--surface);
 border:1px solid var(--border);
 border-radius:var(--radius-sm);
 color:var(--text);
}
.nl-measure-dock--collapsed {
 flex:0 0 auto;
}
.nl-measure-dock:not(.nl-measure-dock--collapsed):not(.nl-measure-dock--tab) {
 flex:0 1 auto;
}
.nl-measure-dock--tab {
 flex:1 1 auto;
 min-height:0;
 margin-top:0;
 border:0;
 display:flex;
 flex-direction:column;
}
.nl-measure-dock-header { flex:none; }
.nl-measure-dock-toggle {
 position:relative;
 display:flex;
 align-items:center;
 gap:var(--space-2);
 width:100%;
 min-height:var(--tap-min);
 min-width:var(--tap-min);
 padding:var(--space-2) var(--space-3);
 border:0;
 background:transparent;
 color:inherit;
 font:inherit;
 text-align:start;
 cursor:pointer;
}
.nl-measure-dock-title {
 flex:none;
 min-width:0;
 font-size:var(--fs-sm);
 font-weight:600;
}
.nl-measure-dock-title--tab { padding:var(--space-2) var(--space-3); }
.nl-measure-dock-summary {
 flex:1;
 min-width:0;
 overflow:hidden;
 text-overflow:ellipsis;
 white-space:nowrap;
 font-size:var(--fs-sm);
 font-weight:400;
 color:var(--text-muted);
}
.nl-measure-dock-toggle-sr {
 position:absolute;
 width:1px;
 height:1px;
 padding:0;
 margin:-1px;
 overflow:hidden;
 clip:rect(0,0,0,0);
 white-space:nowrap;
 border:0;
}
.nl-measure-dock-body {
 flex:0 1 auto;
 min-height:0;
 max-height:var(--nl-measure-body-max);
 overflow:auto;
 padding:var(--space-2) var(--space-3);
}
.nl-measure-dock--tab .nl-measure-dock-body {
 max-height:none;
 flex:1 1 auto;
}
.nl-measure-empty {
 margin:0;
 color:var(--text-muted);
 font-size:var(--fs-sm);
 line-height:1.5;
}

/* Bottom-sheet peek: keep the panel mounted and collapse with transform only. */
.slide-drawer--bottom.open.slide-drawer--peek {
  transform: translateY(calc(100% - 56px));
  transition: none;
}

@media (width < 600px) {
 .nl-header:not(:has(.nl-module-switch)),
 .nl-header:has(.nl-module-switch) {
  display:grid;
  grid-template-columns:minmax(0,1fr) max-content;
  gap:var(--space-3) var(--space-2);
  padding:var(--space-3);
 }
 .nl-header:not(:has(.nl-module-switch)) .nl-header-brand,
 .nl-header:has(.nl-module-switch) .nl-header-brand { grid-column:1; grid-row:1; min-width:0; }
 .nl-header:not(:has(.nl-module-switch)) .nl-header-actions,
 .nl-header:has(.nl-module-switch) .nl-header-actions { grid-column:2; grid-row:1; margin-inline-start:0; flex-wrap:nowrap; gap:0; }
 .nl-header:not(:has(.nl-module-switch)) .nl-header-actions .header-icon-btn,
 .nl-header:has(.nl-module-switch) .nl-header-actions .header-icon-btn { flex-shrink:0; padding:0; }
 .nl-header:has(.nl-module-switch) .nl-module-switch { grid-column:1 / -1; grid-row:2; width:100%; min-width:0; }
 .nl-header:has(.nl-module-switch) .nl-module-switch > button { flex:1 1 0; min-width:0; padding-inline:4px; }
}

