/* Custom CSS Variables for Crisp Light Textbook Theme */
:root {
  --bg-primary: #faf8f5;     /* Warm off-white textbook page */
  --bg-secondary: #f1ede4;   /* Slightly darker beige for inputs */
  --bg-card: #ffffff;        /* Pure white cards */
  --border-color: #cbd5e1;   /* Clean light gray borders */
  --border-active: #d97706;  /* Warm wood/orange active border */
  
  --text-primary: #0f172a;   /* Dark slate (almost black) for primary text */
  --text-secondary: #475569; /* Slate gray for secondary text */
  --text-muted: #94a3b8;

  --accent-emerald: #059669; /* Darker emerald for light theme */
  --accent-cyan: #0891b2;    /* Darker cyan for text labels */
  --accent-orange: #d97706;  /* Warm amber/orange */
  
  --glow-cyan: 0 0 10px rgba(8, 145, 178, 0.2);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.03);

  --font-main: 'Outfit', 'Noto Sans JP', sans-serif;
}

/* Global resets and typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 24px 24px;
  gap: 14px;
}

/* Header */
.app-header {
  border: 0;
  padding: 2px 4px 4px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: transparent;
  box-shadow: none;
}

.recorder-guide-character {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin-left: auto;
  flex: 0 0 auto;
  pointer-events: none;
  filter: drop-shadow(0 8px 14px rgba(15, 23, 42, 0.14));
}

@media (max-width: 640px) {
  .recorder-guide-character {
    width: 72px;
    height: 72px;
  }
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

h1 {
  display: flex;
  flex-direction: column;
}

.title-sub {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent-orange);
  font-weight: 700;
}

