:root {
	color-scheme: dark;
	--bg: #1b2024;
	--surface: #232a30;
	--surface-2: #2e373f;
	--fg: #ffffff;
	--muted: #a9b6c1;
	--accent: #7fb3d5;
	--border: #36414a;
	--danger: #ff9a8f;
	--radius: 6px;
	--space: 1rem;
	--font: "Raleway", "Helvetica Neue", Arial, sans-serif;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: calc(var(--space) * 3) var(--space);
}

h1 {
	margin: 0 0 0.5rem;
	font-size: clamp(1.6rem, 4vw, 2.25rem);
	letter-spacing: -0.02em;
}

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0.9rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.btn:hover {
	filter: brightness(1.05);
}

.btn-secondary {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
}

.card {
	padding: var(--space);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
}

.input,
.select,
.textarea {
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--fg);
	font: inherit;
}

.field {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.35rem;
	margin-bottom: var(--space);
}

.field > label {
	font-size: 0.875rem;
	color: var(--muted);
}

/*
 * 390px-safe, like .grid below. A grid with no column list gets one implicit
 * auto column, and an auto column is never narrower than its widest item's
 * min-content width. One nowrap scrolling strip (days, time slots) anywhere
 * inside an item therefore widened the whole column past the screen: the page
 * scrolled sideways instead of the strip scrolling on its own. minmax(0, 1fr)
 * caps the column at the container; the min-width rule keeps a child from
 * bringing the same floor back if an app redefines the columns. :where() adds
 * no specificity, so a min-width the app sets on a child still wins.
 */
.stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space);
}

