:root {
	--bg: #121212;
	--tile: #2a2a2a;
	--tile-border: #3a3a3a;
	--text: #ececec;
	--muted: #a8a8a8;
	--highlight: #aa0000;
}

html {
	font-size: 14px;
	scroll-padding-top: calc(var(--sticky-header-height, 4.5rem) + 2em);
}

body {
	margin: 0;
	min-height: 100vh;
	display: grid;
	place-items: start center;
	background: var(--bg);
	color: var(--text);
	font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.wrap {
	width: min(92vw, 780px);
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.wrap-spacer {
	flex: 1 1 auto;
}

.page-header {
	position: sticky;
	top: 0;
	z-index: 20;
	margin-bottom: 0.35rem;
	padding: 0.35rem 0 0.4rem;
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	backdrop-filter: blur(4px);
	border-bottom: 1px solid #242424;
}

.top-toolbar {
	display: grid;
	gap: 0.25rem;
}

.page-title-row {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 0.5rem;
}

h1 {
	grid-column: 2;
	margin: 0.35rem 0;
	font-size: 1.2rem;
	font-weight: 700;
	text-align: center;
}

.header-timelapse-btn {
	grid-column: 3;
	justify-self: end;
}

.header-timelapse-btn:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

p {
	margin: 0 0 1rem;
	color: var(--muted);
}

.chart-section + .chart-section {
	margin-top: 1rem;
	padding-top: 0.9rem;
	border-top: 1px solid #2a2a2a;
}

.chart-title {
	position: relative;
	margin: 1.2rem 0 0.3rem;
	font-size: 0.98rem;
	font-weight: 600;
	color: var(--muted);
	text-align: center;
}

.chart-title-link {
	color: inherit;
	text-decoration: none;
}

.chart-title-link:hover,
.chart-title-link:focus-visible {
	text-decoration: underline;
}

.section-collapse-toggle {
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.6rem;
	height: 1.6rem;
	padding: 0;
	border: 1px solid transparent;
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font-size: 0.85rem;
	line-height: 1;
	opacity: 0.6;
	cursor: pointer;
	transition: transform 0.18s ease, opacity 0.18s ease;
}

.section-collapse-toggle:hover,
.section-collapse-toggle:focus-visible {
	opacity: 1;
	outline: none;
}

.chart-section.collapsed .section-collapse-toggle {
	transform: translateY(-50%) rotate(-90deg);
}

.chart-section.collapsed > *:not(.chart-title) {
	display: none !important;
}

.chart-title-with-action {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 0.5rem;
	text-align: center;
}

.chart-title-with-action > .chart-title-main {
	grid-column: 2;
}

.chart-title-with-action > .section-collapse-toggle {
	position: static;
	transform: none;
	grid-column: 1;
	justify-self: start;
}

.chart-section.collapsed .chart-title-with-action > .section-collapse-toggle {
	transform: rotate(-90deg);
}

.chart-title-with-action > .panel-toggle-btn,
.chart-title-with-action > .segmented-toggle,
.chart-title-with-action > .chart-title-actions {
	grid-column: 3;
	justify-self: end;
}

.chart-title-actions {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}

.segmented-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	padding: 0.15rem;
	border: 1px solid #343434;
	border-radius: 999px;
	background: #151515;
}

.segmented-toggle-btn {
	min-width: 2rem;
	height: 1.5rem;
	padding: 0 0.45rem;
	border: 1px solid transparent;
	border-radius: 999px;
	font-size: 0.74rem;
	font-weight: 600;
	line-height: 1;
	background: transparent;
	color: var(--muted);
	cursor: pointer;
}

.panel-toggle-btn.top100-btn {
	font-size: 0.74rem;
	font-weight: 600;
	width: auto;
	padding: 0 0.45rem;
}

.segmented-toggle-btn:hover {
	color: var(--text);
}

.segmented-toggle-btn.is-active {
	border-color: #b58cff;
	background: rgba(181, 140, 255, 0.16);
	color: var(--text);
}

.segmented-toggle-btn:focus-visible {
	outline: 2px solid #b58cff;
	outline-offset: 1px;
}

.panel-toggle-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.8rem;
	height: 1.8rem;
	padding: 0;
	border: 1px solid transparent;
	border-radius: 999px;
	font-size: 1rem;
	line-height: 1;
	background: transparent;
	color: var(--muted);
	opacity: 0.65;
	cursor: pointer;
	transition: transform 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}

.panel-toggle-btn:hover {
	transform: translateY(-1px);
	color: var(--text);
	opacity: 0.85;
}

.panel-toggle-btn.is-active {
	border-color: #b58cff;
	color: var(--text);
	opacity: 1;
}