.title-main {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* Settings Panel */
.settings-panel {
  display: flex;
  gap: 20px;
  align-items: center;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Switch (Sound toggle) */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
}

input:checked + .slider {
  background-color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

input:checked + .slider:before {
  transform: translateX(24px);
  background-color: #ffffff;
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Main Layout Grid */
.app-main {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 24px;
  flex: 1;
}

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

/* Crisp Cards */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.glass-card:hover {
  border-color: #94a3b8;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  border-left: 3px solid var(--accent-orange);
  padding-left: 8px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Keyboard Section (Horizontal Bar at Top) */
.keyboard-section {
  padding: 2px 0 6px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.keyboard-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
}

/* Note buttons keep a compact row while meeting a 44px touch target. */
.key-btn {
  background: rgba(255, 250, 238, 0.9);
  border: 0;
  border-radius: 999px;
  padding: 10px 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(80, 58, 28, 0.09);
  width: 62px;
  height: 44px;
}

.key-btn:hover {
  transform: translateY(-1.5px) scale(1.02);
  background: rgba(255, 244, 213, 0.98);
  box-shadow: 0 6px 14px rgba(80, 58, 28, 0.13);
}

.key-btn:active {
  transform: translateY(0.5px);
}

.key-btn.active {
  background: #f4b54b;
  color: #4a2d09;
  box-shadow: 0 5px 14px rgba(217, 119, 6, 0.25);
}

.key-syllable {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.overline-text {
  text-decoration: overline;
  text-decoration-thickness: 2.5px;
}

.key-btn.active .key-syllable {
  color: #4a2d09;
}

/* Score Section (Sheet Music) */
.score-container {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 180px;
}

.staff-line {
  stroke: #1e293b; /* Dark sharp music staff lines */
  stroke-width: 1.5;
}

.ledger-line {
  stroke: #1e293b;
  stroke-width: 2.2;
  transition: opacity 0.3s ease;
}

.ledger-line.hide {
  opacity: 0;
}

/* Note Head & Stem (Printed textbook style) */
#note-head {
  fill: #1e293b; /* Solid music note */
  filter: none;
}

#note-stem {
  stroke: #1e293b;
  stroke-width: 2.5;
}

/* Note Info Container */
.note-info-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.note-names {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.note-syllable {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* Recorder Visualizer (Center Column) */
.recorder-visualizer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  flex: 1;
}

.front-body-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 14px;
  border-radius: 28px;
  background: rgba(255, 250, 238, 0.72);
  border: 1px solid rgba(190, 168, 130, 0.42);
  box-shadow: 0 12px 28px rgba(76, 55, 31, 0.1);
  backdrop-filter: blur(2px);
}

#recorder-body-svg {
  width: 320px;
  height: 540px;
  display: block;
  overflow: visible;
}

.recorder-silhouette {
  fill: #14161c;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 2.5;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.recorder-windway {
  fill: #0c0e15;
}

.recorder-hole {
  fill: #ffffff; /* Default open state is empty white */
  stroke: #92400e;
  stroke-width: 2.5;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* State Classes for Holes - Closed/Covered holes are solid black */
.recorder-hole.state-closed {
  fill: #000000; /* Solid black when closed */
  stroke: #92400e;
  filter: none;
}

.recorder-hole.state-open {
  fill: #ffffff;
  stroke: #92400e;
}

.recorder-hole.state-half {
  fill: url(#thumb-half-filled); /* Half-black, half-white */
  stroke: #92400e;
}

/* Double Hole Inner Circles (Hole 7) */
.double-hole-inner {
  fill: #ffffff; /* White openings when open */
  stroke: #92400e;
  stroke-width: 0.8;
  pointer-events: none;
  transition: fill 0.3s ease, stroke 0.3s ease;
}

.recorder-hole.state-closed ~ .double-hole-inner {
  fill: #000000; /* Solid black when covered */
  stroke: #000000;
}

/* --- Flat 2D Finger Slide Animation styling --- */

.flat-finger {
  fill: url(#skin-gradient);
  stroke: #7c5638;
  stroke-width: 1.25;
  transition: fill 0.28s ease, stroke 0.28s ease, filter 0.28s ease;
  pointer-events: none;
}

/* Active Finger skin gradient and shadow */
.state-active .flat-finger {
  fill: url(#skin-gradient-active);
  stroke: #a94232;
  filter: drop-shadow(0 3px 7px rgba(169, 66, 50, 0.22));
}

/* Special "half-shift" state for E6/F6 thumb register (Red/Rose) */
.left-thumb.state-half .flat-finger {
  fill: url(#skin-gradient-half);
  stroke: #b45309;
  filter: drop-shadow(0 2px 6px rgba(180, 83, 9, 0.25));
}

/* Right Ring G#5 half-closed state (normal pink skin) */
.right-finger.state-half .flat-finger {
  fill: url(#skin-gradient-active);
  stroke: #b45309;
  filter: drop-shadow(0 2px 6px rgba(180, 83, 9, 0.2));
}

/* Next Finger state - colored green */
.state-next .flat-finger {
  fill: url(#skin-gradient-next) !important;
  stroke: #0f766e !important;
  filter: drop-shadow(0 3px 7px rgba(15, 118, 110, 0.24)) !important;
}

/* Hiragana "はんぶんずらす" text styling */
.half-shift-text {
  font-family: var(--font-main);
  font-size: 8.5px;
  font-weight: 800;
  fill: #4338ca;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.finger-nail {
  fill: #fff6df;
  stroke: #9b7257;
  stroke-width: 0.7;
  opacity: 0.82;
  transition: stroke 0.28s ease, fill 0.28s ease;
  pointer-events: none;
}

.state-active .finger-nail {
  stroke: #fca5a5;
}

.left-thumb.state-half .finger-nail {
  stroke: #c7d2fe;
}

.right-finger.state-half .finger-nail {
  stroke: #fca5a5;
}

/* Left Hand Fingers slide right (0 to cover, -24px when open) */
.left-finger {
  transform: translateX(-24px);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.left-finger.state-active {
  transform: translateX(0);
}

/* Left Thumb slides right (0 to cover, -35px when open) */
.left-thumb {
  transform: translateX(-35px);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.left-thumb.state-active {
  transform: translateX(0);
}

.left-thumb.state-half {
  transform: translate(0px, -10px);
}

/* Right Hand Fingers slide left (0 to cover, 24px when open) */
.right-finger {
  transform: translateX(24px);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.right-finger.state-active {
  transform: translateX(0);
}

.right-finger.state-half {
  transform: translateX(12px); /* Halfway slide to cover only the right double-hole */
}

.hand-title-label {
  font-family: var(--font-main);
  font-size: 9.5px;
  font-weight: 800;
  fill: var(--text-secondary);
  letter-spacing: 0.1em;
}

.hide {
  display: none !important;
}

/* Mastered Check Button for Platform Sync */
.mastered-btn {
  min-height: 44px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  vertical-align: middle;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.mastered-btn:hover {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  background: #f0fdf4;
  transform: translateY(-1px);
}

.mastered-btn:active {
  transform: translateY(0.5px);
}

.mastered-btn.active {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.15);
}

.mastered-btn .check-icon {
  font-size: 0.95rem;
  opacity: 0.5;
  font-weight: 900;
}

.mastered-btn.active .check-icon {
  opacity: 1;
}

/* Keyboard Rows */
.keyboard-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 8px;
}
.keyboard-row {
  display: flex;
  justify-content: center;
  width: 100%;
  gap: 8px;
  flex-wrap: wrap;
}
.keyboard-row.lower-row {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* Mode Selection Panel & Tabs */
.mode-control-panel {
  margin-top: 6px;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 0;
  background: rgba(255, 250, 238, 0.86);
  box-shadow: 0 10px 26px rgba(76, 55, 31, 0.08);
  backdrop-filter: blur(2px);
}

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  border-bottom: 2px solid var(--bg-secondary);
  padding-bottom: 8px;
}

.tab-btn {
  min-height: 44px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
}

.tab-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.tab-btn.active {
  background: #fffbeb;
  color: var(--accent-orange);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.1);
  font-weight: 700;
}

.mode-content {
  min-height: 100px;
}

/* Hide helper class */
.hide {
  display: none !important;
}

/* 1. Practice Mode Styling */
.practice-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.song-select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.song-select-dropdown {
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-btn {
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-btn:hover {
  border-color: var(--accent-orange);
  background: #fffbeb;
  color: var(--accent-orange);
}

.control-btn.play-btn {
  background: var(--accent-orange);
  color: #ffffff;
  border-color: var(--accent-orange);
}

.control-btn.play-btn:hover {
  background: #b45309;
  color: #ffffff;
}

.progress-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 45px;
  text-align: center;
}

/* Song Staff Container */
.song-staff-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  overflow-x: auto;
  min-height: 120px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.02);
}

.song-staff-scroll-wrapper {
  display: flex;
  gap: 16px;
  align-items: center;
  min-width: max-content;
}

/* Individual notes in Practice Mode */
.practice-note-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--bg-primary);
  transition: all 0.2s ease;
  min-width: 50px;
  cursor: pointer;
}

.practice-note-card:hover {
  background: var(--bg-secondary);
}

.practice-note-card.active {
  border-color: var(--accent-emerald);
  background: #ecfdf5;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.15);
  transform: translateY(-2px);
}

.practice-note-card.next {
  border-color: var(--accent-cyan);
  background: #ecfeff;
  border-style: dashed;
}

.practice-note-symbol {
  font-family: 'Noto Music', serif;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--text-primary);
}

.practice-note-name {
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text-secondary);
}

.practice-note-card.active .practice-note-name {
  color: var(--accent-emerald);
}

.practice-note-card.next .practice-note-name {
  color: var(--accent-cyan);
}


/* 2. Editor Mode Styling */
.editor-workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.composer-staff-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.composer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.song-name-input {
  flex: 1;
  min-width: 150px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
}

.composer-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn.danger {
  background: #fee2e2;
  color: #ef4444;
}

.action-btn.danger:hover {
  background: #fca5a5;
}

.action-btn.success {
  background: var(--accent-emerald);
  color: #ffffff;
}

.action-btn.success:hover {
  background: #047857;
}

.editor-tip {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: #fffbeb;
  padding: 6px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--accent-orange);
}

/* Grid Staff Composer */
.composer-grid-outer {
  display: flex;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.composer-grid-y-labels {
  display: grid;
  grid-template-rows: repeat(11, 12px);
  width: 32px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  text-align: center;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  user-select: none;
}

.pitch-y-label {
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
}

.composer-grid-scroll {
  flex: 1;
  overflow-x: auto;
}

.composer-grid {
  display: grid;
  grid-template-rows: repeat(11, 12px);
  grid-template-columns: repeat(16, 36px);
  min-width: max-content;
}

.composer-cell {
  position: relative;
  height: 12px;
  border-right: 1.5px solid rgba(226, 232, 240, 0.45); /* Light grey vertical grid lines */
  border-bottom: 1px solid transparent; /* Completely transparent to display unbroken staff lines */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}

/* Clear vertical divider every 4 columns (1 beat intervals) */
.composer-cell.beat-boundary {
  border-right: 2px solid rgba(148, 163, 184, 0.65);
}

/* Subtle ledger line guide for empty C5 cells (Row 10) */
.composer-cell[data-row="10"]::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 5px;
  height: 1px;
  border-top: 1px dashed #cbd5e1;
  pointer-events: none;
  z-index: 1;
}

/* Staff lines (Rows 0, 2, 4, 6, 8 draw centered lines inside cells) */
.composer-cell[data-row="0"]::before,
.composer-cell[data-row="2"]::before,
.composer-cell[data-row="4"]::before,
.composer-cell[data-row="6"]::before,
.composer-cell[data-row="8"]::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 5px;
  height: 2px;
  background-color: #64748b;
  z-index: 2;
  pointer-events: none;
}

.composer-cell:hover {
  background: #fffbeb;
}

.composer-cell.glow {
  background: #fef3c7;
}

/* Pointer events pass-through during drag (exclude currently dragged block to prevent Safari cancellation) */
.composer-grid.is-dragging-active .composer-note-block:not(.dragging) {
  pointer-events: none !important;
}

.composer-note-glyph {
  font-family: 'Noto Music', serif;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 2;
}

.composer-rest-glyph {
  font-family: 'Noto Music', serif;
  font-size: 2.5rem; /* Enlarge rest size to match note volume */
  line-height: 1;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 2;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* perfectly centered inside grid row */
}

/* Enlarge rest symbols inside the palette list to match note symbols */
.palette-item[data-is-rest="true"] .note-symbol {
  font-size: 2.2rem !important;
}

.composer-glyph-container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  cursor: grab;
}

.composer-glyph-container:active {
  cursor: grabbing;
}

.composer-glyph-container.dragging {
  opacity: 0.5;
}

.composer-palette-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.palette-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
  margin-bottom: 2px;
}

.palette-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.palette-item {
  display: flex;
  flex-direction: column; /* Align symbol and text label vertically */
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 58px; /* Fixed square tile size */
  height: 58px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}

.palette-item:hover {
  border-color: var(--accent-orange);
  background: rgba(254, 243, 199, 0.2);
}

.palette-item.active {
  border-color: var(--accent-orange) !important;
  background: #fffbeb !important;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.2);
}

.palette-item .note-symbol {
  font-family: 'Noto Music', serif;
  font-size: 1.5rem;
  line-height: 1.1;
  text-align: center;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.palette-item .note-label {
  display: block !important; /* Make sure labels are always visible */
  font-size: 0.58rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  color: var(--text-secondary);
  white-space: normal; /* Allow text wrapping if needed */
}

.palette-item.active .note-label {
  color: var(--accent-orange);
}

/* Smartphone Responsive / One-screen No-Scroll Fit */
@media (max-width: 600px) {
  html, body {
    overflow-y: auto !important; /* Allow scroll on mobile for editor layout */
    height: auto !important;
    position: static !important;
  }

  .app-container {
    height: auto !important;
    padding: 8px;
    gap: 8px;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .keyboard-row.lower-row {
    gap: 4px;
  }
  .keyboard-row {
    gap: 4px;
  }

  .keyboard-section {
    padding: 4px;
  }

  .keyboard-container {
    gap: 6px;
  }

  .key-btn {
    width: 44px;
    height: 44px;
    padding: 2px 1px;
    border-radius: 8px;
  }

  .key-syllable {
    font-size: 0.72rem;
  }

  .app-main {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
  }

  .glass-card {
    padding: 8px;
  }

  .info-section {
    display: none !important;
  }

  .visualizer-section {
    min-height: 240px;
  }

  .recorder-visualizer {
    padding: 0;
  }

  #recorder-body-svg {
    max-height: 40vh;
  }

  .editor-workspace {
    grid-template-columns: 1fr;
  }
  .composer-palette-section {
    order: -1;
  }
  .palette-list {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
  .palette-item {
    flex-direction: column;
    padding: 4px;
    min-width: 58px;
    align-items: center;
    gap: 2px;
  }
  .palette-item .note-symbol {
    font-size: 1.4rem;
    width: auto;
  }
  .palette-item .note-label {
    font-size: 0.55rem;
  }
}

/* Rest state styling - Dimming guide overlay */
.app-main.is-rest-active {
  background-color: rgba(15, 23, 42, 0.45);
  transition: background-color 0.3s ease;
  border-radius: 16px;
}
.app-main.is-rest-active .info-section,
.app-main.is-rest-active .visualizer-section {
  opacity: 0.65;
  transition: opacity 0.3s ease;
}
.song-staff-container.is-rest-active {
  background-color: #cbd5e1 !important;
  transition: background-color 0.3s ease;
}

/* Drag-hover glow effect on Grid composer cells */
.composer-cell.drag-hover {
  background-color: #fef3c7 !important;
  box-shadow: inset 0 0 0 2px var(--accent-orange);
}

/* Mode-specific Layout Overrides */
.app-container.mode-explore-active .app-main {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
}
.app-container.mode-explore-active #explore-sheet-card {
  display: block;
}
.app-container.mode-explore-active .visualizer-section {
  display: block;
}

/* 「おと」モードでは下段に中身がないため、タブだけを残して空パネルを作らない。 */
.app-container:not(.mode-practice-active):not(.mode-editor-active) .mode-content,
.app-container.mode-explore-active .mode-content {
  display: none;
}

.app-container:not(.mode-practice-active):not(.mode-editor-active) .mode-control-panel,
.app-container.mode-explore-active .mode-control-panel {
  padding-block: 6px;
  gap: 0;
}

.app-container:not(.mode-practice-active):not(.mode-editor-active) .mode-tabs,
.app-container.mode-explore-active .mode-tabs {
  padding-bottom: 0;
  border-bottom: 0;
}

/* Editor Mode active: Hide visualizer and explore-sheet-card entirely */
.app-container.mode-editor-active .app-main {
  display: none !important;
}
.app-container.mode-editor-active .visualizer-section {
  display: none !important;
}

/* Practice Mode active: Hide explore staff, center the visualizer */
.app-container.mode-practice-active #explore-sheet-card {
  display: none !important;
}
.app-container.mode-practice-active .app-main {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100%;
}
.app-container.mode-practice-active .visualizer-section {
  display: block !important;
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}

/* Breath Glow Animation - lights up the recorder container when blowing a note */
@keyframes breathGlow {
  0% {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.22) 0%, rgba(16, 185, 129, 0.05) 70%, rgba(16, 185, 129, 0) 100%);
    box-shadow: inset 0 0 50px rgba(16, 185, 129, 0.4), 0 0 30px rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.6);
  }
  100% {
    background: radial-gradient(circle, rgba(16, 185, 129, 0) 0%, rgba(16, 185, 129, 0) 100%);
    box-shadow: inset 0 0 0px rgba(16, 185, 129, 0), 0 0 0px rgba(16, 185, 129, 0);
    border-color: var(--border-color);
  }
}

