:root {
  --bg-0: #e8efef;
  --bg-1: #f7fbfa;
  --ink-0: #0f1b22;
  --ink-1: #1f2f3a;
  --ink-2: #4e6270;
  --line: #ccd8de;
  --card: #ffffff;
  --card-soft: #f2f7f8;
  --accent: #0f766e;
  --accent-strong: #0f4f5f;
  --accent-soft: #ddf3f0;
  --warn: #c27803;
  --danger: #b63d2b;
  --success: #1f8f52;
  --shadow: 0 18px 48px rgba(15, 31, 40, 0.12);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'IBM Plex Sans JP', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  color: var(--ink-1);
  line-height: 1.55;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, #d6ece8 0%, rgba(214, 236, 232, 0) 48%),
    radial-gradient(circle at 90% 90%, #dce6f2 0%, rgba(220, 230, 242, 0) 54%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
}

.container {
  max-width: 1560px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

header {
  position: relative;
  padding: 34px 36px 32px;
  color: #eaf5f6;
  background:
    linear-gradient(130deg, #092534 0%, #123447 52%, #15546a 100%);
}

header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(20, 171, 165, 0.2), transparent 40%);
  pointer-events: none;
}

header h1 {
  position: relative;
  font-family: 'Space Grotesk', 'IBM Plex Sans JP', sans-serif;
  letter-spacing: 0.02em;
  font-size: clamp(1.45rem, 2.6vw, 2.35rem);
  font-weight: 700;
}

header .subtitle {
  position: relative;
  margin-top: 6px;
  font-size: 0.98rem;
  color: #b7d9e3;
  font-family: 'IBM Plex Mono', monospace;
}

.main-content {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(420px, 1fr);
  align-items: start;
  gap: 0;
}

.panel {
  padding: 28px;
  overflow-y: auto;
  max-height: calc(100vh - 210px);
}

.parameters-panel {
  background: var(--card-soft);
  border-right: 1px solid var(--line);
}

.controls-panel {
  background: linear-gradient(180deg, #fdfefe 0%, #f6fafb 100%);
}

.panel h2 {
  margin-bottom: 18px;
  font-family: 'Space Grotesk', 'IBM Plex Sans JP', sans-serif;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  color: var(--ink-0);
}

.param-section,
.control-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--card);
  box-shadow: 0 8px 22px rgba(13, 33, 43, 0.06);
  animation: riseIn 480ms ease-out both;
}

.param-section + .param-section,
.control-section + .control-section {
  margin-top: 14px;
}

.param-section:nth-of-type(2),
.control-section:nth-of-type(2) {
  animation-delay: 60ms;
}

.param-section:nth-of-type(3),
.control-section:nth-of-type(3) {
  animation-delay: 120ms;
}

.param-section:nth-of-type(4),
.control-section:nth-of-type(4) {
  animation-delay: 180ms;
}

.param-section h3,
.control-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-0);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2ecef;
  letter-spacing: 0.01em;
}

.param-subgroup {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed #d2dfe5;
  border-radius: var(--radius-sm);
  background: #fbfdfd;
}

.param-subgroup h4 {
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 0.88rem;
  font-weight: 600;
}

.param-group {
  margin-bottom: 13px;
}

.param-group:last-child,
.param-group-inline:last-child {
  margin-bottom: 0;
}

