/* ===== BASE.CSS ===== */

/* Base CSS - Reset, Variables, and Foundation */

/* Cascade layers: utilities > components > base > reset */
@layer reset, base, components, utilities;

/* CSS Reset */
@layer reset {
	*,
	*::before,
	*::after {
		box-sizing: border-box;
		margin: 0;
		padding: 0;
	}

	img,
	picture,
	video,
	canvas,
	svg {
		display: block;
		max-width: 100%;
	}

	input,
	button,
	textarea,
	select {
		font: inherit;
	}

	p,
	h1,
	h2,
	h3,
	h4,
	h5,
	h6 {
		overflow-wrap: break-word;
	}
}

/* Base: variables and element defaults */
@layer base {
	:root {
		color-scheme: light dark;

		/* Colors - light-dark() keeps a single palette for both themes */
		--color-bg: light-dark(#ffffff, #1e1e1e);
		--color-surface: light-dark(#f3f3f3, #2d2d2d);
		--color-surface-hover: light-dark(#e8e8e8, #3d3d3d);
		--color-text: light-dark(#1a1a1a, #e0e0e0);
		--color-text-muted: light-dark(#666666, #a0a0a0);
		--color-border: light-dark(#e0e0e0, #404040);
		--color-border-strong: light-dark(#cccccc, #505050);

		/* Accent Colors (Default Blue - Windows Phone style) */
		--color-accent: light-dark(#0078d4, #4fc3f7);
		--color-accent-hover: light-dark(#106ebe, #29b6f6);
		--color-accent-text: light-dark(#ffffff, #1a1a1a);

		/* Semantic Colors */
		--color-error: #d13438;
		--color-error-bg: light-dark(#fdf3f4, #3d1f1f);
		--color-success: #107c10;
		--color-success-bg: light-dark(#f3faf3, #1f3d1f);
		--color-warning: light-dark(#ffc107, #b8860b);
		--color-warning-bg: light-dark(#fffbf0, #3d331f);
		--color-info: #0078d4;
		--color-info-bg: light-dark(#f0f7ff, #1f2d3d);

		/* On-color text (semantic buttons) */
		--color-on-error: #ffffff;
		--color-on-success: #ffffff;

		/* Typography */
		--font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
		--font-mono: 'Cascadia Code', 'Fira Code', Consolas, Monaco, 'Courier New', monospace;

		--font-size-xs: 0.75rem;
		--font-size-sm: 0.875rem;
		--font-size-base: 1rem;
		--font-size-lg: 1.125rem;
		--font-size-xl: 1.25rem;
		--font-size-2xl: 1.5rem;
		--font-size-3xl: 1.875rem;
		--font-size-4xl: 2.25rem;

		--font-weight-normal: 400;
		--font-weight-medium: 500;
		--font-weight-semibold: 600;
		--font-weight-bold: 700;
		--font-weight-light: 300;

		--line-height-tight: 1.25;
		--line-height-normal: 1.6;
		--line-height-relaxed: 1.75;

		/* Spacing */
		--space-xs: 0.25rem;
		--space-sm: 0.5rem;
		--space-md: 1rem;
		--space-lg: 1.5rem;
		--space-xl: 2rem;
		--space-xxl: 3rem;

		/* Borders */
		--border-radius: 0;
		--border-width: 1px;

		/* Control sizing (form controls) */
		--control-height: 2.5rem;
		--control-padding: 0.5rem;

		/* Shadows (minimal for flat design) */
		--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
		--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
		--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

		/* Transitions */
		--transition-fast: 150ms ease;
		--transition-base: 200ms ease;
	}

	/* Manual theme override */
	:root[data-theme="light"] {
		color-scheme: light;
	}

	:root[data-theme="dark"] {
		color-scheme: dark;
	}

	html {
		-webkit-text-size-adjust: 100%;
		text-size-adjust: 100%;
	}

	body {
		min-height: 100vh;
		line-height: var(--line-height-normal);
		font-family: var(--font-sans);
		background-color: var(--color-bg);
		color: var(--color-text);
	}

	/* Accent color overrides - apply on <html class="accent-*"> or any subtree */
	.accent-blue {
		--color-accent: #0078d4;
		--color-accent-hover: #106ebe;
		--color-accent-text: #ffffff;
	}

	.accent-teal {
		--color-accent: #00aba9;
		--color-accent-hover: #008988;
		--color-accent-text: #ffffff;
	}

	.accent-mango {
		--color-accent: #f09609;
		--color-accent-hover: #d48208;
		--color-accent-text: #1a1a1a;
	}

	.accent-orange {
		--color-accent: #f7630c;
		--color-accent-hover: #d4520b;
		--color-accent-text: #ffffff;
	}

	.accent-pink {
		--color-accent: #e3008c;
		--color-accent-hover: #c4007a;
		--color-accent-text: #ffffff;
	}

	.accent-purple {
		--color-accent: #a200ff;
		--color-accent-hover: #8800d9;
		--color-accent-text: #ffffff;
	}

	.accent-lime {
		--color-accent: #8cbf26;
		--color-accent-hover: #7aa820;
		--color-accent-text: #1a1a1a;
	}

	.accent-green {
		--color-accent: #339933;
		--color-accent-hover: #2d822d;
		--color-accent-text: #ffffff;
	}

	.accent-red {
		--color-accent: #e51400;
		--color-accent-hover: #c41200;
		--color-accent-text: #ffffff;
	}

	.accent-crimson {
		--color-accent: #d13438;
		--color-accent-hover: #b92d31;
		--color-accent-text: #ffffff;
	}
}


/* ===== TYPOGRAPHY.CSS ===== */

/* Typography - Headings, Text Elements, Lists */

@layer base {
	/* Headings - Windows Phone 8 Style: Large, Typography-driven */
	h1, h2, h3, h4, h5, h6 {
		font-weight: var(--font-weight-light);
		line-height: var(--line-height-tight);
		margin-bottom: var(--space-md);
		color: var(--color-text);
		text-wrap: balance;
	}

	h1 {
		font-size: var(--font-size-4xl);
		font-weight: var(--font-weight-light);
		letter-spacing: -0.02em;
		margin-top: var(--space-xl);
	}

	h2 {
		font-size: var(--font-size-3xl);
		font-weight: var(--font-weight-light);
		margin-top: var(--space-lg);
	}

	h3 {
		font-size: var(--font-size-2xl);
		font-weight: var(--font-weight-normal);
		margin-top: var(--space-lg);
	}

	h4 {
		font-size: var(--font-size-xl);
		font-weight: var(--font-weight-semibold);
		margin-top: var(--space-md);
	}

	h5 {
		font-size: var(--font-size-lg);
		font-weight: var(--font-weight-semibold);
		margin-top: var(--space-md);
	}

	h6 {
		font-size: var(--font-size-base);
		font-weight: var(--font-weight-bold);
		text-transform: uppercase;
		letter-spacing: 0.05em;
		margin-top: var(--space-md);
	}

	/* Paragraphs */
	p {
		margin-bottom: var(--space-md);
		max-width: 70ch;
		text-wrap: pretty;
	}

	/* Links */
	a {
		color: var(--color-accent);
		text-decoration: none;
		transition: color var(--transition-fast);

		&:hover {
			color: var(--color-accent-hover);
			text-decoration: underline;
		}

		&:focus-visible {
			outline: 2px solid var(--color-accent);
			outline-offset: 2px;
		}
	}

	/* Strong and Emphasis */
	strong, b {
		font-weight: var(--font-weight-bold);
	}

	em, i {
		font-style: italic;
	}

	/* Small Text */
	small {
		font-size: var(--font-size-sm);
		color: var(--color-text-muted);
	}

	/* Mark/Highlight - legible in both light and dark modes */
	mark {
		background-color: light-dark(#ffd966, #8c6a00);
		color: light-dark(#1a1a1a, #fff8dc);
		padding: 0.125rem 0.25rem;
	}

	/* Deleted and Inserted Text */
	del {
		text-decoration: line-through;
		color: var(--color-text-muted);
	}

	ins {
		text-decoration: none;
		border-bottom: 2px solid var(--color-success);
	}

	/* Subscript and Superscript */
	sub, sup {
		font-size: var(--font-size-xs);
		line-height: 0;
		position: relative;
		vertical-align: baseline;
	}

	sub {
		bottom: -0.25em;
	}

	sup {
		top: -0.5em;
	}

	/* Abbreviations */
	abbr[title] {
		border-bottom: 1px dotted var(--color-text-muted);
		cursor: help;
		text-decoration: none;
	}

	/* Quotes */
	cite {
		font-style: italic;
		color: var(--color-text-muted);
	}

	q {
		quotes: '"' '"' "'" "'";
	}

	/* Lists */
	ul, ol {
		margin-bottom: var(--space-md);
		padding-inline-start: var(--space-lg);

		li {
			margin-bottom: var(--space-xs);
		}
	}

	ul {
		list-style-type: disc;

		ul {
			list-style-type: circle;
			margin-top: var(--space-xs);
		}
	}

	ol {
		list-style-type: decimal;

		ol {
			list-style-type: lower-alpha;
			margin-top: var(--space-xs);
		}
	}

	/* Definition Lists */
	dl {
		margin-bottom: var(--space-md);
	}

	dt {
		font-weight: var(--font-weight-semibold);
		margin-top: var(--space-sm);
	}

	dd {
		margin-inline-start: var(--space-lg);
		margin-bottom: var(--space-sm);
		color: var(--color-text-muted);
	}

	/* Horizontal Rule - Strong horizontal line (WP8 style) */
	hr {
		border: none;
		border-top: var(--border-width) solid var(--color-border);
		margin: var(--space-xl) 0;

		&[data-size="sm"] {
			margin: var(--space-md) 0;
		}

		&[data-size="lg"] {
			margin: var(--space-xxl) 0;
			border-top-width: 2px;
		}
	}

	/* Preformatted Text */
	pre {
		font-family: var(--font-mono);
		font-size: var(--font-size-sm);
		line-height: var(--line-height-normal);
		background-color: var(--color-surface);
		padding: var(--space-md);
		overflow-x: auto;
		margin-bottom: var(--space-md);
	}

	/* Code */
	code {
		font-family: var(--font-mono);
		font-size: 0.9em;
		background-color: var(--color-surface);
		padding: 0.15em 0.4em;
		border-radius: var(--border-radius);
	}

	pre code {
		background-color: transparent;
		padding: 0;
	}

	/* Keyboard Input */
	kbd {
		font-family: var(--font-mono);
		font-size: var(--font-size-sm);
		background-color: var(--color-surface);
		border: 1px solid var(--color-border);
		border-bottom-width: 2px;
		padding: 0.15em 0.4em;
		border-radius: var(--border-radius);
	}

	/* Sample Output */
	samp {
		font-family: var(--font-mono);
		font-size: var(--font-size-sm);
	}

	/* Address */
	address {
		font-style: normal;
		margin-bottom: var(--space-md);
		color: var(--color-text-muted);
	}

	/* Semantic Classes for Text */
	.text-muted {
		color: var(--color-text-muted);
	}

	.text-accent {
		color: var(--color-accent);
	}

	.text-error {
		color: var(--color-error);
	}

	.text-success {
		color: var(--color-success);
	}

	.text-warning {
		color: var(--color-warning);
	}

	.text-small {
		font-size: var(--font-size-sm);
	}

	.text-large {
		font-size: var(--font-size-lg);
	}

	.text-light {
		font-weight: var(--font-weight-light);
	}

	.text-bold {
		font-weight: var(--font-weight-bold);
	}

	.text-uppercase {
		text-transform: uppercase;
		letter-spacing: 0.05em;
	}

	.text-center {
		text-align: center;
	}

	.text-right {
		text-align: right;
	}
}


/* ===== CONTENT.CSS ===== */

/* Content - Articles, Sections, Blockquotes, Tables, Figures */

@layer base {
	/* Articles and Sections */
	article, section {
		margin-bottom: var(--space-xl);
	}

	article > header,
	section > header {
		margin-bottom: var(--space-lg);
		padding-bottom: var(--space-md);
		border-bottom: 1px solid var(--color-border);
	}

	article > footer,
	section > footer {
		margin-top: var(--space-lg);
		padding-top: var(--space-md);
		border-top: 1px solid var(--color-border);
		color: var(--color-text-muted);
		font-size: var(--font-size-sm);
	}

	/* Aside */
	aside {
		background-color: var(--color-surface);
		padding: var(--space-md);
		margin-bottom: var(--space-md);
		border-inline-start: 3px solid var(--color-accent);
	}

	/* Blockquotes - Windows Phone 8 style: strong accent border */
	blockquote {
		margin: var(--space-lg) 0;
		padding: var(--space-md) var(--space-lg);
		border-inline-start: 4px solid var(--color-accent);
		background-color: var(--color-surface);
		color: var(--color-text-muted);

		p:last-child {
			margin-bottom: 0;
		}

		footer,
		cite {
			display: block;
			margin-top: var(--space-sm);
			font-size: var(--font-size-sm);
			color: var(--color-text-muted);
		}
	}

	/* Figures */
	figure {
		margin: var(--space-lg) 0;
	}

	figcaption {
		font-size: var(--font-size-sm);
		color: var(--color-text-muted);
		margin-top: var(--space-sm);
	}

	/* Tables */
	table {
		width: 100%;
		border-collapse: collapse;
		margin-bottom: var(--space-md);
		font-size: var(--font-size-sm);
	}

	caption {
		text-align: start;
		font-size: var(--font-size-sm);
		color: var(--color-text-muted);
		margin-bottom: var(--space-sm);
	}

	thead {
		border-bottom: 2px solid var(--color-border-strong);
	}

	tbody {
		tr {
			border-bottom: 1px solid var(--color-border);

			&:hover {
				background-color: var(--color-surface);
			}
		}
	}

	tfoot {
		border-top: 2px solid var(--color-border-strong);
		font-weight: var(--font-weight-semibold);
	}

	th, td {
		padding: var(--space-sm) var(--space-md);
		text-align: start;
	}

	th {
		font-weight: var(--font-weight-semibold);
		color: var(--color-text);
	}

	/* Striped tables via attribute */
	table[data-striped] {
		tbody {
			tr:nth-child(odd) {
				background-color: var(--color-surface);
			}
		}
	}

	/* Compact tables */
	table[data-compact] {
		th, td {
			padding: var(--space-xs) var(--space-sm);
		}
	}

	/* Details / Summary */
	details {
		margin-bottom: var(--space-md);
		border: 1px solid var(--color-border);
		background-color: var(--color-surface);

		summary {
			padding: var(--space-md);
			cursor: pointer;
			font-weight: var(--font-weight-medium);
			list-style: none;
			display: flex;
			justify-content: space-between;
			align-items: center;

			&::after {
				content: '+';
				font-size: var(--font-size-lg);
				color: var(--color-accent);
			}

			&:hover {
				background-color: var(--color-surface-hover);
			}
		}

		&[open] {
			summary {
				&::after {
					content: '−';
				}
			}
		}

		> *:not(summary) {
			padding: 0 var(--space-md) var(--space-md) var(--space-md);
		}
	}

	/* Progress */
	progress {
		appearance: none;
		width: 100%;
		height: 0.5rem;
		border: none;
		background-color: var(--color-surface);
		margin-bottom: var(--space-sm);

		&::-webkit-progress-bar {
			background-color: var(--color-surface);
		}

		&::-webkit-progress-value {
			background-color: var(--color-accent);
		}

		&::-moz-progress-bar {
			background-color: var(--color-accent);
		}

		&[value="100"] {
			&::-webkit-progress-value {
				background-color: var(--color-success);
			}

			&::-moz-progress-bar {
				background-color: var(--color-success);
			}
		}
	}

	/* Meter */
	meter {
		appearance: none;
		width: 100%;
		height: 0.5rem;
		background: var(--color-surface);
		margin-bottom: var(--space-sm);

		&::-webkit-meter-bar {
			background: var(--color-surface);
			border: none;
			height: 0.5rem;
		}

		&::-webkit-meter-optimum-value {
			background: var(--color-success);
		}

		&::-webkit-meter-suboptimum-value {
			background: var(--color-warning);
		}

		&::-webkit-meter-even-less-good-value {
			background: var(--color-error);
		}
	}

	/* Data */
	data {
		font-weight: var(--font-weight-medium);
	}
}


/* ===== FORMS.CSS ===== */

/* Forms - Inputs, Buttons, Labels, Fieldsets */

@layer base {
	/* Fieldset */
	fieldset {
		border: 1px solid var(--color-border);
		padding: var(--space-md);
		margin-bottom: var(--space-md);
	}

	legend {
		padding: 0 var(--space-sm);
		font-weight: var(--font-weight-medium);
	}

	/* Labels */
	label {
		display: block;
		font-size: var(--font-size-sm);
		font-weight: var(--font-weight-light);
		margin-bottom: var(--space-xs);
		color: var(--color-text);
		text-transform: uppercase;
		& > * {
			text-transform: initial;
		}

		& > input[type="checkbox"] {
			margin-right: var(--space-md);
		}
	}

	/* Form Groups - Moderate spacing for visual separation */
	form > div,
	form > p,
	form > label {
		margin-bottom: var(--space-lg);
	}

	/* Tighter spacing option */
	form[data-compact] > div,
	form[data-compact] > p,
	form[data-compact] > label {
		margin-bottom: var(--space-md);
	}

	/* Text Inputs and Textareas */
	input[type="text"],
	input[type="email"],
	input[type="password"],
	input[type="number"],
	input[type="tel"],
	input[type="url"],
	input[type="search"],
	input[type="date"],
	input[type="datetime-local"],
	input[type="month"],
	input[type="time"],
	input[type="week"],
	textarea,
	sk-input-tag,
	sk-input-filter,
	select {
		appearance: none;
		width: 100%;
		padding: var(--space-sm) var(--space-md);
		font-size: var(--font-size-base);
		line-height: var(--line-height-normal);
		color: var(--color-text);
		background-color: var(--color-bg);
		border: 1px solid var(--color-border);
		border-radius: var(--border-radius);
		transition: border-color var(--transition-fast), box-shadow var(--transition-fast);

		&:hover {
			border-color: var(--color-border-strong);
		}

		&:focus {
			outline: none;
			border-color: var(--color-accent);
			box-shadow: 0 0 0 2px rgb(from var(--color-accent) r g b / 0.2);
		}

		&:disabled {
			background-color: var(--color-surface);
			color: var(--color-text-muted);
			cursor: not-allowed;
		}

		&::placeholder {
			color: var(--color-text-muted);
		}
	}

	/* Textarea specific */
	textarea {
		min-height: 6rem;
		resize: vertical;
	}

	/* Select */
	select {
		background-image: light-dark(
			url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E"),
			url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0a0' d='M6 9L1 4h10z'/%3E%3C/svg%3E")
		);
		background-repeat: no-repeat;
		background-position: right var(--space-md) center;
		padding-inline-end: var(--space-xl);

		&.ghost {
			background-color: transparent;
			background-position: right 0 center;
			border: none;
			border-bottom: 1px solid var(--color-border-strong);
			border-radius: 0;
			box-shadow: none;
			padding: var(--space-xs) 0;
			padding-inline-end: var(--space-lg);

			&:hover {
				border-bottom-color: var(--color-text);
			}

			&:focus {
				border-bottom-color: var(--color-accent);
				box-shadow: none;
			}

			&:disabled {
				background-color: transparent;
				border-bottom-color: var(--color-border);
			}
		}
	}

	/* Checkboxes and Radio Buttons */
	input[type="checkbox"],
	input[type="radio"] {
		appearance: none;
		width: 1.25rem;
		height: 1.25rem;
		border: 1px solid var(--color-border-strong);
		background-color: var(--color-bg);
		display: inline-grid;
		place-content: center;
		cursor: pointer;
		vertical-align: middle;
		margin-inline-end: var(--space-xs);

		&:checked {
			background-color: var(--color-accent);
			border-color: var(--color-accent);
		}

		&:focus-visible {
			outline: 2px solid var(--color-accent);
			outline-offset: 2px;
		}

		&:disabled {
			background-color: var(--color-surface);
			cursor: not-allowed;
		}
	}

	input[type="checkbox"] {
		border-radius: var(--border-radius);

		&::before {
			content: '';
			width: 0.65rem;
			height: 0.65rem;
			transform: scale(0);
			transition: transform var(--transition-fast);
			box-shadow: inset 1em 1em var(--color-accent-text);
			transform-origin: center;
			clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
		}

		&:checked::before {
			transform: scale(1);
		}
	}

	input[type="radio"] {
		border-radius: 50%;

		&::before {
			content: '';
			width: 0.65rem;
			height: 0.65rem;
			border-radius: 50%;
			transform: scale(0);
			transition: transform var(--transition-fast);
			background-color: var(--color-accent-text);
		}

		&:checked::before {
			transform: scale(1);
		}
	}

	/* Toggle Switch - Windows Phone 7 style */
	input[type="checkbox"].toggle {
		width: 3.5rem;
		height: 1.25rem;
		border-radius: 0;
		border: 2px solid var(--color-text);
		background-color: transparent;
		display: inline-block;
		place-content: unset;
		position: relative;
		overflow: visible;
		outline: none;

		&::before {
			content: '';
			position: absolute;
			top: -0.3rem;
			left: 0;
			width: 30%;
			height: 1.7rem;
			background-color: var(--color-text);
			transform: scale(1);
			transform-origin: unset;
			clip-path: none;
			box-shadow: none;
			transition: left var(--transition-base), right var(--transition-base);
			z-index: 1;
		}

		&:checked {
			background: linear-gradient(to right, var(--color-accent) 70%, transparent 60%);

			&::before {
				left: auto;
				right: 0;
			}
		}

		&:disabled {
			border-color: var(--color-border);
			cursor: not-allowed;

			&::before {
				background-color: var(--color-border);
			}
		}
	}

	/* File Input */
	input[type="file"] {
		padding: var(--space-sm);
		font-size: var(--font-size-sm);

		&::file-selector-button {
			padding: var(--space-sm) var(--space-md);
			border: none;
			background-color: var(--color-surface);
			color: var(--color-text);
			font-weight: var(--font-weight-medium);
			cursor: pointer;
			margin-inline-end: var(--space-md);
			transition: background-color var(--transition-fast);

			&:hover {
				background-color: var(--color-surface-hover);
			}
		}
	}

	/* File Drop Area - optional dropzone look. Add the `with-droparea` class to a
	   native `<input type="file">` placed inside a container element (a `<label>`);
	   the label becomes the dashed dropzone via `:has`, while the input is overlaid
	   invisible on top - so click AND drag-and-drop work without JS. The upload icon
	   is a nested `::before`; an optional nested `span` holds a caption.
	   Sizes: `small` / `big` classes. */
	label:has(> input[type="file"].with-droparea) {
		--icon-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M452 432c0 11-9 20-20 20s-20-9-20-20 9-20 20-20 20 9 20 20zm-84-20c-11 0-20 9-20 20s9 20 20 20 20-9 20-20-9-20-20-20zm144-48v104c0 24.3-19.7 44-44 44H44c-24.3 0-44-19.7-44-44V364c0-24.3 19.7-44 44-44h124v-99.3h-52.7c-35.6 0-53.4-43.1-28.3-68.3L227.7 11.7c15.6-15.6 40.9-15.6 56.6 0L425 152.4c25.2 25.2 7.3 68.3-28.3 68.3H344V320h124c24.3 0 44 19.7 44 44zM200 188.7V376c0 4.4 3.6 8 8 8h96c4.4 0 8-3.6 8-8V188.7h84.7c7.1 0 10.7-8.6 5.7-13.7L261.7 34.3c-3.1-3.1-8.2-3.1-11.3 0L109.7 175c-5 5-1.5 13.7 5.7 13.7H200zM480 364c0-6.6-5.4-12-12-12H344v24c0 22.1-17.9 40-40 40h-96c-22.1 0-40-17.9-40-40v-24H44c-6.6 0-12 5.4-12 12v104c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12V364z'/%3E%3C/svg%3E");

		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: var(--space-xs);
		width: 18.75rem;
		height: 12.5rem;
		padding: var(--space-lg);
		margin-bottom: 0;
		border: 1px dashed var(--color-text-muted);
		border-radius: var(--border-radius);
		color: var(--color-text-muted);
		cursor: pointer;
		text-align: center;
		transition: border-color var(--transition-fast), box-shadow var(--transition-fast);

		> input[type="file"] {
			position: absolute;
			inset: 0;
			z-index: 1;
			width: 100%;
			height: 100%;
			padding: 0;
			opacity: 0;
			cursor: pointer;
		}

		/* Upload icon (masked SVG, inherits the current color) */
		&::before {
			content: '';
			width: 3rem;
			height: 3rem;
			flex-shrink: 0;
			background-color: var(--color-text-muted);
			-webkit-mask-image: var(--icon-upload);
			-webkit-mask-position: center;
			-webkit-mask-size: contain;
			-webkit-mask-repeat: no-repeat;
			mask-image: var(--icon-upload);
			mask-position: center;
			mask-size: contain;
			mask-repeat: no-repeat;
		}

		span {
			font-size: var(--font-size-base);
			font-weight: var(--font-weight-medium);
			color: var(--color-text);
		}

		&:has(> input[type="file"].with-droparea.small) {
			width: 9.375rem;
			height: 6.25rem;
			padding: var(--space-sm);

			&::before {
				width: 1.5rem;
				height: 1.5rem;
			}

			span {
				font-size: var(--font-size-sm);
			}
		}

		&:has(> input[type="file"].with-droparea.big) {
			width: 37.5rem;
			height: 25rem;
		}

		&:hover {
			border-color: var(--color-text);
		}

		&:focus-within {
			border-color: var(--color-accent);
			box-shadow: 0 0 0 2px rgb(from var(--color-accent) r g b / 0.2);

			&::before {
				background-color: var(--color-accent);
			}
		}

		&:has(> input[type="file"].with-droparea:disabled) {
			cursor: not-allowed;
			opacity: 0.5;
		}
	}

	/* Range Input */
	input[type="range"] {
		appearance: none;
		width: 100%;
		height: 0.5rem;
		background-color: var(--color-surface);
		border-radius: var(--border-radius);
		outline: none;
		margin: var(--space-sm) 0;

		&::-webkit-slider-thumb {
			appearance: none;
			width: 1.25rem;
			height: 1.25rem;
			background-color: var(--color-accent);
			cursor: pointer;
			border-radius: 50%;
			transition: background-color var(--transition-fast);

			&:hover {
				background-color: var(--color-accent-hover);
			}
		}

		&::-moz-range-thumb {
			width: 1.25rem;
			height: 1.25rem;
			background-color: var(--color-accent);
			cursor: pointer;
			border-radius: 50%;
			border: none;
			transition: background-color var(--transition-fast);

			&:hover {
				background-color: var(--color-accent-hover);
			}
		}
	}

	/* Color Input */
	input[type="color"] {
		width: 3rem;
		height: 2.5rem;
		padding: var(--space-xs);
		cursor: pointer;
		border: 1px solid var(--color-border);
	}

	button,
	input[type="submit"],
	input[type="button"],
	input[type="reset"] {
		appearance: none;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		padding: var(--space-sm) var(--space-md);
		font-size: var(--font-size-base);
		font-weight: var(--font-weight-medium);
		line-height: var(--line-height-tight);
		color: var(--color-text);
		background-color: var(--color-surface);
		border: none;
		cursor: pointer;
		transition: background-color var(--transition-fast), color var(--transition-fast);

		&:hover {
			background-color: var(--color-surface-hover);
		}

		&:focus-visible {
			outline: 2px solid var(--color-accent);
			outline-offset: 2px;
		}

		&:active {
			transform: translateY(1px);
		}

		&:disabled {
			opacity: 0.5;
			cursor: not-allowed;

			&:hover {
				background-color: var(--color-surface);
			}
		}

		&.primary {
			background-color: var(--color-accent);
			color: var(--color-accent-text);

			&:hover {
				background-color: var(--color-accent-hover);
			}
		}

		&.danger {
			background-color: var(--color-error);
			color: var(--color-on-error);

			&:hover {
				background-color: color-mix(in srgb, var(--color-error) 80%, black);
			}
		}

		&.success {
			background-color: var(--color-success);
			color: var(--color-on-success);

			&:hover {
				background-color: color-mix(in srgb, var(--color-success) 80%, black);
			}
		}

		&.ghost {
			background-color: transparent;
			border: 1px solid var(--color-border);

			&:hover {
				background-color: var(--color-surface);
			}
		}
	}

	/* Form Validation Styles */
	input:invalid:not(:placeholder-shown),
	textarea:invalid:not(:placeholder-shown) {
		border-color: var(--color-error);

		&:focus {
			box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-error) 20%, transparent);
		}
	}

	/* Helper text */
	.form-help {
		font-size: var(--font-size-sm);
		color: var(--color-text-muted);
		margin-top: var(--space-xs);
	}

	/* Error message */
	.form-error {
		font-size: var(--font-size-sm);
		color: var(--color-error);
		margin-top: var(--space-xs);
	}

	/* Inline form layout */
	form[data-layout="inline"] {
		display: flex;
		flex-wrap: wrap;
		gap: var(--space-md);
		align-items: flex-end;

		> div,
		> p {
			flex: 1;
			min-width: 200px;
			margin-bottom: 0;
		}
	}

	/* Horizontal form layout */
	form[data-layout="horizontal"] {
		> div,
		> p {
			display: flex;
			gap: var(--space-md);
			align-items: center;

			label {
				width: 120px;
				margin-bottom: 0;
				flex-shrink: 0;
			}

			input,
			textarea,
			select {
				flex: 1;
			}
		}
	}
}


/* ===== INTERACTIVE.CSS ===== */

/* Interactive - Tooltips, Badges, Alerts, Messages */

@layer components {
	/* Badges - Minimal, Accent colored */
	[data-badge] {
		display: inline-flex;
		align-items: center;
		padding: var(--space-xs) var(--space-sm);
		font-size: var(--font-size-xs);
		font-weight: var(--font-weight-medium);
		background-color: var(--color-accent);
		color: var(--color-accent-text);
		line-height: 1;

		&[data-variant="secondary"] {
			background-color: var(--color-surface);
			color: var(--color-text);
		}

		&[data-variant="outline"] {
			background-color: transparent;
			border: 1px solid var(--color-border);
			color: var(--color-text);
		}

		&[data-variant="error"] {
			background-color: var(--color-error);
			color: var(--color-on-error);
		}

		&[data-variant="success"] {
			background-color: var(--color-success);
			color: var(--color-on-success);
		}

		&[data-variant="warning"] {
			background-color: var(--color-warning);
			color: var(--color-text);
		}
	}

	/* Tooltips - Simple, clean */
	[data-tooltip] {
		position: relative;
		cursor: help;

		&::before {
			content: attr(data-tooltip);
			position: absolute;
			bottom: 100%;
			left: 50%;
			transform: translateX(-50%) translateY(-4px);
			padding: var(--space-xs) var(--space-sm);
			background-color: var(--color-text);
			color: var(--color-bg);
			font-size: var(--font-size-xs);
			white-space: nowrap;
			opacity: 0;
			visibility: hidden;
			transition: opacity var(--transition-fast), visibility var(--transition-fast);
			z-index: 1000;
		}

		&:hover::before,
		&:focus-visible::before {
			opacity: 1;
			visibility: visible;
		}
	}

	[role="alert"],
	.alert {
		padding: var(--space-md);
		margin-bottom: var(--space-md);
		background-color: var(--color-info-bg);
		border-inline-start: 4px solid var(--color-info);

		p:last-child {
			margin-bottom: 0;
		}
	}

	[role="alert"][data-variant="error"],
	.alert.error {
		background-color: var(--color-error-bg);
		border-inline-start-color: var(--color-error);
	}

	[role="alert"][data-variant="success"],
	.alert.success {
		background-color: var(--color-success-bg);
		border-inline-start-color: var(--color-success);
	}

	[role="alert"][data-variant="warning"],
	.alert.warning {
		background-color: var(--color-warning-bg);
		border-inline-start-color: var(--color-warning);
	}

	/* Empty State - For lists, content areas */
	[data-empty] {
		text-align: center;
		padding: var(--space-xl);
		color: var(--color-text-muted);

		&::before {
			content: attr(data-empty);
			display: block;
			font-size: var(--font-size-2xl);
			margin-bottom: var(--space-md);
			opacity: 0.5;
		}
	}

	/* Loading State */
	[data-loading] {
		position: relative;
		pointer-events: none;
		opacity: 0.7;

		&::after {
			content: '';
			position: absolute;
			top: 50%;
			left: 50%;
			width: 1.5rem;
			height: 1.5rem;
			margin: -0.75rem 0 0 -0.75rem;
			border: 2px solid var(--color-border);
			border-top-color: var(--color-accent);
			border-radius: 50%;
			animation: spin 1s linear infinite;
		}
	}

	/* Skeleton Loading */
	.skeleton {
		background: linear-gradient(90deg,
				var(--color-surface) 25%,
				var(--color-surface-hover) 50%,
				var(--color-surface) 75%);
		background-size: 200% 100%;
		animation: shimmer 1.5s infinite;
		color: transparent;
		pointer-events: none;
	}

	/* Breadcrumbs */
	nav[aria-label="breadcrumb"] {
		ol {
			display: flex;
			flex-wrap: wrap;
			list-style: none;
			padding: 0;
			margin: 0;
		}

		li {
			display: flex;
			align-items: center;

			&:not(:last-child)::after {
				content: '/';
				margin: 0 var(--space-sm);
				color: var(--color-text-muted);
			}
		}

		a {
			color: var(--color-text-muted);

			&:hover {
				color: var(--color-accent);
			}
		}

		li:last-child {
			color: var(--color-text);
			font-weight: var(--font-weight-medium);
		}
	}

	/* Pagination */
	nav[aria-label="pagination"] {
		display: flex;
		flex-direction: row;
		gap: var(--space-xs);
		margin: var(--space-lg) 0;

		a,
		button,
		span {
			display: inline-flex;
			align-items: center;
			justify-content: center;
			min-width: 2.5rem;
			height: 2.5rem;
			padding: 0 var(--space-sm);
			font-size: var(--font-size-sm);
			background-color: var(--color-surface);
			color: var(--color-text);
			text-decoration: none;
			transition: background-color var(--transition-fast);

			&:hover:not([aria-current]) {
				background-color: var(--color-surface-hover);
			}
		}

		[aria-current="page"] {
			background-color: var(--color-accent);
			color: var(--color-accent-text);
			font-weight: var(--font-weight-medium);
		}
	}

	/* Dialog/Modal */
	dialog {
		padding: 0;
		border: none;
		background: var(--color-bg);
		color: inherit;
		max-width: 90vw;
		max-height: 90vh;
		margin: auto;
		min-width: 20rem;
		min-height: 20rem;
		overflow-y: auto;
		overscroll-behavior: contain;

		@media (max-width: 768px) {
			max-width: 100dvw;
			max-height: 100dvh;
		}

		&::backdrop {
			background: rgba(0, 0, 0, 0.5);
		}

		/* Header/body/footer layout: keep the header and footer pinned
		   while the middle content scrolls. */
		&:has(> header):has(> footer) {
			display: flex;
			flex-direction: column;

			& > div {
				flex: 1 1 auto;
				min-height: 0;
				overflow-y: auto;
				overscroll-behavior: contain;
			}
		}

		& header {
			padding: var(--space-md) var(--space-lg);
			border-bottom: 1px solid var(--color-border);

			& h3 {
				margin: 0;
			}
		}

		& > div {
			padding: var(--space-lg);
		}

		& footer {
			padding: var(--space-md) var(--space-lg);
			border-top: 1px solid var(--color-border);
			display: flex;
			gap: var(--space-sm);
			justify-content: flex-end;
		}
	}
}

@layer base {
	@keyframes spin {
		to {
			transform: rotate(360deg);
		}
	}

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

		100% {
			background-position: -200% 0;
		}
	}
}


/* ===== APP.CSS ===== */

/* App - Web App Specific Components */

@layer components {
	/* App Container */
	.app {
		display: grid;
		grid-template-rows: auto 1fr auto;
		grid-template-columns: auto 1fr auto;
		height: 100dvh;

		& > nav, & > sk-topbar {
			grid-row: 1;
			grid-column: 1 / -1;
		}

		& > aside {
			padding: 0;
			margin: 0;
			grid-row: 2;
			grid-column: 1;

			&.right {
				grid-column: -1;
			}

			& > nav {
				& ul {
					margin: 0;
					padding: 0;
					list-style: none;
					display: flex;
					flex-direction: column;
					gap: 0;

					& ul {
						padding-inline-start: var(--space-lg);
					}

					& li:not(:has(a)), a {
						display: block;
						padding: var(--space-sm) var(--space-lg);
					}

					& > li.active > :first-child:not(ul) {
						background-color: var(--color-surface-hover);
					}

					& > li:not(:has(ul)) {
						padding-inline-end: var(--space-xxl);
					}
				}

				& a {
					text-decoration: none;
					color: inherit;

					&:hover {
						color: var(--color-accent-hover);
					}

					&[aria-current="page"] {
						color: var(--color-accent);
					}
				}
			}
		}

		& > main {
			grid-row: 2;
			overflow-y: auto;
			min-height: 0;
			width: 100%;
			max-width: 1200px;
			margin-inline: auto;
			padding-inline: var(--space-md);

			display: block flex;
			flex-direction: column;
			gap: var(--space-lg);

			&:not(:has(~ aside)):not(aside ~ main) {
				grid-column: 1 / -1;
			}
		}

		& > .hub,
		& > sk-hub {
			grid-row: 2;
			grid-column: 1 / -1;
			width: 100%;
			min-height: 0;
		}

		& > sk-appbar, & > .appbar {
			grid-row: -1;
			grid-column: 1 / -1;
		}
	}

	aside:has(nav) {
		position: sticky;
		top: 0;
	}

	/* Spinner */
	.spinner {
		width: 2.5rem;
		height: 2.5rem;
		border: 3px solid transparent;
		border-top-color: var(--color-accent);
		border-radius: 50%;
		animation: spin 0.8s linear infinite;
	}

	/* Data Display */
	.data-pair {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: var(--space-sm) 0;
		border-bottom: 1px solid var(--color-border);

		&:last-child {
			border-bottom: none;
		}

		dt {
			font-weight: var(--font-weight-medium);
			color: var(--color-text-muted);
		}

		dd {
			font-weight: var(--font-weight-semibold);
			margin: 0;
		}
	}

	/* Status indicators */
	.status {
		display: inline-flex;
		align-items: center;
		gap: var(--space-xs);
		font-size: var(--font-size-sm);
		font-weight: var(--font-weight-medium);

		&::before {
			content: '';
			width: 0.5rem;
			height: 0.5rem;
			border-radius: 50%;
			background-color: var(--color-text-muted);
		}

		&.active::before {
			background-color: var(--color-success);
		}

		&.pending::before {
			background-color: var(--color-warning);
		}

		&.error::before {
			background-color: var(--color-error);
		}

		&.inactive::before {
			background-color: var(--color-text-muted);
		}
	}

	/* Avatar */


	/* Tiles - Windows Phone style */
	.tiles {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
		gap: var(--space-sm);
	}

	/* All immediate children become tiles by convention */
	.tiles > * {
		aspect-ratio: 1;
		background-color: var(--color-accent);
		color: var(--color-accent-text);
		padding: var(--space-sm);
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
		position: relative;
		overflow: hidden;
		min-height: 100px;
		text-decoration: none;
	}

	/* Size variants via data attributes on children */
	.tiles > [data-wide] {
		grid-column: span 2;
		aspect-ratio: 2 / 1;
	}

	.tiles > [data-large] {
		grid-column: span 2;
		grid-row: span 2;
		min-height: 200px;
	}

	.tiles > [data-small] {
		aspect-ratio: 1;
		min-height: 70px;
	}

	/* Tile content elements */
	.tile-title {
		font-size: var(--font-size-sm);
		font-weight: var(--font-weight-semibold);
		line-height: 1.2;
		text-wrap: balance;
	}

	.tile-count {
		position: absolute;
		top: var(--space-sm);
		right: var(--space-sm);
		font-size: var(--font-size-2xl);
		font-weight: var(--font-weight-light);
		opacity: 0.5;
	}

	/* Command Bar - Action buttons at top */
	.command-bar {
		display: flex;
		gap: var(--space-sm);
		padding: var(--space-md) 0;
		border-bottom: 1px solid var(--color-border);
		margin-bottom: var(--space-lg);

		&.sticky {
			position: sticky;
			top: 0;
			background-color: var(--color-bg);
			z-index: 50;
		}

		.primary-actions {
			display: flex;
			gap: var(--space-sm);
		}

		.secondary-actions {
			display: flex;
			gap: var(--space-sm);
			margin-inline-start: auto;
		}
	}

	/* Split View (Master-Detail) */
	.split-view {
		display: grid;
		grid-template-columns: 300px 1fr;
		gap: var(--space-lg);
		min-height: 0;

		.master {
			border-inline-end: 1px solid var(--color-border);
			overflow-y: auto;
		}

		.detail {
			overflow-y: auto;
		}
	}

	@media (max-width: 768px) {
		.split-view {
			grid-template-columns: 1fr;

			.master {
				border-inline-end: none;
				border-bottom: 1px solid var(--color-border);
			}
		}
	}

}


/* ===== LAYOUT.CSS ===== */

/* Layout - Grid, Stack, Container Utilities */

@layer utilities {
	/* Container - Constrain max width */
	.container {
		width: 100%;
		max-width: 1200px;
		margin-inline: auto;
		padding-inline: var(--space-md);

		&.wide {
			max-width: 1400px;
		}

		&.narrow {
			max-width: 800px;
		}

		&.full {
			max-width: none;
			padding-inline: var(--space-lg);
		}
	}

	/* Stack - vertical rhythm */
	.stack {
		display: flex;
		flex-direction: column;
		gap: var(--space-md);
	}

	/* Grid - responsive columns */
	.grid {
		display: grid;
		gap: var(--space-md);
	}

	.grid-cols-2 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.grid-cols-3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	@media (max-width: 768px) {
		.grid-cols-2,
		.grid-cols-3 {
			grid-template-columns: 1fr;
		}
	}

	/* Flex Utilities */
	.flex {
		display: flex;
		flex-direction: column;
		gap: var(--space-md);

		&.gap-sm {
			gap: var(--space-sm);
		}

		&.gap-lg {
			gap: var(--space-lg);
		}

		&.vertical {
			flex-direction: column;
		}

		&.horizontal {
			flex-direction: row;
			align-items: center;
		}

		&.wrap {
			flex-wrap: wrap;
		}

		&.items-center {
			align-items: center;
		}

		&.items-start {
			align-items: flex-start;
		}

		&.items-end {
			align-items: flex-end;
		}

		&.items-baseline {
			align-items: baseline;
		}

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

		&.justify-between {
			justify-content: space-between;
		}

		&.justify-end {
			justify-content: flex-end;
		}

		& > .shrink {
			flex-shrink: 1;
		}

		& > .grow {
			flex-grow: 1;
		}

		& > .end {
			align-self: flex-end;
		}
	}

	/* Width Utilities */
	.width-full {
		width: 100%;
	}

	.width-auto {
		width: auto;
	}

	.width-fit {
		width: fit-content;
	}

	.max-width-full {
		max-width: 100%;
	}

	/* Height Utilities */
	.height-full {
		height: 100%;
	}

	.min-height-screen {
		min-height: 100vh;
	}

	/* Gap Utilities */
	.gap-sm {
		gap: var(--space-sm);
	}

	.gap-md {
		gap: var(--space-md);
	}

	.gap-lg {
		gap: var(--space-lg);
	}
}


/* ===== UTILITIES.CSS ===== */

/* Utilities - Color, Visibility, Display Helpers */

@layer utilities {
	/* Display Utilities */
	.hidden {
		display: none !important;
	}

	.block {
		display: block;
	}

	.inline {
		display: inline;
	}

	.inline-block {
		display: inline-block;
	}

	/* Visibility - Screen Reader Only */
	.sr-only {
		position: absolute;
		width: 1px;
		height: 1px;
		padding: 0;
		margin: -1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border: 0;
	}

	/* Print Visibility */
	@media print {
		.no-print {
			display: none !important;
		}

		.only-print {
			display: block !important;
		}
	}

	@media screen {
		.only-print {
			display: none !important;
		}
	}

	/* Responsive Visibility */
	@media (max-width: 768px) {
		.hide-mobile {
			display: none !important;
		}
	}

	@media (min-width: 769px) {
		.hide-desktop {
			display: none !important;
		}
	}

	/* Background Colors */
	.bg-surface {
		background-color: var(--color-surface);
	}

	.bg-accent {
		background-color: var(--color-accent);
		color: var(--color-accent-text);
	}

	.bg-error {
		background-color: var(--color-error);
		color: var(--color-on-error);
	}

	.bg-success {
		background-color: var(--color-success);
		color: var(--color-on-success);
	}

	.bg-warning {
		background-color: var(--color-warning);
		color: var(--color-text);
	}

	/* Text Colors */
	.text-primary {
		color: var(--color-text);
	}

	/* Border Utilities */
	.border {
		border: 1px solid var(--color-border);
	}

	.border-b {
		border-bottom: 1px solid var(--color-border);
	}

	.border-t {
		border-top: 1px solid var(--color-border);
	}

	.border-l {
		border-inline-start: 1px solid var(--color-border);
	}

	.border-r {
		border-inline-end: 1px solid var(--color-border);
	}

	.border-accent {
		border-color: var(--color-accent);
	}

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

	/* Overflow Utilities */
	.overflow-hidden {
		overflow: hidden;
	}

	.overflow-auto {
		overflow: auto;
	}

	.overflow-x-auto {
		overflow-x: auto;
	}

	.overflow-y-auto {
		overflow-y: auto;
	}

	/* Position Utilities */
	.relative {
		position: relative;
	}

	.absolute {
		position: absolute;
	}

	.fixed {
		position: fixed;
	}

	.sticky {
		position: sticky;
	}

	/* Z-Index Utilities */
	.z-10 {
		z-index: 10;
	}

	.z-50 {
		z-index: 50;
	}

	.z-100 {
		z-index: 100;
	}

	/* Cursor Utilities */
	.cursor-pointer {
		cursor: pointer;
	}

	.cursor-not-allowed {
		cursor: not-allowed;
	}

	/* Object Fit */
	.object-cover {
		object-fit: cover;
	}

	.object-contain {
		object-fit: contain;
	}

	/* Rounded Corners (minimal for WP8 style) */
	.rounded {
		border-radius: 0.25rem;
	}

	/* Shadow Utilities */
	.shadow-sm {
		box-shadow: var(--shadow-sm);
	}

	.shadow-md {
		box-shadow: var(--shadow-md);
	}

	.shadow-lg {
		box-shadow: var(--shadow-lg);
	}

	.shadow-none {
		box-shadow: none;
	}

	/* List Reset */
	.list-none {
		list-style: none;
		padding-inline-start: 0;
	}

	/* Truncate Text */
	.truncate {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	/* Break Words */
	.break-words {
		overflow-wrap: break-word;
	}

	/* No Wrap */
	.whitespace-nowrap {
		white-space: nowrap;
	}

	/* Scroll Behavior */
	.scroll-smooth {
		scroll-behavior: smooth;
	}

	/* Selection Color */
	::selection {
		background-color: var(--color-accent);
		color: var(--color-accent-text);
	}

	/* Print Styles */
	@media print {
		/* Hide interactive elements */
		.no-print,
		nav,
		.demo-nav,
		.demo-sidebar,
		button[data-close],
		[role="tablist"],
		code-preview,
		.spinner,
		.skeleton,
		[data-loading] {
			display: none !important;
		}

		/* Force light theme colors for print */
		:root {
			color-scheme: light;
			--color-bg: #ffffff !important;
			--color-surface: #f5f5f5 !important;
			--color-text: #000000 !important;
			--color-text-muted: #666666 !important;
			--color-border: #cccccc !important;
			--color-accent: #0066cc !important;
		}

		body {
			background: white !important;
			color: black !important;
			font-size: 12pt;
			line-height: 1.5;
		}

		/* Links - show URL after link text */
		a[href]::after {
			content: " (" attr(href) ")";
			font-size: 90%;
			color: var(--color-text-muted);
		}

		a[href^="#"]::after,
		a[href^="javascript:"]::after {
			content: "";
		}

		/* Page breaks */
		section,
		article {
			break-inside: avoid;
		}

		h1, h2, h3 {
			break-after: avoid;
		}

		table {
			break-inside: auto;
		}

		tr {
			break-inside: avoid;
		}

		img, figure {
			break-inside: avoid;
			max-width: 100% !important;
		}

		/* Form elements - show values but styled for print */
		input, textarea, select {
			border: 1px solid #ccc !important;
			background: transparent !important;
		}

		/* Cards and containers */
		.card, aside, blockquote {
			border: 1px solid #ccc !important;
			box-shadow: none !important;
		}

		/* Adjust font sizes for print */
		h1 { font-size: 24pt; }
		h2 { font-size: 20pt; }
		h3 { font-size: 16pt; }
		h4 { font-size: 14pt; }

		/* Remove backgrounds that waste ink */
		* {
			background: transparent !important;
		}

		.card,
		aside,
		tbody tr:hover,
		.list-item:hover {
			background-color: transparent !important;
		}
	}
}


/* ===== APPBAR.CSS ===== */

@layer components {
	.appbar, sk-appbar {
		&.fixed {
			position: fixed;
		}

		width: 100%;
		height: min-content;
		bottom: 0;
		left: 0;
		box-sizing: border-box;
		min-height: fit-content;
		margin: 0.4rem 0;
		display: block flex;
		flex-direction: row;
		gap: var(--space-sm, 0.6rem);
		justify-content: flex-end;
		background-color: var(--color-bg);

		&:has(input[type="checkbox"]:checked) > *::after {
			content: attr(title);
			display: block;
			width: 100%;
			text-align: center;
			cursor: pointer;
			color: inherit !important;
			text-decoration: none;
			font-size: x-small;
		}

		& > * {
			display: block flex !important;
			flex-direction: column;
			justify-content: center !important;
			align-content: center !important;
			align-items: center !important;
			gap: var(--space-sm, 0.2rem);
			color: inherit;
			cursor: pointer;
			fill: currentColor !important;
			width: fit-content;
			padding: 0;
			background-color: transparent;
			border: none;
			font-size: inherit;
			font-weight: inherit;
			line-height: inherit;

			&:hover {
				background-color: transparent;
				color: var(--color-accent-hover);
			}

			&:active {
				transform: none;
			}

			& > svg, & > i > svg {
				width: 2.4rem !important;
				height: 2.4rem !important;
				min-width: 2.4rem !important;
				min-height: 2.4rem !important;
				max-width: 2.4rem !important;
				max-height: 2.4rem !important;
				display: block;
				overflow: visible;
				padding: 0.4em;
				box-sizing: border-box;
				border-radius: 50%;
				border: 0.15rem solid var(--color-surface);

				&:hover {
					background: rgba(0, 0, 0, 0.219);
					border-color: var(--color-surface-hover);
				}
			}
		}

		& > input[type="checkbox"] {
			appearance: none;
			-webkit-appearance: none;
			width: 2.4rem;
			height: 2.4rem;
			border-radius: 50%;
			border: 0.15rem solid transparent;
			background: transparent;
			cursor: pointer;
			position: relative;
			transition: all 0.3s ease;

			&::before {
				content: "·\A·\A·";
				white-space: pre;
				line-height: 0.4;
				display: inline-block;
				text-align: center;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
				color: currentColor;
				font-weight: bold;
				clip-path: none;
				box-shadow: none;
				transition: none;
				width: auto !important;
				height: min-content !important;
			}
		}
	}
}


/* ===== LISTS.CSS ===== */

@layer components {
	/* List - convention-based metro list:
	   optional thumbnail (.icon / i / img:first-child), a content column
	   (.content or the first div; its first child is the title), and optional
	   time / count on the right. */
	.list {
		list-style: none;
		padding: 0;
		margin: 0;
		gap: var(--space-md);
		display: flex;
		flex-direction: column;
		max-width: 100%;

		& > li {
			display: flex;
			flex-direction: row;
			align-items: center;
			flex-wrap: nowrap;
		}

		& > li:not(:has(a)),
		& > li > a {
			width: 100%;
			margin: 0;
			display: flex;
			flex-wrap: nowrap;
			gap: var(--space-md);
			align-items: flex-start;
			padding: var(--space-sm) var(--space-sm);
			text-decoration: none;
			min-width: 0;
			white-space: nowrap;
			color: inherit;
			overflow: hidden;
			font-weight: 300;
			transition: background-color var(--transition-fast);
			max-width: 40rem;

			&:hover:not(.heading) {
				/*background-color: var(--color-surface);*/
				color: var(--color-accent-hover);
			}

			&:active:not(.heading) {
				color: var(--color-accent);
			}

			&[aria-selected="true"],
			&.selected {
				border-inline-start: 1px solid var(--color-accent);
			}

			/* Square image/thumbnail - first child convention */
			& > img:first-child,
			& > .icon:first-child,
			& > i:first-child {
				width: 3.5rem;
				height: 3.5rem;
				max-width: 3.5rem;
				max-height: 3.5rem;
				object-fit: cover;
				flex-shrink: 0;
				border-radius: 0;
				margin-top: 0.25rem;
			}

			/* Icon placeholder alternative */
			& > .icon,
			& > i {
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: var(--font-size-2xl);
				background-color: var(--color-surface);
			}

			/* Content column - first child is the title, the rest are subtitles */
			& > .content,
			& > div:first-of-type {
				flex-grow: 1;
				flex-shrink: 2;
				min-width: 0;
				display: flex;
				flex-direction: column;
				gap: 0.125rem;
				padding-top: 0.4rem;
				overflow-x: hidden;
				white-space: nowrap;
				font-size: inherit;

				& > *:not(:first-child) {
					display: block;
					font-size: 0.65em;
					color: var(--color-text-muted);
					overflow-x: hidden;
					text-overflow: ellipsis;
					height: fit-content;
					line-height: normal;
				}

				& > :first-child {
					font-size: inherit;
				}
			}

			& > * {
				flex-shrink: 0;
			}

			&.heading {
				text-transform: uppercase;
				font-size: small;
				font-weight: bold;
				margin-bottom: -1.2em;
				margin-top: 1.4em;
			}

			& .is-sub {
				font-size: 0.5em;
				display: block;
				color: var(--color-text-muted);
				margin-top: -0.5em;
			}

			& .svg-icon {
				margin-right: 0.4em;
				background-color: var(--color-surface);
				width: 2em;
				height: 2em;
				max-width: 2em;
				max-height: 2em;

				& > svg {
					padding: 0.3em;
					width: 1.4em;
					height: 1.4em;
					max-width: 1.4em;
					max-height: 1.4em;
					fill: var(--color-accent);
				}
			}

			& .shrink {
				flex-shrink: 3;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			/* Time / metadata - right side */
			& > .right,
			& > div:not([class]) ~ div:not([class]):not(:has(~ div:not([class]))) {
				font-size: var(--font-size-xs);
				color: var(--color-text-muted);
				display: flex;
				flex-direction: column;
				align-items: flex-end;
				flex-grow: 0;
				flex-shrink: 0;
				align-self: flex-start;
				padding-top: 0.5rem;
				min-width: 3rem;
				text-align: right;
			}

			/* Count badge - far right */
			& > data,
			& > .count,
			& > [data-count] {
				font-size: var(--font-size-lg);
				font-weight: var(--font-weight-light);
				color: var(--color-accent);
				flex-shrink: 0;
				align-self: flex-start;
				padding-top: 0.25rem;
				min-width: 1.5rem;
				text-align: right;
			}
		}

		&.big > li {
			font-size: var(--font-size-xl);
		}

		&.small > li {
			font-size: var(--font-size-sm);
		}
	}
}


/* ===== COMPONENTS.CSS ===== */

@layer components {
	/* SVG ICONS */
	i {
		font-size: 1.2em;
		display: inline flex;

		width: fit-content;
		height: fit-content;
		justify-content: center;
		align-content: center;
		align-items: center;
		--size: 1.2rem;
		font-size: var(--size);

		&.interactive {
			cursor: pointer;

			&:hover {
				& > svg {
					stroke: var(--color-text);
					fill: var(--color-text);
				}
			}

			&.primary {
				border-radius: 50%;
				padding: 0.5em;

				&:hover {
					background-color: rgba(0, 0, 0, 0.054);
				}
			}
		}

		& > * {
			display: flex;
			align-items: center;
			justify-content: center;
			stroke: var(--color-text-muted);
			max-width: var(--size);
			max-height: var(--size);
			width: var(--size);
			height: var(--size);
			fill: var(--color-text-muted);
		}

		&.xxl {
			--size: 2.2rem;
		}

		&.xl {
			--size: 1.9rem;
		}

		&.lg {
			--size: 1.6rem;
		}

		&.sm {
			--size: 0.6rem;
		}

		&.active {
			& > svg {
				stroke: var(--color-accent);
				fill: var(--color-accent);
			}

			&:hover {
				& > svg {
					stroke: var(--color-accent-hover);
					fill: var(--color-accent-hover);
				}
			}
		}

		&.is-warning {
			& > svg {
				stroke: var(--color-warning);
				fill: var(--color-warning);
			}
		}
	}

	.tabs {
		display: grid;
		grid-template-rows: auto auto;
		border-bottom: 2px solid var(--color-border);
		margin-bottom: var(--space-md);

		& > *:has(label) {
			display: contents;

			& > * {
				display: none;
			}

			&:has(input[type="radio"]:checked) {
				& > *:not(label) {
					grid-row: 2;
					grid-column: 1 / -1;
					display: block;
					width: 100%;
					padding: var(--space-md) 0;
				}
			}
		}

		& > label,
		& > * > label {
			display: block;
			grid-row: 1;
			padding: var(--space-sm) var(--space-md);
			background: none;
			border: none;
			border-bottom: 2px solid transparent;
			margin-bottom: -2px;
			color: var(--color-text-muted);
			cursor: pointer;
			transition:
				color var(--transition-fast),
				border-color var(--transition-fast);
			font-weight: var(--font-weight-normal);
			position: relative;

			&:hover {
				color: var(--color-text);
			}

			&:has(input[type="radio"]:checked) {
				color: var(--color-accent);
				border-bottom-color: var(--color-accent);
				font-weight: var(--font-weight-medium);
			}

			input[type="radio"] {
				position: absolute;
				opacity: 0;
				width: 0;
				height: 0;
			}
		}
	}

	nav {
		display: block flex;
		gap: var(--space-md);
		flex-direction: column;

		&.horizontal {
			flex-direction: row;
		}

		& > a {
			text-decoration: none;
			color: var(--color-text);

			&.active,
			&[aria-current]:not([aria-current="false"]) {
				color: var(--color-accent);
			}

			&:hover {
				color: var(--color-accent-hover);
			}
		}
	}

	/* Pivot Navigation - Windows Phone 8 Metro style.
	   Every direct child is a pivot header; the active one is
	   detected via [aria-current="page"] or .active. */
	.pivot {
		display: flex;
		flex-direction: row;
		overflow-x: auto;
		scrollbar-width: none;
		-ms-overflow-style: none;
		border-bottom: 2px solid var(--color-border);
		margin-bottom: var(--space-lg);
		gap: var(--space-xl);

		&::-webkit-scrollbar {
			display: none;
		}

		> * {
			flex-shrink: 0;
			padding: var(--space-sm) 0;
			background: none;
			border: none;
			border-bottom: 2px solid transparent;
			margin-bottom: -2px;
			color: var(--color-text-muted);
			text-decoration: none;
			font-size: var(--font-size-2xl);
			font-weight: var(--font-weight-light);
			line-height: 1.2;
			transition:
				color var(--transition-fast),
				border-color var(--transition-fast);
			cursor: pointer;
			white-space: nowrap;

			&:hover {
				color: var(--color-text);
			}
		}

		> :is([aria-current="page"], .active) {
			color: var(--color-accent);
			border-bottom-color: var(--color-accent);
			font-weight: var(--font-weight-normal);
		}

		&[data-compact] > * {
			font-size: var(--font-size-lg);
			padding: var(--space-xs) 0;
		}
	}

	.hub,
	sk-hub {
		display: grid;
		grid-template-rows: auto auto 1fr;
		grid-auto-flow: column;
		grid-auto-columns: minmax(0, fit-content(26rem));
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding: 0;
		padding: 0;
		scrollbar-width: thin;
		container-type: inline-size;


		& > *,
		& > section {
			grid-row: 3;
			scroll-snap-align: start !important;
			margin-bottom: 0;
			overflow-y: auto;
			max-width: 100%;
			width: fit-content;
			min-width: 20rem;
			overflow-x: hidden;
			padding: 0 1rem;

			& > :is(h1, h2, h3, h4, h5, h6),
			&::before {
				display: block;
				line-height: inherit;
				margin: 0 0 var(--space-lg) 0;
				padding-bottom: var(--space-sm);
				font-size: var(--font-size-4xl);
				font-weight: var(--font-weight-light);
				text-wrap: balance;
				position: sticky;
				top: 0;
				background-color: var(--color-bg);
			}

			&[data-title] {
				> :is(h1, h2, h3, h4):first-child {
					display: none;
				}

				&::before {
					content: attr(data-title);
				}
			}
		}

		& > :is(h1, h2, h3, h4, h5, h6):first-child {
			grid-row: 1;
			grid-column: 1 / -1;
			position: sticky;
			min-width: 0;
			overflow-wrap: anywhere;
			left: 0;
			will-change: transform;
			pointer-events: none;
			white-space: nowrap;
			margin: 0;
			padding: 0;
			line-height: 1em;
			margin-bottom: 0.3em;
			text-transform: lowercase;
			font-size: 5rem;
			font-weight: 100;
			letter-spacing: 0.01em;
			overflow: initial;
		}

		@media (max-width: 768px) {
			grid-auto-columns: 100dvw;
			gap: var(--space-sm);

			&.peek {
				grid-auto-columns: 90dvw;
				& > section {
					max-width: 90cqw;
				}
			}
		}
	}

	.card {
		background-color: var(--color-surface);
		border: 1px solid var(--color-border);
		padding: var(--space-lg);
		margin-bottom: var(--space-md);
		transition: border-color var(--transition-fast);

		&:hover {
			border-color: var(--color-accent);
		}

		> header {
			display: flex;
			justify-content: space-between;
			align-items: flex-start;
			margin-bottom: var(--space-md);
			padding-bottom: var(--space-sm);
			border-bottom: 1px solid var(--color-border);

			h1,
			h2,
			h3,
			h4,
			h5,
			h6 {
				margin: 0;
				font-size: var(--font-size-lg);
				font-weight: var(--font-weight-semibold);
			}
		}

		> footer {
			display: flex;
			gap: var(--space-sm);
			margin-top: var(--space-md);
			padding-top: var(--space-md);
			border-top: 1px solid var(--color-border);
		}
	}

	.avatar {
		width: 2.5rem;
		height: 2.5rem;
		border-radius: 50%;
		background-color: var(--color-accent);
		color: var(--color-accent-text);
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: var(--font-weight-medium);
		font-size: var(--font-size-sm);
		flex-shrink: 0;

		&[data-size="sm"] {
			width: 1.75rem;
			height: 1.75rem;
			font-size: var(--font-size-xs);
		}

		&[data-size="lg"] {
			width: 3.5rem;
			height: 3.5rem;
			font-size: var(--font-size-lg);
		}

		&[data-size="xl"] {
			width: 5rem;
			height: 5rem;
			font-size: var(--font-size-2xl);
		}
	}

	.stats {
		display: flex;
		flex-direction: horizontal;
		gap: var(--space-xxl);
		& > div {
			display: inline flex;
			align-items: center;
			flex-direction: column;
			dd,
			& > :nth-child(2):not([class]):not(dt):not(dd),
			& > .value {
				display: block;
				font-size: var(--font-size-3xl);
				font-weight: var(--font-weight-light);
				color: var(--color-accent);
				line-height: 1;
				margin-inline: 0;
				margin: 0;
			}

			dt,
			& > :first-child:not([class]):not(dt):not(dd),
			& > .label {
				display: block;
				font-size: var(--font-size-sm);
				color: var(--color-text-muted);
				text-transform: uppercase;
				letter-spacing: 0.05em;
				font-weight: 300;
				margin-top: var(--space-xs);
				margin-inline: 0;
				margin: 0;
			}
		}
	}
}


/* ===== CUSTOM-ELEMENTS.CSS ===== */

@layer components {
	sk-attachment {
		display: inline-block;

		figure.attachment {
			margin: 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			gap: var(--space-xs, 0.25rem);

			img {
				max-width: 100%;
				height: auto;
				border-radius: var(--border-radius);
				object-fit: contain;
			}

			figcaption {
				font-size: var(--font-size-sm);
				color: var(--color-text-muted);
				text-align: center;
				overflow-wrap: anywhere;
			}
		}

		&[display-size="medium"] img {
			max-height: 200px;
		}

		&[display-size="large"] img {
			max-height: 400px;
		}
	}

	sk-topbar {
		&.ghost {
			background-color: transparent;
		}
	}

	sk-html-demo {
		display: block;
		margin: var(--space-lg, 1.5rem) 0;
		border: 1px solid var(--color-border, #ccc);
		background: var(--color-bg, #fff);

		&:not(:defined) {
			visibility: hidden;
		}

		.sk-html-demo-example {
			padding: var(--space-md, 1rem);
		}

		.sk-html-demo-actions {
			display: flex;
			gap: var(--space-sm, 0.5rem);
			padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
			border-top: 1px solid var(--color-border, #ccc);
			background: var(--color-surface, #f5f5f5);
		}

		.sk-html-demo-code {
			margin: 0;
			border-top: 1px solid var(--color-border, #ccc);
			border-radius: 0;
			max-height: 320px;
			overflow: auto;
		}
	}

	sk-editor {
		display: block;
		border: 1px solid var(--color-border, #ccc);
		border-radius: var(--border-radius, 4px);
		overflow: hidden;
		font-family: var(--font-sans, system-ui, sans-serif);

		.sk-editor-toolbar {
			display: flex;
			flex-wrap: wrap;
			gap: 2px;
			padding: 4px;
			border-bottom: 1px solid var(--color-border, #ccc);
			background: var(--color-surface, #f5f5f5);
			user-select: none;

			.sk-toolbar-group {
				display: flex;
				gap: 1px;
				padding-inline-end: 6px;
				border-inline-end: 1px solid var(--color-border, #ddd);

				&:last-child {
					border-inline-end: none;
					padding-inline-end: 0;
				}
			}

			button {
				all: unset;
				display: inline-flex;
				align-items: center;
				justify-content: center;
				min-width: 28px;
				height: 28px;
				padding: 2px 4px;
				border-radius: 3px;
				cursor: pointer;
				font-size: 0.8em;
				line-height: 1;
				color: var(--color-text, #333);

				&:hover {
					background: var(--color-accent, #0078d4);
					color: var(--color-bg, #fff);
				}

				&.active {
					background: var(--color-accent, #0078d4);
					color: var(--color-bg, #fff);
				}
			}
		}

		.sk-editor-area {
			min-height: 200px;
			max-height: 70vh;
			overflow-y: auto;
			padding: 12px 16px;
			outline: none;
			line-height: 1.6;
			color: var(--color-text, #222);
			background: var(--color-bg, #fff);
			cursor: text;

			&:empty::before {
				content: attr(data-placeholder);
				color: var(--color-text-muted, #999);
				pointer-events: none;
			}

			& > *:first-child { margin-block-start: 0; }
			& > *:last-child { margin-block-end: 0; }

			h1, h2, h3, h4, h5, h6 {
				margin-block: 0.6em 0.3em;
				line-height: 1.3;
			}

			p { margin-block: 0.4em; }

			ul, ol {
				padding-inline-start: 1.5em;
				margin-block: 0.4em;
			}

			li {
				margin-block: 0.15em;

				&:has(> input[type="checkbox"]) {
					list-style: none;
					margin-inline-start: -1.5em;
				}

				& > input[type="checkbox"] {
					margin-inline-end: 0.4em;
					vertical-align: middle;
				}
			}

			hr {
				border: none;
				margin-block: 1em;
			}

			a {
				text-decoration: underline;
			}

			img {
				max-width: 100%;
				height: auto;
				border-radius: 4px;
				margin-block: 0.5em;
			}

			table {
				width: 100%;
				border-collapse: collapse;
				margin-block: 0.6em;

				th, td {
					border: 1px solid var(--color-border, #ccc);
					text-align: start;
					min-width: 2em;
				}
			}
		}

		.sk-table-toolbar {
			display: none;
			flex-wrap: wrap;
			gap: 2px;
			padding: 3px 4px;
			background: var(--color-surface, #f5f5f5);
			border-bottom: 1px solid var(--color-border, #ccc);
			user-select: none;
			align-items: center;
			font-size: 0.78em;
			color: var(--color-text-muted, #666);

			&.visible {
				display: flex;
			}

			span.sk-table-label {
				padding-inline: 4px;
				font-weight: 600;
			}

			button {
				all: unset;
				display: inline-flex;
				align-items: center;
				justify-content: center;
				min-width: 24px;
				height: 24px;
				padding: 1px 5px;
				border-radius: 3px;
				cursor: pointer;
				color: var(--color-text, #333);

				&:hover {
					background: var(--color-accent, #0078d4);
					color: var(--color-bg, #fff);
				}
			}

			.sk-table-sep {
				width: 1px;
				height: 16px;
				background: var(--color-border, #ddd);
				margin-inline: 3px;
			}
		}

		.sk-editor-raw {
			display: none;
			width: 100%;
			min-height: 200px;
			max-height: 70vh;
			padding: 12px 16px;
			border: none;
			outline: none;
			resize: vertical;
			font-family: ui-monospace, monospace;
			font-size: 0.9em;
			line-height: 1.6;
			color: var(--color-text, #222);
			background: var(--color-bg, #fff);
			tab-size: 4;
			box-sizing: border-box;
		}
	}
}