.chart-description {
	margin: 0 0 0.7rem;
	font-size: 0.88rem;
	line-height: 1.35;
	color: var(--muted);
	text-align: center;
	text-wrap: balance;
}

.chart-stack {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
}

.chart-stack svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.tile-base {
	fill: none;
	stroke: var(--tile-border);
	stroke-width: 2;
	rx: 10;
}

.likelihood-tile {
	stroke: var(--tile-border);
	stroke-width: 2;
	rx: 10;
}

.likelihood-percent {
	font-weight: 700;
	font-size: 26px;
	text-anchor: middle;
	dominant-baseline: middle;
	pointer-events: none;
}

.likelihood-label {
	font-size: 11px;
	text-anchor: middle;
	dominant-baseline: hanging;
	pointer-events: all;
	user-select: text;
	-webkit-user-select: text;
}

.count,
.bubble-count {
	font-weight: 700;
	pointer-events: none;
}

.bubble circle {
	cursor: grab;
	touch-action: none;
}

.bubble.is-dragging circle {
	cursor: grabbing;
}

.axis-label {
	fill: var(--muted);
	font-size: 13px;
	text-anchor: middle;
}

#error {
	margin-top: 0.7rem;
	font-size: 0.9rem;
	color: var(--highlight);
	text-align: center;
	opacity: 0;
}

#error:not(:empty) {
	animation: error-fade-in 0.25s ease 1s forwards;
}

@keyframes error-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.timelapse-controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	margin-top: 0.15rem;
	flex-wrap: wrap;
}

.timelapse-controls[hidden] {
	display: none;
}

.timelapse-btn,
.timelapse-speed-select {
	border: 1px solid #5a5a5a;
	background: #1d1d1d;
	color: var(--text);
	font: inherit;
	font-size: 0.82rem;
	border-radius: 999px;
	height: 1.8rem;
}

.timelapse-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.2rem;
	padding: 0;
	cursor: pointer;
	opacity: 0.8;
	transition: opacity 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.timelapse-btn:hover {
	transform: translateY(-1px);
	opacity: 1;
}

.timelapse-btn:disabled {
	opacity: 0.3;
	cursor: not-allowed;
	transform: none;
}

.timelapse-btn.is-active {
	border-color: #b58cff;
	opacity: 1;
}

.timelapse-speed-select {
	padding: 0 0.65rem;
}

