html,
body {
	height: 100%;
	width: 100%;
}

:root {
	/* Colors from https://stephango.com/flexoki */
	/* Flexoki Light Theme Colors */
	--theme-light-color: #1c1b1a;
	--theme-light-background: #fffcf0;
	--theme-light-tr-primary: rgba(242, 240, 229, 0.8);
	--theme-light-tr-other: rgba(242, 240, 229, 0.4);
	--theme-light-link: #66800b; /* Flexoki Green */
	--theme-light-accent: #879a39; /* Flexoki Green */
	--theme-light-border: #d2d0c5;
	--theme-light-error: #d14d41;

	/* Flexoki Dark Theme Colors */
	--theme-dark-color: #cecdc3;
	--theme-dark-background: #100f0f;
	--theme-dark-tr-primary: rgba(35, 33, 32, 0.8);
	--theme-dark-tr-other: rgba(35, 33, 32, 0.4);
	--theme-dark-link: #879a39; /* Flexoki Green Light */
	--theme-dark-accent: #3aa99f; /* Flexoki Cyan Light */
	--theme-dark-border: #403e3c;
	--theme-dark-error: #af3029;

	/* Default to light theme - will be overridden by JS and media queries */
	--color-text: var(--theme-light-color);
	--color-background: var(--theme-light-background);
	--color-primary: var(--theme-light-link);
	--color-accent: var(--theme-light-accent);
	--color-border: var(--theme-light-border);
	--color-tr-primary: var(--theme-light-tr-primary);
	--color-tr-other: var(--theme-light-tr-other);
	--color-error: var(--theme-light-error);
}

/* Auto-detect system preference when no explicit choice is made */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) {
		--color-text: var(--theme-dark-color);
		--color-background: var(--theme-dark-background);
		--color-primary: var(--theme-dark-link);
		--color-accent: var(--theme-dark-accent);
		--color-border: var(--theme-dark-border);
		--color-tr-primary: var(--theme-dark-tr-primary);
		--color-tr-other: var(--theme-dark-tr-other);
		--color-error: var(--theme-dark-error);
	}
}

#theme-light:checked ~ main {
	--color-text: var(--theme-light-color);
	--color-background: var(--theme-light-background);
	--color-primary: var(--theme-light-link);
	--color-accent: var(--theme-light-accent);
	--color-border: var(--theme-light-border);
	--color-tr-primary: var(--theme-light-tr-primary);
	--color-tr-other: var(--theme-light-tr-other);
	--color-error: var(--theme-light-error);
}

#theme-dark:checked ~ main {
	--color-text: var(--theme-dark-color);
	--color-background: var(--theme-dark-background);
	--color-primary: var(--theme-dark-link);
	--color-accent: var(--theme-dark-accent);
	--color-border: var(--theme-dark-border);
	--color-tr-primary: var(--theme-dark-tr-primary);
	--color-tr-other: var(--theme-dark-tr-other);
	--color-error: var(--theme-dark-error);
}

body {
	font-family: Times, 'Times New Roman', Georgia, serif;
	font-size: larger;
	line-height: 1.6;
	margin: 0;
	padding: 1px 5px 1px 1px;
	min-height: 100vh;
	color: var(--color-text);
	background-color: var(--color-background);
	transition: color 0.3s, background-color 0.3s;
}

/* Fix body padding for mobile */
@media (max-width: 480px) {
	body {
		padding: 1px;
	}
}

main {
	min-height: 100vh;
	color: var(--color-text);
	background: var(--color-background);
}

#content {
	max-width: 800px;
	margin: 0 auto;
}

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

th,
td {
	padding: 10px;
	border: 1px solid var(--color-border);
	text-align: left;
}

th {
	background-color: var(--color-tr-primary);
	font-weight: bold;
}

tr:nth-child(even) {
	background-color: var(--color-tr-other);
}

a {
	color: var(--color-primary);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

.theme-switch {
	position: fixed;
	top: 20px;
	right: 20px;
	display: flex;
	gap: 10px;
}

.theme-switch label {
	cursor: pointer;
	padding: 5px 10px;
	border-radius: 5px;
	background-color: var(--color-tr-other);
	color: var(--color-text);
	border: 1px solid var(--color-border);
	transition: all 0.2s ease;
}

.theme-switch label:hover {
	background-color: var(--color-tr-primary);
}

#theme-light:checked ~ .theme-switch label[for='theme-light'],
#theme-dark:checked ~ .theme-switch label[for='theme-dark'] {
	background-color: var(--color-primary);
	color: var(--color-background);
}

