/*
 * SPDX-FileCopyrightText: 2026 André L Schauer <info@ono-system.com>
 * SPDX-License-Identifier: AGPL-3.0-or-later
 *
 * NiceColors — Stylesheet
 * Extracted from /opt/niceunits-staging/index.html (Phase 1.3 of Container-per-App-Refactor sprint).
 * Sections marked [EXT:*] are candidates for future split into design-extensions/*.css.
 */

/* ===================================================================
   RESET & TOKENS (Core, shared baseline)
   =================================================================== */
@font-face { font-family: 'Haffer'; src: url('/vendor/fonts/Haffer-382.woff2') format('woff2'); font-weight: 382; font-display: swap; }
@font-face { font-family: 'Haffer'; src: url('/vendor/fonts/Haffer-618.woff2') format('woff2'); font-weight: 618; font-display: swap; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --space-xxs: clamp(0.331rem, 0.328rem + 0.014vw, 0.35rem);
  --space-xs:  clamp(0.531rem, 0.526rem + 0.023vw, 0.563rem);
  --space-s:   clamp(0.675rem, 0.669rem + 0.027vw, 0.713rem);
  --space-m:   clamp(0.863rem, 0.854rem + 0.037vw, 0.913rem);
  --space-l:   clamp(1.394rem, 1.38rem + 0.059vw, 1.475rem);
  --space-xl:  clamp(2.25rem, 2.227rem + 0.096vw, 2.381rem);
  --space-xxl: clamp(3.644rem, 3.607rem + 0.156vw, 3.856rem);
  --type-xxs: clamp(10px, 0.55vw, 14px); --type-xs: clamp(12px, 0.7vw, 17px);
  --type-s: clamp(14px, 0.89vw, 22px); --type-m: clamp(17px, 1.13vw, 28px);
  --type-l: clamp(20px, 1.44vw, 36px); --type-xl: clamp(24px, 1.83vw, 46px);
  --radius-xs: clamp(0.531rem, 0.526rem + 0.023vw, 0.563rem);
  --radius-s: clamp(0.675rem, 0.669rem + 0.027vw, 0.713rem);
  --radius-m: clamp(0.863rem, 0.854rem + 0.037vw, 0.913rem);
  --radius-l: clamp(1.394rem, 1.38rem + 0.059vw, 1.475rem);
  --radius-full: 9999px;
  --stroke-s: calc(var(--type-xs) * 0.146); --stroke-m: calc(var(--type-xs) * 0.236);
  --duration-s: 161ms; --duration-m: 260ms; --duration-l: 421ms;
  --fw: 382; --fw-b: 618;
  --toolbar-h: calc(var(--space-xl) + var(--space-xxs) * 2);
  --header-h: calc(var(--toolbar-h) + var(--space-m) * 2);
  --footer-h: 44px;
  --orange: #FD9501;
  --orange-dark: color-mix(in srgb, var(--orange) 32%, var(--background));
  /* Dark (default) — ONO OS tokens */
  --background: #09090b; --foreground: #fafafa;
  --card: #18181b; --card-foreground: #fafafa;
  --muted: #2A2725; --muted-foreground: #A39E98;
  --accent: #27272a; --accent-foreground: #fafafa;
  --border: #27272a; --input: #27272a; --ring: #FD9501;
  --bg: var(--background); --bg2: var(--card); --bg3: var(--accent);
  --text: var(--foreground); --text2: var(--muted-foreground); --text3: #52525b;
  color-scheme: dark;
}
[data-theme="light"] {
  --background: #fafafa; --foreground: #09090b;
  --card: #ffffff; --card-foreground: #09090b;
  --muted: #F5F4ED; --muted-foreground: #6B6560;
  --accent: #F5F4ED; --accent-foreground: #09090b;
  --border: #E8E7E0; --input: #E8E7E0; --ring: #FD9501;
  --bg: var(--background); --bg2: var(--card); --bg3: var(--accent);
  --text: var(--foreground); --text2: var(--muted-foreground); --text3: #a1a1aa;
  color-scheme: light;
}

