/* DX7 — plain CSS (no build step). Look follows B Synth: dark panels,
   knob/accents via --accent, sticky header, fixed keyboard at the bottom. */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&family=Share+Tech+Mono&display=swap');

:root {
	--bg: #1a1a1a;
	--panel: #222;
	--line: #333;
	--text: #fff;
	--muted: #999;
	--teal: #3fc1b0;   /* DX7 membrane green */
	--rose: #d0457a;   /* DX7 membrane burgundy */
	--lcd-bg: #1b2414;
	--lcd-fg: #b9e05a;
	--accent: var(--teal);
	--kbd-h: 150px;
}

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

html { font-size: 16px; }
@media (max-width: 500px) { html { font-size: calc(16 / 500 * 100vw); } }

body {
	font-family: 'Noto Sans JP', sans-serif;
	color: var(--text);
	background: var(--bg);
	min-height: 100vh;
	padding-bottom: calc(var(--kbd-h) + 1em);
}

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

/* ---------------------------------------------------------------- header */
.app-header { position: sticky; top: 0; z-index: 10; }
@media (max-width: 700px) { .app-header { position: static; } }

.tab-nav {
	display: flex;
	align-items: stretch;
	background: #111;
}
.tab-nav .brand {
	padding: .45em 1em;
	font-weight: 700;
	letter-spacing: .15em;
	color: var(--teal);
	border-bottom: 2px solid #444;
}
.tab-nav button {
	flex: 0 1 10em;
	padding: .6em 1.5em;
	background: #222;
	border: none;
	border-bottom: 2px solid #444;
	color: #888;
	font-size: .875em;
	font-weight: 600;
	cursor: pointer;
}
.tab-nav button.active { background: #333; color: var(--teal); border-bottom-color: var(--teal); }
.tab-nav button:hover:not(.active) { color: #ccc; background: #2a2a2a; }
.nav-status {
	margin-left: auto;
	display: flex;
	align-items: center;
	padding: 0 1em;
	font-size: .75em;
	color: var(--muted);
	border-bottom: 2px solid #444;
}
.nav-status .hint { color: var(--teal); }

.topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .75em 1.5em;
	padding: .6em 1em;
	background: #181818;
	border-bottom: 1px solid var(--line);
}

.lcd {
	font-family: 'Share Tech Mono', monospace;
	font-size: 1.15em;
	line-height: 1.25;
	padding: .35em .7em;
	min-width: 13em;
	background: var(--lcd-bg);
	color: var(--lcd-fg);
	border: 3px solid #0a0a0a;
	border-radius: 4px;
	box-shadow: inset 0 0 10px rgba(0, 0, 0, .7);
	text-shadow: 0 0 4px rgba(185, 224, 90, .45);
}

.lcd div { white-space: normal; }

.bank-ctl { display: flex; flex-direction: column; gap: .35em; }
.row { display: flex; align-items: center; gap: .4em; }

.ui-select {
	appearance: none;
	min-width: 12em;
	padding: .35em 2em .35em .7em;
	background: #2a2a2a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23aaa'/%3E%3C/svg%3E") no-repeat right .7em center;
	border: 1px solid #444;
	border-radius: 4px;
	cursor: pointer;
}

.btn {
	display: inline-block;
	padding: .3em .8em;
	background: #2c2c2c;
	border: 1px solid #444;
	border-radius: 4px;
	font-size: .85em;
	cursor: pointer;
	user-select: none;
}
.btn:hover { background: #383838; }
.btn.active { background: var(--rose); border-color: var(--rose); }

.waveforms { display: flex; gap: .5em; margin-left: auto; }
.waveforms canvas { display: block; width: 192px; height: 72px; border: 1px solid var(--line); border-radius: 4px; }
@media (max-width: 900px) { .waveforms { margin-left: 0; } }

.message {
	padding: .5em 1em;
	background: #3a2a10;
	color: #ffcf7a;
	font-size: .8em;
	cursor: pointer;
}

/* knobs (same mechanics as B Synth's knob.js) */
.knob { display: flex; flex-direction: column; align-items: center; gap: .25em; width: 4.25em; }
.knob-label { font-size: .75em; font-weight: 600; color: #aaa; }
.knob-dial {
	position: relative;
	width: 2.6em;
	aspect-ratio: 1;
	border-radius: 50%;
	cursor: ns-resize;
	touch-action: none;
	background: conic-gradient(from 225deg, var(--accent) 0deg calc(var(--v, 0) * 270deg), #444 calc(var(--v, 0) * 270deg) 270deg, transparent 270deg);
}
.knob-dial::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: #1a1a1a; }
.knob-dial::after {
	content: ''; position: absolute; left: calc(50% - 1px); top: 8px; width: 2px; height: calc(50% - 8px);
	background: #ddd; transform-origin: 50% 100%; transform: rotate(calc(-135deg + var(--v, 0) * 270deg));
}
.knob-dial input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.knob-value { font-size: .75em; }

/* ----------------------------------------------------------------- voices */
main { padding: 1em; }

.voices {
	display: grid;
	grid-auto-flow: column;
	grid-template-rows: repeat(8, auto);
	grid-template-columns: repeat(4, 1fr);
	gap: 3px;
	margin-bottom: 1em;
}
@media (max-width: 700px) {
	.voices { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(2, 1fr); }
}
.voice-btn {
	display: flex;
	align-items: center;
	gap: .6em;
	padding: .3em .6em;
	background: #242424;
	border: 1px solid #2e2e2e;
	border-radius: 3px;
	font-family: 'Share Tech Mono', monospace;
	font-size: .95em;
	text-align: left;
	white-space: normal;
	cursor: pointer;
}
.voice-btn .num { width: 1.6em; color: #777; text-align: right; }
.voice-btn:hover { background: #2e2e2e; }
.voice-btn.active { background: #17302c; border-color: var(--teal); color: var(--lcd-fg); }
.voice-btn.active .num { color: var(--teal); }

/* ----------------------------------------------------------------- panels */
.group {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15em, 1fr));
	gap: .75em;
	margin-bottom: .75em;
}
.group-global { grid-template-columns: minmax(16em, 1.6fr) repeat(auto-fit, minmax(14em, 1fr)); }
.panel {
	background: var(--panel);
	border: 1px solid var(--line);
	border-top: 2px solid var(--accent);
	border-radius: 6px;
	padding: .7em .9em;
}
.panel h3 { font-size: .8em; letter-spacing: .08em; color: var(--accent); margin-bottom: .5em; }
.panel h3 b { color: #fff; font-size: 1.3em; margin-right: .5em; }
.panel h3 small { color: #aaa; font-weight: 600; }
.panel h3 small b { font-size: 1.1em; }

.params { display: grid; grid-template-columns: auto 1fr; gap: .2em .8em; font-size: .85em; }
.params dt { color: var(--muted); font-size: .85em; align-self: center; }
.params dd { font-family: 'Share Tech Mono', monospace; text-align: right; }
.params dd small { color: var(--muted); }
.params.small { font-size: .78em; margin-top: .5em; }
.params.form dd { display: flex; align-items: center; justify-content: flex-end; gap: .5em; font-family: inherit; }
.params.form dd > span { width: 2em; text-align: right; font-family: 'Share Tech Mono', monospace; }
.params.form input[type="range"] { width: 8em; accent-color: var(--accent); }
.params.form .assign { flex-wrap: wrap; font-size: .85em; }
.params.form .assign label { display: flex; align-items: center; gap: .2em; }

.seg { display: inline-flex; border: 1px solid #444; border-radius: 4px; overflow: hidden; }
.seg button { padding: .2em .7em; background: #2a2a2a; border: none; font-size: .85em; cursor: pointer; }
.seg button.active { background: var(--accent); color: #111; font-weight: 700; }

/* algorithm chart */
.alg-wrap { display: flex; justify-content: center; }
/* chart on the left, ALGORITHM / FEEDBACK / TRANSPOSE / OSC SYNC on the right */
.alg-panel {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	column-gap: 1em;
}
.alg-panel h3 { grid-column: 1 / -1; }
.alg-panel .knobs { display: grid; grid-template-columns: repeat(2, auto); margin-top: 0; }
.alg-svg { display: block; width: 100%; max-width: 260px; height: auto; }
.alg-wire { fill: none; stroke: #888; stroke-width: 1.5; }
.alg-fb { fill: none; stroke: var(--rose); stroke-width: 1.5; }
.alg-op { cursor: pointer; }
.alg-op rect:first-child { fill: #2d2d2d; stroke: #888; stroke-width: 1.5; }
.alg-op.carrier rect:first-child { fill: #17302c; stroke: var(--teal); }
.alg-op text { fill: #fff; font-family: 'Share Tech Mono', monospace; font-size: 14px; pointer-events: none; }
.alg-op .alg-meter { fill: var(--lcd-fg); }
.alg-op.off { opacity: .3; }
.alg-op:hover rect:first-child { stroke: #fff; }

/* EG graphs */
.eg { margin: .3em 0; }
.eg-svg { display: block; width: 100%; height: 56px; background: #161616; border-radius: 3px; }
.eg-line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.eg-fill { fill: var(--accent); opacity: .12; }
.eg-key { stroke: #333; stroke-width: 1; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }
.eg-t { fill: #777; font-size: 9px; font-family: 'Share Tech Mono', monospace; }
.eg-table { width: 100%; border-collapse: collapse; font-family: 'Share Tech Mono', monospace; font-size: .85em; }
.eg-table th { width: 1.5em; color: var(--muted); text-align: left; font-weight: 400; }
.eg-table td { text-align: center; }

/* operator cards */
.ops {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15.5em, 1fr));
	gap: .75em;
}
.op-card {
	--accent: #9aa;
	background: var(--panel);
	border: 1px solid var(--line);
	border-top: 2px solid var(--accent);
	border-radius: 6px;
	padding: .6em .8em;
}
.op-card.carrier { --accent: var(--teal); }
.op-card.off { opacity: .4; }
.op-card header { display: flex; align-items: center; gap: .5em; margin-bottom: .4em; }
.op-toggle {
	padding: .1em .55em;
	background: #2c2c2c;
	border: 1px solid var(--accent);
	border-radius: 3px;
	font-weight: 700;
	cursor: pointer;
}
.op-card.off .op-toggle { border-color: #555; text-decoration: line-through; }
.op-role { font-size: .7em; color: var(--muted); letter-spacing: .08em; }
.op-meter { flex: 1; height: 4px; background: #333; border-radius: 2px; overflow: hidden; }
.op-meter i { display: block; height: 100%; background: var(--lcd-fg); transition: width .05s linear; }
.op-main { display: flex; justify-content: space-between; gap: .4em; }
.op-main .big { display: flex; flex-direction: column; }
.op-main .big small { font-size: .65em; color: var(--muted); letter-spacing: .06em; }
.op-main .big b { font-family: 'Share Tech Mono', monospace; font-size: 1.2em; font-weight: 400; }

.function-tab .note { font-size: .8em; color: var(--muted); margin-bottom: .75em; }
.group-fn { --accent: var(--rose); grid-template-columns: repeat(auto-fill, minmax(19em, 1fr)); }

/* ------------------------------------------------------------- keyboard */
.vui {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 5;
	display: flex;
	gap: .5em;
	height: var(--kbd-h);
	padding: .4em;
	background: #0c0c0c;
	border-top: 1px solid var(--line);
}
.perf { display: flex; gap: .4em; flex: 0 0 auto; }
.wheel {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .2em;
	font-size: .65em;
	color: var(--muted);
	width: 2.6rem;
}
.wheel input {
	writing-mode: vertical-lr;
	direction: rtl;
	width: 1.6rem;
	flex: 1;
	accent-color: var(--teal);
}
.perf-ctl { display: flex; flex-direction: column; justify-content: center; gap: .4em; font-size: .75em; }
.perf-ctl span { width: 2.4em; color: var(--muted); }
.perf-ctl b { min-width: 2.2em; text-align: center; font-family: 'Share Tech Mono', monospace; }
.perf-ctl input[type="range"] { width: 6em; accent-color: var(--teal); }
.perf-ctl label { display: flex; align-items: center; gap: .3em; }
@media (max-width: 700px) { .perf-ctl { display: none; } }

.piano {
	flex: 1;
	display: flex;
	position: relative;
	user-select: none;
	touch-action: none;
	min-width: 0;
}
.key { position: relative; cursor: pointer; }
.key.white {
	flex: 0 0 calc(100% / 36);
	background: linear-gradient(#e8e8e8, #fff 90%);
	border: 1px solid #111;
	border-radius: 0 0 4px 4px;
	z-index: 1;
}
.key.black {
	flex: 0 0 calc(100% / 36 * .6);
	margin: 0 calc(-100% / 36 * .3);
	height: 62%;
	background: linear-gradient(#222, #3a3a3a);
	border: 1px solid #000;
	border-radius: 0 0 3px 3px;
	z-index: 2;
}
.key.white.down { background: linear-gradient(#a9e6dc, #7fd3c4); }
.key.black.down { background: linear-gradient(#1c6b60, #2f9384); }
.key span {
	position: absolute;
	bottom: .3em;
	left: 0; right: 0;
	text-align: center;
	font-size: .55em;
	color: #888;
	pointer-events: none;
}

/* ------------------------------------------------------------ drag & drop */
.drop-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 50;
	align-items: center;
	justify-content: center;
	background: rgba(23, 48, 44, .85);
	border: 3px dashed var(--teal);
	font-size: 1.5em;
	color: var(--lcd-fg);
	pointer-events: none;
}
body.dragging .drop-overlay { display: flex; }

@media (max-width: 700px) {
	.waveforms, .nav-status { display: none; }
	.tab-nav button { padding: .6em 1em; }
	main { padding: .75em; }
	.group, .group-global, .group-fn { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------- editing */
.btn:disabled, .mini:disabled { opacity: .35; cursor: default; }
.edit-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .5em;
	margin-bottom: .75em;
}
.name-edit {
	display: flex;
	align-items: center;
	gap: .5em;
	font-size: .75em;
	color: var(--muted);
	font-weight: 600;
	margin-right: .5em;
}
.name-edit input {
	width: 9.5em;
	padding: .25em .5em;
	background: var(--lcd-bg);
	color: var(--lcd-fg);
	border: 1px solid #0a0a0a;
	border-radius: 3px;
	font-family: 'Share Tech Mono', monospace;
	font-size: 1.35em;
	letter-spacing: .05em;
}
.edit-hint { font-size: .7em; color: #666; margin-left: auto; }
.voice-btn .edited { color: var(--rose); margin-left: auto; }

.knobs { display: flex; flex-wrap: wrap; gap: .5em .2em; margin-top: .4em; }
.knobs.tight { gap: .3em .1em; margin-top: .2em; }
.val-input {
	width: 3.6em;
	padding: .05em 0;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 3px;
	font-family: 'Share Tech Mono', monospace;
	font-size: .8em;
	text-align: center;
}
.val-input:hover { border-color: #444; }
.val-input:focus { border-color: var(--accent); background: #111; outline: none; }

.toggle {
	min-width: 3.2em;
	padding: .2em .5em;
	background: #2a2a2a;
	border: 1px solid #444;
	border-radius: 3px;
	font-size: .75em;
	font-weight: 700;
	cursor: pointer;
}
.toggle.on { background: var(--accent); border-color: var(--accent); color: #111; }
.toggle-knob { justify-content: center; }

.ui-select.small { min-width: 0; padding: .2em 1.8em .2em .5em; font-size: .8em; }
.lfo-row { gap: .6em; }
.lfo-row .knob-label { margin-left: auto; }

.mini {
	padding: .05em .4em;
	background: #2a2a2a;
	border: 1px solid #444;
	border-radius: 3px;
	font-size: .6em;
	color: #aaa;
	cursor: pointer;
}
.mini:hover:not(:disabled) { color: #fff; border-color: #777; }

.op-card .knob { width: 3.5em; }
.op-card .knob-dial { width: 2.1em; }
.op-card .knob-label { font-size: .62em; }
.op-freq { display: flex; align-items: center; justify-content: space-between; gap: .5em; }
.op-freq .freq { font-family: 'Share Tech Mono', monospace; font-size: 1.4em; font-weight: 400; color: var(--lcd-fg); }
.op-group h4 { font-size: .6em; letter-spacing: .08em; color: var(--muted); margin-top: .5em; }
.curves { display: flex; gap: .8em; margin-top: .4em; }
.curves label { display: flex; flex-direction: column; gap: .2em; font-size: .62em; color: var(--muted); font-weight: 600; }
.ops { grid-template-columns: repeat(auto-fill, minmax(16em, 1fr)); }
.panel .knob-label { font-size: .62em; white-space: nowrap; }
.panel .knob { width: 4.4em; }

.btn.save { border-color: #3a6b63; }
.notice {
	padding: .5em 1em;
	background: #17302c;
	color: var(--lcd-fg);
	font-size: .8em;
	cursor: pointer;
}

.eg-toggle { cursor: pointer; }
.eg-toggle:hover .eg-svg { outline: 1px solid #444; }
.eg-tag { fill: #888; }