h1 {
	margin-bottom: 10px;
}

.spaced {
	letter-spacing: 5px;
}

h2 {
	font-size: 28pt;
	margin-bottom: 15px;
	margin-top: 0px;
	color: var(--color-primary);
}

h3 {
	color: var(--color-primary);
	margin-bottom: 15px;
}

.container {
	max-width: 1200px;
	margin: 0 auto;
}

@media (min-width: 768px) and (max-width: 1200px) {
	.container {
		margin: 2rem;
	}
}

/* Responsive container padding */
@media (max-width: 768px) {
	.container {
		margin: 1rem;
	}
}

@media (max-width: 480px) {
	.container {
		margin: 0.5rem;
	}
}

.header {
	text-align: center;
	margin-bottom: 40px;
}

.header p {
	font-style: italic;
	color: var(--color-text);
	opacity: 0.8;
}

.main-content {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 40px;
	margin-bottom: 40px;
}

@media (max-width: 768px) {
	.main-content {
		grid-template-columns: 1fr;
		gap: 20px;
	}
}

.section {
	background: var(--color-tr-primary);
	padding: 20px;
	border-radius: 8px;
	border: 1px solid var(--color-border);
}

/* Responsive section padding */
@media (max-width: 768px) {
	.section {
		padding: 15px;
	}
}

@media (max-width: 480px) {
	.section {
		padding: 15px 10px; /* Maintain some internal padding on mobile */
	}
}

.test-section {
	grid-column: 1 / -1;
}

.utilities-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin: 0 0 15px 0;
	cursor: pointer;
	user-select: none;
}

.utilities-toggle {
	background: none;
	border: none;
	color: var(--color-text);
	font-size: 16px;
	cursor: pointer;
	padding: 5px;
	border-radius: 3px;
	transition: all 0.2s ease;
}

.utilities-toggle:hover {
	background-color: var(--color-tr-other);
}

.utilities-content {
	overflow: hidden;
	transition: max-height 0.3s ease, opacity 0.3s ease;
	max-height: 1000px;
	opacity: 1;
}

.utilities-content.collapsed {
	max-height: 0;
	opacity: 0;
}

.form-group {
	margin-bottom: 15px;
}

.form-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 15px;
}

@media (max-width: 480px) {
	.form-row {
		grid-template-columns: 1fr;
		gap: 10px;
	}
}

.form-group label {
	display: block;
	margin-bottom: 5px;
	font-weight: bold;
	color: var(--color-text);
}

.form-group input,
.form-group select {
	width: 100%;
	padding: 8px;
	border: 1px solid var(--color-border);
	border-radius: 4px;
	background: var(--color-background);
	color: var(--color-text);
	font-family: inherit;
	font-size: 14px;
	box-sizing: border-box; /* Fix for input width overflow */
}

.form-group input:focus,
.form-group select:focus {
	outline: none;
	border-color: var(--color-primary);
	box-shadow: 0 0 0 2px rgba(139, 69, 19, 0.2);
}

.phrase-input {
	background: var(--color-tr-other);
	padding: 15px;
	border-radius: 6px;
	margin-bottom: 20px;
	border: 1px solid var(--color-border);
}

.phrase-input h3 {
	margin-top: 0;
}

button {
	background: var(--color-primary);
	color: var(--color-background);
	border: none;
	padding: 12px 24px;
	border-radius: 4px;
	cursor: pointer;
	font-family: inherit;
	font-size: 14px;
	font-weight: bold;
	transition: background-color 0.3s;
}

button:hover {
	opacity: 0.8;
}

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

button[type='submit'] {
	background: var(--color-primary);
	font-size: 16px;
	padding: 15px 30px;
	width: 100%;
}

.loading {
	text-align: center;
	font-style: italic;
	color: var(--color-primary);
}