/* ===================================================================
   BODY + TYPOGRAPHY (Core, shared baseline)
   =================================================================== */
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Haffer', -apple-system, system-ui, sans-serif;
  font-weight: var(--fw); font-size: var(--type-s); line-height: 1.618;
  text-transform: lowercase;
  font-kerning: normal;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1, 'ss01' 1, 'ss03' 1, 'ss04' 1, 'ss05' 1, 'tnum' 1, 'zero' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex; flex-direction: column;
  padding-bottom: var(--footer-h);
}
code, pre, input, textarea, select, [contenteditable], .preserve-case { text-transform: none; }
h1, h2, h3, h4, .heading, [class*="text-2xl"], [class*="text-3xl"], [class*="text-4xl"], [class*="text-5xl"] {
  font-feature-settings: 'kern' 1, 'liga' 0, 'calt' 1, 'ss01' 1, 'ss03' 1, 'ss04' 1, 'ss05' 1, 'tnum' 1, 'zero' 1;
}
::selection { background: var(--orange); color: #fff; }

.main { display: flex; flex: 1 0 auto; overflow: visible; min-height: 0; }
.content { flex: 1 0 auto; overflow: visible; }
.scroll-shell { flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; min-height: 0; }

/* ===================================================================
   SUBHEADER — for #subheader-colors (Gamut/Swatches toggle wrapper)
   =================================================================== */
.subheader { display: flex; align-items: center; gap: var(--space-xs); height: var(--header-h); padding: 0 var(--space-m); border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; }
.subheader .search-wrap { flex: 1; max-width: 320px; }
.subheader-right { display: flex; align-items: center; gap: var(--space-xxs); margin-left: auto; }

#subheader-colors { position: absolute; top: var(--header-h); left: 50%; transform: translateX(-50%); z-index: 11; height: auto; padding: var(--space-s) 0; border: none; background: transparent; pointer-events: none; }
#subheader-colors > * { pointer-events: auto; }

/* ===================================================================
   [EXT:gamut-3d-viewer] — Gamut canvas + body.gamut-active state
   =================================================================== */
/* Gamut view ALWAYS dark — regardless of light-mode. The 3D color dots need a
   dark backdrop for correct perception; overrides force dark surfaces while
   body.gamut-active is set. NiceColors = dark-mode-only-app. */
body.gamut-active { color-scheme: dark; }
body.gamut-active {
  --background: #09090b; --foreground: #fafafa;
  --card: #18181b; --card-foreground: #fafafa;
  --muted: #2A2725; --muted-foreground: #A39E98;
  --accent: #27272a; --accent-foreground: #fafafa;
  --border: #27272a; --input: #27272a;
  --bg: var(--background); --bg2: var(--card); --bg3: var(--accent);
  --text: var(--foreground); --text2: var(--muted-foreground); --text3: #52525b;
}
body.gamut-active .ono-headroom-nav {
  --hn-bg: #000;
  --hn-fg: #fafafa;
  --hn-line: rgba(255,255,255,0.08);
  --hn-muted: #1F1F23;
}
body.gamut-active .colors-split .colors-systems,
body.gamut-active .colors-split .colors-sidebar { background: rgba(255, 255, 255, 0.035); border-color: rgba(255, 255, 255, 0.08); color: #fafafa; }
body.gamut-active .sys-toolbar { background: rgba(9,9,11,0.78); border-bottom-color: rgba(255, 255, 255, 0.08); }
body.gamut-active .sys-search,
body.gamut-active .sys-filter-btn { background: rgba(0, 0, 0, 0.35); border-color: rgba(255, 255, 255, 0.12); color: #fafafa; }
body.gamut-active .mega-menu { background: #111114; border-color: rgba(255, 255, 255, 0.12); color: #fafafa; }
body.gamut-active #sysInfoPanel { background: rgba(24, 24, 27, 0.75); border-color: rgba(255, 255, 255, 0.06); color: #fafafa; }
body.gamut-active .site-footer { background: rgba(9, 9, 11, 0.55); color: #a1a1a1; border-top-color: rgba(255, 255, 255, 0.06); }
body.gamut-active .site-footer a { color: #a1a1a1; }
body.gamut-active #gamutGridToggle { background: rgba(0, 0, 0, 0.6); border-color: rgba(255, 255, 255, 0.15); color: #fff; }
body.gamut-active #gamutGridToggle svg { stroke: #fff; }
body.gamut-active header { background: rgba(9,9,11,0.55); backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%); position: relative; z-index: 10; border-bottom: none; }
body.gamut-active .subheader { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; position: relative; z-index: 10; border-bottom: none; }
body.gamut-active .main { background: transparent; position: relative; z-index: 1; }
body.gamut-active .scroll-shell { display: none; }

#gamutBgCanvas { position: fixed; inset: 0; z-index: 0; background: #09090b; pointer-events: none; }
#gamutBgCanvas #gamut3d { pointer-events: auto; }
#gamutFence { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity var(--duration-m); }
#gamutFence.visible { opacity: 0.85; }

/* ===================================================================
   COLORS-SPLIT LAYOUT — main 3-column container
   =================================================================== */
.colors-split { display: flex; flex: 1; overflow: hidden; height: 100%; position: relative; max-height: calc(100vh - var(--header-h) - var(--footer-h)); }
.colors-split .colors-main { flex: 1; overflow-y: auto; overflow-x: hidden; min-width: 0; position: relative; z-index: 1; }
.colors-split:not(.gamut-mode) .colors-main { padding-top: var(--space-xl); }
.colors-split.gamut-mode { }
.colors-split.gamut-mode .colors-main { overflow: visible; background: transparent; pointer-events: none; }
.colors-split.gamut-mode .colors-main > div { background: transparent !important; pointer-events: auto; }
.colors-split .colors-systems, .colors-split .colors-sidebar { position: relative; z-index: 2; }

/* ===================================================================
   [EXT:color-system-picker] — .colors-systems sidebar (left)
   =================================================================== */
.colors-split .colors-systems { width: 388px; flex-shrink: 0; margin: var(--space-s) 0 var(--space-s) var(--space-s); border-radius: var(--radius-l); overflow-y: auto; padding: var(--space-s) var(--space-xxs); background: rgba(255,255,255,0.035); backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%); border: 1px solid rgba(255,255,255,0.06); position: relative; box-shadow: 0 8px 32px rgba(0,0,0,0.25); }

.colors-systems .sys-info-btn { width: var(--space-m); height: var(--space-m); border-radius: 50%; border: 1px solid rgba(255,255,255,0.18); background: transparent; color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; font: 618 10px/1 Haffer,sans-serif; cursor: pointer; margin-left: var(--space-xs); flex-shrink: 0; transition: all var(--duration-s); }
.colors-systems .sys-info-btn:hover { border-color: var(--orange); color: var(--orange); }

#sysInfoPanel { position: absolute; top: var(--space-s); left: calc(388px + var(--space-s) + var(--space-xs)); width: 360px; height: calc(100% - var(--space-s) * 2); background: rgba(24,24,27,0.75); backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%); border: 1px solid rgba(255,255,255,0.06); border-radius: var(--radius-l); padding: var(--space-l); overflow-y: auto; z-index: 3; opacity: 0; pointer-events: none; transform: translateX(-8px); transition: opacity var(--duration-m), transform var(--duration-m); box-shadow: 0 8px 32px rgba(0,0,0,0.25); }
#sysInfoPanel.open { opacity: 1; pointer-events: auto; transform: translateX(0); }
#sysInfoPanel.pinned { box-shadow: 0 0 0 2px var(--orange) inset; }

.colors-systems .sys-btn-row { display: flex; align-items: center; gap: 2px; padding-right: var(--space-xs); border-radius: var(--radius-xs); transition: background var(--duration-s); }
.colors-systems .sys-btn-row:hover { background: var(--muted); }
.colors-systems .sys-btn-row.row-active { background: var(--muted); }
.colors-systems .sys-btn { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-xs) var(--space-s); margin: 0; border-radius: var(--radius-xs); border: 1px solid transparent; cursor: pointer; font-size: var(--type-xs); font-family: inherit; background: transparent; color: var(--muted-foreground); text-align: left; flex: 1; min-width: 0; transition: color var(--duration-s); white-space: nowrap; }
.colors-systems .sys-btn:hover { color: var(--foreground); }
.colors-systems .sys-btn.active { color: var(--foreground); font-weight: 618; }
.colors-systems .sys-btn:hover .sys-dot,
.colors-systems .sys-btn.active .sys-dot { background: var(--orange) !important; border-color: var(--orange); box-shadow: none; }
.colors-systems .sys-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1px solid var(--border); transition: background var(--duration-s), border-color var(--duration-s); }
.colors-systems .sys-count { margin-left: auto; opacity: 0.6; font-size: var(--type-xxs); font-variant-numeric: tabular-nums; }
.colors-systems .sys-header { font-size: var(--type-xxs); color: var(--muted-foreground); font-weight: 618; padding: var(--space-xs) var(--space-s) var(--space-xxs); letter-spacing: 0.04em; }

/* Sticky search + filter chrome at the top of the systems sidebar */
.sys-toolbar { position: sticky; top: 0; z-index: 5; background: rgba(24,24,27,0.78); -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%); padding: var(--space-xs) var(--space-s) var(--space-s); display: flex; flex-direction: column; gap: var(--space-xs); border-bottom: 1px solid rgba(255,255,255,0.05); border-radius: var(--radius-m) var(--radius-m) 0 0; }
.sys-search-wrap { position: relative; display: flex; align-items: center; }
.sys-search { width: 100%; box-sizing: border-box; padding: var(--space-xs) var(--space-s) var(--space-xs) 30px; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-m); color: var(--foreground); font: 382 var(--type-xs)/1.3 Haffer,sans-serif; outline: none; transition: border-color var(--duration-s); }
.sys-search:focus { border-color: var(--orange); }
.sys-search::placeholder { color: var(--muted-foreground); }
.sys-search-icon { position: absolute; left: 10px; width: 12px; height: 12px; color: var(--muted-foreground); pointer-events: none; }

