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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}

.demo-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.demo-header {
  padding: 12px 16px;
  background: #16162a;
  border-bottom: 1px solid #2a2a4a;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.demo-header h1 {
  font-size: 15px;
  font-weight: 600;
  color: #aaa;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
}

.speed-control input[type="range"] {
  width: 88px;
  accent-color: #40916c;
}

#anim-speed-label {
  min-width: 42px;
  color: #aaa;
  font-variant-numeric: tabular-nums;
}

.demo-status {
  margin-left: auto;
  font-size: 13px;
  color: #888;
}

@media (max-width: 520px) {
  .demo-header h1 {
    width: 100%;
  }

  .demo-status {
    margin-left: 0;
    width: 100%;
  }

  .speed-control input[type="range"] {
    flex: 1;
    min-width: 60px;
  }
}

.demo-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}

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

.demo-btn-shuffle {
  background: #5a3a8a;
  color: #fff;
}

.demo-btn-shuffle:hover:not(:disabled) {
  background: #6a4a9a;
}

.demo-btn-restore {
  background: #2d6a4f;
  color: #fff;
}

.demo-btn-restore:hover:not(:disabled) {
  background: #40916c;
}

.demo-btn-input {
  background: #3a5a8a;
  color: #fff;
}

.demo-btn-input:hover:not(:disabled) {
  background: #4a6a9a;
}

.step-mode-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #888;
  cursor: pointer;
  user-select: none;
}

.step-mode-control input {
  accent-color: #40916c;
  cursor: pointer;
}

.demo-btn-step {
  background: #6a5a2a;
  color: #fff;
}

.demo-btn-step:hover:not(:disabled) {
  background: #8a7a3a;
}

#cube-container {
  flex: 1;
  min-height: 0;
}

.legend {
  padding: 10px 20px;
  background: #16162a;
  border-top: 1px solid #2a2a4a;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.demo-log-panel {
  height: 180px;
  flex-shrink: 0;
  border-top: 1px solid #2a2a4a;
  display: flex;
  flex-direction: column;
  background: #12122a;
}

.demo-log-header {
  padding: 6px 16px;
  background: #16162a;
  border-bottom: 1px solid #2a2a4a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #888;
}

.demo-log-clear {
  padding: 2px 10px;
  border: 1px solid #3a3a5a;
  background: #1e1e3a;
  color: #aaa;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}

.demo-log-clear:hover {
  background: #2a2a50;
  border-color: #5a5a8a;
}

#demo-output {
  flex: 1;
  padding: 8px 16px;
  overflow-y: auto;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.demo-output-line {
  padding: 1px 0;
  color: #b8c5d6;
  word-break: break-word;
}