.app-main.is-blowing {
  border-radius: 16px;
  animation: breathGlow 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Timeline Beat Blocks (DAW-style but made transparent to look like real sheet music) */
/* Timeline Beat Blocks - Visibly styled as neat rectangular blocks with borders */
.composer-note-block {
  position: relative;
  height: 12px;
  background: rgba(6, 182, 212, 0.16) !important; /* semi-transparent cyan block */
  border: 1.5px solid rgba(6, 182, 212, 0.75) !important; /* solid border */
  border-radius: 4px;
  display: flex;
  align-items: center;
  z-index: 10;
  cursor: grab;
  user-select: none;
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.composer-note-block:hover {
  background: rgba(6, 182, 212, 0.26) !important;
  border-color: rgba(6, 182, 212, 1) !important;
  transform: scaleY(1.15); /* Slightly pop vertically to show interactive state */
}

.composer-note-block.is-rest {
  background: rgba(148, 163, 184, 0.22) !important; /* semi-transparent slate grey block */
  border: 1.5px solid rgba(148, 163, 184, 0.7) !important;
}

.composer-note-block.is-rest:hover {
  background: rgba(148, 163, 184, 0.32) !important;
  border-color: rgba(148, 163, 184, 1) !important;
  transform: scaleY(1.15);
}

.composer-note-block:active {
  cursor: grabbing;
}

.composer-note-block.dragging {
  opacity: 0.35;
}

.composer-note-block.selected {
  background: rgba(6, 182, 212, 0.18) !important;
  border: 1px solid rgba(6, 182, 212, 0.8) !important;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
}

.composer-note-block svg {
  position: absolute;
  left: 4px;
  top: -42px; /* centered relative to cell */
  pointer-events: none;
}

.block-note-label {
  position: absolute;
  left: 32px;
  font-size: 0.65rem;
  font-weight: bold;
  color: var(--accent-cyan);
  pointer-events: none;
  white-space: nowrap;
}

/* App Header styling */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  margin-bottom: 12px;
  border-radius: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-sizing: border-box;
}
.app-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}
.header-scan-btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-scan-btn:hover {
  background: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.35);
  transform: translateY(-1px);
}