.sys-filter-btn { width: 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); padding: var(--space-xs) var(--space-s); background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-m); color: var(--foreground); font: 618 var(--type-xs)/1.3 Haffer,sans-serif; cursor: pointer; transition: all var(--duration-s); text-align: left; }
.sys-filter-btn:hover { border-color: rgba(255,255,255,0.22); }
.sys-filter-btn.active { border-color: var(--orange); background: rgba(255,165,0,0.10); }
.sys-filter-btn .sys-filter-left { display: inline-flex; align-items: center; gap: 6px; }
.sys-filter-btn .sys-filter-right { display: inline-flex; align-items: center; gap: var(--space-xs); }
.sys-filter-btn .count-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9999px; background: var(--orange); color: #fff; font: 618 10px/1 Haffer,sans-serif; }
.sys-filter-btn .count-pill[hidden] { display: none; }
.sys-filter-reset { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 9999px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #fff; font: 618 var(--type-xxs)/1 Haffer,sans-serif; cursor: pointer; user-select: none; transition: background var(--duration-s), border-color var(--duration-s); }
.sys-filter-reset:hover { background: var(--orange); border-color: var(--orange); color: #fff; }
.sys-filter-reset[hidden] { display: none; }
.sys-filter-btn .chevron { font-size: 9px; opacity: 0.7; }

#sysRowList { padding-top: var(--space-s); }

/* Mega-menu — color-system filter selector (distinct from niceatoms .mega-filter) */
.mega-menu { position: absolute; left: var(--space-s); right: var(--space-s); top: 100%; margin-top: -1px; z-index: 60; max-height: 70vh; overflow-y: auto; padding: var(--space-s) var(--space-m) var(--space-m); background: #111114; border: 1px solid rgba(255,255,255,0.12); border-top: none; border-radius: 0 0 var(--radius-m) var(--radius-m); box-shadow: 0 16px 48px rgba(0,0,0,0.6); display: flex; flex-direction: column; gap: var(--space-m); }
.mega-menu[hidden] { display: none; }
.sys-filter-btn[aria-expanded="true"] { background: #111114; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-color: rgba(255,255,255,0.12); }
.sys-filter-btn[aria-expanded="true"].active { border-color: var(--orange); }
.mega-menu .mega-head { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-xs); padding-bottom: var(--space-xs); border-bottom: 1px solid rgba(255,255,255,0.06); }
.mega-menu .mega-head-actions { display: flex; gap: var(--space-xs); align-items: center; }
.mega-menu .mega-clear {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font: 618 var(--type-xxs)/1 Haffer,sans-serif;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 9999px;
  transition: background var(--duration-s), border-color var(--duration-s);
}
.mega-menu .mega-clear:hover { background: var(--orange); border-color: var(--orange); color: #fff; }
.mega-menu .mega-close { background: transparent; border: none; color: var(--muted-foreground); font-size: 14px; cursor: pointer; line-height: 1; padding: 0 4px; }
.mega-menu .mega-group-label { font: 618 var(--type-xxs)/1 Haffer,sans-serif; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.mega-menu label.mega-row { display: flex; align-items: center; gap: var(--space-xs); padding: 4px 6px; border-radius: var(--radius-s); cursor: pointer; font-size: var(--type-xs); color: var(--foreground); user-select: none; }
.mega-menu label.mega-row.on { background: rgba(255,165,0,0.10); }
.mega-menu label.mega-row.dim { opacity: 0.35; cursor: not-allowed; }
.mega-menu label.mega-row input[type=checkbox] {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.25); background: transparent;
  cursor: pointer; margin: 0; flex-shrink: 0; position: relative;
  transition: background var(--duration-s), border-color var(--duration-s);
}
.mega-menu label.mega-row input[type=checkbox]:hover { border-color: rgba(255,255,255,0.45); }
.mega-menu label.mega-row input[type=checkbox]:checked { background: var(--orange); border-color: var(--orange); }
.mega-menu label.mega-row input[type=checkbox]:checked::after {
  content: ''; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.mega-menu label.mega-row.dim input[type=checkbox] { cursor: not-allowed; }
.mega-menu .mega-row-count { margin-left: auto; color: var(--muted-foreground); font-size: var(--type-xxs); font-variant-numeric: tabular-nums; }

/* ===================================================================
   [EXT:swatches-grid + nc-table] — Swatches grid + table view
   =================================================================== */
#ncTable { display: none; }
body.swatches-table #ncGrid { display: none !important; }
body.swatches-table #ncTable { display: block !important; }
body.swatches-table #gamutBgCanvas,
body.swatches-table #gamutFence,
body.swatches-table #gamutGridToggle,
body.swatches-table #gamutLegend { display: none !important; }
body.swatches-table .colors-main { background: transparent; }

.nc-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--type-xs); font-family: Haffer,sans-serif; }
.nc-table thead th { text-align: left; padding: var(--space-xs) var(--space-s); font: 618 var(--type-xxs)/1 Haffer,sans-serif; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid rgba(255,255,255,0.08); position: sticky; top: 0; background: rgba(9,9,11,0.9); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); z-index: 2; white-space: nowrap; }
.nc-table tbody td { padding: var(--space-xs) var(--space-s); border-bottom: 1px solid rgba(255,255,255,0.04); color: var(--foreground); vertical-align: middle; }
.nc-table-row { cursor: pointer; transition: background var(--duration-s); }
.nc-table-row:hover td { background: rgba(255,255,255,0.04); }
.nc-table-row.selected td { background: rgba(255,165,0,0.10); box-shadow: inset 2px 0 0 var(--orange); }
.nc-table .tdot { width: 22px; height: 22px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.1); display: inline-block; vertical-align: middle; }
.nc-table .mono { font-family: ui-monospace, Menlo, monospace; font-size: var(--type-xxs); color: var(--muted-foreground); letter-spacing: 0.02em; }
.nc-table .code-cell { font-weight: 618; color: var(--foreground); white-space: nowrap; }
.nc-table .sys-cell { color: var(--muted-foreground); font-size: var(--type-xxs); white-space: nowrap; }
.nc-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* ===================================================================
   [EXT:color-detail-modal] — Colors-sidebar (selected-color detail)
   =================================================================== */
.colors-split .colors-sidebar { width: 320px; flex-shrink: 0; margin: var(--space-s) var(--space-s) var(--space-s) 0; border-radius: var(--radius-l); background: rgba(255,255,255,0.035); backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%); border: 1px solid rgba(255,255,255,0.06); overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.25); }