.rarity-controls {
	margin-top: 0.2rem;
	display: flex;
	justify-content: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.rarity-hint {
	margin: 0.2rem 0 0;
	font-size: 0.75rem;
	text-align: center;
	color: var(--muted);
	opacity: 0.6;
}

.rarity-hint-touch {
	display: none;
}

@media (hover: none) {
	.rarity-hint-touch {
		display: block;
	}
}

.rarity-btn {
	border: 1px solid #5a5a5a;
	background: #1d1d1d;
	color: var(--text);
	font: inherit;
	font-size: 0.88rem;
	padding: 0.33rem 0.68rem;
	border-radius: 999px;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity 120ms ease, border-color 120ms ease, transform 120ms ease;
	user-select: none;
	-webkit-user-select: none;
}

.rarity-btn:hover {
	transform: translateY(-1px);
}

body.modifier-solo-active .rarity-btn {
	cursor: zoom-in;
}

.rarity-btn.is-active {
	opacity: 1;
	border-color: var(--rarity);
}

.rarity-btn.is-long-press {
	animation: long-press-fill 500ms linear forwards;
}

@keyframes long-press-fill {
	from { box-shadow: inset 0 0 0 0px var(--rarity, #888); }
	to   { box-shadow: inset 0 0 0 40px var(--rarity, #888); }
}

.rarity-btn[data-rarity='yellow'] { --rarity: #f1ce45; }
.rarity-btn[data-rarity='green'] { --rarity: #6dc16f; }
.rarity-btn[data-rarity='blue'] { --rarity: #6aa5ff; }
.rarity-btn[data-rarity='purple'] { --rarity: #b58cff; }

.explorer-tile {
	transition: fill 180ms ease, stroke 180ms ease;
}

.explorer-tile.is-selected {
	filter: drop-shadow(0 0 6px rgba(181, 140, 255, 0.5));
}

.explorer-pct {
	font-weight: 700;
	font-size: 24px;
	pointer-events: none;
	transition: fill 180ms ease;
}

.explorer-count {
	pointer-events: none;
	transition: fill 180ms ease;
}

#gradient-heatmaps {
	margin-top: 0.2rem;
}

.gradient-heatmaps-host {
	width: 100%;
}

.gradient-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 380px));
	gap: 0.6rem;
	justify-content: center;
	justify-items: center;
}

.gradient-card-title {
	margin: 0 0 0.25rem;
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--muted);
	text-align: center;
}

.gradient-chart-stack {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
}

.gradient-canvas,
.gradient-svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.gradient-canvas {
	pointer-events: none;
}

.gradient-tile {
	fill: none;
	stroke: var(--tile-border);
	stroke-width: 1.5;
}

.gradient-count {
	fill: #ffffff;
	font-size: 14px;
	font-weight: 700;
	text-anchor: middle;
	dominant-baseline: middle;
	pointer-events: none;
}

.gradient-yellow .gradient-count,
.gradient-green .gradient-count,
.gradient-blue .gradient-count {
	fill: #151515;
}

@media (max-width: 700px) {
	.gradient-row {
		grid-template-columns: 1fr;
	}
}

#group-name-word-bars {
	margin-top: 0.2rem;
}

.wordbars-host {
	width: 100%;
}

.word-filter-toolbar {
	display: grid;
	gap: 0.3rem;
	margin: 0 0 0.45rem;
}

.word-filter-label {
	font-size: 0.78rem;
	color: var(--muted);
}

.word-filter-input {
	width: 100%;
	border: 1px solid #3a3a3a;
	border-radius: 6px;
	background: #151515;
	color: var(--text);
	font: inherit;
	font-size: 0.9rem;
	padding: 0.45rem 0.55rem;
}

.word-filter-input:focus-visible {
	outline: 2px solid #b58cff;
	outline-offset: 1px;
}

.wordbars-chart-stack {
	position: relative;
	width: 100%;
	max-height: min(760px, 80vh);
	overflow: auto;
	border: 1px solid #2d2d2d;
	border-radius: 8px;
	background: #171717;
}

.wordbars-svg {
	display: block;
	width: 100%;
	height: auto;
}

.wordbars-label {
	fill: var(--text);
	font-size: 11px;
}

.wordbars-empty {
	fill: var(--muted);
	font-size: 14px;
}

.wordbars-row.is-selected .wordbars-label {
	fill: #d9beff;
	font-weight: 700;
}

.wordbars-row.is-selected .wordbars-segment {
	stroke: #f0e2ff;
	stroke-width: 1;
}

.wordbars-inline-panel {
	position: absolute;
	z-index: 2;
	padding: 0.35rem 0.4rem 0.4rem;
	border: 1px solid #2e2e2e;
	border-radius: 6px;
	background: #151515;
	box-sizing: border-box;
}

.wordbars-inline-panel-title {
	font-size: 10px;
	color: var(--muted);
	margin-bottom: 0.22rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wordbars-inline-panel-empty {
	font-size: 10px;
	color: var(--muted);
}

.wordbars-inline-panel-rows {
	display: grid;
	gap: 0.2rem;
}

.wordbars-inline-panel-row {
	display: grid;
	grid-template-columns: minmax(56px, 1fr) minmax(80px, 2fr) 2.4rem;
	gap: 0.3rem;
	align-items: center;
}

.wordbars-inline-panel-label,
.wordbars-inline-panel-metric {
	font-size: 10px;
	line-height: 1.1;
}

.wordbars-inline-panel-label {
	color: var(--text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wordbars-inline-panel-metric {
	color: var(--muted);
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.wordbars-inline-panel-bar-track {
	height: 8px;
	border-radius: 3px;
	background: #2a2a2a;
	overflow: hidden;
}

.wordbars-inline-panel-bar-fill {
	height: 100%;
	display: flex;
}

.wordbars-inline-panel-seg {
	height: 100%;
	display: block;
}

#hint-word-length-histograms {
	margin-top: 0.2rem;
}

.hintlen-host {
	width: 100%;
}

.hintlen-chart-stack {
	position: relative;
	width: 100%;
	border: 1px solid #2d2d2d;
	border-radius: 8px;
	background: #171717;
	overflow: hidden;
}

.hintlen-svg {
	display: block;
	width: 100%;
	height: auto;
}

.hintlen-empty {
	fill: var(--muted);
	font-size: 13px;
}

.chart-description-collapsible {
	margin: 0.1rem 0 0.55rem;
	text-align: left;
}

#hint-word-length-weekday-wrap {
	margin-top: 0.6rem;
	border: 1px solid #2b2b2b;
	border-radius: 8px;
	background: #151515;
	padding: 0.45rem 0.55rem 0.55rem;
}

#hint-word-length-weekday-polygons {
	margin-top: 0.2rem;
}

.collapsible-host {
	overflow: hidden;
	transform-origin: top;
	transition: max-height 220ms ease, opacity 180ms ease;
}

.collapsible-host.is-collapsed {
	pointer-events: none;
}

.hintlen-weekday-host {
	width: 100%;
}

.hintlen-weekday-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 320px));
	gap: 0.6rem;
	justify-content: center;
	justify-items: center;
}

.hintlen-weekday-title {
	margin: 0 0 0.2rem;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--muted);
	text-align: center;
}