/* Modals overlays & components */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.modal-overlay.hide {
  display: none !important;
}
.modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: 20px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes modalSlideUp {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.modal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.4;
}
#qr-code-container img {
  margin: 0 auto;
  border: 8px solid #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.modal-close-btn {
  margin-top: 16px;
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  background: var(--accent-blue);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.modal-close-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.modal-close-btn.danger {
  background: #ef4444;
}
.modal-close-btn.danger:hover {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
#scanner-preview {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--accent-cyan);
  background: #000000;
}

/* ==========================================================================
   Practice Mode Safe Screen-Fit Responsive Settings
   ========================================================================== */

/* 縦の高さが短い Chromebook (高低 720px 以下) や、スマートフォン (幅 768px 以下) の場合 */
@media (max-height: 720px), (max-width: 768px) {
  /* 見本曲の音符はスマホでも教材の主役。隠さず、横スクロールの小型譜面として残す。 */
  .app-container.mode-practice-active .song-staff-container {
    display: block !important;
    min-height: 78px;
    max-height: 94px;
    padding: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .app-container.mode-practice-active .song-staff-scroll-wrapper {
    gap: 7px;
  }

  .app-container.mode-practice-active .practice-note-card {
    min-width: 44px;
    padding: 4px 6px;
  }

  .app-container.mode-practice-active .practice-note-symbol {
    font-size: 1.75rem;
  }

  .app-container.mode-practice-active .practice-note-name {
    margin-top: 2px;
    font-size: 0.68rem;
  }

  /* 練習モード時の操作コントロール周辺の余白を小さくし、1画面に収まりやすくする */
  .app-container.mode-practice-active .mode-control-panel {
    margin-top: 8px !important;
    padding: 10px !important;
    gap: 10px !important;
  }

  .app-container.mode-practice-active .practice-controls {
    margin-bottom: 0 !important;
    gap: 8px !important;
  }

  /* アプリ全体のパディングも少し縮小 */
  .app-container.mode-practice-active {
    padding: 12px !important;
    gap: 12px !important;
  }
}

/* ==========================================================================
   Tie Feature & Blowing Visualizations
   ========================================================================== */

/* 1. Blowing feedback
   背景世界は変えず、リコーダー直近だけを淡く反応させる。 */
body.is-blowing-active.is-blowing-note .front-body-container {
  animation: blowing-recorder-pulse 1.25s forwards ease-out;
}

@keyframes blowing-recorder-pulse {
  0% {
    box-shadow:
      0 0 0 7px rgba(34, 211, 238, 0.22),
      0 18px 36px rgba(76, 55, 31, 0.12);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(34, 211, 238, 0),
      0 12px 28px rgba(76, 55, 31, 0.1);
  }
}

/* 2. Tie Feature Visuals on Editor composer blocks */
.composer-note-block.is-tied-active {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

.composer-tie-arch {
  pointer-events: none;
}

/* 3. Tie arc curves on Practice mode staff note cards */
.practice-note-card.is-tied {
  position: relative;
}

.practice-note-card.is-tied::after {
  content: "⌒";
  position: absolute;
  right: -9px;
  top: 15%;
  font-size: 1.6rem;
  color: var(--accent-cyan);
  pointer-events: none;
  font-weight: bold;
  transform: rotate(0deg);
  z-index: 5;
}

/* ===== Immersion pass 2026-09-27 =====
   世界観背景を主役にし、教材操作に不要な外枠を減らす。 */
.app-header.glass-card,
.visualizer-section.glass-card {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.app-header.glass-card {
  padding: 2px 4px 4px;
}

.visualizer-section.glass-card {
  padding: 2px 0;
  gap: 6px;
  align-items: center;
}

.visualizer-section .section-title {
  align-self: center;
  margin: 0 0 2px;
  padding: 5px 12px;
  border-left: 0;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.78);
  box-shadow: 0 4px 12px rgba(76, 55, 31, 0.08);
  backdrop-filter: blur(2px);
}

.keyboard-section.glass-card {
  border-radius: 0;
}

@media (max-width: 820px) {
  .app-container {
    padding: 12px 12px 18px;
    gap: 10px;
  }

  .app-container.mode-explore-active .app-main {
    grid-template-columns: 1fr;
  }

  .mode-tabs {
    gap: 4px;
    padding-bottom: 6px;
  }

  .tab-btn {
    flex: 1 1 0;
    padding-inline: 6px;
    font-size: 0.82rem;
  }

  .song-select-wrapper,
  .playback-controls {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .tempo-control-wrapper {
    margin-left: 0 !important;
  }

  .front-body-container {
    padding: 4px 8px;
    border-radius: 22px;
  }

  #recorder-body-svg {
    width: min(300px, 88vw);
    height: auto;
  }
}

/* ==========================================================================
   Score editor redesign 2026-09-29
   Flat / MuseScore の「楽譜が主役・入力ツールは一列・高度機能は二段目」
   という考え方を、3年生向けに簡略化したUI。
   ========================================================================== */

#panel-editor {
  min-width: 0;
}

.editor-workspace {
  display: block;
}

.composer-staff-section {
  --composer-row-height: 24px;
  gap: 10px;
  min-width: 0;
}

.composer-header {
  display: grid !important;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: end !important;
  gap: 10px !important;
  padding: 10px 12px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
}

.editor-song-title-field {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 800;
}

.editor-song-title-field > span {
  padding-left: 2px;
}

.song-name-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid #d8dee8;
  border-radius: 10px;
  background: #fff;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
}