/* --- Sidebar-card sub-elements (sidebar-title/subtitle/section + id-grid/item) --- */
.colors-split .colors-sidebar .sidebar-title { font-size: var(--type-xl); font-weight: var(--fw-b); letter-spacing: -0.03em; line-height: 1.2; margin-bottom: var(--space-xxs); margin-right: var(--space-xl); color: var(--foreground); }
.colors-split .colors-sidebar .sidebar-subtitle { font-size: var(--type-xs); color: var(--text2); margin-bottom: var(--space-l); }
.colors-split .colors-sidebar .sidebar-section { margin-top: var(--space-xl); }
.colors-split .colors-sidebar .sidebar-section h3 { font-size: var(--type-xxs); font-weight: var(--fw-b); color: var(--orange); letter-spacing: 0.06em; text-transform: lowercase; margin: 0 0 var(--space-s) 0; }
.colors-split .colors-sidebar .id-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xxs); }
.colors-split .colors-sidebar .id-item { font-size: var(--type-xxs); padding: var(--space-xxs) var(--space-xs); background: rgba(255,255,255,0.04); border-radius: var(--radius-xs); border: 1px solid rgba(255,255,255,0.05); }
.colors-split .colors-sidebar .id-item .id-type { color: var(--text3); display: block; font-size: 9px; letter-spacing: 0.04em; text-transform: lowercase; margin-bottom: 2px; }
.colors-split .colors-sidebar .id-item .id-val { color: var(--text); font-weight: var(--fw-b); word-break: break-all; }
[data-theme="light"] .colors-split .colors-sidebar .id-item { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.06); }

