.perfectfft-layout {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 80px 8px 16px;
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(320px, 3fr);
  grid-template-rows: 146px minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

.has-music-player .perfectfft-layout {
  padding-top: 128px;
}

.music-player {
  --music-theme: var(--projects-theme);
  --music-bg: rgba(0, 0, 0, 0.82);

  box-shadow: 0 0 14px rgba(238, 111, 122, 0.24);
}

.music-volume::-webkit-slider-thumb {
  box-shadow: 0 0 8px rgba(238, 111, 122, 0.7);
}

.music-volume::-moz-range-thumb {
  box-shadow: 0 0 8px rgba(238, 111, 122, 0.7);
}

.perfectfft-box {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 5px solid var(--projects-theme);
  background-color: #000000;
  box-shadow:
    0 0 16px rgba(238, 111, 122, 0.16),
    inset 0 0 0 1px rgba(238, 111, 122, 0.16);
}

.project-title-box,
.track-box {
  padding: 18px 20px;
  overflow: hidden;
}

.perfectfft-box-small {
  grid-column: 1;
  grid-row: 1;
}

.perfectfft-box-large {
  grid-column: 1;
  grid-row: 2;
}

.perfectfft-box-tall {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.language-list {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 54%;
  padding: 6px 7px 7px;
  border-left: 2px solid var(--projects-theme);
  border-bottom: 2px solid var(--projects-theme);
  background-color: #000000;
}

.language-list span {
  padding: 3px 7px;
  color: var(--projects-theme);
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--projects-theme-mid);
}

.project-heading {
  max-width: calc(100% - 220px);
  margin: 0;
  color: white;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: normal;
  line-height: 1;
}

.project-subtext {
  width: min(100%, 520px);
  margin: 14px 0 0;
  padding: 8px 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 17px;
  line-height: 1.35;
  border: 1px solid rgba(238, 111, 122, 0.46);
  outline: none;
}

.project-info-button {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 34px;
  height: 34px;
  color: #000000;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  background-color: var(--projects-theme);
  border: 1px solid var(--projects-theme);
  cursor: pointer;
  text-shadow: none;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.project-info-button:hover,
.project-info-button:focus-visible {
  outline: none;
  transform: translate(-2px, -2px);
  box-shadow: 0 0 14px rgba(238, 111, 122, 0.42);
}

.track-box {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.track-list-title {
  margin: 0;
  color: white;
  font-size: 24px;
  font-weight: normal;
  line-height: 1.1;
}

.track-list {
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 6px;
}

.track-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  color: white;
  font: inherit;
  font-size: 16px;
  line-height: 1.15;
  text-align: left;
  background-color: transparent;
  border: 2px solid var(--projects-theme-mid);
  cursor: pointer;
  transition:
    color 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.track-button:hover,
.track-button:focus-visible,
.track-button.is-active {
  color: var(--projects-theme);
  border-color: var(--projects-theme);
  background-color: rgba(238, 111, 122, 0.08);
  outline: none;
  box-shadow:
    0 0 14px rgba(238, 111, 122, 0.28),
    inset 0 0 0 1px rgba(238, 111, 122, 0.32);
}

.track-title-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.track-author {
  color: rgba(190, 190, 190, 0.82);
  font-size: 12px;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.track-button:hover .track-author,
.track-button:focus-visible .track-author,
.track-button.is-active .track-author {
  color: rgba(210, 210, 210, 0.9);
}

.audio-upload-box {
  display: grid;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px solid rgba(238, 111, 122, 0.46);
}

.audio-upload-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 34px;
  padding: 7px 12px;
  color: #000000;
  font-size: 15px;
  line-height: 1;
  background-color: var(--projects-theme);
  border: 1px solid var(--projects-theme);
  cursor: pointer;
  text-shadow: none;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.audio-upload-button:hover,
.audio-upload-button:focus-within {
  outline: none;
  transform: translate(-2px, -2px);
  box-shadow: 0 0 14px rgba(238, 111, 122, 0.42);
}

.audio-upload-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.audio-upload-note {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.25;
}

.visualizer-box {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 100px;
  gap: 12px;
  padding: 18px;
  overflow: hidden;
}

.visualizer-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--projects-theme-mid);
  background:
    linear-gradient(rgba(238, 111, 122, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 111, 122, 0.08) 1px, transparent 1px),
    #000000;
  background-size: 18px 18px;
}

#frequency-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.visualizer-control-space {
  min-height: 0;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
  gap: 12px;
  border: 1px solid rgba(238, 111, 122, 0.46);
  background-color: #000000;
}

.visualizer-mode-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  width: fit-content;
}