:where(.field, .stack, .list) > * {
	min-width: 0;
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

/*
 * 390px-safe. An unclamped minmax track overflows a 390px viewport once the
 * shell padding is subtracted, and nothing in the pipeline ever looked at a
 * phone-width layout, so every generated app inherited the horizontal scroll.
 * min() clamps the track to the container instead.
 */
.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

.table th {
	font-size: 0.8125rem;
	color: var(--muted);
	font-weight: 600;
}

.empty {
	padding: calc(var(--space) * 2);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 600;
}

/* Loading. Every fetch has one; without a primitive each app invented its own. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Placeholder for content whose shape is known before its data arrives. */
.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Error strip: a failure the user can see and retry, never a silent no-op. */
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/*
 * The scaffold had exactly one @media rule (prefers-color-scheme) and no width
 * breakpoint at all, so the shell was a 42rem column at every size.
 * Mobile-first stays the default; these only widen it.
 */
@media (min-width: 48rem) {
	.shell {
		max-width: 52rem;
		padding: calc(var(--space) * 3) calc(var(--space) * 1.5);
	}
}

@media (min-width: 64rem) {
	.shell {
		max-width: 64rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton {
		animation: none;
	}
}

/* App */
.app {
	max-width: 480px;
	margin: 0 auto;
	min-height: 100dvh;
}

.main {
	padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

.screen {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
	scroll-margin-top: 0;
}

.top {
	padding-top: max(12px, env(safe-area-inset-top));
}

.logo {
	font-size: 1.9rem;
	font-weight: 300;
	letter-spacing: -0.01em;
}

.logo span {
	color: var(--accent);
}

.headline {
	margin: 8px 0 0;
	font-size: 2.2rem;
	line-height: 1.1;
	font-weight: 800;
	color: #d3dde5;
	letter-spacing: -0.02em;
}

.muted {
	margin: 0;
	color: var(--muted);
}

.label {
	margin: 0 0 8px;
	color: var(--muted);
	font-size: 0.875rem;
	font-weight: 700;
}

.search {
	display: flex;
	gap: 8px;
}

.search-input {
	flex: 1;
	min-width: 0;
	min-height: 52px;
	padding: 0 14px;
	border: 2px solid var(--accent);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--fg);
	font: 500 1.1rem var(--font);
}

.search-input::placeholder {
	color: #7d8b97;
}

.search-btn {
	flex: none;
	width: 52px;
	min-height: 52px;
	border: 0;
	border-radius: var(--radius);
	background: var(--accent);
	color: var(--bg);
	cursor: pointer;
	display: grid;
	place-items: center;
}

.modes {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.mode {
	flex: 1;
	min-height: 44px;
	padding: 0 8px;
	white-space: nowrap;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: transparent;
	color: var(--muted);
	font: 600 0.95rem var(--font);
	cursor: pointer;
}

.mode.on {
	background: var(--fg);
	color: var(--bg);
	border-color: var(--fg);
}

.intro {
	display: grid;
	gap: 12px;
}

.scheme {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 4px;
}

.scheme span {
	aspect-ratio: 1;
	display: grid;
	place-items: center;
	font-weight: 800;
	font-size: 1.3rem;
	color: rgba(255, 255, 255, 0.9);
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.chips.center {
	justify-content: center;
}

.chip {
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--fg);
	font: 500 1rem var(--font);
	cursor: pointer;
}

.chip.static {
	display: inline-flex;
	align-items: center;
	min-height: 36px;
	cursor: default;
}

.count {
	margin: 0;
	color: var(--muted);
}

.count strong {
	color: var(--fg);
}

.results {
	display: grid;
	gap: 20px;
}

.group {
	display: grid;
	gap: 10px;
}

.group-title {
	margin: 0;
	padding-left: 10px;
	border-left: 4px solid;
	font-size: 1rem;
	font-weight: 700;
	color: #d3dde5;
}

.word {
	min-height: 44px;
	padding: 0 14px;
	border: 0;
	border-radius: 3px;
	color: #fff;
	font: 600 1.05rem var(--font);
	cursor: pointer;
	transition: transform 0.1s;
}

.word:active,
.tile:active,
.chip:active {
	transform: scale(0.96);
}

.pad {
	width: 100%;
	min-height: 160px;
	padding: 14px;
	border: 1px solid var(--surface-2);
	border-radius: 6px;
	background: var(--surface);
	color: var(--fg);
	font: 500 1.05rem/1.6 var(--font);
	resize: vertical;
}

.bars {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 6px;
}

.bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	min-height: 44px;
	padding: 4px 12px;
	border-radius: 6px;
	background: var(--surface);
}

.bar-text {
	color: #d3dde5;
	overflow-wrap: anywhere;
}

/* Gothic dark theme */
:root {
	--bg: #08060b;
	--surface: #120d18;
	--surface-2: #1d1426;
	--fg: #e8ecf5;
	--muted: #9a93ab;
	--accent: #b3202f;
	--border: #2d2038;
	--font: "Pirata One", "UnifrakturCook", Georgia, serif;
}

body {
	background: radial-gradient(ellipse at top, #1a0f24 0%, #08060b 60%) fixed;
	letter-spacing: 0.02em;
}

.logo,
.headline,
.group-title {
	font-family: "UnifrakturCook", "Pirata One", serif;
	font-weight: 700;
}

.logo {
	font-size: 2.2rem;
	color: #e8ecf5;
	text-shadow: 0 0 14px rgba(179, 32, 47, 0.6);
}

.headline {
	font-size: 2rem;
	letter-spacing: 0;
	color: #cfe0ff;
	text-shadow: 0 0 18px rgba(120, 160, 255, 0.35);
}

.search-input {
	border-color: #b3202f;
	font-size: 1.15rem;
	box-shadow: 0 0 16px rgba(179, 32, 47, 0.25);
}

.search-btn {
	color: #fff;
}

.mode.on {
	background: #b3202f;
	border-color: #b3202f;
	color: #fff;
}

.group-title {
	font-size: 1.15rem;
	color: #cfe0ff;
}

.chips {
	gap: 4px;
}

.word {
	min-height: 38px;
	padding: 0 10px;
	font: 600 0.95rem "Raleway", "Helvetica Neue", Arial, sans-serif;
	letter-spacing: 0.01em;
	color: #fff;
	text-shadow: none;
	border: 1px solid rgba(255, 255, 255, 0.28);
}

.group {
	gap: 8px;
}

.results {
	gap: 14px;
}

.mode,
.tab,
.count,
.label,
.muted {
	font-family: "Raleway", "Helvetica Neue", Arial, sans-serif;
	letter-spacing: 0.02em;
}

.tabbar {
	background: #0c0911;
	border-top-color: #2d2038;
}

.bar-end {
	min-height: 44px;
	padding: 0 14px;
	border: 0;
	border-radius: 3px;
	color: #fff;
	font: 700 1.05rem var(--font);
}

.bar-end.on {
	outline: 2px solid #fff;
}

.pad-rhymes {
	display: grid;
	gap: 12px;
}

.word.static {
	display: inline-flex;
	align-items: center;
}

.tiles {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 4px;
}

.tile {
	position: relative;
	aspect-ratio: 1;
	border: 0;
	color: #fff;
	font: 700 1.05rem var(--font);
	cursor: pointer;
	display: grid;
	place-items: center;
	text-transform: capitalize;
}

.tile-letter {
	position: absolute;
	top: 6px;
	left: 8px;
	font-size: 0.8rem;
	opacity: 0.7;
}

.stage {
	display: grid;
	justify-items: center;
	gap: 16px;
	padding: 16px 0;
}

.ring {
	width: min(240px, 70vw);
	aspect-ratio: 1;
	border-radius: 50%;
	display: grid;
	place-items: center;
	transition: background 0.3s;
}

.ring-inner {
	width: 86%;
	aspect-ratio: 1;
	border-radius: 50%;
	background: var(--bg);
	display: grid;
	place-content: center;
	text-align: center;
}

.stage-word {
	font-size: 2.2rem;
	font-weight: 800;
	text-transform: capitalize;
}

.stage-time {
	color: var(--muted);
	font-variant-numeric: tabular-nums;
	font-weight: 700;
}

input[type="range"] {
	width: 100%;
	min-height: 44px;
	accent-color: var(--accent);
}

.drill-actions {
	display: flex;
	gap: 8px;
}

.drill-actions .btn {
	flex: 1;
	justify-content: center;
	min-height: 52px;
	font-weight: 700;
	color: var(--bg);
}

.drill-actions .btn-secondary {
	color: var(--fg);
}

.tabbar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	justify-content: center;
	background: rgba(20, 24, 28, 0.96);
	border-top: 1px solid var(--border);
	padding-bottom: max(8px, env(safe-area-inset-bottom));
	z-index: 10;
}

.tab {
	flex: 1;
	max-width: 160px;
	min-height: 60px;
	display: grid;
	place-items: center;
	align-content: center;
	gap: 2px;
	border: 0;
	background: none;
	color: var(--muted);
	font: 600 0.75rem var(--font);
	cursor: pointer;
}

.tab.on {
	color: var(--accent);
}

.tab,
.mode,
.search-input,
.search-input::placeholder,
.pad {
	font-family: "Raleway", "Helvetica Neue", Arial, sans-serif;
}

.tab {
	font-weight: 700;
	font-size: 0.78rem;
	letter-spacing: 0.02em;
}

.search-input::placeholder {
	color: #a9a2b8;
	opacity: 1;
}

.getapp {
	margin: 24px 0 8px;
	padding: 0 14px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: #120d19;
	font-family: Raleway, "Helvetica Neue", Arial, sans-serif;
}

.getapp summary {
	display: flex;
	align-items: center;
	min-height: 48px;
	color: #fff;
	font-weight: 700;
	cursor: pointer;
}

.getapp summary::after {
	content: "▾";
	margin-left: auto;
	font-size: 1.2rem;
}

.getapp[open] summary::after {
	content: "▴";
}

.getapp p {
	margin: 0 0 10px;
	font-size: 0.95rem;
	line-height: 1.45;
}

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