/* ===================================================================
   LEGAL MODAL (shared with other apps but copied for standalone)
   =================================================================== */
.legal-modal { position: fixed; inset: 0; z-index: 1000; display: none; }
.legal-modal.open { display: flex; }
.legal-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.legal-modal__card { position: relative; margin: auto; width: calc(100vw - var(--space-xl)); max-width: 1100px; height: calc(100vh - var(--space-xl)); background: rgba(9,9,11,0.82); -webkit-backdrop-filter: blur(24px) saturate(140%); backdrop-filter: blur(24px) saturate(140%); border: 1px solid rgba(255,255,255,0.10); border-radius: var(--radius-l); box-shadow: 0 32px 96px rgba(0,0,0,0.6); overflow: hidden; display: flex; flex-direction: column; }
.legal-modal__head { display: flex; justify-content: space-between; align-items: center; padding: var(--space-m) var(--space-l); border-bottom: 1px solid rgba(255,255,255,0.06); flex-shrink: 0; }
.legal-modal__tabs { display: flex; gap: var(--space-m); }
.legal-modal__tabs a { color: var(--muted-foreground); text-decoration: none; font-size: var(--type-xs); font-weight: 618; border-bottom: 2px solid transparent; padding-bottom: 4px; transition: color var(--duration-s), border-color var(--duration-s); }
.legal-modal__tabs a:hover { color: var(--foreground); }
.legal-modal__tabs a.active { color: var(--foreground); border-bottom-color: var(--orange); }
.legal-modal__close { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #fff; cursor: pointer; font-size: 20px; line-height: 1; transition: background var(--duration-s), border-color var(--duration-s); }
.legal-modal__close:hover { background: var(--orange); border-color: var(--orange); }
.legal-modal__body { flex: 1; overflow-y: auto; padding: var(--space-l) var(--space-xl); color: var(--foreground); line-height: 1.618; font-size: var(--type-xs); }
.legal-modal__body h2 { font-size: var(--type-l); font-weight: 618; margin-bottom: var(--space-m); padding-bottom: var(--space-s); border-bottom: 1px solid rgba(255,255,255,0.08); }
.legal-modal__body h3 { font-size: var(--type-s); font-weight: 618; margin-top: var(--space-l); margin-bottom: var(--space-s); }
.legal-modal__body p, .legal-modal__body ul { margin-bottom: var(--space-s); }
.legal-modal__body ul { padding-left: var(--space-m); }
.legal-modal__body dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-xxs) var(--space-m); margin-bottom: var(--space-m); }
.legal-modal__body dl dt { color: var(--muted-foreground); }
.legal-modal__body dl dd { color: var(--foreground); font-weight: 618; }
.legal-modal__body a { color: var(--orange); }
.legal-modal__body a:hover { text-decoration: underline; }
.legal-modal__body code { font-family: ui-monospace, Menlo, monospace; background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }
.legal-modal__section { display: none; }
.legal-modal__section.active { display: block; }

