* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05070b;
  color: #eef1f6;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
body.dragging #view { cursor: grabbing; }

.panel {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(540px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(10, 14, 22, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 1s ease;
}

.backdrops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.thumb {
  position: relative;
  padding: 0;
  aspect-ratio: 5 / 3;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, opacity 0.2s;
  opacity: 0.7;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb span {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 10px 4px 3px;
  font-size: 11px;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}
.thumb:hover { opacity: 1; }
.thumb[aria-checked="true"] { opacity: 1; border-color: rgba(255, 255, 255, 0.85); }

.row { display: flex; align-items: center; gap: 20px; }

.toggle {
  flex: none;
  font: inherit;
  font-size: 13px;
  color: inherit;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}
.toggle[aria-pressed="true"] { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.6); }

.slider { display: flex; align-items: center; gap: 10px; flex: 1; font-size: 13px; }
.slider span { flex: none; }
.slider .value { flex: none; min-width: 3.6em; font-size: 12px; opacity: 0.7; text-align: right; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

button:focus-visible, input:focus-visible {
  outline: 2px solid rgba(160, 200, 255, 0.9);
  outline-offset: 3px;
}

.error {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  margin: 0;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.75);
  line-height: 1.7;
  text-align: center;
}
.error code { background: rgba(255, 255, 255, 0.12); padding: 2px 6px; border-radius: 4px; }

/* 一段时间无操作后隐藏界面，只留下窗景 */
body.idle { cursor: none; }
body.idle .panel { opacity: 0; pointer-events: none; }

/* 调音面板 */
.tuner {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(400px, calc(100% - 32px));
  overflow-y: auto;
  padding: 12px 14px 16px;
  border-radius: 14px;
  background: rgba(10, 14, 22, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 12px;
  z-index: 2;
}
.tuner[hidden] { display: none; }
.tuner-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.tuner-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.tuner-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tuner .toggle { font-size: 12px; padding: 3px 8px; }
.tuner-hint { margin: 8px 0; opacity: 0.65; line-height: 1.5; }
.tuner-test { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.tuner-status { min-height: 1.4em; margin: 4px 0; color: #a8d4ff; }
.tuner details { border-top: 1px solid rgba(255, 255, 255, 0.1); }
.tuner summary { padding: 8px 0; cursor: pointer; font-size: 13px; }
.tuner-group { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }
.tuner-row { display: grid; grid-template-columns: 9.5em 1fr 4.8em 1.6em; align-items: center; gap: 6px; }
.tuner-row label { opacity: 0.8; line-height: 1.3; }
.tuner-row.changed label { opacity: 1; color: #ffd38a; }
.tuner-row input[type="number"] {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 2px 4px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}
.tuner-undo {
  visibility: hidden;
  font: inherit;
  color: inherit;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0.7;
}
.tuner-row.changed .tuner-undo { visibility: visible; }
.tuner-undo:hover { opacity: 1; }
.tuner-group-reset { align-self: flex-start; margin-top: 4px; }