.param-group label,
.param-info label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.param-group-inline {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.param-group-inline label {
  margin-bottom: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
}

.param-info {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f2faf8, #eef5fb);
  border: 1px solid #d6e7e8;
}

.notes-display {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.93rem;
  color: #0d5e73;
  letter-spacing: 0.03em;
  word-break: break-word;
}

.param-group input[type="number"],
.param-group select {
  width: 100%;
  border: 1px solid #c8d7df;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-1);
  padding: 9px 10px;
  font-size: 0.94rem;
}

.param-group select {
  cursor: pointer;
}

.param-group input[type="number"] {
  max-width: 160px;
}

.param-group input[type="range"] {
  width: calc(100% - 86px);
  vertical-align: middle;
}

.value-display {
  display: inline-block;
  min-width: 68px;
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: #f6fbfc;
  background: var(--accent-strong);
  border-radius: 999px;
  padding: 5px 8px;
}

.timbre-selection {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.timbre-option {
  border: 1px solid #cad8df;
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  background: #f8fbfc;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.timbre-option input[type="radio"] {
  display: none;
}

.timbre-option span {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-1);
}

.timbre-option:hover {
  transform: translateY(-1px);
  border-color: #95b2bc;
  box-shadow: 0 6px 14px rgba(18, 45, 58, 0.08);
}

.timbre-option:has(input[type="radio"]:checked) {
  border-color: var(--accent);
  background: linear-gradient(160deg, #effcf9, #e2f7f3);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.18);
}

.timbre-option:has(input[type="radio"]:checked) span {
  color: #0e5d57;
}

.button-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.button-group:has(#initBtn) {
  grid-template-columns: 1fr;
}

.btn {
  border: 0;
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.18s ease, box-shadow 0.22s ease;
}

.btn:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn-primary {
  background: #0e5f73;
  color: #f4fafb;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 14px rgba(14, 95, 115, 0.3);
}

.btn-success {
  background: #21734b;
  color: #f5fdf8;
}

.btn-success:hover:not(:disabled) {
  box-shadow: 0 6px 14px rgba(33, 115, 75, 0.26);
}

.btn-danger {
  background: #9f3a2b;
  color: #fff5f3;
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 6px 14px rgba(159, 58, 43, 0.26);
}

.btn-secondary {
  background: #3e4f62;
  color: #f2f7fb;
  width: 100%;
}

.btn-secondary:hover:not(:disabled) {
  box-shadow: 0 6px 14px rgba(52, 69, 88, 0.24);
}

.playback-info {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d6e2e8;
  border-radius: var(--radius-sm);
  background: #fcffff;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 7px;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-label {
  color: var(--ink-2);
  font-weight: 600;
}

.info-value {
  color: #0e5f73;
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
}

.status-display {
  border: 1px solid #d3e2ea;
  border-radius: var(--radius-sm);
  background: #fbfeff;
  min-height: 54px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
}

.status-display p {
  font-size: 0.9rem;
  color: #2a495b;
}

.info-section ol {
  padding-left: 18px;
}

.info-section li {
  margin-bottom: 6px;
  font-size: 0.88rem;
  color: #3a5462;
}

.visualizer-container {
  margin-top: 2px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid #194153;
  background:
    linear-gradient(180deg, #0c1d27 0%, #0a1a23 100%);
  box-shadow: inset 0 0 0 1px rgba(29, 93, 118, 0.32);
}

.visualizer-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.bpm-display {
  font-family: 'IBM Plex Mono', monospace;
  color: #9ec7d4;
  font-size: 0.8rem;
}

.bpm-display span {
  color: #44d7ce;
  font-weight: 700;
}

#visualizerCanvas {
  width: 100%;
  height: 220px;
  border-radius: 6px;
  display: block;
  background: #08141a;
}

footer {
  border-top: 1px solid var(--line);
  padding: 14px 20px;
  background: #f3f8f9;
  color: #4a6574;
  text-align: center;
}

footer p {
  font-size: 0.8rem;
  margin: 2px 0;
}

.copyright {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: linear-gradient(90deg, #c6d7df, #d8e5eb);
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #e9f9f7;
  background: #0f766e;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(13, 59, 71, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #e9f9f7;
  background: #0f766e;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(13, 59, 71, 0.2);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .panel {
    max-height: none;
  }

  .parameters-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  body {
    padding: 10px;
  }

  header {
    padding: 22px 18px;
  }

  header .subtitle {
    font-size: 0.86rem;
  }

  .panel {
    padding: 14px;
  }

  .button-group {
    grid-template-columns: 1fr;
  }

  .timbre-selection {
    grid-template-columns: 1fr;
  }

  .param-group input[type="range"] {
    width: calc(100% - 78px);
  }

  .value-display {
    min-width: 58px;
    font-size: 0.74rem;
  }

  #visualizerCanvas {
    height: 180px;
  }
}
