:root {
  color: #111111;
  background: #feeee7;
  color-scheme: light;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  --background: #feeee7;
  --foreground: #111111;
  --card: #ffffff;
  --primary: #fcd56b;
  --secondary: #eaf6f7;
  --muted: #f7f7f4;
  --accent-cyan: #01c5d5;
  --accent-cyan-dark: #059ba7;
  --accent-blue: #8dcbf8;
  --accent-orange: #f0530f;
  --accent-pink: #e89ab9;
  --ink: #252525;
  --text-subtle: #747474;
  --border: #d7d7d7;
  --progress: 0%;
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 9% 16%, rgba(252, 213, 107, 0.65), transparent 20rem),
    radial-gradient(circle at 91% 11%, rgba(1, 197, 213, 0.22), transparent 22rem),
    radial-gradient(circle at 86% 84%, rgba(232, 154, 185, 0.2), transparent 18rem),
    linear-gradient(160deg, #feeee7 0%, #fef5db 52%, #eaf6f7 100%);
}

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

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  overflow: hidden;
  place-items: center;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.82), transparent 13rem),
    radial-gradient(circle at 70% 70%, rgba(1, 197, 213, 0.22), transparent 18rem),
    linear-gradient(160deg, #feeee7 0%, #fef5db 54%, #eaf6f7 100%);
  pointer-events: none;
  animation: splashExit 620ms cubic-bezier(0.65, 0, 0.35, 1) 1350ms forwards;
}

.splash-screen::before,
.splash-screen::after {
  position: absolute;
  width: 44vw;
  min-width: 360px;
  height: 140vh;
  content: "";
  transform: rotate(18deg) translateY(-8%);
}

.splash-screen::before {
  left: -22vw;
  background: var(--primary);
  animation: splashStripeLeft 1100ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.splash-screen::after {
  right: -24vw;
  background: rgba(1, 197, 213, 0.86);
  animation: splashStripeRight 1100ms cubic-bezier(0.2, 0.8, 0.2, 1) 120ms both;
}

.splash-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
  transform: scale(1.04);
  animation: none;
}

.splash-panel {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  gap: 18px;
  color: var(--ink);
  animation: splashPanelIn 820ms cubic-bezier(0.18, 1, 0.32, 1) both;
}

.splash-note,
.app-mark {
  display: grid;
  place-items: center;
  border: 5px solid var(--ink);
  border-radius: 30%;
  background: var(--primary);
  color: var(--ink);
  font-weight: 900;
  line-height: 1;
  paint-order: stroke fill;
  box-shadow: 12px 12px 0 var(--accent-cyan);
  text-shadow:
    1px 0 0 currentColor,
    -1px 0 0 currentColor,
    0 1px 0 currentColor,
    0 -1px 0 currentColor;
  -webkit-text-stroke: 0.04em currentColor;
}

.splash-note {
  width: clamp(80px, 12vw, 128px);
  height: clamp(80px, 12vw, 128px);
  font-size: clamp(2.8rem, 7vw, 5.3rem);
  transform: rotate(-7deg);
  animation: splashNotePop 960ms cubic-bezier(0.18, 1, 0.32, 1) both;
}