.song-name-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

.editor-mode-indicator {
  display: none;
  align-self: center;
  padding: 6px 9px;
  border: 1px solid #86efac;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.composer-actions .action-btn {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  white-space: nowrap;
}

.editor-secondary-action {
  background: #fff;
  border-color: #d8dee8 !important;
  color: #334155;
}

.editor-secondary-action:hover {
  background: #f8fafc;
  border-color: #94a3b8 !important;
}

.editor-save-action {
  min-width: 74px;
}

.editor-guide {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 10px;
  background: #f0fdfa;
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 800;
}

.composer-palette-section {
  order: 0 !important;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #d8dee8;
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.94);
  min-width: 0;
}

.palette-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.palette-group-label {
  flex: 0 0 auto;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.palette-list {
  min-width: 0;
}

.palette-list-primary,
.palette-list-advanced {
  display: flex;
  flex-flow: row nowrap;
  justify-content: flex-start;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding: 1px;
}

.palette-item {
  flex: 0 0 58px;
  width: 58px;
  height: 54px;
  min-width: 58px;
  padding: 3px 4px;
  border: 2px solid #d8dee8;
  border-radius: 10px;
  background: #fff;
}

.palette-item:hover {
  transform: translateY(-1px);
}

.palette-item.active {
  border-color: #f59e0b !important;
  background: #fff7dd !important;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.12);
}

.palette-item .note-symbol {
  font-size: 1.45rem;
}

.palette-item[data-is-rest="true"] .note-symbol {
  font-size: 1.75rem !important;
}

.palette-item .note-label {
  display: block !important;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.composer-advanced-tools {
  flex: 0 0 auto;
  position: relative;
}

.composer-advanced-tools > summary {
  list-style: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid #d8dee8;
  border-radius: 10px;
  background: #fff;
  color: #475569;
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.composer-advanced-tools > summary::-webkit-details-marker {
  display: none;
}

.composer-advanced-tools[open] {
  width: min(100%, 380px);
}

.composer-advanced-tools[open] > summary {
  margin-bottom: 7px;
  border-color: #94a3b8;
}

.editor-tie-action {
  flex: 0 0 auto;
  min-width: 58px;
  height: 54px;
  min-height: 54px;
  padding: 6px 10px;
  background: #fff7ed;
  border: 2px solid #fdba74;
  border-radius: 10px;
  color: #9a3412;
}

.composer-grid-outer {
  min-height: calc(var(--composer-row-height) * 11 + 2px);
  border: 2px solid #bac5d3;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.composer-grid-y-labels {
  grid-template-rows: repeat(11, var(--composer-row-height));
  width: 46px;
  background: #f8fafc;
  border-right: 2px solid #d8dee8;
}

.pitch-y-label {
  height: var(--composer-row-height);
  font-size: 0.7rem;
  font-weight: 900;
  color: #475569;
}

.pitch-y-label.high {
  color: #0369a1;
}

.composer-grid {
  grid-template-rows: repeat(11, var(--composer-row-height));
}

.composer-cell,
.composer-note-block {
  height: var(--composer-row-height);
}

.composer-cell {
  border-right-color: rgba(203, 213, 225, 0.5);
}

.composer-cell.beat-boundary {
  border-right: 2px solid rgba(148, 163, 184, 0.68);
}

.composer-cell.measure-boundary {
  border-right: 3px solid rgba(71, 85, 105, 0.82);
}

.composer-cell[data-row="10"]::after {
  top: calc(50% - 1px);
}

.composer-cell[data-row="0"]::before,
.composer-cell[data-row="2"]::before,
.composer-cell[data-row="4"]::before,
.composer-cell[data-row="6"]::before,
.composer-cell[data-row="8"]::before {
  top: calc(50% - 1px);
  background-color: #475569;
}

.composer-cell:hover,
.composer-cell.glow {
  background: #fff7dd;
}

.composer-note-block.selected {
  background: rgba(14, 165, 233, 0.14) !important;
  border: 2px solid #0284c7 !important;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.composer-selection-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 44px;
}

.composer-trash-zone {
  min-height: 44px;
  opacity: 0.58;
  padding: 8px 12px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fff;
  color: #b91c1c;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.composer-trash-zone.has-selection {
  opacity: 1;
  background: #fff7f7;
}

.composer-trash-zone.drag-active,
.composer-trash-zone:hover {
  opacity: 1;
  background: #fef2f2;
  border-color: #f87171;
}

.editor-delete-hint {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ==========================================================================
   Immersion cleanup 2026-09-30
   背景世界を隠す「外側の箱」をなくし、必要な情報だけ局所的に支える。
   ========================================================================== */

.mode-control-panel.glass-card {
  margin-top: 2px;
  padding: 4px 0 0;
  gap: 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.mode-tabs {
  width: min(100%, 430px);
  margin-inline: auto;
  padding: 4px;
  gap: 4px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.78);
  box-shadow: 0 5px 16px rgba(76, 55, 31, 0.10);
  backdrop-filter: blur(3px);
}

.tab-btn {
  border-radius: 999px;
}

/* PCの「おと」モードでは、次に使う3タブを常に見える位置へ。
   練習・楽譜づくりは下に操作内容が続くため固定しない。 */
@media (min-width: 821px) {
  .app-container.mode-explore-active .mode-control-panel,
  .app-container:not(.mode-practice-active):not(.mode-editor-active) .mode-control-panel {
    position: fixed;
    left: 50%;
    bottom: 12px;
    z-index: 40;
    width: min(430px, calc(100vw - 32px));
    margin: 0;
    padding: 0;
    transform: translateX(-50%);
  }

  .app-container.mode-explore-active .app-main,
  .app-container:not(.mode-practice-active):not(.mode-editor-active) .app-main {
    padding-bottom: 60px;
  }
}

#explore-sheet-card.glass-card {
  padding: 0;
  gap: 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

#explore-sheet-card .section-title {
  align-self: flex-start;
  margin: 0;
  padding: 5px 12px;
  border-left: 0;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.78);
  box-shadow: 0 4px 12px rgba(76, 55, 31, 0.08);
  backdrop-filter: blur(2px);
}

#explore-sheet-card .score-container {
  min-height: 164px;
  padding: 10px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(76, 55, 31, 0.09);
  backdrop-filter: blur(2px);
}

#explore-sheet-card .note-info-container {
  gap: 6px;
}