.visualizer-mode-button {
  min-height: 32px;
  padding: 6px 12px;
  color: white;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  background-color: transparent;
  border: 1px solid var(--projects-theme-mid);
  cursor: pointer;
  transition:
    color 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.visualizer-mode-button:hover,
.visualizer-mode-button:focus-visible,
.visualizer-mode-button.is-active {
  color: var(--projects-theme);
  border-color: var(--projects-theme);
  background-color: rgba(238, 111, 122, 0.08);
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(238, 111, 122, 0.3);
}

.visualizer-playback-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.visualizer-seek {
  --seek-thumb-size: 10px;

  width: 100%;
  height: 24px;
  background: transparent;
  cursor: pointer;
  appearance: none;
}

.visualizer-seek:disabled {
  cursor: default;
  opacity: 0.42;
}

.visualizer-seek::-webkit-slider-runnable-track {
  height: 2px;
  background-color: var(--projects-theme);
}

.visualizer-seek::-webkit-slider-thumb {
  width: var(--seek-thumb-size);
  height: var(--seek-thumb-size);
  margin-top: calc((2px - var(--seek-thumb-size)) / 2);
  background-color: var(--projects-theme);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(238, 111, 122, 0.7);
  appearance: none;
}

.visualizer-seek::-moz-range-track {
  height: 2px;
  background-color: var(--projects-theme);
}

.visualizer-seek::-moz-range-thumb {
  width: var(--seek-thumb-size);
  height: var(--seek-thumb-size);
  background-color: var(--projects-theme);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(238, 111, 122, 0.7);
}

.visualizer-seek-time {
  min-width: 92px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.bbcode-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: rgba(0, 0, 0, 0.62);
}

.bbcode-modal[hidden] {
  display: none;
}

.bbcode-modal-window {
  width: min(760px, 100%);
  max-height: min(620px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr;
  color: white;
  background-color: #000000;
  border: 2px solid var(--projects-theme);
  box-shadow:
    0 0 24px rgba(238, 111, 122, 0.36),
    inset 0 0 0 1px rgba(238, 111, 122, 0.18);
}

.bbcode-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--projects-theme);
}

.bbcode-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: normal;
}

.bbcode-modal-close {
  width: 32px;
  height: 32px;
  color: white;
  font: inherit;
  line-height: 1;
  background-color: #000000;
  border: 1px solid var(--projects-theme);
  cursor: pointer;
}

.bbcode-modal-body {
  min-height: 0;
  padding: 18px;
  overflow: auto;
  font-size: 18px;
  line-height: 1.45;
}

.bbcode-modal-body ul {
  margin: 10px 0 14px;
  padding-left: 24px;
}

.bbcode-modal-body .bbcode-image {
  display: block;
  max-width: min(62%, 500px);
  max-height: 270px;
  height: auto;
  margin: 18px auto;
}

@media (max-width: 780px) {
  .perfectfft-layout {
    height: auto;
    min-height: 100vh;
    padding: 152px 10px 16px;
    grid-template-columns: 1fr;
    grid-template-rows: auto 320px minmax(440px, calc(100dvh - 40px));
    overflow: visible;
  }

  .has-music-player .perfectfft-layout {
    padding-top: 196px;
  }

  .perfectfft-box-small,
  .perfectfft-box-large,
  .perfectfft-box-tall {
    grid-column: 1;
    grid-row: auto;
  }

  .project-heading {
    max-width: none;
    padding-top: 34px;
  }

  .project-title-box {
    min-height: 154px;
    padding-bottom: 62px;
  }

  .language-list {
    max-width: 100%;
  }

  .visualizer-box {
    grid-template-rows: minmax(0, 1fr) 84px;
  }

  .visualizer-playback-control {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .visualizer-seek-time {
    text-align: left;
  }
}

@media (max-width: 520px) {
  .has-music-player .perfectfft-layout {
    padding-top: 228px;
  }

  .perfectfft-layout {
    padding-right: 8px;
    padding-left: 8px;
    grid-template-rows: auto 340px minmax(420px, calc(100dvh - 32px));
  }

  .project-title-box,
  .track-box,
  .visualizer-box {
    border-width: 3px;
  }

  .project-heading {
    font-size: 32px;
  }

  .project-subtext {
    font-size: 16px;
  }

  .track-button {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .track-author {
    text-align: left;
  }

  .visualizer-mode-button {
    padding-right: 9px;
    padding-left: 9px;
  }
}