.splash-title {
  padding: 7px 18px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-cyan-dark);
  font-size: clamp(0.92rem, 2vw, 1.35rem);
  font-weight: 900;
  letter-spacing: 0.12em;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(1180px, calc(100vw - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 58px 0 52px;
  flex-direction: column;
  align-items: center;
}

.intro {
  display: flex;
  width: min(100%, 1080px);
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.app-mark {
  position: relative;
  width: 76px;
  height: 76px;
  border-width: 4px;
  font-size: 2.45rem;
  transform: rotate(-5deg);
  box-shadow: 9px 9px 0 var(--accent-cyan);
}

.app-mark::after {
  position: absolute;
  right: -13px;
  bottom: -10px;
  width: 22px;
  height: 22px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  content: "";
  background: var(--accent-pink);
}

.intro h1 {
  position: relative;
  margin: 28px 0 0;
  color: var(--ink);
  font-size: clamp(3.35rem, 9.5vw, 7.25rem);
  font-weight: 900;
  letter-spacing: -0.08em;
  line-height: 0.86;
  text-shadow:
    -2px -2px 0 #ffffff,
    3px 3px 0 var(--primary),
    8px 8px 0 rgba(1, 197, 213, 0.32);
}

.intro h1::after {
  display: block;
  width: fit-content;
  margin: 32px auto 0;
  padding: 5px 14px 4px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  content: "8BIT CHORD TUBE";
  background: #ffffff;
  color: var(--accent-cyan-dark);
  font-size: clamp(0.78rem, 1.5vw, 1.1rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  text-shadow: none;
}

.lead {
  width: min(100%, 680px);
  margin: 16px 0 0;
  color: #333333;
  font-size: clamp(1rem, 2vw, 1.18rem);
  font-weight: 800;
  line-height: 1.65;
}

.converter-card {
  position: relative;
  display: grid;
  width: min(100%, 1040px);
  margin-top: 32px;
  padding: clamp(20px, 3.2vw, 34px);
  gap: 18px;
  border: 3px solid var(--ink);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.95);
}

.converter-main {
  display: grid;
  grid-template-columns: minmax(340px, 1.12fr) minmax(300px, 0.88fr);
  gap: clamp(16px, 2.4vw, 28px);
  align-items: stretch;
}

.control-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.dropzone {
  display: grid;
  min-height: 276px;
  padding: clamp(26px, 4vw, 42px) clamp(18px, 3vw, 34px);
  gap: 11px;
  place-items: center;
  border: 2px dashed var(--accent-cyan-dark);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(1, 197, 213, 0.18), transparent 58%),
    linear-gradient(180deg, #ffffff 0%, #f6fdff 100%);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  transform: translateY(-2px);
  border-color: var(--accent-orange);
  box-shadow: 0 16px 32px rgba(1, 197, 213, 0.14);
}

.dropzone-kicker,
.section-label {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  color: var(--accent-cyan-dark);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.dropzone-kicker {
  padding: 5px 12px;
  background: var(--primary);
  color: var(--ink);
}

.dropzone strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(1.28rem, 3.2vw, 2rem);
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone span:last-of-type {
  color: var(--text-subtle);
  font-size: 0.86rem;
  font-weight: 700;
}

.swing-control {
  display: grid;
  padding: 20px;
  gap: 14px;
  border: 2px solid rgba(37, 37, 37, 0.08);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(252, 213, 107, 0.55), rgba(255, 255, 255, 0.76) 48%),
    #fef5db;
}

.control-heading {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.control-heading p {
  margin: 4px 0 0;
  color: #555555;
  font-size: 0.86rem;
  font-weight: 700;
}

.control-heading strong {
  min-width: 4.75rem;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 900;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-cyan);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-subtle);
  font-size: 0.76rem;
  font-weight: 800;
}

.advanced-settings {
  border: 2px solid rgba(37, 37, 37, 0.1);
  border-radius: 20px;
  background: #ffffff;
}

.advanced-settings summary {
  --summary-icon-size: 1.65rem;
  --summary-icon-pad: 16px;
  position: relative;
  display: flex;
  width: 100%;
  min-height: 52px;
  padding: 14px calc(var(--summary-icon-pad) + var(--summary-icon-size) + 12px) 14px var(--summary-icon-pad);
  align-items: center;
  gap: 12px;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 900;
  list-style: none;
  user-select: none;
  transition: background-color 160ms ease;
}

.advanced-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-settings summary::after {
  position: absolute;
  z-index: 0;
  top: 50%;
  right: var(--summary-icon-pad);
  display: block;
  width: var(--summary-icon-size);
  height: var(--summary-icon-size);
  border: 2px solid var(--ink);
  border-radius: 999px;
  content: "";
  background: var(--primary);
  transform: translateY(-50%);
  transition: background-color 160ms ease, transform 160ms ease;
}

.advanced-settings summary::before {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: calc(var(--summary-icon-pad) + 0.825rem + 1px);
  width: 11px;
  height: 11px;
  content: "";
  background:
    linear-gradient(var(--ink), var(--ink)) center / 11px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 2px 11px no-repeat;
  transform: translate(50%, -50%);
  transition: background 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.advanced-settings summary:hover {
  background: rgba(1, 197, 213, 0.08);
}

.advanced-settings[open] summary {
  border-bottom: 1px solid rgba(37, 37, 37, 0.08);
}

.advanced-settings[open] summary::after {
  background: var(--accent-cyan);
  transform: translateY(-50%) rotate(180deg);
}

.advanced-settings[open] summary::before {
  background: linear-gradient(#ffffff, #ffffff) center / 12px 2px no-repeat;
  transform: translate(50%, -50%) rotate(180deg);
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--text-subtle);
  font-size: 0.78rem;
  font-weight: 900;
}

.field-hint {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.55;
}

.field input,
.field select {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid #d7d7d7;
  border-radius: 13px;
  background-color: #fbfbfb;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
}

.checkline {
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.checkline input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-cyan);
}

.waveform-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.scope {
  overflow: hidden;
  border: 2px solid rgba(37, 37, 37, 0.08);
  border-radius: 20px;
  background: #f7f7f4;
}

.scope-header {
  display: flex;
  min-height: 48px;
  padding: 8px 10px 0 14px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.scope-label {
  display: block;
  color: var(--accent-cyan-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.scope-play {
  min-height: 34px;
  min-width: 82px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--accent-cyan);
  transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.scope-play:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  background: var(--primary);
  box-shadow: 4px 4px 0 var(--accent-cyan);
}

.scope audio {
  display: none;
}

canvas {
  display: block;
  width: 100%;
  height: 148px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.main-action {
  flex: 0 1 360px;
}

button,
.btn-lg {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-lg-primary {
  border: 2px solid var(--ink);
  background: var(--primary);
  color: var(--ink);
  font-weight: 900;
  box-shadow: 5px 5px 0 var(--accent-cyan);
  transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.btn-lg-primary:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  background: #ffe18b;
  box-shadow: 7px 7px 0 var(--accent-cyan);
}

.btn-lg-secondary {
  border: 2px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
}

.status-area {
  display: grid;
  gap: 10px;
  padding: 5px 2px 0;
}

.status-area p {
  margin: 0;
  color: #555555;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
}

.progress-meter {
  position: relative;
  display: grid;
  overflow: hidden;
  height: 34px;
  place-items: center;
  border: 2px solid rgba(37, 37, 37, 0.14);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.progress-meter::before {
  position: absolute;
  z-index: 0;
  inset: 0 auto 0 0;
  width: var(--progress);
  content: "";
  border-radius: inherit;
  background:
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.48) 45%, transparent 90%),
    linear-gradient(90deg, var(--accent-cyan), var(--accent-blue), var(--primary));
  background-position: -140px 0, 0 0;
  background-size: 140px 100%, 100% 100%;
  animation: progressFlow 1200ms linear infinite;
  transition: width 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-meter::after {
  position: relative;
  z-index: 1;
  content: attr(data-progress);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

.result-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  justify-items: center;
  border: 2px solid rgba(37, 37, 37, 0.08);
  border-radius: 20px;
  background: #eaf6f7;
  text-align: center;
}

.result-panel[hidden],
[hidden] {
  display: none !important;
}

.result-panel p {
  margin: 0;
  color: #333333;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.7;
  text-align: center;
}

.download-link {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--ink);
  background: var(--primary);
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
  box-shadow: 5px 5px 0 var(--accent-cyan);
}

.download-link[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.trust-row {
  display: flex;
  margin-top: 18px;
  justify-content: center;
  color: #555555;
  font-size: 0.77rem;
  font-weight: 800;
  line-height: 1.7;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@keyframes splashExit {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.04);
  }
}

@keyframes splashPanelIn {
  0% {
    opacity: 1;
    transform: translateY(18px) scale(0.88);
  }
  58% {
    opacity: 1;
    transform: translateY(-2px) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes splashNotePop {
  0% {
    opacity: 0;
    transform: translateY(34px) rotate(-18deg) scale(0.54);
  }
  52% {
    opacity: 1;
    transform: translateY(-12px) rotate(6deg) scale(1.18);
  }
  76% {
    opacity: 1;
    transform: translateY(5px) rotate(-10deg) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(-7deg) scale(1);
  }
}

@keyframes splashStripeLeft {
  0% {
    transform: rotate(18deg) translate(-38%, -8%);
  }
  100% {
    transform: rotate(18deg) translate(0, -8%);
  }
}

@keyframes splashStripeRight {
  0% {
    transform: rotate(18deg) translate(38%, -8%);
  }
  100% {
    transform: rotate(18deg) translate(0, -8%);
  }
}

@keyframes progressFlow {
  0% {
    background-position: -140px 0, 0 0;
  }
  100% {
    background-position: 140px 0, 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-delay: 0ms !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }

  .splash-screen {
    display: none;
  }

  .progress-meter::before {
    animation: none !important;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100%, calc(100vw - 28px));
    padding-top: 36px;
  }

  .app-mark {
    width: 64px;
    height: 64px;
    font-size: 2rem;
    box-shadow: 7px 7px 0 var(--accent-cyan);
  }

  .converter-card {
    margin-top: 28px;
    border-radius: 24px;
  }

  .converter-main,
  .waveform-panel {
    grid-template-columns: 1fr;
  }

  .dropzone {
    min-height: 188px;
  }

  .dropzone strong {
    white-space: normal;
  }

  .main-action {
    flex: 1 1 220px;
  }
}

@media (max-width: 520px) {
  .intro h1 {
    letter-spacing: -0.09em;
    text-shadow:
      -1px -1px 0 #ffffff,
      2px 2px 0 var(--primary),
      5px 5px 0 rgba(1, 197, 213, 0.3);
  }

  .converter-card {
    padding: 18px;
  }

  .action-row {
    justify-content: stretch;
  }
}