#explore-sheet-card .note-names {
  align-self: center;
  padding: 4px 8px 4px 12px;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.80);
  box-shadow: 0 4px 12px rgba(76, 55, 31, 0.08);
  backdrop-filter: blur(2px);
}

.front-body-container {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

#recorder-body-svg {
  filter: drop-shadow(0 10px 14px rgba(76, 55, 31, 0.16));
}

.song-staff-container {
  border: 0;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(76, 55, 31, 0.09);
  backdrop-filter: blur(2px);
}

@media (max-width: 600px) {
  #explore-sheet-card {
    display: none !important;
  }

  .visualizer-section.glass-card {
    min-height: 0;
    padding: 0;
  }

  .front-body-container {
    width: 100%;
  }

  #recorder-body-svg {
    width: min(270px, 76vw);
    max-height: 58vh;
  }

  .app-container.mode-explore-active .mode-control-panel,
  .app-container:not(.mode-practice-active):not(.mode-editor-active) .mode-control-panel {
    padding-top: 0;
  }

  .app-container.mode-editor-active {
    padding: 8px !important;
    gap: 8px !important;
  }

  .app-container.mode-editor-active .mode-control-panel {
    padding: 8px;
    gap: 8px;
  }

  .app-container.mode-editor-active .mode-content {
    min-height: 0;
  }

  .composer-staff-section {
    --composer-row-height: 28px;
    gap: 8px;
  }

  .composer-header {
    grid-template-columns: 1fr;
    align-items: stretch !important;
    gap: 7px !important;
    padding: 8px;
  }

  .editor-song-title-field {
    gap: 3px;
  }

  .composer-actions {
    display: grid;
    grid-template-columns: 0.8fr 1fr 1fr;
    gap: 6px;
  }

  .composer-actions .action-btn {
    width: 100%;
    padding-inline: 6px;
    font-size: 0.76rem;
  }

  .editor-mode-indicator {
    justify-self: start;
  }

  .editor-guide {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 0.72rem;
    line-height: 1.35;
  }

  .composer-palette-section {
    order: 0 !important;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 7px;
  }

  .palette-primary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
  }

  .palette-group-label {
    align-self: center;
    font-size: 0.66rem;
  }

  .palette-list {
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    overflow-x: auto;
    gap: 5px !important;
  }

  .palette-item {
    flex: 0 0 52px;
    width: 52px;
    min-width: 52px !important;
    height: 50px;
    padding: 2px !important;
  }

  .palette-item .note-symbol {
    font-size: 1.3rem;
  }

  .palette-item .note-label {
    font-size: 0.62rem !important;
  }

  .composer-advanced-tools[open] {
    width: 100%;
  }

  .composer-advanced-tools > summary {
    min-height: 40px;
    font-size: 0.7rem;
  }

  .editor-tie-action {
    height: 50px;
    min-height: 50px;
  }

  .composer-grid-y-labels {
    width: 42px;
  }

  .pitch-y-label {
    font-size: 0.64rem;
  }

  .composer-grid-scroll {
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .composer-selection-actions {
    justify-content: space-between;
    gap: 6px;
  }

  .composer-trash-zone {
    min-height: 44px;
    padding: 7px 9px;
    font-size: 0.72rem;
  }

  .editor-delete-hint {
    text-align: right;
    font-size: 0.66rem;
  }
}