@media (max-width: 700px) {
	.hintlen-weekday-row {
		grid-template-columns: 1fr;
	}
}

@media (orientation: landscape) and (max-height: 500px) {
	.page-header {
		position: static;
		backdrop-filter: none;
	}

	.chart-stack,
	.gradient-chart-stack {
		width: min(92vw, 52vh);
		margin-inline: auto;
	}
}

.pattern-freq-host {
	margin-top: 0.2rem;
	max-height: 80vh;
	overflow: auto;
}

@media (max-width: 700px) {
	.wordbars-chart-stack,
	.pattern-freq-host {
		max-height: 60vh;
	}
}

.pattern-freq-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.55rem;
	counter-reset: pattern-freq;
}

.pattern-freq-item {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.7rem;
	align-items: center;
	padding: 0.55rem 0.7rem;
	border: 1px solid #2d2d2d;
	border-radius: 8px;
	background: #171717;
}

.pattern-freq-grid {
	display: block;
	flex-shrink: 0;
}

.pattern-freq-cell {
	fill: #222;
	stroke: #333;
	stroke-width: 1;
	transition: fill 180ms ease, opacity 180ms ease;
}

.pattern-freq-cell.is-active {
	fill: #b58cff;
	stroke: #d4b8ff;
}

.pattern-freq-body {
	display: grid;
	gap: 0.3rem;
	min-width: 0;
}

.pattern-freq-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.5rem;
	font-size: 0.86rem;
	color: var(--text);
}

.pattern-freq-rank {
	font-weight: 700;
	color: var(--muted);
	min-width: 2.2rem;
}

.pattern-freq-total {
	font-weight: 600;
}

.pattern-freq-days {
	margin-left: auto;
	color: var(--muted);
	font-size: 0.82rem;
	font-variant-numeric: tabular-nums;
}

.pattern-freq-bar {
	display: flex;
	height: 0.7rem;
	width: 100%;
	border-radius: 4px;
	overflow: hidden;
	background: #242424;
}

.pattern-freq-seg {
	height: 100%;
	transition: width 220ms ease;
}

.pattern-freq-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	font-size: 0.76rem;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.pattern-freq-legend-item {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
}

.pattern-freq-swatch {
	display: inline-block;
	width: 0.6rem;
	height: 0.6rem;
	border-radius: 2px;
}

.pattern-freq-empty {
	padding: 0.8rem;
	text-align: center;
	color: var(--muted);
	font-size: 0.88rem;
	border: 1px dashed #333;
	border-radius: 8px;
}

#group-density-series {
	margin-top: 0.2rem;
}

.density-series-host {
	width: 100%;
}

.density-series-chart-stack {
	position: relative;
	width: 100%;
	border: 1px solid #2d2d2d;
	border-radius: 8px;
	background: #171717;
	overflow: hidden;
}

.density-series-svg {
	display: block;
	width: 100%;
	height: auto;
}

.density-series-empty {
	fill: var(--muted);
	font-size: 13px;
}

.density-series-tooltip {
	position: absolute;
	z-index: 2;
	pointer-events: none;
	min-width: 128px;
	max-width: 220px;
	padding: 0.45rem 0.55rem;
	border: 1px solid #3a3a3a;
	border-radius: 6px;
	background: rgba(18, 18, 18, 0.95);
	color: var(--text);
	font-size: 0.78rem;
	line-height: 1.35;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.density-series-tooltip-date {
	font-weight: 600;
	margin-bottom: 0.2rem;
	color: #d7d7d7;
}

.density-series-tooltip-row {
	display: flex;
	align-items: center;
	gap: 0.38rem;
	white-space: nowrap;
}

.density-series-tooltip-swatch {
	display: inline-block;
	width: 0.55rem;
	height: 0.55rem;
	border-radius: 999px;
	flex: 0 0 auto;
}

#footer-info {
	margin: 3em 0 1em;
	padding-top: 1rem;
	display: grid;
	gap: 0.2rem;
	text-align: center;
	border-top: 1px solid #242424;
}

#status {
	font-size: 0.9rem;
	color: var(--muted);
}

#source {
	font-size: 0.82rem;
	text-align: center;
}

#source a {
	color: var(--muted);
	text-decoration: underline;
	text-underline-offset: 2px;
}

#source a:hover {
	color: var(--text);
}
