* {
	box-sizing: border-box;
}

body {
	background: #181818;
	color: #eee;
	font-family: system-ui, sans-serif;
	margin: 0;
}

button,
input,
select {
	font: inherit;
}

button {
	background: #333;
	border: 1px solid #555;
	border-radius: .4rem;
	color: #eee;
	cursor: pointer;
	padding: .35rem .7rem;
}

button:hover {
	background: #444;
}

button:disabled {
	cursor: not-allowed;
	opacity: .55;
}

input,
select {
	background: #222;
	border: 1px solid #555;
	border-radius: .35rem;
	color: #eee;
	padding: .3rem .45rem;
}

.app {
	display: grid;
	grid-template-columns: 1fr 1fr;
	height: 100vh;
	overflow: hidden;
}

.panel {
	overflow: auto;
	padding: 1rem;
}

.panel-left {
	border-right: 1px solid #444;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.panel-right {
	overflow: hidden;
	padding: 0;
}

.sequencer-zone {
	height: 100%;
	overflow: auto;
	padding: 1rem;
}

.pattern-header {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: .75rem;
}

.pattern-name {
	font-weight: 700;
	min-width: 8rem;
}

.pattern-play-button {
	min-width: 3.6rem;
}

.pattern-play-button.is-playing {
	background: #ffd166;
	border-color: #fff0b3;
	color: #181818;
}

.advanced-pattern-tempo {
	width: 4.2rem;
}

.project-transfer-controls {
	display: inline-flex;
	gap: .5rem;
	margin-left: auto;
}

.project-transfer-button {
	white-space: nowrap;
}

.place-pattern-button {
	align-items: center;
	background: #333;
	border: 1px dashed #777;
	border-radius: .4rem;
	color: #eee;
	cursor: grab;
	display: inline-flex;
	height: 2rem;
	justify-content: center;
	padding: .25rem;
	touch-action: none;
	user-select: none;
	width: 2rem;
}

.place-pattern-button:hover {
	background: #444;
}

.place-pattern-button:focus-visible {
	outline: 2px solid #80d0ff;
	outline-offset: 2px;
}

.place-pattern-button:active {
	cursor: grabbing;
}

.place-pattern-button svg {
	height: 1.2rem;
	pointer-events: none;
	width: 1.2rem;
}

.line-break-drag-button {
	font-weight: 800;
}

.simple-pattern-drag-button {
	margin-left: auto;
}

.trash-drop-zone {
	align-items: center;
	background: #2b2020;
	border: 1px solid #704040;
	border-radius: .5rem;
	bottom: 1rem;
	box-shadow: 0 .5rem 1.5rem rgb(0 0 0 / .35);
	color: #ffd4d4;
	display: flex;
	gap: .5rem;
	opacity: 0;
	padding: .7rem .9rem;
	pointer-events: none;
	position: fixed;
	right: 1rem;
	transform: translateY(.5rem);
	transition: opacity 100ms ease-out, transform 100ms ease-out,
		background-color 100ms ease-out, border-color 100ms ease-out;
	z-index: 20;
}

