/*! CSS Portal — CSS Color Variable Generator */
.cv { display: grid; gap: 16px; }
.cv [hidden] { display: none !important; }
.cv .ct-toolbar { margin: 0; }
.cv [data-ct="input"].ce, .cv [data-ct="output"].ce { height: clamp(280px, 46vh, 520px); }
.cv .gt-card__head h2 { margin: 0; }
.cv .gt-card__head { flex-wrap: wrap; gap: 8px 16px; }
.cv-count { font-size: 12.5px; font-weight: 500; color: var(--ct-muted); }

/* merge controls */
.cv-merge { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-left: auto; }
.cv-threshold { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 500; color: var(--ct-text); }
.cv-threshold input { width: 130px; margin: 0; accent-color: var(--ct-accent); }
.cv-threshold output { min-width: 30px; font: 600 13px/1 var(--ct-mono); color: var(--ct-accent); text-align: right; }
.cv-threshold.is-off { opacity: .45; }

/* palette */
.cv-list, .cv-chips, .cv-props { margin: 0; padding: 0; list-style: none; }
.cv-head, .cv-row { display: grid; grid-template-columns: 52px minmax(0, 1.1fr) minmax(0, 1.2fr) minmax(220px, 1fr); gap: 16px; align-items: start; padding: 12px 16px; }
.cv-head { padding-top: 10px; padding-bottom: 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ct-muted); border-bottom: 1px solid var(--ct-border); }
.cv-head span:first-child { grid-column: 1 / span 2; }
.cv-row { border-bottom: 1px solid var(--ct-border); }
.cv-row:last-child { border-bottom: 0; }
.cv-row.is-merged { background: var(--ct-accent-soft); }
.cv-row.is-off .cv-swatch, .cv-row.is-off .cv-value, .cv-row.is-off .cv-usage { opacity: .45; }

.cv-swatch { display: block; width: 52px; height: 52px; border-radius: 10px; background: linear-gradient(var(--c), var(--c)), repeating-conic-gradient(#cbd5e1 0 25%, #fff 0 50%) 0 0 / 10px 10px; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .12); }
.cv-value, .cv-usage, .cv-name { display: grid; gap: 8px; min-width: 0; }
.cv-value__main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0; line-height: 1.4; }
.cv-value__main code { padding: 0; font: 600 14px/1.4 var(--ct-mono); color: var(--ct-text); background: none; overflow-wrap: anywhere; }
.cv-uses { font-size: 12.5px; color: var(--ct-muted); }
.cv-chips, .cv-props { display: flex; flex-wrap: wrap; gap: 4px; }
.cv-chip, .cv-props li { display: inline-flex; align-items: center; gap: 5px; margin: 0; padding: 2px 8px; font: 500 12px/1.5 var(--ct-mono); color: var(--ct-text); background: var(--ct-bg); border: 1px solid var(--ct-border); border-radius: 999px; overflow-wrap: anywhere; }
.cv-props li { color: var(--ct-accent); background: var(--ct-accent-soft); border-color: transparent; }
.cv-dot { flex: none; display: inline-block; width: 10px; height: 10px; padding: 0; border-radius: 50%; background: linear-gradient(var(--c), var(--c)), repeating-conic-gradient(#cbd5e1 0 25%, #fff 0 50%) 0 0 / 6px 6px; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .18); }
.cv-sel { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ct-muted); overflow-wrap: anywhere; }
.cv-sel span { display: inline; padding: 0; }
.cv-sel__label { font-weight: 600; }
.cv-more { margin: 0 0 0 4px; padding: 0; font: inherit; font-weight: 600; color: var(--ct-accent); background: none; border: 0; cursor: pointer; }
.cv-more:hover { text-decoration: underline; }
.cv-more:focus-visible { outline: 2px solid var(--ct-accent); outline-offset: 2px; border-radius: 3px; }

/* variable name */
.cv-input { display: flex; align-items: stretch; margin: 0; height: 36px; background: var(--ct-bg); border: 1px solid var(--ct-border); border-radius: 8px; overflow: hidden; }
.cv-input:focus-within { border-color: var(--ct-accent); box-shadow: 0 0 0 3px var(--ct-accent-soft); }
.cv-dash { display: flex; align-items: center; padding: 0 1px 0 10px; letter-spacing: -.12em; font: 600 13.5px/1 var(--ct-mono); color: var(--ct-muted); }
.cv-input input { flex: 1; min-width: 0; height: 100%; margin: 0; padding: 0 10px 0 0; font: 500 13.5px/1 var(--ct-mono); color: var(--ct-text); background: transparent; border: 0; outline: none; box-shadow: none; }
.cv-input input:disabled { color: var(--ct-muted); }
.cv-input:has(input[aria-invalid="true"]) { border-color: var(--ct-err); }
.cv-err { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--ct-err); }
.cv-err:empty { display: none; }
.cv-keep { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; font-weight: 500; color: var(--ct-muted); cursor: pointer; justify-self: start; }
.cv-keep input { width: 15px; height: 15px; margin: 0; accent-color: var(--ct-accent); }
.cv-keep span { padding: 0; }

.cv-empty { margin: 0; padding: 22px 16px; font-size: 14px; text-align: center; color: var(--ct-muted); }
.cv-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ct-muted); }
.cv-legend::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--ct-accent-soft); box-shadow: inset 0 0 0 1px var(--ct-accent); }

@media (max-width: 900px) {
	.cv-head { display: none !important; }
	.cv-row { grid-template-columns: 44px minmax(0, 1fr); gap: 10px 14px; }
	.cv-swatch { width: 44px; height: 44px; }
	.cv-usage, .cv-name { grid-column: 2; }
	.cv-merge { margin-left: 0; width: 100%; }
}

/* dark theme: keep dark swatches visible */
.dark-mode .cv-swatch, .dark-mode .cv-dot { box-shadow: inset 0 0 0 1px rgba(226, 232, 240, .22); }