/* ===================================================================
   UTILITIES (empty/loading + circular-sticker)
   =================================================================== */
.empty { text-align: center; padding: var(--space-xxl); color: var(--text3); }
.loading { text-align: center; padding: var(--space-xxl); color: var(--text3); }
.loading::after { content:''; display:inline-block; width:14px; height:14px; border:2px solid var(--border); border-top-color:var(--orange); border-radius:50%; animation:spin .6s linear infinite; margin-left:8px; vertical-align:middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.circular-sticker { position: absolute; top: 88px; right: var(--space-l, 24px); width: 172px; height: 172px; z-index: 10; animation: cs-spin 22s linear infinite; color: var(--fg); pointer-events: none; display: block; }
.circular-sticker:hover { animation-duration: 4s; }
@keyframes cs-spin { to { transform: rotate(360deg); } }
.circular-sticker svg { width: 100%; height: 100%; }

.sep { width: var(--stroke-s); height: var(--space-m); background: var(--border); flex-shrink: 0; }
.stats-text { font-size: var(--type-xxs); color: var(--muted-foreground); font-weight: 618; letter-spacing: 0.03em; margin-left: auto; white-space: nowrap; }
.stats-text b { color: var(--foreground); }

/* ===================================================================
   LIGHT-MODE OVERRIDES (nicecolors surfaces only — gamut stays dark)
   =================================================================== */
[data-theme="light"] .colors-split .colors-systems,
[data-theme="light"] .colors-split .colors-sidebar { background: rgba(0, 0, 0, 0.035); border-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .sys-toolbar { background: rgba(255,255,255,0.85); border-bottom-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .sys-search { background: rgba(255, 255, 255, 0.8); border-color: rgba(0, 0, 0, 0.18); }
[data-theme="light"] .sys-search:focus { border-color: var(--orange); }
[data-theme="light"] .sys-filter-btn { background: rgba(255, 255, 255, 0.8); border-color: rgba(0, 0, 0, 0.18); }
[data-theme="light"] .sys-filter-btn:hover { border-color: rgba(0, 0, 0, 0.32); }
[data-theme="light"] .sys-filter-btn.active { background: rgba(253, 149, 1, 0.12); border-color: var(--orange); }
[data-theme="light"] .sys-filter-btn[aria-expanded="true"] { background: #ffffff; border-color: rgba(0, 0, 0, 0.18); }
[data-theme="light"] .sys-filter-btn[aria-expanded="true"].active { border-color: var(--orange); }
[data-theme="light"] .mega-menu { background: #ffffff; border-color: rgba(0, 0, 0, 0.12); box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18); color: var(--foreground); }
[data-theme="light"] .mega-menu .mega-head { border-bottom-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .mega-menu label.mega-row input[type=checkbox] { border-color: rgba(0, 0, 0, 0.3); }
[data-theme="light"] .mega-menu label.mega-row input[type=checkbox]:hover { border-color: rgba(0, 0, 0, 0.55); }
[data-theme="light"] .mega-menu .mega-clear { background: rgba(0, 0, 0, 0.06); border-color: rgba(0, 0, 0, 0.14); color: var(--foreground); }
[data-theme="light"] .mega-menu .mega-clear:hover { background: var(--orange); border-color: var(--orange); color: #fff; }
[data-theme="light"] .sys-filter-reset { background: rgba(0, 0, 0, 0.06); border-color: rgba(0, 0, 0, 0.14); color: var(--foreground); }
[data-theme="light"] .sys-filter-reset:hover { background: var(--orange); border-color: var(--orange); color: #fff; }
[data-theme="light"] .colors-systems .sys-btn-row:hover,
[data-theme="light"] .colors-systems .sys-btn-row.row-active { background: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .colors-systems .sys-info-btn { border-color: rgba(0, 0, 0, 0.22); }
[data-theme="light"] #sysInfoPanel { background: rgba(255, 255, 255, 0.92); border-color: rgba(0, 0, 0, 0.08); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18); color: var(--foreground); }
[data-theme="light"] .nc-table thead th { background: rgba(250, 250, 250, 0.92); border-bottom-color: rgba(0, 0, 0, 0.1); }
[data-theme="light"] .nc-table tbody td { border-bottom-color: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .nc-table-row:hover td { background: rgba(0, 0, 0, 0.04); }
[data-theme="light"] .nc-table-row.selected td { background: rgba(253, 149, 1, 0.12); }
[data-theme="light"] .nc-table .tdot { border-color: rgba(0, 0, 0, 0.12); }
[data-theme="light"] .nc-swatch { border-color: rgba(0, 0, 0, 0.08) !important; }
[data-theme="light"] body:not(.gamut-active) #gamutGridToggle { background: rgba(255, 255, 255, 0.92); border-color: rgba(0, 0, 0, 0.14); color: var(--foreground); }
[data-theme="light"] body:not(.gamut-active) #gamutGridToggle svg { stroke: var(--foreground); }
[data-theme="light"] .legal-modal__card { background: rgba(255, 255, 255, 0.92); border-color: rgba(0, 0, 0, 0.10); box-shadow: 0 32px 96px rgba(0, 0, 0, 0.25); }
[data-theme="light"] .legal-modal__head { border-bottom-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .legal-modal__close { background: rgba(0, 0, 0, 0.05); border-color: rgba(0, 0, 0, 0.14); color: var(--foreground); }
[data-theme="light"] .legal-modal__body h2 { border-bottom-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .legal-modal__body code { background: rgba(0, 0, 0, 0.05); }

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 768px) {
  .colors-split { flex-direction: column; }
  .colors-split .colors-sidebar { width: auto; margin: 0 var(--space-s) var(--space-s); max-height: 40vh; }
  .legal-modal__card { width: 100vw; height: 100vh; border-radius: 0; border: none; }
  .legal-modal__head { padding: var(--space-s) var(--space-m); }
  .legal-modal__body { padding: var(--space-m); }
  .legal-modal__tabs { gap: var(--space-s); }
  .circular-sticker { top: auto; bottom: 20px; right: 20px; width: 120px; height: 120px; }
  .stats-text { display: none; }
}

/* ===================================================================
   [EXT:pillify-2026-05-14] — Heilige Regeln nicecolors-specific:
   (1) Schrift NIE grau/transparent — solid foreground oder semantic orange
   (2) Listitems/eyebrows/buttons IMMER pillenförmig (radius-full)
   (3) Icon-Glyphen (i, A, etc.) IMMER in kreisrunden Hintergründen
   (4) Hover/active → orange pill mit invertiertem schwarzem Text
   =================================================================== */

/* Left systems list — pill rows + solid text + orange hover-pill */
.colors-systems .sys-btn-row { border-radius: var(--radius-full); }
.colors-systems .sys-btn { color: var(--foreground); border-radius: var(--radius-full); }
.colors-systems .sys-btn.active { color: var(--foreground); }
.colors-systems .sys-count { opacity: 1; color: var(--orange); font-weight: var(--fw-b); }
.colors-systems .sys-header { color: var(--foreground); }
.colors-systems .sys-info-btn { color: var(--foreground); border-color: rgba(255,255,255,0.55); }
.colors-systems .sys-btn-row:hover,
.colors-systems .sys-btn-row.row-active { background: var(--orange); }
.colors-systems .sys-btn-row:hover .sys-btn,
.colors-systems .sys-btn-row.row-active .sys-btn,
.colors-systems .sys-btn-row:hover .sys-count,
.colors-systems .sys-btn-row.row-active .sys-count { color: #000; }
.colors-systems .sys-btn-row:hover .sys-info-btn,
.colors-systems .sys-btn-row.row-active .sys-info-btn { color: #000; border-color: rgba(0,0,0,0.55); background: transparent; }
.colors-systems .sys-btn-row:hover .sys-info-btn:hover,
.colors-systems .sys-btn-row.row-active .sys-info-btn:hover { background: #000; color: var(--orange); border-color: #000; }

/* Light-mode invert: hover-pill stays orange, but text on it must stay readable */
[data-theme="light"] .colors-systems .sys-btn-row:hover,
[data-theme="light"] .colors-systems .sys-btn-row.row-active { background: var(--orange); }
[data-theme="light"] .colors-systems .sys-btn-row:hover .sys-btn,
[data-theme="light"] .colors-systems .sys-btn-row.row-active .sys-btn,
[data-theme="light"] .colors-systems .sys-btn-row:hover .sys-count,
[data-theme="light"] .colors-systems .sys-btn-row.row-active .sys-count { color: #000; }

/* Sidebar detail-card — pill id-items + solid text + orange eyebrows */
.colors-split .colors-sidebar .sidebar-subtitle { color: var(--foreground); opacity: 1; }
.colors-split .colors-sidebar .id-item { border-radius: var(--radius-full); }
.colors-split .colors-sidebar .id-item .id-type { color: var(--orange); }
.colors-split .colors-sidebar .id-item .id-val { color: var(--foreground); }
[data-theme="light"] .colors-split .colors-sidebar .sidebar-subtitle { color: var(--foreground); }

/* Sub-header pill-toggle: ensure solid text (no muted state) */
.subheader .phi-pill-toggle__item { color: var(--foreground); }

/* Footer + small helper text — never gray */
.colors-systems .sys-btn:hover { color: #000; }
body.gamut-active .colors-systems .sys-btn-row:hover .sys-btn,
body.gamut-active .colors-systems .sys-btn-row.row-active .sys-btn,
body.gamut-active .colors-systems .sys-btn-row:hover .sys-count,
body.gamut-active .colors-systems .sys-btn-row.row-active .sys-count { color: #000; }

/* Table view — solid text (no muted-foreground) */
.nc-table .mono { color: var(--foreground); }
.nc-table .sys-cell { color: var(--foreground); }
.nc-table thead th { color: var(--orange); }

/* Stats text bottom — solid */
.stats-text { color: var(--foreground); opacity: 1; }

/* ===================================================================
   [EXT:pillify-2026-05-14-phase-2] — ONO-DS phi-token-konformer Polish
   • Search + filter buttons → pill (--radius-full)
   • Stats-text + sys-header → solid foreground (no gray)
   • font-feature-settings re-applied on all `font:` shorthand selectors
     (shorthand resets feature-settings, killing Haffer ss01/ss03/ss04/ss05)
   • Placeholder solid foreground at 382 weight (distinguish from typed)
   =================================================================== */

/* Pill-shape on search + filter (was --radius-m rectangle) */
.sys-search,
.sys-filter-btn,
.sys-filter-btn[aria-expanded="true"],
.sys-filter-btn[aria-expanded="true"].active { border-radius: var(--radius-full); }
.sys-filter-btn[aria-expanded="true"] { border-bottom-left-radius: var(--radius-full); border-bottom-right-radius: var(--radius-full); }

/* Solid text — no muted-foreground anywhere */
.stats-text,
.stats-text b,
.colors-systems .sys-header,
.sys-search::placeholder,
.mega-menu .mega-group-label,
.legal-modal__tabs a,
.legal-modal__body dl dt { color: var(--foreground); }
.sys-search::placeholder { font-weight: var(--fw); }

/* Re-apply font-feature-settings on every selector that used `font:` shorthand.
   The shorthand resets font-feature-settings → ss01/ss03/ss04/ss05 lost. */
.colors-systems .sys-info-btn,
.sys-search,
.sys-filter-btn,
.sys-filter-btn .count-pill,
.sys-filter-reset,
.mega-menu,
.mega-menu .mega-group-label,
.nc-table,
.nc-table thead th { font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1, "ss03" 1, "ss04" 1, "ss05" 1, "tnum" 1, "zero" 1; }

/* Detail-card sub-elements: also re-apply for safety */
.colors-split .colors-sidebar .id-item,
.colors-split .colors-sidebar .id-item .id-type,
.colors-split .colors-sidebar .id-item .id-val,
.colors-split .colors-sidebar .sidebar-section h3,
.colors-split .colors-sidebar .sidebar-title,
.colors-split .colors-sidebar .sidebar-subtitle { font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1, "ss03" 1, "ss04" 1, "ss05" 1, "tnum" 1, "zero" 1; }

/* Phi-token weights consistent (no hardcoded 618) */
.colors-systems .sys-btn.active,
.colors-systems .sys-header,
.nc-table .code-cell { font-weight: var(--fw-b); }