body.is-pattern-dragging .trash-drop-zone {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

.trash-drop-zone.is-drag-over {
	background: #5a2020;
	border-color: #d06060;
}

.trash-drop-zone svg {
	height: 1.35rem;
	width: 1.35rem;
}

.pattern-control {
	align-items: center;
	display: inline-flex;
	gap: .35rem;
}

.pattern-control input[type="number"] {
	width: 4rem;
}

.grid-wrapper {
	flex: 1;
	min-height: 0;
	overflow: auto;
}

table.rhythm-grid {
	border-collapse: separate;
	border-spacing: 0;
	font-size: .85rem;
	min-width: 100%;
	table-layout: fixed;
}

.rhythm-grid th,
.rhythm-grid td {
	border-bottom: 1px solid #333;
	border-right: 1px solid #333;
	height: 1.8rem;
	min-width: 2.8rem;
	padding: .15rem .35rem;
	text-align: center;
}

.rhythm-grid th {
	background: #282828;
	position: sticky;
	top: 0;
	z-index: 1;
}

.rhythm-grid th:first-child,
.rhythm-grid td:first-child {
	background: #242424;
	left: 0;
	max-width: 4.5rem;
	min-width: 4.5rem;
	position: sticky;
	width: 4.5rem;
	z-index: 2;
}

.rhythm-grid th:first-child {
	z-index: 3;
}

.rhythm-grid .pattern-settings-row td {
	background: #202020;
	border-bottom: 2px solid #555;
	border-top: 2px solid #777;
	max-width: none;
	min-width: 0;
	padding: .75rem;
	position: static;
	text-align: left;
	width: auto;
}

.pattern-body.is-pattern-reorder-target-before .pattern-settings-row td {
	box-shadow: inset 0 3px 0 #80d0ff;
}

.pattern-body.is-pattern-reorder-target-after tr:last-child td {
	box-shadow: inset 0 -3px 0 #80d0ff;
}

.column-header {
	cursor: grab;
	line-height: 1.1;
	max-width: 2.8rem;
	overflow-wrap: anywhere;
	user-select: none;
	white-space: normal;
	width: 2.8rem;
}

.column-header:active {
	cursor: grabbing;
}

.add-column-header {
	color: #80d0ff;
	cursor: pointer;
	font-weight: 800;
	max-width: 3rem;
	min-width: 3rem !important;
	width: 3rem;
}

.cell {
	cursor: pointer;
	user-select: none;
}

.cell.is-active {
	background: #f25800;
	box-shadow: inset 0 0 0 2px #ffb080;
}

.cell.is-playing {
	background: #ffd166;
	box-shadow: inset 0 0 0 2px #fff0b3;
	transition: none;
}

.cell.is-playback-fading {
	background: transparent;
	box-shadow: none;
	transition: background-color 110ms ease-out, box-shadow 110ms ease-out;
}

.cell.is-active.is-playback-fading {
	background: #f25800;
	box-shadow: inset 0 0 0 2px #ffb080;
}

.measure-start td,
.measure-start th {
	border-top: 3px solid #777;
}

.time-start td,
.time-start th {
	border-top: 2px solid #555;
}

.empty-sequencer {
	align-items: center;
	border: 1px dashed #555;
	border-radius: .7rem;
	color: #aaa;
	display: flex;
	height: calc(100vh - 5rem);
	justify-content: center;
	text-align: center;
}

.advanced-pattern-list {
	display: grid;
	gap: .75rem;
	margin-bottom: .75rem;
}

.advanced-pattern {
	background: #202020;
	border: 1px solid #444;
	border-radius: .7rem;
	padding: .75rem;
}

.advanced-pattern.is-song-plan {
	background: #252525;
	border-color: #80d0ff;
	box-shadow: inset 0 0 0 1px rgb(128 208 255 / .35);
}

.advanced-pattern-header {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: .75rem;
	margin-bottom: .65rem;
}

.advanced-pattern-measure-count {
	color: #bbb;
	white-space: nowrap;
}

.song-plan-icon {
	align-items: center;
	color: #bfe8ff;
	display: inline-flex;
	height: 2rem;
	justify-content: center;
	width: 2rem;
}

.song-plan-icon svg {
	height: 1.2rem;
	width: 1.2rem;
}

.advanced-pattern-drop-zone {
	background: #1b1b1b;
	border: 1px dashed #555;
	border-radius: .5rem;
	display: flow-root;
	min-height: 5rem;
	padding: .6rem;
	transition: background-color 100ms ease-out, border-color 100ms ease-out;
}

.advanced-pattern-drop-zone.is-drag-over {
	background: #252f34;
	border-color: #80d0ff;
}

.advanced-pattern-placeholder {
	color: #888;
	display: block;
	text-align: center;
}

.advanced-pattern-reference {
	background: #333;
	border: 1px solid #666;
	box-sizing: border-box;
	border-radius: .4rem;
	cursor: grab;
	display: inline-flex;
	float: left;
	font-weight: 700;
	margin: 0 .45rem .45rem 0;
	padding: .4rem .7rem;
	position: relative;
	user-select: none;
}

.advanced-pattern-reference:active {
	cursor: grabbing;
}

.advanced-pattern-reference.is-advanced {
	background: #293a45;
	border-color: #52758a;
}

.advanced-pattern-reference.is-substitution-drop-start,
.advanced-pattern-reference.is-substitution-drop-end {
	border-color: #5e8da7;
}

.advanced-pattern-reference.is-substitution-drop-add {
	border-color: #9fd36a;
}

.advanced-pattern-reference.is-substitution-drop-start {
	box-shadow: inset 3px 0 0 #5e8da7;
}

.advanced-pattern-reference.is-substitution-drop-end {
	box-shadow: inset -3px 0 0 #5e8da7;
}

.advanced-pattern-reference.is-substitution-drop-start.is-substitution-drop-add {
	box-shadow: inset 3px 0 0 #9fd36a, inset 7px 0 0 rgb(159 211 106 / .32);
}

.advanced-pattern-reference.is-substitution-drop-end.is-substitution-drop-add {
	box-shadow: inset -3px 0 0 #9fd36a, inset -7px 0 0 rgb(159 211 106 / .32);
}

.advanced-pattern-reference.is-substitution-drop-forbidden {
	border-color: #ff6b6b;
	box-shadow: inset 0 0 0 2px #ff6b6b;
	cursor: not-allowed;
}

.pattern-substitution-chain {
	display: inline-flex;
}

.pattern-substitution-chain.is-end {
	margin-left: auto;
}

.advanced-pattern-reference-label + .pattern-substitution-chain.is-end:not(:empty) {
	padding-left: .45rem;
}

.pattern-substitution-chip {
	background: #333;
	border: 1px dashed currentColor;
	border-radius: 0;
	cursor: grab;
	font-weight: 700;
	margin-bottom: -.45rem;
	margin-top: -.45rem;
	padding: .4rem .7rem;
	user-select: none;
}

.pattern-substitution-chip.is-add {
	border-style: double;
	border-color: #9fd36a;
	box-shadow: inset 0 -3px 0 rgb(159 211 106 / .45);
}

.pattern-substitution-chip.is-replace {
	border-color: #80d0ff;
}

.pattern-substitution-chain.is-start .pattern-substitution-chip:first-child {
	border-bottom-left-radius: .4rem;
	border-top-left-radius: .4rem;
	margin-left: -.75rem;
}

.pattern-substitution-chain.is-start .pattern-substitution-chip:not(:last-child) {
	margin-right: -1px;
}

.pattern-substitution-chain.is-start .pattern-substitution-chip {
	border-bottom-right-radius: 0;
	border-top-right-radius: 0;
}

.pattern-substitution-chain.is-start:not(:empty) + .advanced-pattern-reference-label {
	margin-left: .45rem;
}

.pattern-substitution-chain.is-end .pattern-substitution-chip:last-child {
	border-bottom-right-radius: .4rem;
	border-top-right-radius: .4rem;
	margin-right: -.75rem;
}

.pattern-substitution-chain.is-end .pattern-substitution-chip:not(:first-child) {
	margin-left: -1px;
}

.pattern-substitution-chain.is-end .pattern-substitution-chip {
	border-bottom-left-radius: 0;
	border-top-left-radius: 0;
}

.pattern-substitution-chip.is-advanced {
	background: #293a45;
}

.pattern-substitution-chip:active {
	cursor: grabbing;
}

.advanced-pattern-reference.is-playing .pattern-substitution-chip:not(.is-playing) {
	color: #eee;
}

.pattern-substitution-chip.is-playing {
	background: #ffd166;
	border-color: #fff0b3;
	box-shadow: inset 0 0 0 1px #fff0b3;
	color: #181818;
	transition: none;
}

.pattern-substitution-chip.is-playback-fading {
	background: #333;
	border-color: currentColor;
	box-shadow: none;
	color: #eee;
	transition: background-color 110ms ease-out, border-color 110ms ease-out,
		box-shadow 110ms ease-out, color 110ms ease-out;
}

.pattern-substitution-chip.is-advanced.is-playback-fading {
	background: #293a45;
}

.pattern-drag-preview {
	margin: 0;
	opacity: .95;
	pointer-events: none;
	position: fixed;
	z-index: 40;
}

.pattern-drag-preview.is-normal {
	background: #333;
	border: 1px solid #666;
	border-radius: .4rem;
	color: #eee;
	font-weight: 700;
	padding: .4rem .7rem;
}

.pattern-drag-preview.is-normal.is-advanced {
	background: #293a45;
	border-color: #52758a;
}

.pattern-drag-preview.is-start,
.pattern-drag-preview.is-end {
	background: #333;
	border: 1px dashed currentColor;
	border-radius: 0;
	color: #eee;
	font-weight: 700;
	padding: .4rem .7rem;
}

.pattern-drag-preview.is-add {
	border-color: #9fd36a;
	border-style: double;
	box-shadow: inset 0 -3px 0 rgb(159 211 106 / .45);
}

.pattern-drag-preview.is-start {
	border-bottom-left-radius: .4rem;
	border-top-left-radius: .4rem;
}

.pattern-drag-preview.is-end {
	border-bottom-right-radius: .4rem;
	border-top-right-radius: .4rem;
}

.pattern-drag-preview.is-start.is-advanced,
.pattern-drag-preview.is-end.is-advanced {
	background: #293a45;
}

.is-song-plan-drop-zone .advanced-pattern-reference.is-advanced {
	clear: both;
	margin-right: 0;
	width: 100%;
}

.reference-drop-indicator {
	background: #80d0ff;
	border-radius: 999px;
	box-shadow: 0 0 0 2px rgb(128 208 255 / .25);
	pointer-events: none;
	position: fixed;
	z-index: 30;
}

.advanced-pattern-reference.is-line-break {
	align-items: center;
	background: #3a3325;
	border-color: #8a7648;
	color: #ffd166;
	display: inline-flex;
	justify-content: center;
	min-width: 2.6rem;
}

.advanced-pattern-reference.is-after-line-break {
	clear: both;
}

.advanced-pattern-reference.is-playing {
	background: #ffd166;
	border-color: #fff0b3;
	box-shadow: inset 0 0 0 1px #fff0b3;
	color: #181818;
	transition: none;
}

.advanced-pattern-reference.is-playback-fading {
	background: #333;
	border-color: #666;
	box-shadow: none;
	color: #eee;
	transition: background-color 110ms ease-out, border-color 110ms ease-out,
		box-shadow 110ms ease-out, color 110ms ease-out;
}

.advanced-pattern-reference.is-advanced.is-playback-fading {
	background: #293a45;
	border-color: #52758a;
}

dialog {
	background: #222;
	border: 1px solid #666;
	border-radius: .7rem;
	color: #eee;
	min-width: 18rem;
	padding: 1rem;
}

dialog::backdrop {
	background: rgb(0 0 0 / .55);
}

.dialog-actions {
	display: flex;
	gap: .5rem;
	justify-content: flex-end;
	margin-top: 1rem;
}

.danger {
	background: #5a2020;
	border-color: #8a3030;
}

.field {
	display: block;
	margin-top: .8rem;
}

.small-note {
	color: #aaa;
	font-size: .8rem;
	margin-top: .35rem;
}
