* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #1a1a1e;
  color: #d0d0d0;
  min-height: 100vh;
  padding: 16px;
}

.main-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding-bottom: 12px;
}

.global-talk {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: calc(100% - 32px);
  max-width: 1100px;
  background: #252528;
  border: none;
  border-left: 6px solid #444;
  border-top: 3px solid #444;
  color: #888;
  height: clamp(48px, 7vw, 80px);
  border-radius: 0;
  font-size: clamp(0.8rem, 2.5vw, 1.2rem);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.global-talk:hover {
  color: #ccc;
}

.global-talk.active {
  background: #3a2815;
  border-left-color: #e8863a;
  color: #e8863a;
}

.settings-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: #2a2a2e;
  border: 1px solid #444;
  color: #aaa;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.settings-toggle:hover {
  background: #3a3a3e;
  color: #fff;
}

.settings-toggle.active {
  background: #e94560;
  border-color: #e94560;
  color: #fff;
}

.settings-panel {
  position: fixed;
  top: 54px;
  right: 12px;
  z-index: 99;
  background: #2a2a2e;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 14px 18px;
  display: none;
  flex-direction: column;
  gap: 12px;
  min-width: 220px;
}

.settings-panel.open {
  display: flex;
}

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

.settings-row label {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}

.settings-row input[type="range"] {
  flex: 1;
  accent-color: #e94560;
}

.settings-row .duck-val {
  color: #e94560;
  font-weight: bold;
  min-width: 32px;
  text-align: center;
  font-size: 0.85rem;
}

.settings-row input[type="number"] {
  width: 60px;
  background: #333;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.8rem;
  text-align: center;
}

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

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 650px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 400px) {
  .grid { grid-template-columns: 1fr; }
}

@media (orientation: portrait) and (max-width: 600px) {
  .global-talk {
    height: clamp(80px, 18vw, 140px);
    font-size: clamp(1.1rem, 5vw, 1.6rem);
  }
}

.slot {
  background: #252528;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: none;
  border-left: 6px solid #444;
  transition: border-color 0.3s, background 0.3s;
  min-width: 0;
  aspect-ratio: 1.15;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  container-type: inline-size;
}

.slot:hover {
  background: #2c2c30;
}

.slot.loaded {
  border-left-color: #3a6ea5;
}

.slot.playing {
  border-left-color: #e94560;
  background: #22252a;
}

.slot.ducking {
  border-left-color: #e94560;
  background: #282024;
}

.slot.playing, .slot.ducking {
  cursor: pointer;
}

.slot-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
  padding: 8px 10px 6px 10px;
  background: rgba(0,0,0,0.2);
}

.slot-number {
  background: #3a3a40;
  color: #aaa;
  width: 9cqi;
  height: 9cqi;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 4.5cqi;
  flex-shrink: 0;
}

.slot-name {
  font-size: 5cqi;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid transparent;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.slot-clear {
  background: transparent;
  color: #555;
  border: none;
  font-size: 0.85rem;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}
.slot-clear:hover:not(:disabled) {
  color: #e94560;
  background: rgba(233,69,96,0.1);
}
.slot-clear:disabled {
  opacity: 0;
  cursor: default;
}

.slot-name:hover {
  border-color: #555;
  background: rgba(255,255,255,0.05);
}

.slot-name:focus {
  border-color: #00d4ff;
  background: rgba(0,0,0,0.3);
  overflow-x: auto;
  overflow-y: hidden;
  text-overflow: unset;
  scrollbar-width: none;
}

.slot-name:focus::-webkit-scrollbar { display: none; }

.slot-name.unloaded {
  color: #555;
  font-style: italic;
  font-weight: normal;
  cursor: pointer;
}

.slot-name.unloaded:hover {
  border-color: transparent;
  background: transparent;
}

.slot-name.unavailable {
  color: #e94560;
  font-weight: normal;
}

.upload-label { display: none; }
input[type="file"] { display: none; }

.progress-bar {
  width: 100%;
  height: 16px;
  background: #333;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: #00b894;
  width: 0%;
  transition: width 0.2s linear;
  border-radius: 0 2px 2px 0;
}

.slot.playing .progress-fill {
  background: #00b894;
}

.slot.ducking .progress-fill {
  background: #e8863a;
}

.slot.countdown .time-display {
  color: #e94560;
}

.time-display {
  font-size: 12cqi;
  font-weight: 700;
  color: #444;
  text-align: center;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  font-family: 'Inter', sans-serif;
  letter-spacing: 2px;
  transition: color 0.2s;
  pointer-events: none;
}

.slot.loaded .time-display {
  color: #e0e0e0;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3cqi;
  flex-shrink: 0;
  padding: 3cqi;
  margin-top: auto;
}

.btn {
  aspect-ratio: 2.5 / 1;
  padding: 0;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 5cqi;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.btn-fade {
  background: #2a2a2e;
  color: #555;
  font-size: 6.5cqi;
}
.btn-fade:hover:not(:disabled) { background: #333338; color: #777; }
.btn-fade.active {
  background: #2a1f3d;
  color: #a29bfe;
}
.btn-fade.active:hover { background: #33264a; }

.btn-duck {
  background: #2a2a2e;
  color: #555;
  font-size: 6.5cqi;
}
.btn-duck:hover:not(:disabled) { background: #333338; color: #777; }
.btn-duck.active {
  background: #3a2815;
  color: #e8863a;
}
.btn-duck.active:hover { background: #45301a; }

.btn-export {
  background: #333;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.btn-export:hover {
  border-color: #3a6ea5;
  background: #3a3a40;
}

.progress-hover {
  display: none;
  position: absolute;
  top: 0;
  height: 100%;
  width: 1px;
  background: #fff;
  pointer-events: none;
  z-index: 2;
}

.progress-hover::before {
  content: attr(data-time);
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  background: rgba(26, 26, 30, 0.85);
  color: #e0e0e0;
  font-size: 0.65rem;
  font-family: 'Inter', sans-serif;
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
}

.progress-hover.flip::before {
  left: auto;
  right: 8px;
}

body.fade-mode-maintained .btn-fade {
  display: none;
}

.radio-group {
  display: flex;
  gap: 12px;
}

.radio-label {
  font-size: 0.8rem;
  color: #aaa;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.radio-label input[type="radio"] {
  accent-color: #e94560;
}

.hold-ring {
  position: absolute;
  border-radius: 50%;
  border: 5px solid #fff;
  pointer-events: none;
  z-index: 10;
  transform: translate(-50%, -50%) scale(1);
  animation: holdRing 0.85s ease-out forwards;
}

@keyframes holdRing {
  0% {
    width: 80px;
    height: 80px;
    opacity: 0.8;
  }
  100% {
    width: 20px;
    height: 20px;
    opacity: 0;
  }
}
