html {
  --mixer-width: 300px;
  text-align: center;
  height: 100%;
}

body {
  margin: 0;
  background: #333;
  color: white;
  display: flex;
  flex-direction: column; /* 縦方向に配置 */
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body > #controller {
  display: flex;
  flex: 1;
}

body > #library {
  display: flex;
  flex: 1;
  border-top: solid 1px #555;
  text-align: left;
  overflow: auto;
}

body > #status {
  background: #333;
  padding: 0 0.5rem;
  display: flex;
  gap: 1rem;
  border-top: solid 1px #555;
  text-align: right;
  flex: 0 0 auto;
}

/**
 * Controller
 */
#controller > * {
  padding: 10px;
  box-sizing: border-box; /* widthにmarginも含める */
}

#controller > .deck {
  flex-grow: 1;
}

#controller > .deck.selected {
  background: #444;
}

#controller > #mixer {
  width: var(--mixer-width);
  border-left: solid 1px #555;
  border-right: solid 1px #555;
}

/**
 * Controller-Deck
 */
.deck .preview {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  position: relative;
}

.deck .preview .yt-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.deck .seek-bar {
  position: relative;
  height: 2em;
  line-height: 1em;
  background: linear-gradient(to bottom, #fff2, transparent);
}

.deck .seek-bar .bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: linear-gradient(to bottom, #f006, transparent);
  box-sizing: border-box;
  animation: none;
}

.deck.muted .seek-bar .bar {
  background: linear-gradient(to bottom, #fff6, transparent);
}

.deck .seek-bar .indicator {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 2px;
  transform: translateX(-50%);
  background: #f008;
}

.deck .seek-bar .hotcues {
  position: absolute;
  top: 0.2em;
  left: 0;
  right: 0;
  height: 0.7em;
  font-size: 0.7em;
  line-height: 0.7em;
}

.deck .seek-bar .hotcues span {
  transform: translateX(-50%);
  position: absolute;
}

.deck .seek-bar .loop {
  position: absolute;
  top: 1em;
  left: 0;
  right: 0;
  height: 0.7em;
  font-size: 0.7em;
  line-height: 0.7em;
}

.deck .seek-bar .loop span {
  transform: translateX(-50%);
  position: absolute;
}

.deck .seek-bar .time {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 0.2em;
}

.deck .seek-bar.syncing .bar {
  animation: blink 0.1s infinite alternate;
}

@keyframes blink {
  0% {
    opacity: 0.3;
  }
  100% {
    opacity: 0.7;
  }
}

.deck .controls {
  margin-top: 10px;
  display: flex;
  gap: 10px;
}

.deck .controls > * {
  flex: 1;
}

.deck .controls .adjust {
  min-width: 150px;
  display: grid; /* Gridを有効にする */
  grid-template-columns: repeat(3, 1fr); /* 3列のレイアウトを作成 */
  row-gap: 0.5rem;
}

.deck .controls .adjust > * {
  line-height: 50px;
  height: 50px;
  padding: 0;
}

.deck .controls .speed .fader-container {
  --fader-range: 150px;
  height: var(--fader-range);
  margin: auto;
}

.deck .controls .speed .fader-container input {
  width: var(--fader-range);
}

.deck .controls .speed input[type="number"] {
  width: 50px;
  background: none;
  border: none;
  border-bottom: solid 1px #555;
  outline: none;
  color: white;
}

/**
 *  Controller-Mixer
 */
#mixer .load {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

#mixer .load .youtube {
  background: red;
  color: white;
  border-radius: 9px;
  border: 2px solid #333;
}

#mixer .load-track {
  margin-bottom: 10px;
}

#mixer .load-track .yt-thumbnail {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

#mixer .load-track input#input-videoId {
  width: 100%;
  background: none;
  border: none;
  border-bottom: solid 1px #555;
  outline: none;
  color: white;
}

#mixer .vertical-fader-container {
  --fader-range: 130px;
  display: flex;
  justify-content: space-between;
  padding: 10px;
}

#mixer .vertical-fader-container > .fader-container {
  height: var(--fader-range);
}