.results {
	min-height: 100px;
	max-height: 400px;
	overflow-y: auto;
	border: 1px solid var(--color-border);
	padding: 15px;
	border-radius: 4px;
	background: var(--color-background);
}

.error {
	background: var(--color-tr-other);
	color: var(--color-error);
	padding: 15px;
	border-radius: 4px;
	border: 1px solid var(--color-error);
}

.phrase-result {
	background: var(--color-tr-other);
	padding: 10px;
	border-radius: 4px;
	margin-bottom: 10px;
	border: 1px solid var(--color-border);
}

.phrase-result h4 {
	margin: 0 0 5px 0;
	color: var(--color-primary);
}

.phrase-result p {
	margin: 0;
	font-size: 14px;
	opacity: 0.8;
}

.lilypond-output {
	background: var(--color-tr-primary);
	padding: 15px;
	border-radius: 4px;
	margin-top: 15px;
	border: 1px solid var(--color-border);
}

.lilypond-output h4 {
	margin: 0 0 10px 0;
	color: var(--color-primary);
}

.test-buttons {
	display: flex;
	gap: 10px;
	margin-bottom: 20px;
}

.test-buttons button {
	flex: 1;
	background: var(--color-text);
	color: var(--color-background);
}

.test-output {
	background: var(--color-background);
	border: 1px solid var(--color-border);
	padding: 15px;
	border-radius: 4px;
	min-height: 100px;
	max-height: 300px;
	overflow-y: auto;
	font-family: 'Courier New', monospace;
	white-space: pre-wrap;
}

.test-output pre {
	margin: 0;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.test-output .error {
	background: none;
	border: none;
	padding: 0;
	color: var(--color-error);
	font-weight: bold;
}

.lilypond-text {
	background: var(--color-tr-primary);
	padding: 15px;
	border-radius: 4px;
	margin-top: 15px;
	border: 1px solid var(--color-border);
}

.lilypond-text h4 {
	margin: 0 0 10px 0;
	color: var(--color-primary);
}

.lilypond-text pre {
	background: var(--color-background);
	border: 1px solid var(--color-border);
	padding: 15px;
	border-radius: 4px;
	max-height: 300px;
	overflow-y: auto;
	font-family: 'Courier New', monospace;
	font-size: 12px;
	line-height: 1.4;
	white-space: pre-wrap;
	word-wrap: break-word;
	margin-bottom: 15px;
}

.download-button {
	background: var(--color-primary);
	color: var(--color-background);
	border: none;
	padding: 10px 20px;
	border-radius: 4px;
	cursor: pointer;
	font-family: inherit;
	font-size: 14px;
	font-weight: bold;
	transition: background-color 0.3s;
}

.download-button:hover {
	opacity: 0.8;
}

.download-button:active {
	transform: translateY(1px);
}

.button-group {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.button-group button {
	flex: 1;
	min-width: 100px;
}

@media (max-width: 480px) {
	.button-group {
		flex-direction: column;
	}

	.button-group button {
		width: 100%;
	}
}

.lilypond-viewer-section {
	background: var(--color-tr-primary);
	padding: 20px;
	border-radius: 8px;
	border: 1px solid var(--color-border);
	margin-bottom: 40px;
	grid-column: 1 / -1;
}

.viewer-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 15px;
}

.viewer-header h2 {
	margin: 0;
	color: var(--color-primary);
}

.hacklily-link {
	color: inherit;
	text-decoration: none;
	transition: all 0.3s ease;
	border-radius: 4px;
	padding: 2px 4px;
}

.hacklily-link:hover {
	color: var(--color-primary);
	text-decoration: none;
	cursor: pointer;
	background-color: var(--color-tr-other);
}

.close-button {
	background: var(--color-text);
	color: var(--color-background);
	border: none;
	padding: 5px 10px;
	border-radius: 4px;
	cursor: pointer;
	font-size: 16px;
	font-weight: bold;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.close-button:hover {
	opacity: 0.8;
}

.iframe-container {
	border: 2px solid var(--color-border);
	border-radius: 4px;
	overflow: hidden;
	background: var(--color-background);
}

.iframe-container iframe {
	display: block;
	width: 100%;
	min-height: 600px;
}

@media (max-width: 768px) {
	.iframe-container iframe {
		min-height: 400px;
	}
}
