* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	min-height: 100vh;
	background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
	color: #fff;
	padding: 1rem;
}

@media (min-width: 480px) {
	body {
		padding: 1.5rem;
	}
}

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

header {
	text-align: center;
	margin-bottom: 1.5rem;
}

header h1 {
	font-size: 2rem;
	font-weight: bold;
	background: linear-gradient(90deg, #818cf8, #c084fc);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	margin-bottom: 0.5rem;
}

@media (min-width: 480px) {
	header h1 {
		font-size: 2.5rem;
	}
}

header p {
	color: rgba(255, 255, 255, 0.6);
}

/* タブUI */
.tabs {
	display: flex;
	gap: 0.25rem;
	margin-bottom: 1rem;
	background: rgba(255, 255, 255, 0.05);
	padding: 0.25rem;
	border-radius: 0.75rem;
}

.tab-btn {
	flex: 1;
	padding: 0.625rem 1rem;
	background: transparent;
	border: none;
	border-radius: 0.5rem;
	color: rgba(255, 255, 255, 0.6);
	font-size: 0.875rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
}

.tab-btn:hover {
	color: rgba(255, 255, 255, 0.8);
}

.tab-btn.active {
	background: rgba(99, 102, 241, 0.5);
	color: #fff;
}

.tab-content {
	display: none;
}

.tab-content.active {
	display: block;
}

@media (min-width: 480px) {
	.tab-btn {
		font-size: 1rem;
		padding: 0.75rem 1.25rem;
	}
}

.panel {
	background: rgba(255, 255, 255, 0.05);
	backdrop-filter: blur(20px);
	border-radius: 1rem;
	padding: 1rem;
	margin-bottom: 1rem;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (min-width: 480px) {
	.panel {
		padding: 1.5rem;
		margin-bottom: 1.5rem;
	}
}

.input-row {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 1.25rem;
}

.input-row input {
	flex: 1;
	min-width: 0;
	padding: 0.625rem 0.75rem;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 0.75rem;
	color: #fff;
	font-size: 0.9rem;
	outline: none;
	transition: border-color 0.2s;
}

@media (min-width: 480px) {
	.input-row {
		gap: 0.75rem;
		margin-bottom: 1.5rem;
	}

	.input-row input {
		padding: 0.75rem 1rem;
		font-size: 1rem;
	}
}

.input-row input::placeholder {
	color: rgba(255, 255, 255, 0.4);
}

.input-row input:focus {
	border-color: #818cf8;
}

.btn-clear {
	padding: 0.625rem 1rem;
	background: rgba(239, 68, 68, 0.2);
	border: 1px solid rgba(239, 68, 68, 0.3);
	border-radius: 0.75rem;
	color: #fca5a5;
	cursor: pointer;
	transition: background 0.2s;
	font-size: 0.875rem;
	white-space: nowrap;
}

.btn-clear:hover {
	background: rgba(239, 68, 68, 0.3);
}

@media (min-width: 480px) {
	.btn-clear {
		padding: 0.75rem 1.25rem;
		font-size: 1rem;
	}
}

/* ピアノ鍵盤 */
.piano {
	position: relative;
	height: 120px;
	max-width: 420px;
	margin: 0 auto 1rem;
	display: flex;
}

@media (min-width: 480px) {
	.piano {
		height: 140px;
		margin: 0 auto 1.5rem;
	}
}

.white-key {
	flex: 1;
	height: 100%;
	background: #fff;
	border: 1px solid #ccc;
	border-radius: 0 0 6px 6px;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	align-items: center;
	padding-bottom: 6px;
	transition: background 0.1s;
	position: relative;
}

@media (min-width: 480px) {
	.white-key {
		padding-bottom: 8px;
	}
}

.white-key:hover {
	background: #f0f0f0;
}

.white-key.selected {
	background: #818cf8;
}

.white-key.bass {
	background: #f97316;
}

.white-key span {
	font-size: 0.625rem;
	color: #666;
	font-weight: 500;
}

@media (min-width: 480px) {
	.white-key span {
		font-size: 0.75rem;
	}
}

.white-key.selected span,
.white-key.bass span {
	color: #fff;
}

.black-key {
	position: absolute;
	width: 10%;
	height: 55%;
	background: #1f2937;
	border-radius: 0 0 4px 4px;
	cursor: pointer;
	z-index: 10;
	transition: background 0.1s;
}

@media (min-width: 480px) {
	.black-key {
		width: 9%;
	}
}

.black-key:hover {
	background: #374151;
}

.black-key.selected {
	background: #4f46e5;
}

.black-key.bass {
	background: #ea580c;
}

/* 選択音表示 */
.selected-notes {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.375rem;
	margin-bottom: 0.75rem;
}

.selected-notes .label {
	color: rgba(255, 255, 255, 0.5);
	font-size: 0.75rem;
}

.note-badge {
	padding: 0.25rem 0.625rem;
	border-radius: 9999px;
	font-size: 0.75rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
	background: rgba(99, 102, 241, 0.4);
	color: rgba(255, 255, 255, 0.9);
	border: none;
}

@media (min-width: 480px) {
	.selected-notes {
		gap: 0.5rem;
		margin-bottom: 1rem;
	}

	.selected-notes .label {
		font-size: 0.875rem;
	}

	.note-badge {
		padding: 0.375rem 0.75rem;
		font-size: 0.875rem;
	}
}

.note-badge:hover {
	background: rgba(99, 102, 241, 0.6);
}

.note-badge.bass {
	background: #f97316;
	color: #fff;
}

.help-text {
	text-align: center;
	color: rgba(255, 255, 255, 0.4);
	font-size: 0.625rem;
	line-height: 1.5;
}

@media (min-width: 480px) {
	.help-text {
		font-size: 0.75rem;
	}
}

/* 結果表示 */
.results-title {
	font-size: 1rem;
	font-weight: 600;
	color: rgba(255, 255, 255, 0.9);
	margin-bottom: 0.75rem;
}

@media (min-width: 480px) {
	.results-title {
		font-size: 1.125rem;
		margin-bottom: 1rem;
	}
}

.result-item {
	padding: 0.75rem 0.75rem;
	border-radius: 0.75rem;
	margin-bottom: 0.5rem;
	background: rgba(255, 255, 255, 0.1);
	display: grid;
	grid-template-columns: minmax(0, 1fr) 160px;
	align-items: center;
	gap: 0.25rem;
	transition: background 0.2s;
}

.result-item:hover {
	background: rgba(255, 255, 255, 0.15);
}

.result-item.top {
	background: linear-gradient(90deg, #4f46e5, #7c3aed);
	box-shadow: 0 10px 30px rgba(79, 70, 229, 0.3);
}

.result-left {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
	min-width: 0;
	overflow: hidden;
}

.chord-name {
	font-size: 1.25rem;
	font-weight: bold;
	color: rgba(255, 255, 255, 0.9);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.result-item.top .chord-name {
	color: #fff;
}

.chord-type {
	font-size: 0.65rem;
	color: rgba(255, 255, 255, 0.5);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.result-item.top .chord-type {
	color: rgba(255, 255, 255, 0.7);
}

.result-right {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.5rem;
	width: 160px;
}

.score-bar {
	width: 60px;
	height: 6px;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 9999px;
	overflow: hidden;
	flex-shrink: 0;
}

.score-fill {
	height: 100%;
	border-radius: 9999px;
	background: #818cf8;
	transition: width 0.5s;
}

.result-item.top .score-fill {
	background: #fff;
}

.score-value {
	font-size: 0.875rem;
	font-family: monospace;
	width: 2rem;
	text-align: right;
	color: rgba(255, 255, 255, 0.7);
	flex-shrink: 0;
}

.result-item.top .score-value {
	color: #fff;
}

@media (min-width: 480px) {
	.result-item {
		grid-template-columns: minmax(0, 1fr) 200px;
		padding: 0.875rem 1rem;
	}

	.result-left {
		flex-direction: row;
		align-items: center;
		gap: 0.75rem;
	}

	.score-bar {
		width: 80px;
		height: 8px;
	}

	.result-right {
		width: 200px;
	}

	.chord-name {
		font-size: 1.5rem;
	}

	.chord-type {
		font-size: 0.75rem;
	}
}

/* 折りたたみ詳細 */
.result-item {
	cursor: pointer;
	user-select: none;
}

.expand-icon {
	display: inline-block;
	font-size: 0.5rem;
	color: rgba(255, 255, 255, 0.4);
	transition: transform 0.2s;
	margin-left: 0.375rem;
	vertical-align: middle;
}

.result-item.expanded .expand-icon {
	transform: rotate(180deg);
}

.result-item.top .expand-icon {
	color: rgba(255, 255, 255, 0.6);
}

.chord-details {
	grid-column: 1 / -1;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
	margin-top: 0;
}

.result-item.expanded .chord-details {
	max-height: 150px;
	margin-top: 0.75rem;
}

.chord-details-inner {
	padding-top: 0.75rem;
	border-top: 1px solid rgba(255, 255, 255, 0.15);
}

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

.detail-label {
	font-size: 0.7rem;
	color: rgba(255, 255, 255, 0.5);
	white-space: nowrap;
}

.detail-notes {
	display: flex;
	gap: 0.25rem;
	flex-wrap: wrap;
}

.detail-note {
	padding: 0.2rem 0.5rem;
	background: rgba(255, 255, 255, 0.15);
	border-radius: 4px;
	font-size: 0.75rem;
	font-weight: 500;
	color: rgba(255, 255, 255, 0.9);
}

.detail-note.root {
	background: rgba(99, 102, 241, 0.5);
}

.detail-note.bass {
	background: rgba(249, 115, 22, 0.5);
}

.detail-note.not-in-input {
	background: rgba(255, 255, 255, 0.08);
	color: rgba(255, 255, 255, 0.4);
	border: 1px dashed rgba(255, 255, 255, 0.3);
}

.result-item.top .detail-note {
	background: rgba(255, 255, 255, 0.25);
}

.result-item.top .detail-note.root {
	background: rgba(255, 255, 255, 0.4);
}

.result-item.top .detail-note.bass {
	background: rgba(249, 115, 22, 0.6);
}

.result-item.top .detail-note.not-in-input {
	background: rgba(255, 255, 255, 0.1);
	color: rgba(255, 255, 255, 0.5);
	border: 1px dashed rgba(255, 255, 255, 0.4);
}

.result-item.top .chord-details-inner {
	border-top-color: rgba(255, 255, 255, 0.25);
}

@media (min-width: 480px) {
	.detail-label {
		font-size: 0.75rem;
	}

	.detail-note {
		font-size: 0.8rem;
		padding: 0.25rem 0.625rem;
	}
}

.empty-state {
	text-align: center;
	padding: 2rem 1rem;
}

.empty-state .icon {
	font-size: 2.5rem;
	margin-bottom: 0.75rem;
}

.empty-state p {
	color: rgba(255, 255, 255, 0.5);
	font-size: 0.875rem;
}

@media (min-width: 480px) {
	.empty-state {
		padding: 3rem 1rem;
	}

	.empty-state .icon {
		font-size: 3rem;
		margin-bottom: 1rem;
	}
}

footer {
	text-align: center;
	color: rgba(255, 255, 255, 0.3);
	font-size: 0.625rem;
	line-height: 1.8;
	padding: 0 0.5rem;
}

@media (min-width: 480px) {
	footer {
		font-size: 0.75rem;
	}
}

/* 逆引きタブ用スタイル */
.selector-section {
	margin-bottom: 1rem;
}

.selector-label {
	font-size: 0.75rem;
	color: rgba(255, 255, 255, 0.5);
	margin-bottom: 0.5rem;
	display: block;
}

.note-selector {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
}

.note-btn {
	padding: 0.5rem 0.625rem;
	min-width: 2.25rem;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 0.5rem;
	color: rgba(255, 255, 255, 0.8);
	font-size: 0.8rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.15s;
	text-align: center;
}

.note-btn:hover {
	background: rgba(255, 255, 255, 0.2);
}

.note-btn.active {
	background: rgba(99, 102, 241, 0.6);
	border-color: rgba(99, 102, 241, 0.8);
	color: #fff;
}

.chord-type-selector {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

/* カテゴリセクション */
.chord-category {
	background: rgba(255, 255, 255, 0.05);
	border-radius: 0.5rem;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

.chord-category-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.625rem 0.875rem;
	cursor: pointer;
	transition: background 0.2s;
	user-select: none;
}

.chord-category-label {
	font-size: 0.6rem;
	font-weight: 600;
	color: rgba(255, 255, 255, 0.4);
}

.chord-category-count {
	font-size: 0.7rem;
	color: rgba(255, 255, 255, 0.4);
	background: rgba(255, 255, 255, 0.1);
	padding: 0.125rem 0.5rem;
	border-radius: 9999px;
	margin-left: auto;
}


.chord-category-content {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	padding: 0 0.875rem 0.75rem;
}

.chord-type-btn {
	padding: 0.375rem 0.625rem;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 0.375rem;
	color: rgba(255, 255, 255, 0.7);
	font-size: 0.75rem;
	cursor: pointer;
	transition: all 0.15s;
}

.chord-type-btn:hover {
	background: rgba(255, 255, 255, 0.15);
}

.chord-type-btn.active {
	background: rgba(168, 85, 247, 0.5);
	border-color: rgba(168, 85, 247, 0.7);
	color: #fff;
}

.reverse-input-row {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 1rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.reverse-input-row input {
	flex: 1;
	min-width: 0;
	padding: 0.5rem 0.75rem;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 0.5rem;
	color: #fff;
	font-size: 0.875rem;
	outline: none;
}

.reverse-input-row input::placeholder {
	color: rgba(255, 255, 255, 0.4);
}

/* 可変オクターブピアノ（1〜3オクターブ対応） */
.piano-multi-oct {
	position: relative;
	height: 100px;
	margin: 1rem auto 0;
	display: flex;
	max-width: 100%;
	overflow-x: auto;
}

.piano-multi-oct .white-key {
	flex: 1;
	min-width: 24px;
	height: 100%;
	background: #fff;
	border: 1px solid #ccc;
	border-radius: 0 0 4px 4px;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	align-items: center;
	padding-bottom: 4px;
	transition: background 0.1s;
}

.piano-multi-oct .white-key span {
	font-size: 0.5rem;
	color: #666;
	font-weight: 500;
}

.piano-multi-oct .white-key.highlighted span,
.piano-multi-oct .white-key.root-note span,
.piano-multi-oct .white-key.bass-note span {
	color: #fff;
}

.piano-multi-oct .white-key.highlighted {
	background: #818cf8;
}

.piano-multi-oct .white-key.highlighted span {
	color: #fff;
}

.piano-multi-oct .white-key.root-note {
	background: #6366f1;
}

.piano-multi-oct .white-key.bass-note {
	background: #f97316;
}

.piano-multi-oct .black-key {
	position: absolute;
	width: 5%;
	min-width: 16px;
	height: 55%;
	background: #1f2937;
	border-radius: 0 0 3px 3px;
	z-index: 10;
	transition: background 0.1s;
}

.piano-multi-oct .black-key.highlighted {
	background: #6366f1;
}

.piano-multi-oct .black-key.root-note {
	background: #4f46e5;
}

.piano-multi-oct .black-key.bass-note {
	background: #ea580c;
}

/* 逆引き結果 */
.reverse-result {
	margin-top: 1.25rem;
	padding: 1rem;
	background: rgba(99, 102, 241, 0.15);
	border-radius: 0.75rem;
	border: 1px solid rgba(99, 102, 241, 0.3);
}

.reverse-result-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
}

.reverse-chord-name {
	font-size: 1.5rem;
	font-weight: bold;
	color: #fff;
}

.reverse-chord-type {
	font-size: 0.8rem;
	color: rgba(255, 255, 255, 0.6);
}

.reverse-notes {
	display: flex;
	flex-wrap: wrap;
	gap: 0.375rem;
}

.reverse-note {
	padding: 0.375rem 0.625rem;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 0.375rem;
	font-size: 0.875rem;
	font-weight: 500;
	color: #fff;
}

.reverse-note.root {
	background: rgba(99, 102, 241, 0.6);
}

.reverse-empty {
	text-align: center;
	padding: 2rem 1rem;
	color: rgba(255, 255, 255, 0.5);
}

/* 再生ボタン */
.play-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.375rem;
	padding: 0.5rem 1rem;
	background: rgba(34, 197, 94, 0.2);
	border: 1px solid rgba(34, 197, 94, 0.4);
	border-radius: 0.5rem;
	color: #4ade80;
	font-size: 0.8rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
}

.play-btn:hover {
	background: rgba(34, 197, 94, 0.3);
}

.play-btn:active {
	transform: scale(0.95);
}

.play-btn.playing {
	background: rgba(34, 197, 94, 0.4);
}

.play-btn-icon {
	font-size: 1rem;
}

.result-item .play-btn {
	padding: 0.3rem 0.6rem;
	font-size: 0.7rem;
	white-space: nowrap;
}

.reverse-result-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
	flex-wrap: wrap;
}

.reverse-result-header .play-btn {
	padding: 0.5rem 1rem;
	font-size: 0.85rem;
}

@media (min-width: 480px) {
	.note-btn {
		padding: 0.5rem 0.75rem;
		min-width: 2.5rem;
		font-size: 0.875rem;
	}

	.chord-category-label {
		font-size: 0.6rem;
	}

	.chord-category-count {
		font-size: 0.75rem;
	}

	.chord-type-btn {
		padding: 0.4rem 0.75rem;
		font-size: 0.8rem;
	}

	.piano-multi-oct {
		height: 120px;
	}

	.piano-multi-oct .white-key {
		min-width: 30px;
	}

	.piano-multi-oct .white-key span {
		font-size: 0.6rem;
	}

	.piano-multi-oct .black-key {
		min-width: 20px;
	}
}