#mixer .vertical-fader-container > .fader-container > input {
  width: var(--fader-range);
}

/**
 * Library
 */
#library {
  position: relative;
}

#library > .drag-overlay {
  display: grid;
  position: absolute;
  place-items: center;
  inset: 0;
  background: #fff8;
  z-index: 9;
  color: #000 !important;
  font-size: 9em;
}

#library:not(.drag-over) > .drag-overlay {
  display: none;
}

#library > :not(.focused) {
  color: #999;
}

#library > .playlist {
  width: 150px;
  border-right: solid 1px #555;
  text-align: center;
}

#library > .playlist > button {
  margin: 8px auto;
}

#library > .playlist > ul {
  text-align: left;
  list-style: none;
  margin: 0;
  padding: 0;
}

#library > .playlist > ul > li {
  padding-left: 1rem;
}

#library > .playlist > ul li.focused,
#library > .playlist > ul li:hover {
  background: #fff3;
}

#library > .playlist {
  width: 150px;
  border-right: solid 1px #555;
}

#library > .videolist {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

#library > .videolist > table {
  width: 100%;
  white-space: nowrap;
  border-spacing: 0;
}

#library > .videolist > table thead {
  z-index: 1;
  position: sticky;
  top: 0;
  background: #222;
}

#library > .videolist > table thead th:nth-child(1) {
  text-align: center;
}

#library > .videolist > table thead th:nth-child(2) {
  padding-left: 10rem;
}

#library > .videolist > table tbody tr:nth-child(odd) {
  background: #fff1;
}

#library > .videolist > table tbody tr.focused,
#library > .videolist > table tbody tr:hover {
  background: #fff3;
}

#library > .videolist > table tbody img {
  display: block;
  height: 1.6rem;
  aspect-ratio: 10/4;
  object-fit: cover;
}

#library > .videolist > table tbody td:nth-child(2) {
  padding-left: 0.5rem;
}

#library > .videolist > input#search-keyword {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 9;
  background: #333;
  border: none;
  border-left: solid 1px #555;
  border-bottom: solid 1px #555;
  height: 1.5rem;
  color: #fff;
}

#library > .videolist > input#search-keyword:focus {
  outline: none;
}
/**
 * Status
 */
#status > div {
  display: inline-block;
  padding: 2px;
}

#status > div:nth-child(2) {
  margin-left: auto;
}

#status > div.clickable:hover {
  background: #555;
}

#status .indicator {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 1rem;
  background: #f00;
}

#status .indicator.active {
  background: #0f0;
}

/**
 * Common
 */
button {
  padding: 4px 12px;
  background: #222;
  color: white;
  border: solid 1px #555;
  border-radius: 4px;
}

button:hover {
  background: #000;
}

fieldset {
  border: none;
  padding: 0 8px;
  border-top: groove 1px #555;
}

.hidden {
  display: none !important;
}

/**
 * モーダル
 */
#terms {
  display: flex;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#terms .terms-content {
  background-color: #333;
  padding: 20px;
  border-radius: 8px;
  width: 60%;
  max-width: 600px;
  position: relative;
}

#terms .terms-content iframe {
  width: 100%;
  height: 50vh;
  min-height: 300px;
  background: #fff;
}

#terms #terms-agree-btn {
  margin-top: 20px;
  padding: 10px 20px;
  background-color: #4caf50;
  color: white;
  border: none;
  cursor: pointer;
}

#terms #terms-agree-btn:hover {
  background-color: #45a049;
}

/**
 *  Config Popup
 */
#config {
  display: flex;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#config .config-popup {
  background-color: #333;
  padding: 20px;
  border-radius: 8px;
  width: 60%;
  max-width: 600px;
  position: relative;
}

#config h1 {
  margin-top: 0;
}

#config .inputs {
  text-align: left;
}

#config .buttons {
  text-align: right;
}

#config #close-config-editor {
  margin-top: 20px;
  padding: 10px 20px;
  background-color: #4caf50;
  color: white;
  border: none;
  cursor: pointer;
}

#config #close-config-editor:hover {
  background-color: #45a049;
}
